對齊多個獨立方程

對齊多個獨立方程

早安,

我發現了很多關於如何對齊多行方程式的問題和教程,甚至超過了幾頁,但我無法弄清楚如何將多個方程式與它們之間的文字段落對齊。

這是我的問題的一個最小的工作示例:

    \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}

在此輸入影像描述

相關內容