amsmath 預設是否對齊環境顯示樣式?

amsmath 預設是否對齊環境顯示樣式?

環境是aligned自動的嗎\displaystyle?這個測試似乎表明它是:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
  \(\begin{aligned}
    \int_{0}^{\pi}f(x)dx &= \frac{1}{\pi} \\
  \end{aligned}\)

  \(\int_{0}^{\pi}f(x)dx = \frac{1}{\pi} \)
\end{document}

此外,還amsmath.sty包含以下程式碼:

\newcommand{\start@aligned}[2]{%
    \RIfM@\else
        \nonmatherr@{\begin{\@currenvir}}%
    \fi
    \savecolumn@ % Assumption: called inside a group
    \alignedspace@left
    \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup
        \maxfields@#2\relax
        \ifnum\maxfields@>\m@ne
            \multiply\maxfields@\tw@
            \let\math@cr@@@\math@cr@@@alignedat
            \alignsep@\z@skip
        \else
            \let\math@cr@@@\math@cr@@@aligned
            \alignsep@\minalignsep
        \fi
        \Let@ \chardef\dspbrk@context\@ne
        \default@tag
        \spread@equation % no-op if already called
        \global\column@\z@
        \ialign\bgroup
           &\column@plus
            \hfil
            \strut@
            $\m@th\displaystyle{##}$%
            \tabskip\z@skip
           &\column@plus
            $\m@th\displaystyle{{}##}$%
            \hfil
            \tabskip\alignsep@
            \crcr
}

不幸的是,我不是一個 tex 黑客,所以我不能確定,但宏定義確實包含\displaystyle.但是,我無法在文檔中找到這些資訊。第 3 節(amsmath 使用者指南)列出了顯示的方程,但aligned不在其中。

有沒有一個好的方法來確定給定的數學環境是否是\displaystyle?通常,我會假設內聯數學預設為不顯示,但環境在oraligned內部使用。\(\)$$

答案1

程式碼包含該片段

\ialign\bgroup % spaces before and after & included for clarity
       & \hfil$\m@th\displaystyle{#}$ & $\m@th\displaystyle{{}#}$\hfil \crcr
%        \____________  ____________/   \_____________  _____________/
%                     \/                               \/
%         first column specification       second column specification

我刪除了很多與主題無關的內容;為了清楚起見,我還在 & 符號周圍引入了空格&,儘管它之前的空格實際上很重要;我已將其替換##為單個#,因為加倍源於嵌套定義的常見 TeX 規則。&暫時忘記第一個。\ialign是 的初始化形式\halign,水平對齊的 TeX 原語(它將列間距離設為零)。第一列有規格

\hfil $\m@th\displaystyle{#}$

這意味著“右對齊,顯示樣式數學”。使用包的符號,array這將是以下形式的列說明符

>{$\m@th\displaystyle\bgroup}r<{\egroup$}

第二列包含

$\m@th\displaystyle{{}#}$\hfil

這意味著“左對齊,顯示樣式數學,並以空\mathord原子開始”(對於正確的間距很重要)。

&那我先告訴忽略的第一行呢?這是一個 TeX 結構;引自TeXBook(第241頁)

前導碼通常具有週期性結構,如果您&在其中一個模板之前添加一個額外的內容,TeX 會認為前導碼是一個無限序列,當\cr達到 時,該序列再次從標記的模板開始。

因此,這種右對齊、左對齊的列序列可以無限重複。因此,aligned環境基本上對應於具有重複列的表格rlrlrlrl...,全部處於顯示樣式數學模式。

相關內容