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}

最初の 2 つのコメントの間に手動でスペースを挿入することもできます&。一方、コメントを右に寄せても、式の理解に役立つとは思いません。

ここに画像の説明を入力してください

答え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}

出力:

出力

関連情報