> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/24-missing-right-inserted.md).

# 已插入缺少的 \right

当排版数学公式时，如果 `\left` 命令被使用了，但相应的 `\right` 缺失。本文讨论此错误的常见原因以及如何修复它们。

## 对 \left 和 \right 命令的简要介绍

该 `\left` 和 `\right` 这些命令用于排版动态大小的定界符，并且必须在数学内容中一起使用，形式为

$$\verb'\left'\thinspace\textit{delim}*{\thinspace\text{L}}\quad\textit{math expression}\quad \verb'\right'\thinspace\textit{delim}*{\thinspace\text{R}}$$

其中 $$\textit{delim}*{\thinspace\text{L}}$$ 和 $$\textit{delim}*{\thinspace\text{R}}$$ 是用于包围你的 $$\textit{math expression}$$。通常， $$\textit{delim}*{\thinspace\text{L}}$$ 和 $$\textit{delim}*{\thinspace\text{R}}$$ 可以是以下字符之一 `() [] | \| \{ \}` 或者点号“`.`”，它用作“[空定界符](#forgetting-a-blank-delimiter)”。

### 示例

下面是一个使用 `\left` 和 `\right` 来排版完全包住一个分数的括号：

```latex
\[
  \left(\frac{x}{y} \right)
\]
```

这段代码生成 $$\left(\frac{x}{y}\right)$$

如果你不使用 `\left` 和 `\right` 在放置定界符（包括括号）时使用这些命令，那么这些定界符将不会完全包住数学表达式；例如，写成

```latex
\[
  (\frac{x}{y})
\]
```

会生成如下

$$(\frac{x}{y})$$

## 此错误的原因及一些解决方法

### 忘记包含一个 \right 命令

写出一个 `\left` 命令而没有与之对应的 `\right` 是此错误的常见原因。这个疏忽，如下例所示，可能导致一连串错误，包括 `插入了缺失的 \right.`.

```latex
\[
\pi =
\left( \int_{-\infty}^{+\infty} e^{-x^2} dx )
\]
```

[打开此 **会产生错误的** Overleaf 中的示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+demonstrating+a+missing+delimiter\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%0A%5Cpi+%3D+%0A%5Cleft%28+%5Cint_%7B-%5Cinfty%7D%5E%7B%2B%5Cinfty%7D+e%5E%7B-x%5E2%7D+dx+%29%0A%5C%5D%0A%5Cend%7Bdocument%7D)

要修复这些错误，请补上缺失的 `\right` 命令：

```latex
\[
\pi =
\left( \int_{-\infty}^{+\infty} e^{-x^2} dx \right)
\]
```

[打开此 **修正后的示例** 在 Overleaf 中](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Correcting+a+missing+delimiter\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%0A%5Cpi+%3D+%0A%5Cleft%28+%5Cint_%7B-%5Cinfty%7D%5E%7B%2B%5Cinfty%7D+e%5E%7B-x%5E2%7D+dx+%5Cright%29%0A%5C%5D%0A%5Cend%7Bdocument%7D)

这段代码会生成以下输出

$$\pi = \left( \int\_{-\infty}^{+\infty} e^{-x^2} dx \right)$$

### 忘记使用空定界符

当尝试编写如下所示的函数时，常会出现此错误：

$$f(x)= \left{\begin{array}{lr} 0 & x\leq 0 \ 1 & x > 0 \end{array}\right.$$

如果你尝试通过写出以下内容来排版此函数

```latex
\[
f(x)= \left\{
  \begin{array}{lr}
      0 & x\leq 0 \\
      1 & x > 0
      \end{array}
\]
```

[打开此 **会产生错误的** Overleaf 中的示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+showing+a+missing+%5Cright+command\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%0Af%28x%29%3D+%5Cleft%5C%7B%0A++%5Cbegin%7Barray%7D%7Blr%7D+%0A++++++0+%26+x%5Cleq+0+%5C%5C%0A++++++1+%26+x+%3E+0+%0A++++++%5Cend%7Barray%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

那么你将会产生错误，因为 `\right` 定界符缺失。

要排版一个 `\left` 仅限定界符，请使用一个点号（“`.`”）作为 `\right` 定界符，写成 `\right.` 这样，如下所示，会排版出一个空的，即“null”定界符。

```latex
\[
f(x)= \left\{
  \begin{array}{lr}
      0 & x\leq 0 \\
      1 & x > 0
      \end{array}
\right.
\]
```

[打开此 **已更正** Overleaf 中的示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+dot+delimiter\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%0Af%28x%29%3D+%5Cleft%5C%7B%0A++%5Cbegin%7Barray%7D%7Blr%7D+%0A++++++0+%26+x%5Cleq+0+%5C%5C%0A++++++1+%26+x+%3E+0+%0A++++++%5Cend%7Barray%7D%0A%5Cright.%0A%5C%5D%0A%5Cend%7Bdocument%7D)

这个修正后的示例会产生所需的结果：

$$f(x)= \left{\begin{array}{lr} 0 & x\leq 0 \ 1 & x > 0 \end{array}\right.$$

#### 另一种选择：使用 cases 环境

你可以避免直接使用 `\left` 和 `\right` 通过由……提供的 cases 环境使用 `amsmath` 包。我们的函数可以如下排版：

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(x)= \begin{cases}
      0 & x\leq 0 \\
      1 & x > 0
      \end{cases}
\]
\end{document}
```

[在 Overleaf 中打开此示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+amsmath+cases+environment\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%0Af%28x%29%3D+%5Cbegin%7Bcases%7D+%0A++++++0+%26+x%5Cleq+0+%5C%5C%0A++++++1+%26+x+%3E+0+%0A++++++%5Cend%7Bcases%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

### 在 \left 和 \right 命令内部使用换行

当使用……编写多行方程时 `amsmath` 包环境 `align`, `align*` 或 `对齐`， `\left` 和 `\right` 命令必须成对平衡 *在每一行中，并且位于 `&`*。如果你试图在成对的……之间插入换行，LaTeX 将产生一系列错误。 `\left` 和 `\right` 命令的作用被保存并重新插入输入（作为单 token 列表）

下面的代码片段使用了一个换行（`\\`）位于 `\left` 和 `\right` 命令之间，因此会出错：

```latex
\begin{align*}
y  = 1 + & \left(  \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} + \cdots  \\
  & \quad  + \frac{1}{x^{n-1}} + \frac{1}{x^n} \right)
\end{align*}
```

[打开此 **会产生错误的** Overleaf 中的 LaTeX 片段](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=brackets+and+parentheses+example+with+errors\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0Ay++%3D+1+%2B+%26+%5Cleft%28++%5Cfrac%7B1%7D%7Bx%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E2%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E3%7D+%2B+%5Ccdots++%5C%5C%0A++%26+%5Cquad++%2B+%5Cfrac%7B1%7D%7Bx%5E%7Bn-1%7D%7D+%2B+%5Cfrac%7B1%7D%7Bx%5En%7D+%5Cright%29%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

#### 如何修复这些错误：两种解决方案

**解决方案 1：使用空定界符**

此解决方案通过添加一个……来使用空定界符 `\right.` 在第一行末尾添加一个， `\left.` 在第二行开头、位于……之后 `&`:

```latex
\begin{align*}
y  = 1 + & \left(  \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} + \cdots \right. \\
  &\left. \quad + \frac{1}{x^{n-1}} + \frac{1}{x^n} \right)
\end{align*}
```

[打开此 **已更正** Overleaf 中的 LaTeX 片段](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Line+breaks+and+delimiters\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0Ay++%3D+1+%2B+%26+%5Cleft%28++%5Cfrac%7B1%7D%7Bx%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E2%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E3%7D+%2B+%5Ccdots+%5Cright.+%5C%5C%0A++%26%5Cleft.+%5Cquad+%2B+%5Cfrac%7B1%7D%7Bx%5E%7Bn-1%7D%7D+%2B+%5Cfrac%7B1%7D%7Bx%5En%7D+%5Cright%29%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此示例生成如下输出：

$$\begin{align\*} y = 1 + & \left( \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} + \cdots \right. \ &\left. \quad + \frac{1}{x^{n-1}} + \frac{1}{x^n} \right)\end{align\*}$$

**解决方案 2：手动选择定界符大小**

我们可以使用 `\biggl(` 和 `\biggr)` 因为它们可以跨越换行正常工作：

```latex
\begin{align*}
y  = 1 + & \biggl(  \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} + \cdots  \\
  & \quad + \frac{1}{x^{n-1}} + \frac{1}{x^n} \biggr)
