对齐括号

对齐括号
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{dsfont}

\begin{document}

\begin{equation*}
\begin{split}
&=\sum_{\substack{\theta_1,\theta_2\\a,b}}\sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\ y_2-\sqrt{r}\theta_2x_2=b}}\mathds{1}_{\mathcal{E}}(x_2)\mathds{1}_{\mathcal{E}}(y_2)\sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}\mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1) \sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_3\neq x_2}}\mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)\\
&=\sum \limits_{x_2,y_2\in \mathcal{E}} \underbrace{\left(\sum\limits_{\theta_1,a}\sum \limits_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}\mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1)\mathds{1}_{\{a\}}(y_2-\sqrt{r}\theta_1x_2)\right)}_{\mathrm{I}}\\
    &\underbrace{\left(\sum\limits_{\theta_2,b}\sum \limits_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}\mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)\mathds{1}_{\{b\}}(y_2-\sqrt{r}\theta_2x_2)\right)}_{\mathrm{II}}.
\end{split}
\end{equation*}

\end{document}

上述代码表示以下公式在此处输入图片描述

问题:如何将最后一行向右移动,以使其与上面的括号处于同一水平?

答案1

我建议您使用“内部”aligned环境来对齐这两个\underbrace项目。我还会使用\smashoperator[r]{...}包装器来“贴合”求和符号和它们相加的项目,并赋予这些\mathds{1}...项目(它们是指示函数或运算符,对吗?\mathop)状态。我还会使用\Biggland\Biggr而不是\leftand\right来调整大括号的大小。

顺便问一下,您不应该在多行表达式的第一行使用三对大括号来对三个求和表达式进行分组吗?

在此处输入图片描述

\documentclass{article}
%%\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage{mathtools}
\usepackage{dsfont}
\newcommand\oneE[1][\mathcal{E}]{\mathop{\mathds{1}^{}_{#1}}} % indicator functions

\begin{document}

\begin{align*}
&=\sum_{\substack{\theta_1,\theta_2\\a,b}}\,
  \smashoperator[r]{%
  \sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\ y_2-\sqrt{r}\theta_2x_2=b}}}
  \oneE(x_2)\oneE(y_2)
  \smashoperator[r]{%
  \sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}}
  \oneE(x_1)\oneE(y_1) 
  \smashoperator[r]{%
  \sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_3\neq x_2}}}
  \oneE(x_3)\oneE(y_3) \\[\jot]
&=\sum _{x_2,y_2\in \mathcal{E}}
  \begin{aligned}[t]
  &\underbrace{\Biggl(\,
  \sum_{\theta_1,a}\,
  \smashoperator[r]{%
  \sum _{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}}
  \oneE(x_1)\oneE(y_1)\oneE[\{a\}](y_2-\sqrt{r}\theta_1x_2)
  \!\Biggr)}_{\mathrm{I}} \times \\
  &\underbrace{\Biggl(\,
  \sum_{\theta_2,b}\,
  \smashoperator[r]{%
  \sum _{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}}
  \oneE(x_3)\oneE(y_3)\oneE[\{b\}](y_2-\sqrt{r}\theta_2x_2)
  \!\Biggr)}_{\mathrm{II}} 
  \end{aligned}
\end{align*}

\end{document}

附录:这是一个增强解决方案。与上面给出的解决方案相比,新解决方案还 (a) 将第 1 行中的三个求和项括在它们自己的大括号中,并且 (b) 注意将任何材料的第一行放置在这些\sum项下方的相同高度,而不管\substack指令是否存在。

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools} % for \smashoperator macro
\usepackage{dsfont}    % for \mathds macro
\newcommand\oneE[1][\mathcal{E}]{\mathop{\mathds{1}^{}_{\!#1}}} % indicator function
\newcommand\mystrut{\vphantom{\sqrt{r}}} % set up a typographic strut 

\begin{document}

\begin{align*}
&\sum_{\mathclap{\substack{\theta_1,\theta_2\mystrut\\a,b}}}
  \Biggl(\,\smashoperator[r]{%
     \sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}}
     \oneE(x_1)\oneE(y_1)\!\Biggr)\!
  \Biggl(\,\smashoperator[r]{%
     \sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\ y_2-\sqrt{r}\theta_2x_2=b}}}
     \oneE(x_2)\oneE(y_2)\!\Biggr)\!
  \Biggl(\,\smashoperator[r]{%
     \sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_3\neq x_2}}}
     \oneE(x_3)\oneE(y_3)\!\Biggr) \\[\jot]
&\qquad=
 \sum _{x_2,y_2\in \mathcal{E}\mystrut}
  \begin{aligned}[t]
  &\underbrace{\Biggl(\,
     \sum_{\theta_1,a\mystrut}\,
     \smashoperator[r]{%
     \sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}}
     \oneE(x_1)\oneE(y_1)\oneE[\{a\}](y_2-\sqrt{r}\theta_1x_2)
     \!\Biggr)}_{\mathrm{I}}  \times \\
  &\underbrace{\Biggl(\,
     \sum_{\theta_2,b\mystrut}\,
     \smashoperator[r]{%
     \sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}}
     \oneE(x_3)\oneE(y_3)\oneE[\{b\}](y_2-\sqrt{r}\theta_2x_2)
     \!\Biggr)}_{\mathrm{II}} 
  \end{aligned}
\end{align*}

\end{document}

答案2

我将这两个分组放在顶部对齐的aligned环境中。我还必须使用\rlap句号,以免错位。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{dsfont}
\begin{document}

