对齐多个独立方程

对齐多个独立方程

早上好,

我发现了很多关于如何对齐多行方程式的问题和教程,甚至跨越几页等等,但我无法弄清楚如何对齐多个方程式及其之间的文本段落。

以下是我的问题的一个最小工作示例:

    \documentclass[10pt,a4paper]{book}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{fleqn}
    \begin{document}
    Since we have
    \begin{equation}
        e^x = \frac{d}{dx}e^x
    \end{equation}
    and
    \begin{equation}
        e^x = \int e^x dx
    \end{equation}
    one of my students concluded that
    \begin{equation}
        \int dx = \frac{d}{dx}.
    \end{equation}
    \end{document}

编译结果如下:

等式 1 和 2 完全一致,但等式 3 不一致。

如您所见,前两个等式完全对齐,因为左侧占据相同的宽度。等式 3 没有对齐,因为左侧更宽。我正在寻找一个简单的解决方案来对齐所有等号,至少在一页上对齐,如果不是整个文档的话。

在我正在编写的完整文档中,方程式之间有几行解释,有时带有内联数学、参考文献等,因此,我认为在数学环境中简单地将几个单词以纯文本形式放入的解决方案并不可行。

我希望我已经清楚地陈述了我的问题并祝您有美好的一天。

答案1

我知道您说过“在数学环境中以纯文本形式输入几个单词”的解决方案似乎不可行。但您可能仍需要考虑\intertext( amsmath) 和\shortintertext( mathtools) 命令。

这些允许您将整段文本放在方程式之间,包括内联数学和引用。

两个命令的区别在于间距:\shortintertext段落之间的间距较小,如下例所示。

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{mathtools}

\usepackage{filecontents}

\begin{filecontents}{references.bib}
@inproceedings{TestSmith,
    title={This is a Test},
    author={Smith, John and Jones, Ben},
    booktitle={2016 Placeholder Conference on Citation Testing},
    pages={3--4},
    year={2016}
}
\end{filecontents}


\begin{document}

The "intertext" and "shortintertext" commands allow you to put text inside an align environment.
\begin{align}
c + c + e^x &= \frac{d}{dx}e^x 
\intertext{this is normal "intertext"} 
\intertext{It has large spacing between paragraphs} 
b + b + b + e^x &= \int e^x dx
\shortintertext{"shortintertext" from the "mathtools" package has smaller spacing}
\shortintertext{like this}
\int dx &= \frac{d}{dx}.
\shortintertext{This works even for multi-line paragraphs, inline math ($x=\alpha+\frac{a}{b+1}$) and citations~\cite{TestSmith}.}    
\shortintertext{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. . Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.}
\int dx &= \frac{d}{dx} + a + a + a.
\end{align}

\bibliographystyle{apalike}
\bibliography{references}

\end{document}

上述代码的输出

答案2

\intertext如果足以满足您的需要,则可以适用于单个或多个页面。

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{fleqn}
\begin{document}

Since we have
\begin{align}
    e^x &= \frac{d}{dx}e^x
\intertext{and}
    e^x &= \int e^x dx
\intertext{one of my students concluded that.. one of my students concluded that.. one of my students concluded that..}
    \int dx &= \frac{d}{dx}.
\end{align}

\end{document}

在此处输入图片描述

相关内容