我在对齐环境中有一堆文本溢出到边距。我想将其换行。请注意,我使用的文档类与下面的状态不同。
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
e_i &= \varepsilon(d_i, y_i) + \lambda\frac{1}{2} \vert w \vert ^2\label{eq:regularisation} \\
\textnormal{where:} & \nonumber \\
\varepsilon(\cdot) &= \textnormal{cost function} \nonumber \\
w &= \textnormal{weights matrix of connection from immediate right layer (towards output layer)} \nonumber
\end{align}
\end{document}
我能想到的唯一解决方案是:
w &= \textnormal{weights matrix of connection from immediate right} \nonumber \\
&= \textnormal{layer (towards output layer)} \nonumber
我希望有一个更好的解决方案,因为我不想每次句子长度改变时都要进行更改。
答案1
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
e_i &= \varepsilon(d_i, y_i) + \lambda\frac{1}{2} \vert w \vert ^2\label{eq:regularisation} \\
\textnormal{where:} & \nonumber \\
\varepsilon(\cdot) &= \parbox[t]{5cm}{\raggedright cost function} \nonumber \\
w &= \parbox[t]{5cm}{\raggedright weights matrix of connection from immediate right layer (towards output layer)} \nonumber
\end{align}
\end{document}
答案2
您可以使用tabular
环境来获得完全控制权,并且\shortintertext
从mathtools
:
\documentclass[11pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
e_i &= \varepsilon(d_i, y_i) + \lambda\frac{1}{2} \vert w \vert ^2\label{eq:regularisation} \\
\shortintertext{where:}
\varepsilon(\cdot) &= \textnormal{cost function} \nonumber \\
w &= \begin{tabular}[t]{@{}l@{}}weights matrix of connection from immediate right layer\\ (towards output layer)\end{tabular} \nonumber
\end{align}
\end{document}