嘗試在使用 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
and做你想做的事\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}
輸出: