我有一个等式,我想将其右对齐:
\documentclass{report}
\usepackage{amsmath,amsfonts,amsthm,bm} %math
%----------------------------------------
%Align Equations to LEFT MARGIN (use \mathleft then \mathcenter)
\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother
%----------------------------------------
\begin{document}
\begin{align}
center
\end{align}
\mathleft
\begin{align}
left
\end{align}
\end{document}
我有一段很棒的代码,可以让我用它来左对齐\mathleft
,是否可以让它右对齐?
答案1
当然可以,但必须先阅读 TeXbook(练习 19.8)。不过,请看最后一个例子,它可能就是你要找的。
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum*[2]
\begin{equation}
\hfilneg \text{left} \hspace{10000pt minus 1fil}
\end{equation}
\lipsum*[2]
\begin{equation}
\text{center}
\end{equation}
\lipsum*[4]
\begin{equation}
\hspace{10000pt minus 1fil} \text{right} \hfilneg
\end{equation}
But I guess you want something like this final example,
because ``right aligning'' equations has generally no
use:
\begin{multline}
\text{the first part of a very long equation,
that is set flush left} \\
\text{the final part, also quite long, set flush right}
\end{multline}
\end{document}
答案2
您可以使用 flalign 右对齐方程
\begin{flalign}
&& E^2 = (mC^2)^2 + (pC)^2
\end{flalign}