正如標題已經表明我有一個包含多個單元格的方程,我希望每個單元格的內容左對齊。下列的這個答案我嘗試使用flalign
但這似乎只是左對齊整個方程式。下面是一個小例子:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
\textrm{Some stuff about } \rho & & \\
\qquad \textrm{This is a really long equation and the following} \qquad & \textrm{should be left aligned} & \\
\qquad \textrm{Short equation (should be left too)} \qquad & \textrm{but quite a long one on the right though} &
\end{flalign*}
\end{document}
這個範例產生以下輸出(我做了一些註解來表明我想要實現的目標):
經過一些研究後,我感覺這些 二方法應該可以,但我無法讓它發揮作用。
繼第一種方法我試過:
\documentclass{article}
\usepackage{amsmath}
\usepackage{calc}
\newcommand*{\mbc}[2]{\makebox[\widthof{$F(\alpha)$}][#1]{$#2$}}
\begin{document}
\begin{flalign*}
\mbc{l}{\textrm{Some stuff about } \rho} & & \\
\qquad \textrm{This is a really long equation and the following} \qquad & \textrm{should be left aligned} & \\
\qquad \textrm{Short equation (should be left too)} \qquad & \textrm{but quite a long one on the right though} &
\end{flalign*}
\end{document}
令人驚訝的是,第一行現在似乎最終出現在第二個單元格中(而不是在第一個單元格中左對齊):
這第二種方法似乎不適用於數學符號:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\pushleft}[1]{\ifmeasuring@#1\else\omit$\displaystyle#1$\hfill\fi\ignorespaces}
\begin{document}
\begin{flalign*}
\pushleft{\textrm{Some stuff about } \rho} & & \\
\qquad \textrm{This is a really long equation and the following} \qquad & \textrm{should be left aligned} & \\
\qquad \textrm{Short equation (should be left too)} \qquad & \textrm{but quite a long one on the right though} &
\end{flalign*}
\end{document}
給出輸出:
$ pdflatex test.tex
[...]
! Undefined control sequence.
\pushleft #1->\ifmeasuring
@#1\else \omit $\displaystyle #1$\hfill \fi \igno...
l.20 \end{flalign*}
插入額外的$$
也沒幫助。我能得到的最接近的是使用\omit
and\hfill
但\omit
似乎選擇退出數學模式,所以我需要插入額外的$$
:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
\omit $\textrm{Some stuff about } \rho$ \hfill & & \\
\omit $\qquad \textrm{This is a really long equation and the following} \qquad$ \hfill & \textrm{should be left aligned} & \\
\omit $\qquad \textrm{Short equation (should be left too)} \qquad$ \hfill & \textrm{but quite a long one on the right though} &
\end{flalign*}
\end{document}
$$
它可以工作,但是我的 IDE到處都將額外的內容標記為錯誤,這絕對令人不快。我也不確定這是否是一個乾淨的解決方案,總是能按預期工作。
有誰知道如何在包含數學符號的方程式中實現單元格左對齊?或對後一種方法\omit
有何評論?\hfill
$$
答案1
像這樣?
\documentclass{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}
\begin{document}
\begin{flalign*}
& \textrm{Some stuff about } \rho & & \\
& \qquad \textrm{This is a really long equation and the following} && \textrm{should be left aligned} \\
& \qquad \textrm{Short equation (should be left too)} & & \textrm{but quite a long one on the right though}
\end{flalign*}
\end{document}
其他對齊的範例程式碼:
\documentclass{article}
\usepackage{mathtools}
\usepackage[showframe]{geometry}
\begin{document}
\begin{flalign*}
\shortintertext{\texttt{Columns left-aligned:} }
& \textrm{Some stuff about } \rho \\
& \qquad \textrm{This is a really long equation and the following} && \textrm{should be left aligned} \\
& \qquad \textrm{Short equation (should be left too)} & & \textrm{but quite a long one on the right though}
\end{flalign*}
\begin{flalign*}
\shortintertext{\texttt{Columns right-aligned:} }
& \rlap{Some stuff about $\rho $} \\
& & \textrm{This is a really long equation and the following}& & \textrm{should be right aligned}& \\
& &\textrm{Short equation (should be rightt too)} && \textrm{but quite a long one on the right though}&
\end{flalign*}
\begin{flalign*}
\shortintertext{\texttt{Left column centred, right column left-aligned: }}
& \textrm{Some stuff about } \rho \\
& \begin{gathered} \textrm{This is a really long equation and the following}\\\textrm{Short equation (should be centred)}\end{gathered}
& \begin{aligned} & \textrm{should be left aligned} \\
& \textrm{but quite a long one on the right though}\end{aligned}&
\end{flalign*}
\end{document}