我希望将评论保留在侧面,因此我不想使用互文或短互文,而是将长行设为两行,并保持所有内容等距!有什么技巧/命令?
\documentclass{article}
\usepackage{amsmath,xcolor,geometry}
\begin{document}
$\begin{aligned}[t] \dfrac{20-5x^{2}}{x^{2}+x-6}&=\dfrac{5(4-x^{2})}{(x+3)
(x-2)} && \textcolor{blue}{\text{Factor}} \\
&=\dfrac{5(2+x)(2-x)}
{(x+3)(x-2)} && \textcolor{blue}{\text{Factor completely}} \\
&=\dfrac{5(2+x) \cdot \textcolor{red}{-1}(\colorbox{cyan!25!white}{$x-2$})}
{(x+3)(\colorbox{cyan!25!white}{$x-2$})} && \textcolor{blue}{\text{Notice
opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify}} \\
&=-\dfrac{5(2+x)}{x+3}
\end{aligned}$
\end{document}
答案1
在这种情况下,我会采取以下措施。
\documentclass{article}
\usepackage{amsmath,xcolor,geometry}
\newbox\aebox
\newcommand\aecomment[1]{%%
\begin{lrbox}\aebox
\begin{minipage}[t]{2in}
\raggedright
\textcolor{blue}{#1}%%
\end{minipage}%%
\end{lrbox}%%
\raisebox{0pt}[\height][0pt]{\usebox{\aebox}}}
\begin{document}
$
\begin{aligned}[t]
\dfrac{20-5x^{2}}{x^{2}+x-6} &=\dfrac{5(4-x^{2})}{(x+3) (x-2)} && \textcolor{blue}{\text{Factor}} \\
&=\dfrac{5(2+x)(2-x)}{(x+3)(x-2)} && \textcolor{blue}{\text{Factor completely}} \\
&=\dfrac{5(2+x) \cdot \textcolor{red}{-1}(\colorbox{cyan!25!white}{$x-2$})}
{(x+3)(\colorbox{cyan!25!white}{$x-2$})}
%% && \textcolor{blue}{\text{Notice opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify}} \\
&& \aecomment{Notice opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify} \\
&=-\dfrac{5(2+x)}{x+3}
\end{aligned}
$
\end{document}
现在,我应该提醒一下,我已经消除了评论的深度。这意味着如果你写了类似的东西:
$
\begin{aligned}[t]
\dfrac{20-5x^{2}}{x^{2}+x-6} &=\dfrac{5(4-x^{2})}{(x+3) (x-2)} && \textcolor{blue}{\text{Factor}} \\
&=\dfrac{5(2+x)(2-x)}{(x+3)(x-2)} && \textcolor{blue}{\text{Factor completely}} \\
&=\dfrac{5(2+x) \cdot \textcolor{red}{-1}(\colorbox{cyan!25!white}{$x-2$})}
{(x+3)(\colorbox{cyan!25!white}{$x-2$})}
%% && \textcolor{blue}{\text{Notice opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify}} \\
&& \aecomment{Notice opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify} \\
&=-\dfrac{5(2+x)}{x+3}
&& \textcolor{red}{\text{\bfseries Smashes into line above!!!}}
\end{aligned}
$
您将遇到评论冲突。因此,请注意。
我倾向于谨慎使用此类注释。因此,此类冲突对我来说不是一个重大问题。但在这里您可以看到如果我不将深度置零会发生什么:
如果您不介意长注释在等式中产生的额外空间,那么只需删除部分\raisebox
细节即可。
这种崩溃可能是避免\raisebox
通过实际使用增加框按指定量移动。在这里,我重新定义了\aecomment
\newbox\aebox
\newcommand\aecomment[2][0pt]{%%
\begin{lrbox}\aebox
\begin{minipage}[t]{2in}
\raggedright
\textcolor{blue}{#2}%%
\end{minipage}%%
\end{lrbox}%%
\raisebox{#1}[\height][0pt]{\usebox{\aebox}}}
调用方式如下:
$
\begin{aligned}[t]
\dfrac{20-5x^{2}}{x^{2}+x-6} &=\dfrac{5(4-x^{2})}{(x+3) (x-2)} && \textcolor{blue}{\text{Factor}} \\
&=\dfrac{5(2+x)(2-x)}{(x+3)(x-2)} && \textcolor{blue}{\text{Factor completely}} \\
&=\dfrac{5(2+x) \cdot \textcolor{red}{-1}(\colorbox{cyan!25!white}{$x-2$})}
{(x+3)(\colorbox{cyan!25!white}{$x-2$})}
&& \aecomment[2.5ex]{Notice opposites in $2-x$ and $x-2$. Write $2-x$ as $-1(x-2)$ and simplify} \\
&=-\dfrac{5(2+x)}{x+3}
&& \textcolor{red}{\text{\bfseries No crashing into line above!!!}}
\end{aligned}
$
不会发生冲突,而且也不会影响方程本身的间距。
答案2
使用软件包的简单解决方案stackengine
:
\documentclass{article}
\usepackage{amsmath,xcolor,geometry}
\usepackage[usestackEOL]{stackengine}
\begin{document}
$\begin{aligned}[t] \dfrac{20-5x^{2}}{x^{2}+x-6}&=\dfrac{5(4-x^{2})}{(x+3)
(x-2)} && \textcolor{blue}{\text{Factor}} \\
&=\dfrac{5(2+x)(2-x)}
{(x+3)(x-2)} && \textcolor{blue}{\text{Factor completely}} \\
&=\dfrac{5(2+x) \cdot \textcolor{red}{-1}(\colorbox{cyan!25!white}{$x-2$})}
{(x+3)(\colorbox{cyan!25!white}{$x-2$})} && \textcolor{blue}{\Centerstack[l]{Notice
opposites in $2-x$ and $x-2$. \\Write $2-x$ as $-1(x-2)$ and simplify}} \\
&=-\dfrac{5(2+x)}{x+3}
\end{aligned}$
\end{document}