> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-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 中打开此 **会产生错误的** 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 中打开此 **修正后的示例** 在 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 中打开此 **会产生错误的** 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.` ，如下面所示，这会排版出一个空的，即“零”定界符。

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

[在 Overleaf 中打开此 **已更正** 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` 通过由 `amsmath` 提供的 cases 环境。我们的函数可以排版如下：

```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*` 或 `aligned`， `\left` 和 `\right` 命令必须成对匹配 *在每一行上，并且位于 `&`*。如果你尝试在成对的 `\left` 和 `\right` 命令。

之间加入换行，LaTeX 会生成一系列错误。`\\`） `\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 中打开此 **会产生错误的** 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 中打开此 **已更正** 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 中打开此 **已更正** 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` 命令。

定界符大小按从小到大的顺序为 `\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://overleaf-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.
