我正在尝试用文字写一个除法方程,由于文字太长,我希望将方程写成更多行,这意味着分母使用 2 行(“相对”和“位移”写成 2 行),分子也是如此。
那可能吗?
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
(\mbox{percentage error})_{max}=100\ *\ \frac{\abs{\mbox{ relative displacement(t)}_{A}-\mbox{relative displacement}(t)_{B}}_{max}}{\mbox{relative displacement(t)}_{A}},
\label{eq:percentage_error}
\end{gather*}
\end{document}
答案1
您应该使用符号而不是长单词:
\documentclass{article}
\usepackage{amsmath,mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand{\tvar}[1]{\mathit{#1}}
\begin{document}
In the following formula, $\tvar{pe}$ stands for \emph{percentage error}
and $\tvar{rd}$ for \emph{relative displacement} depending on time.
\begin{equation}
\tvar{pe}_{\mathrm{max}}=
100\,\frac{\abs{\tvar{rd}(t)_{A}-\tvar{rd}(t)_{B}}_{\mathrm{max}}}{\tvar{rd}(t)_{A}},
\label{eq:percentage_error}
\end{equation}
\end{document}
替代方案
\begin{equation}
(\text{percentage error})_{\mathrm{max}}=
100\,\frac{\abs*{
\begin{multlined}
\text{relative displacement}(t)_{A}\\
-\text{relative displacement}(t)_{B}
\end{multlined}
}_{\mathrm{max}}}{\text{relative displacement}(t)_{A}},
\label{eq:percentage_error}
\end{equation}
不漂亮。
另一种可能性是multline
:
\begin{multline}
(\text{percentage error})_{\mathrm{max}}\\
=100\,\frac{\abs{
\text{relative displacement}(t)_{A}
-\text{relative displacement}(t)_{B}
}_{\mathrm{max}}}{\text{relative displacement}(t)_{A}},
\label{eq:percentage_error}
\end{multline}
答案2
看看以下解决方案是否是您想要的:
\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\begin{document}
\begin{gather*}
(\mbox{percentage error})_{\max}
= 100*\frac{\left|\addstackgap{\stackunder{relative}{displacement$(t)_{A}$}} -
\stackunder{relative}{displacement$(t)_{B}$}\right|_{\max}}
{\stackon{displacement$_{A}$}{relative}},
\label{eq:percentage_error}
\end{gather*}
\end{document}
附录:\stackunder
如果使用 以下方法,则会获得更好的结果\Centerstack
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\begin{document}
\begin{gather*}
(\mbox{percentage error})_{\max}
= 100*\frac{\left|\Centerstack{relative displacement$(t)_{A}$} -
\Centerstack{relative displacement$(t)_{B}$}\right|_{\max}}
{\stackon{displacement$_{A}$}{relative}},
\label{eq:percentage_error}
\end{gather*}
\end{document}