\end{align*}
```

[打开此 **已更正** Overleaf 中的 LaTeX 片段](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Line+breaks+and+delimiters+example+2\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0Ay++%3D+1+%2B+%26+%5Cbiggl%28++%5Cfrac%7B1%7D%7Bx%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E2%7D+%2B+%5Cfrac%7B1%7D%7Bx%5E3%7D+%2B+%5Ccdots++%5C%5C%0A++%26+%5Cquad+%2B+%5Cfrac%7B1%7D%7Bx%5E%7Bn-1%7D%7D+%2B+%5Cfrac%7B1%7D%7Bx%5En%7D+%5Cbiggr%29%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此解决方案产生相同的结果：

$$\begin{align\*}y = 1 + & \left( \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} + \cdots \right. \ &\left. \quad + \frac{1}{x^{n-1}} + \frac{1}{x^n} \right)\end{align\*}$$

#### 关于手动选择定界符大小的一些说明

LaTeX 提供了若干命令来 [手动设置定界符大小](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md#reference-guide)。这些命令所选定界符的大小是固定的——它们是 *不* 根据它们所包围的数学表达式动态调整大小。其优点是不需要像……那样以相同方式成对使用 `\left` 和 `\right` 命令的作用被保存并重新插入输入（作为单 token 列表）

定界符大小按从小到大的顺序为 `\big`, `\Big`, `\bigg`，以及 `\Bigg`；例如：

| LaTeX 标记                        | 显示为                                                |
| ------------------------------- | -------------------------------------------------- |
| `\bigl( \Bigl( \biggl( \Biggl(` | $$\displaystyle\bigl(; \Bigl(; \biggl(; \Biggl($$  |
| `\bigr) \Bigr) \biggr) \Biggr)` | $$\displaystyle\bigr); \Bigr); \biggr); \Biggr);$$ |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/latex/zh-cn/latex-cuo-wu/24-missing-right-inserted.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
