对使用 leqno 的方程式的注释进行右对齐

对使用 leqno 的方程式的注释进行右对齐

当我尝试向使用 leqno 的方程式添加注释时,我无法获得正确的格式。理想情况下,我希望方程式保持居中,无论它是否编号。任何建议都将不胜感激。

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}
\begin{document}
\noindent The equation is centered and does not contain a comment. Everything looks fine here.
\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}
 Adding a comment using align no longer centers the equation and the comment is not right justified.
\begin{align}
   (a+b)^2&=a^2+2ab+b^2 && \text{Right justify me!}
\end{align}
Commenting on an unnumbered equation causes equation to become uncentered and comment is on the wrong side.
\begin{equation*}
  (a+b)^2=a^2+2ab+b^2 \tag*{(Wrong side) }
\end{equation*}
\end{document}

在此处输入图片描述

答案1

你可以用flalign和做你想做的事\llap

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}

\begin{document}

\noindent The equation is centred and does not contain a comment. Everything looks fine here.
\begin{equation}
  (a+b)^2=a^2+2ab+b^2
\end{equation}


With \verb+flalign+ and \verb+\llap+, it remains centred:
\begin{flalign}
  & & (a+b)^2&=a^2+2ab+b^2 && \llap{Right justify me!}
\end{flalign}

\end{document}

在此处输入图片描述

答案2

可能对你来说不太满意,但flalign可以完成工作:

\documentclass[12pt, leqno]{book}
\usepackage{amsmath}
\begin{document}
\noindent The equation is centered and does not contain a comment. Everything looks fine here.
\begin{equation}
   (a+b)^2=a^2+2ab+b^2
\end{equation}
Adding a comment using align no longer centers the equation and the comment is not right justified.
\begin{flalign}
  &&(a+b)^2=a^2+2ab+b^2
  &&\text{Right justify me!}
\end{flalign}
\end{document}

您可能需要在前两个之间手动插入一些空格&。另一方面,我认为将注释向右对齐实际上无助于理解等式。

在此处输入图片描述

答案3

正如所述问题,您可以在 leqno 和 reqno 之间切换,然后使用\tag*{•}宏。

\documentclass[12pt]{book}
\usepackage[leqno]{amsmath}

\makeatletter
\newcommand{\leqnomode}{\tagsleft@true}
\newcommand{\reqnomode}{\tagsleft@false}
\makeatother

\begin{document}
\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}

\reqnomode
\begin{align*}
  (a+b)^2=a^2+2ab+b^2 \tag*{Right side}
\end{align*}
\leqnomode

\begin{equation}
   (a+b)^2=a^2+2ab+b^2 
\end{equation}

\end{document}

输出:

输出

相关内容