如何使包含数学符号的等式中的每个单元格左对齐?

如何使包含数学符号的等式中的每个单元格左对齐?

正如标题所示,我有一个包含多个单元格的方程式,我希望每个单元格的内容都左对齐。以下这个答案我尝试过,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}

令人惊讶的是,第一行现在似乎出现在第二个单元格中(而不是在第一个单元格中左对齐):

使用 \mbc 输出

第二种方法似乎不适用于数学符号:

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

使用 \omit 和 \hfill 输出

$$它确实有效,但是我的 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} 

在此处输入图片描述

相关内容