对齐:编号旁边的单词

对齐:编号旁边的单词
\begin{flalign}
  x &= 4^2 - 1\\
  &= 16 - 1\\
  &= 15&
\end{flalign}

上述代码将导致(1)的右侧出现x = 4^2 - 1,每一行都是如此。

我想在 旁边放上普通的单词(1), (2), etc.

假设是这样的:

\begin{flalign}
  x &= 4^2 - 1 \someFunction{given}\\
  &= 16 - 1 \someFunction{exponent}\\
  &= 15 \someFunction{substraction}&
\end{flalign}

答案1

flalign由于以下原因,我永远不会使用;请自行选择。

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\section{Bad example with \texttt{flalign}}

This is bad because the tags are too far away from the equations
\begin{flalign}
&&  x &= 4^{2} - 1 && \text{given}\\
&&    &= 16 - 1    && \text{exponent}\\
&&    &= 15        && \text{subtraction}
\end{flalign}

\section{Better example with \texttt{align}}

This is better because the tags are not mingled with the
equation number
\begin{align}
x &= 4^{2} - 1 && \text{given}\\
  &= 16 - 1    && \text{exponent}\\
  &= 15        && \text{subtraction}
\end{align}

\section{Even better example with \texttt{alignat}}

Here we set the tags nearer to the equations, which is
where they belong
\begin{alignat}{2}
x &= 4^{2} - 1 && \qquad\text{(given)}\\
  &= 16 - 1    && \qquad\text{(exponent)}\\
  &= 15        && \qquad\text{(subtraction)}
\end{alignat}

\end{document}

在此处输入图片描述

答案2

这里有两种变体:第一种将考虑文本宽度的方程式中心组放置在方程式编号旁边;第二种将文本放在零宽度的框中,看起来更像是一个对齐环境,没有文本:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{amsmath}

\begin{document}

\begin{flalign}
  & & x &= 4^2 - 1 & \text{given}\\
  & & &= 16 - 1 & \text{exponent}\\
  & & &= 15 & \text{substraction}
\end{flalign}

\begin{flalign}
  & & x &= 4^2 - 1 & \llap{given}\\
  & & &= 16 - 1 & \llap{exponent}\\
  & & &= 15 & \llap{substraction}
\end{flalign}

\begin{align}
   x &= 4^2 - 1 \\
   &= 16 - 1 \\
   &= 15 
\end{align}

\end{document} 

在此处输入图片描述

相关内容