当我尝试向使用 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}
输出: