0

I have a bunch of text in an align environment which is overflowing to the margin. I would like to wrap it. Note I'm using a different document class than the one state below.

\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}

overflowed-text


Only solution I can think of is:

    w &= \textnormal{weights matrix of connection from immediate right} \nonumber \\
      &= \textnormal{layer (towards output layer)} \nonumber 

Was hoping for a better solution as I don't want to have to change this every time the length of sentence changes.

1
  • 1
    \parbox[t]{3cm}{weights of ....} Commented Apr 13, 2018 at 15:47

2 Answers 2

3

enter image description here

\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}
1

You can use a tabular environment to have full control, and \shortintertext from 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} 

enter image description here

2
  • I like this solution because I don't have to guess the correct size needed for parbox. Thanks! What's the relevance of shortintertext? Why should I choose it over what I have i.e. using align?
    – user14492
    Commented Apr 18, 2018 at 19:49
  • 1
    It is aligned at the left margin, and the vertical spacing is shorter than with the standard \intertext.
    – Bernard
    Commented Apr 18, 2018 at 20:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .