我想将一个方程式移到 align 或 flalign 的最右端,但它会移到页边距之外。MWE 如下所示
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1] \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begin{flalign*}
x&=(a+b^2)(a+c^2+ sqrt(a+b^2))(a+b^2)(a+c^2+ sqrt(a+b^2))\\
&=z(a+c^2 +sqrt(z)) z(a+c^2 +sqrt(z))\\
&&where \ \ z=(a+b^2)
% \sin 2x &= 2\sin x\cos x \\
% &&\cos 2x &= \cos^2 x-\sin^2 x
\end{flalign*}
\lipsum[2]
\end{document}
答案1
我会这样做:
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1] \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begingroup
\setlength{\multlinegap}{0pt}
\begin{multline*}
x=(a+b^2)(a+c^2+\sqrt(a+b^2))(a+b^2)(a+c^2+\sqrt(a+b^2))\\
=z(a+c^2+\sqrt(z)) z(a+c^2+\sqrt(z))\\
\text{where } z=(a+b^2)
\end{multline*}
\endgroup
\lipsum[2]
And another use of \texttt{multline*}:
\begin{multline*}
a=\\b=\\c
\end{multline*}
As you can see, \verb|\multilinegap| has again the default value.
\end{document}
输出如下:
添加: 如果您坚持要使前两行在标志处对齐=
,则以下可能是最直接的解决方案:
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1] \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begingroup
\setlength{\multlinegap}{0pt}
\begin{multline*}
\begin{aligned}
x&=(a+b^2)(a+c^2+\sqrt(a+b^2))(a+b^2)(a+c^2+\sqrt(a+b^2))\\
&=z(a+c^2+\sqrt(z)) z(a+c^2+\sqrt(z))
\end{aligned} \\
\text{where } z=(a+b^2)
\end{multline*}
\endgroup
\lipsum[2]
And another use of \texttt{multline*}:
\begin{multline*}
a=\\b=\\c
\end{multline*}
As you can see, \verb|\multilinegap| has again the default value.
\end{document}
输出:
第二次补充:别忘了,这里还有魔法\hidewidth
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1] \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begin{flalign*}
x&=(a+b^2)(a+c^2+\sqrt(a+b^2))(a+b^2)(a+c^2+\sqrt(a+b^2))\\
&=z(a+c^2+\sqrt(z)) z(a+c^2+\sqrt(z))\\
&&\hidewidth \text{where } z=a+b^2
\end{flalign*}
\lipsum[2]
\end{document}
输出:
答案2
这where...
是句子结构的一部分,而不是数学,不需要对齐,所以只需将其放在对齐之外。
\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}
\begin{document}
\lipsum[1] \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begin{flalign*}
x&=(a+b^2)(a+c^2+ \sqrt{a+b^2})(a+b^2)(a+c^2+ \sqrt{a+b^2})\\
&=z(a+c^2 +\sqrt{z}) z(a+c^2 +\sqrt{z})
\end{flalign*}
\begin{flushright}
where $z=(a+b^2)$
\end{flushright}
\lipsum[2]
\end{document}
答案3
flalign
\mathllap
与(来自)配合使用效果很好mathtools
。我提出了第二种解决方案,使用alignat
(并且,再次,`\mathllap):
\documentclass{article}
\usepackage{mathtools}
\usepackage{showframe}%
\renewcommand\ShowFrameLinethickness{0.3pt}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\begin{flalign*}
& & x&=(a+b^2)(a+c^2+\sqrt{a+b^2})(a+b^2)(a+c^2+ \sqrt{a+b^2}) & & \\
& & &=z(a+c^2 +\sqrt{z}) z(a+c^2 + \sqrt{z})\\
& & &&& \mathllap{\text{where\enspace}z=a+b^2}
\end{flalign*}
\lipsum[2]
\begin{alignat*}{2}
x&=(a+b^2)(a+c^2+\sqrt{a+b^2})(a+b^2) & (a+c^2+ \sqrt{a+b^2}) & \\
&=z(a+c^2 +\sqrt{z}) z(a+c^2 + \sqrt{z})\\
&&& \mathllap{\text{where\enspace}z=a+b^2}
\end{alignat*}
\end{document}