[Tex/LaTex] Equation in Table Too Large

equationstables

I have a table where one of the formulas is simply too long. Is there a way to break up an equation in Latex in a table? It's already rotated and I tried p{5cm} but it simply overlaps the text as it can't find a place to break the equation, even with spaces added. Which packages might be useful? The one relevant answer on here that I found was frustratingly unhelpful.
Thanks in advance!

The code for my table:

\begin{sidewaystable}
\begin{center}
\begin{tabular}{|l|l|l|l|} \hline
Objekt & Trägheitsmoment & Fehler Formel & Trägheitsmoment [$kg\cdot m^{2}$] \\ \hline
Hantelkörper &&& \\ \hline
Hohlzylinder & $J=\frac{m}{2}\left(r_{a}^{2}+r_{i}^{2}\right)^{2}$ & $\sqrt{\sigma_{m}^{2}\left(\frac{1}{2}\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2} +\sigma_{r_{a}}^{2}\left(r_{a}m\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2} +\sigma_{r_{i}}^{2}\left(r_{i}m\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2}}$ & $0.00057668 \pm 0.00000000$ \\ \hline


\end{tabular}
\end{center}
\end{sidewaystable}

Best Answer

I can think of two main options: first, use a substitution for common expressions. Second, make a savebox of a more complicated aligned equation, and insert that box into the table. This protects the & characters from being interpreted by the tabular environment.

Also, in terms of general table layout, see the booktabs documentation. I've left your format intact, but if it were me, I'd get rid of most or all of the rules.

enter image description here

enter image description here

\documentclass{article}

\usepackage{rotating}
\usepackage{amsmath} % for aligned environment

\begin{document}

% Option 1: substiute single variable for common expression
\begin{sidewaystable}
\begin{center}
\begin{tabular}{|l|l|l|l|} \hline
Objekt & Trägheitsmoment & Fehler Formel & Trägheitsmoment [$kg\cdot m^{2}$] \\ \hline
Hantelkörper &&& \\ \hline
Hohlzylinder & $J=\frac{m}{2}R^{2}$ & $\sqrt{\sigma_{m}^{2}\left(\frac{1}{2}R\right)^{2} +\sigma_{r_{a}}^{2}\left(r_{a}mR\right)^{2} +\sigma_{r_{i}}^{2}\left(r_{i}mR\right)^{2}}$ & \\
&& $R=\left(r_{a}^{2}+r_{i}^{2}\right)$ & $0.00057668 \pm 0.00000000$ \\
\hline
\end{tabular}
\end{center}
\end{sidewaystable}

% Option 2: make a multi-line radical, but hide the & characters from the tabular with a savebox
\newsavebox\bigeqn
\begin{lrbox}{\bigeqn}
  \begin{minipage}{0.32\textwidth}
$\sqrt{%
\begin{aligned}
   & \sigma_{m}^{2}\left(\frac{1}{2}\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2} + \\
   & \sigma_{r_{a}}^{2}\left(r_{a}m\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2} + \\
   & \sigma_{r_{i}}^{2}\left(r_{i}m\left(r_{a}^{2}+r_{i}^{2}\right)\right)^{2}
\end{aligned}}
$
\end{minipage}
\end{lrbox}

\begin{sidewaystable}
\begin{center}
\begin{tabular}{|l|l|l|l|} \hline
Objekt & Trägheitsmoment & Fehler Formel & Trägheitsmoment [$kg\cdot m^{2}$] \\ \hline
Hantelkörper &&& \\ \hline
Hohlzylinder & $J=\frac{m}{2}\left(r_{a}^{2}+r_{i}^{2}\right)^{2}$ & \usebox{\bigeqn} & $0.00057668 \pm 0.00000000$ \\ \hline
\end{tabular}
\end{center}
\end{sidewaystable}

\end{document}
Related Question