0

I'm using the align environment to create four rows which each contain three formulas. One of them is to long. How do I break this specific formula to two lines?

\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{align}
\textnormal{FFNN eins:} && w &= (180*h_1)+(h_1*13) & b &= h_1+13 \label{eqn:w_ffnn_1}  \\
\textnormal {FFNN zwei:} && w &= (180*h_1)+(h_1*h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_ffnn_2} \\
\textnormal{RNN eins:} && w &= (9*h_1 + h_1^2)+(h_1*13) & b &= h_1 + 13 \label{eqn:w_rnn_1} \\
\textnormal {RNN zwei:} && w &= (9*h_1+h_1^2+h_1)+(h_1*h_2+h_2^2+h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_rnn_2}
\end{align}

\end{document}

The middle formula in the last row is to long and makes everything look ugly.

1

You could add another line to the align environment which you don't number:

\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{align}
\textnormal{FFNN eins:} && w &= (180*h_1)+(h_1*13) & b &= h_1+13 \label{eqn:w_ffnn_1}  \\
\textnormal {FFNN zwei:} && w &= (180*h_1)+(h_1*h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_ffnn_2} \\
\textnormal{RNN eins:} && w &= (9*h_1 + h_1^2)+(h_1*13) & b &= h_1 + 13 \label{eqn:w_rnn_1} \\
\textnormal {RNN zwei:} && w &= (9*h_1+h_1^2+h_1) & b &= h_1 + h_2 + 13
\label{eqn:w_rnn_2}\\
&&&\phantom{={}}+(h_1*h_2+h_2^2+h_2)+(h_2*13) \nonumber
\end{align}

\end{document}

enter image description here

Or you could use an aligned environment in that line:

\documentclass{book}
\usepackage{amsmath}
\begin{document}
\begin{align}
\textnormal{FFNN eins:} && w &= (180*h_1)+(h_1*13) & b &= h_1+13 \label{eqn:w_ffnn_1}  \\
\textnormal {FFNN zwei:} && w &= (180*h_1)+(h_1*h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_ffnn_2} \\
\textnormal{RNN eins:} && w &= (9*h_1 + h_1^2)+(h_1*13) & b &= h_1 + 13 \label{eqn:w_rnn_1} \\
\textnormal {RNN zwei:} && w &=
\begin{aligned}[t]&(9*h_1+h_1^2+h_1)\\&+(h_1*h_2+h_2^2+h_2)+(h_2*13)\end{aligned} & b &= h_1 + h_2 + 13 \label{eqn:w_rnn_2}
\end{align}

\end{document}

(Output looks the same)

1

if * is just a normal product I would drop it (aaa) if it is a special product and you need the * syntax then you can cramp the space slightly (bbb)

enter image description here

\documentclass{book}
\usepackage{mathtools}
\begin{document}
aaa
\begin{align}
\shortintertext{FFNN eins:}
w &= (180h_1)+(h_113) & b &= h_1+13 \label{eqn:w_ffnn_1}  \\
\shortintertext{FFNN zwei:}
 w &= (180h_1)+(h_1h_2)+(h_213) & b &= h_1 + h_2 + 13 \label{eqn:w_ffnn_2} \\
\shortintertext{RNN eins:}
w &= (9h_1 + h_1^2)+(h_113) & b &= h_1 + 13 \label{eqn:w_rnn_1} \\
\shortintertext{RNN zwei:}
 w &= (9h_1+h_1^2+h_1)+(h_1h_2+h_2^2+h_2)+(h_213) & b &= h_1 + h_2 + 13 \label{eqn:w_rnn_2}
\end{align}

bbb{\medmuskip=2mu
\begin{align}
\shortintertext{FFNN eins:}
w &= (180*h_1)+(h_1*13) & b &= h_1+13 \label{eqn:w_ffnn_1}  \\
\shortintertext{FFNN zwei:}
 w &= (180*h_1)+(h_1*h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_ffnn_2} \\
\shortintertext{RNN eins:}
w &= (9*h_1 + h_1^2)+(h_1*13) & b &= h_1 + 13 \label{eqn:w_rnn_1} \\
\shortintertext{RNN zwei:}
 w &= (9*h_1+h_1^2+h_1)+(h_1*h_2+h_2^2+h_2)+(h_2*13) & b &= h_1 + h_2 + 13 \label{eqn:w_rnn_2}
\end{align}}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.