问题

问题

以下解决方案需要最新版本的 LaTeX


当我尝试在自己的机器上运行以下解决方案时,我无法重现其结果,但仍然得到了不必要的偏移。通过更新最新的 LaTeX 发行版 (2018) 解决了这个问题。正如这条评论所指出的那样,这是因为其环境amsmath已经更新。aligned

问题

我的证明中有几行,我想对齐几个术语,如下所示:

输出

在此处输入图片描述

我可以在需要的地方使用以下方法实现以下目的phantom

平均能量损失

\documentclass{extarticle}

\usepackage{amsmath,bbm,bm,amssymb,amsthm,mathtools,cleveref,physics,letltxmacro}

% For usage in align environments. 
\newcommand\phantomrel[1]{\mathrel{\phantom{#1}}}
\newcommand\phantombin[1]{\mathbin{\phantom{#1}}}

\begin{document}
\begin{align*}
A
& = \text{several short lines}\\
& = \text{some very long line which takes up most of the width of the page} \\ 
& = \text{several short lines} \\
& = B + \mathbb{E}(\abs{a + b + c + d}) \qquad \text{(typically too long for a single line)} \\
& \leq B + \mathbb{E}(\abs{a})  \\ % Using the triangle inequality.
& \phantomrel{\leq} \phantom{B} + \mathbb{E}(\abs{b}) \\
& \phantomrel{\leq} \phantom{B} + \mathbb{E}(\abs{c}) \\
& \phantomrel{\leq} \phantom{B} + \mathbb{E}(\abs{d}) \\
\end{align*}
\end{document}

但是,如果我发现错误并需要更改为更广泛的符号集,我担心这似乎不太具有可扩展性B,并且想避免陷入复制/粘贴循环。

我正在使用phantomrelphantombin因为我之前的一个问题

对于更好的写作模式,我首先想到的是以下两个模式:

  • aligned在原来的内使用align
  • 使用数组。

使用数组?

\begin{align*}
A
& = \text{several short lines}\\
& = \text{some very long line which takes up most of the width of the page} \\ 
& = \text{several short lines} \\
& = B + \mathbb{E}(\abs{a + b + c + d}) \qquad \text{(typically too long for a single line)} \\
& \leq B 
\begin{array}[t]{r}
{} + \mathbb{E}(\abs{a}) \\
{} + \mathbb{E}(\abs{b}) \\
{} + \mathbb{E}(\abs{c}) \\
{} + \mathbb{E}(\abs{d}) \\
\end{array}
\end{align*}

在此处输入图片描述

尽管+由于数组边距的原因,符号偏移得太远。

使用aligned

\begin{align*}
A
& = \text{several short lines}\\
& = \text{some very long line which takes up most of the width of the page} \\ 
& = \text{several short lines} \\
& = B + \mathbb{E}(\abs{a + b + c + d}) \qquad \text{(typically too long for a single line)} \\
& 
\begin{aligned}
\leq B & + \mathbb{E}(\abs{a})  \\ % Using the triangle inequality.
& + \mathbb{E}(\abs{b}) \\
& + \mathbb{E}(\abs{c}) \\
& + \mathbb{E}(\abs{d}) 
\end{aligned}
\end{align*}

在此处输入图片描述

差不多,但是对齐有点偏离,我不知道为什么。

为什么不直接用于aligned整个事物呢?

我不知道如何在没有选择性使用mathclap(或类似符号的情况下处理很长的行,并且宁愿将“&”符号的使用保持在最低限度。

答案1

我将在环境中使用顶部对齐的aligned环境(双关语)align*

另外,我还会尝试使用更少的括号来使方程式看起来更简洁。

在此处输入图片描述

\documentclass{extarticle}

\usepackage{mathtools,bbm,bm,amssymb,amsthm,physics,
            letltxmacro,cleveref} % load 'cleveref' last
\DeclareMathOperator{\E}{\mathbb{E}} % expectation operator

\begin{document}
\begin{align*}
A
&= \text{several short lines}\\
&= \text{some very long line which takes up most of the width of the page} \\ 
&= \text{several short lines} \\
&= B + \E\abs{a + b + c + d} \qquad \text{(typically too long for a single line)} \\
&\leq B 
\begin{aligned}[t]
   &+ \E \abs{a} \\ % by triangle inequality
   &+ \E \abs{b} \\
   &+ \E \abs{c} \\
   &+ \E \abs{d} 
\end{aligned}
\end{align*}
\end{document}

答案2

在此处输入图片描述

我添加了{}所以你得到关系间距

\documentclass{extarticle}

\usepackage{amsmath,bbm,bm,amssymb,amsthm,mathtools,cleveref,physics,letltxmacro}

% For usage in align environments. 
\newcommand\phantomrel[1]{\mathrel{\phantom{#1}}}
\newcommand\phantombin[1]{\mathbin{\phantom{#1}}}

\begin{document}
\begin{align*}
A
& = \text{several short lines}\\
& = \text{some very long line which takes up most of the width of the page} \\ 
& = \text{several short lines} \\
& = B + \mathbb{E}(\abs{a + b + c + d}) \qquad \text{(typically too long for a single line)} \\
& 
\begin{aligned}
{}\leq B & + \mathbb{E}(\abs{a})  \\ % Using the triangle inequality.
& + \mathbb{E}(\abs{b}) \\
& + \mathbb{E}(\abs{c}) \\
& + \mathbb{E}(\abs{d}) 
\end{aligned}
\end{align*}\end{document}

答案3

我对对齐(测量精度:0.1pt)和此代码没有任何问题。无关:我删除了不必要的包。

\documentclass{extarticle}

\usepackage{bm,amssymb, amsthm, mathtools, cleveref, physics, letltxmacro}

% For usage in align environments.
\newcommand\phantomrel[1]{\mathrel{\phantom{#1}}}
\newcommand\phantombin[1]{\mathbin{\phantom{#1}}}

\begin{document}

\begin{align*}
A
& = \text{several short lines}\\
& = \text{some very long line which takes up most of the width of the page} \\
& = \text{several short lines} \\
& = B + \mathbb{E}(\abs{a + b + c + d}) \qquad \text{(typically too long for a single line)} \\
& \leq B \begin{aligned}[t] & + \mathbb{E}(\abs{a}) \\ % Using the triangle inequality.
  & + \mathbb{E}(\abs{b}) \\
 & + \mathbb{E}(\abs{c}) \\
 & + \mathbb{E}(\abs{d})
\end{aligned}
\end{align*}

\end{document} 

在此处输入图片描述

相关内容