如何避免对齐时出现较大的水平间隙?

如何避免对齐时出现较大的水平间隙?

到目前为止,我能想到的最接近我所寻找的解决方案是这样的

\[
\begin{align*}
A & = & B & C\\
& = & B & (D\\
& & + & E)
\end{align*}
\]

从而产生了这个

上述代码的输出

现在,这已经非常接近我想要的效果了。D 和 E 是相当大的表达式,所以我必须将它们放在不同的行上,并且像这样对齐它们在审美上非常令人愉悦。但是等号和 B 之间有一个神秘的间隙。有办法消除它吗?或者也许有一种完全不同的排版方法?

答案1

我不确定我是否明白你想要做什么,但我会选择这样的事情:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
\usepackage[utf8]{inputenc}      % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}



\begin{document}

An example:
\begin{equation}
    \begin{split}
        A &= \text{1st fairly large expr.}\cdot C \\
            &=\text{1st fairly large expr.} \cdot
            \begin{aligned}[t]
                & (\text{2nd fairly large expr.} \\
                & \quad + \text{3rd fairly large expr.})
            \end{aligned}
    \end{split}
\end{equation}
This assumes that you want to label the whole block with a single
equation number.

\end{document}

这是输出:

代码示例的输出


另外一个选择

如果希望每行都编号,请使用alignat

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
\usepackage[utf8]{inputenc}      % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\newcommand*{\myexpr}[1]{%
    \langle\text{#1 fairly large expr.}\rangle
}



\begin{document}

An example:
\begin{equation}
    \begin{split}
        A &= \myexpr{1st} \cdot C \\
            &= \myexpr{1st} \cdot
            \begin{aligned}[t]
                & (\myexpr{2nd} \\
                & \quad + \myexpr{3rd})
            \end{aligned}
    \end{split}
\end{equation}
This assumes you want to label the whole block with a single equation number.
Individual lines can be numbered with the help of the \texttt{alignat}
environment:

\begin{alignat}{2}
    A &= \myexpr{1st} && \cdot C \\
        &= \myexpr{1st}
            && \cdot (\myexpr{2nd} \notag \\ % no number on this line
        &   && \mathbin{\hphantom{\cdot}} \quad {} + \myexpr{3rd})
\end{alignat}
We've also shown how to suppress the equation number on a particular line.

\end{document}

请注意幻象的二元运算符的性质是如何\cdot被保留的,以便它被正确地间隔开。

输出为:

第二个代码示例的输出

答案2

这里有两个选项:

在此处输入图片描述

\documentclass{article}

\usepackage{amsmath}

\begin{document}

Option 1:
\begin{align*}
  A = {} & B C \\
    = {} & B (D \\
         & \phantom{B} + E)
\end{align*}

Option 2:
\begin{align*}
  A &= B C \\
    &= B (D \\
    &\phantom{{}= B} + E)
\end{align*}

\end{document}

由于您将括号拆分到多行,因此不能使用\left- \right。有关更多信息,请参阅如何使\left,\right对分隔符在多行上起作用?

相关内容