\begin{equation*}
\begin{split}
&=\sum_{\substack{\theta_1,\theta_2\\a,b}}
\sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\ 
y_2-\sqrt{r}\theta_2x_2=b}}\mathds{1}_{\mathcal{E}}(x_2)
\mathds{1}_{\mathcal{E}}(y_2)\sum_{\substack{y_1-\sqrt{r}
\theta_1x_1=a\\ x_1\neq x_2}}\mathds{1}_{\mathcal{E}}(x_1)
\mathds{1}_{\mathcal{E}}(y_1) \sum_{\substack{y_3-\sqrt{r}
\theta_2x_3=b\\ x_3\neq x_2}}\mathds{1}_{\mathcal{E}}(x_3)
\mathds{1}_{\mathcal{E}}(y_3)\\
&=\sum \limits_{x_2,y_2\in \mathcal{E}} 
\begin{aligned}[t]
\underbrace{\left(\sum\limits_{\theta_1,a}\sum 
\limits_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}
\mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1)
\mathds{1}_{\{a\}}(y_2-\sqrt{r}\theta_1x_2)\right)}_{\mathrm{I}}\\
    \times \underbrace{\left(\sum\limits_{\theta_2,b}\sum 
\limits_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}
\mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)
\mathds{1}_{\{b\}}(y_2-\sqrt{r}\theta_2x_2)\right)}_{\mathrm{II}}
\rlap{.}
\end{aligned}
\end{split}
\end{equation*}
\end{document}

在此处输入图片描述

答案3

通过添加nccmath包并使用alignat*数学环境。要使第一个方程更窄,其用法\smashoperator[r]{...}与@Mico 在其回答中类似 (+1)。

编辑:正如@Mico 所建议的,\smashoperator[r]{...}现在也用于方程的第二行和第三行:

\documentclass{article}
\usepackage{nccmath,
            mathtools}
\usepackage{dsfont}

\begin{document}
\begin{fleqn}[2em]
\begin{alignat*}{2}
& = \mathrlap{%
    \sum_{\substack{\theta_1,\theta_2\\a,b}}\ 
    \smashoperator[r]{\sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\
                  y_2-\sqrt{r}\theta_2x_2=b}}}
        \mathds{1}_{\mathcal{E}}(x_2)\mathds{1}_{\mathcal{E}}(y_2)
    \smashoperator[r]{\sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\
                   x_1\neq x_2}}}
        \mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1)
    \smashoperator[r]{\sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_3\neq x_2}}}
        \mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)  
            }
    &&   \\
%
& = \sum\limits_{x_2,y_2\in \mathcal{E}}\ 
    &&   \underbrace{\left(\sum\limits_{\theta_1,a}\
         \smashoperator[r]{\sum\limits_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ 
                                                  x_1\neq x_2}}}
        \mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1)
        \mathds{1}_{\{a\}}(y_2-\sqrt{r}\theta_1x_2)\right)}_{\mathrm{I}} \times\\
%
&   &&   \underbrace{\left(\sum\limits_{\theta_2,b}\ 
         \smashoperator[r]{\sum \limits_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}}
        \mathds{1}_{\mathcal{E}}(x_3)
        \mathds{1}_{\mathcal{E}}(y_3)\mathds{1}_{\{b\}}(y_2-\sqrt{r}\theta_2x_2)\right)}_{\mathrm{II}}.
    \end{alignat*}
\end{fleqn}
\end{document}

在此处输入图片描述

(红线表示文本区域边框)

答案4

这是一个快速而肮脏的方法\hphantom

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{dsfont}

\begin{document}

\begin{equation*}
\begin{split}
&=\sum_{\substack{\theta_1,\theta_2\\a,b}}\sum_{\substack{y_2-\sqrt{r}\theta_1x_2=a\\ y_2-\sqrt{r}\theta_2x_2=b}}\mathds{1}_{\mathcal{E}}(x_2)\mathds{1}_{\mathcal{E}}(y_2)\sum_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}\mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1) \sum_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_3\neq x_2}}\mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)\\
&=\sum \limits_{x_2,y_2\in \mathcal{E}} \underbrace{\left(\sum\limits_{\theta_1,a}\sum \limits_{\substack{y_1-\sqrt{r}\theta_1x_1=a\\ x_1\neq x_2}}\mathds{1}_{\mathcal{E}}(x_1)\mathds{1}_{\mathcal{E}}(y_1)\mathds{1}_{\{a\}}(y_2-\sqrt{r}\theta_1x_2)\right)}_{\mathrm{I}}\\
&\hphantom{{}=\sum \limits_{x_2,y_2\in \mathcal{E}}}\underbrace{\left(\sum\limits_{\theta_2,b}\sum \limits_{\substack{y_3-\sqrt{r}\theta_2x_3=b\\ x_2\neq x_3}}\mathds{1}_{\mathcal{E}}(x_3)\mathds{1}_{\mathcal{E}}(y_3)\mathds{1}_{\{b\}}(y_2-\sqrt{r}\theta_2x_2)\right)}_{\mathrm{II}}.
\end{split}
\end{equation*}

\end{document}

MWE 渲染版本的屏幕截图

请注意中的{}之前的,如果省略它,可能不会被视为二进制数学运算符,从而导致略有不同的间距。=\hphantom=

如果您想要乘号,可以将其添加到倒数第二行的末尾,或者使用例如将其添加到第一行的开头。\mathllap

相关内容