# Vertical alignment of equations including fractions in a table

I need to cramp a table into a tight space, but unfortunately the equations aren't aligning/fitting into it vertically. Here is the code:

\documentclass[12pt]{article}
\usepackage[a4paper, top = 0.8cm, left = 1cm, right = 1cm, bottom = 0.8cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{array}

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\scriptsize
\tabcolsep=0.05cm
\setlength\extrarowheight{0.15cm}
\begin{tabular}{C{1.5cm}|C{1.5cm}|C{1.3cm}|C{4.4cm}|C{1.8cm}}
Querschnitt & Zug/Druck & Schub & Biegung & Torsion\\\hline
Spannung & $\sigma_w = \frac{F}{A_w}$ & $\tau_{w}= \frac{F_q}{A_w}$ & $\sigma_{wb} = \frac{M_{bx}}{W_{wbx}}$ &  $\tau_{wt} = \frac{M_t}{W_{wt}}$\\\hline
Rechteck & \multicolumn{2}{c|}{$A_w = 2a(b+t)$} & $W_{wbx} = \frac{(t+a)(b+a)^3-(t-a)(b-a)^3}{6(b+a)}$ &  $W_{wt} = 2abt$\\\cline{1-5}
Kreis & \multicolumn{2}{c|}{$A_w = \pi da$} & $W_{wb} = \frac{\pi\left[(d+a)^4 -(d-a)^4\right]}{32(d+a)}$ &  $W_{wt} = 2W_{wb}$\\
\end{tabular}
\end{document}


And what it currently looks like:

As you can see, \extrarowheight fixed the issue of the equations overlapping the \hline on the top, but unfortunately they are still overlapping them on the bottom. In the document I'm using this table it also happens to be inconsistent for every cell, though I use the same snippet as added above.

Using m{} unfotunately didn't center the cells when using \extrarowheight, so I'm in some kind of dillema here as I can either center the equations or stop them from overlapping (on the top only). \arraystretch has the same effect as \extrarowheight.

Does anybody have a solution for this issue?

Thanks!

• Did you try https://tex.stackexchange.com/questions/6355/problem-with-table-vertical-alignment? – JPi May 7 '17 at 17:27
• @JPi Yep, this unfortunately breaks the equations though, even when making their cells way longer than they actually are. – Skydiver May 7 '17 at 17:31

You can insert "bottom [typographic] struts" to obtain more vertical whitespace between the lowest item in a formula and the horizontal line immediately below it.

• Provide some manual kerning for the 7 instances of W_{w...}.
• Since no linebreaks seem to be called for in any of the cells, you might was well use the basic c column type instead of a centered version of the p column type.
• Since the contents of almost all cells should be rendered in math mode, switching from a tabular environment to an array environment will save you from having to type lots and lots of $ tokens. \documentclass[12pt]{article} \usepackage[a4paper, vmargin = 0.8cm, hmargin = 1cm]{geometry} \usepackage[utf8]{inputenc} \usepackage{array} % for "\extrarowheight" macro \newcommand\Bstrut{\rule[-1ex]{0pt}{0pt}} % "bottom" strut \begin{document} \noindent \scriptsize \setlength\arraycolsep{1mm} \setlength\extrarowheight{1.5mm}$\begin{array}{@{} >{$}c<{$} |c|c|c|c @{}} % first col. in text mode
Querschnitt & $Zug/Druck$ & $Schub$ & $Biegung$ & $Torsion$ \\
\hline
Spannung &
\sigma_w = \frac{F_{\vphantom{q}}}{A_{w\Bstrut}} &
\tau_{w}= \frac{F_{\!q}}{A_{w\Bstrut}} &
\sigma_{wb} = \frac{M_{bx}}{W_{\!wbx\Bstrut}} &
\tau_{wt} = \frac{M_t}{W_{\!wt\Bstrut}} \\
\hline
Rechteck &
\multicolumn{2}{c|}{A_w = 2a(b+t)} &
W_{\!wbx} = \frac{(t+a)(b+a)^3-(t-a)(b-a)^3}{6(b+a)\Bstrut} &
W_{\!wt\Bstrut} = 2abt \\
\cline{1-5}
Kreis &
\multicolumn{2}{c|}{A_w = \pi da} &
W_{\!wb} = \frac{\pi[(d+a)^{4} -(d-a)^4]}{32(d+a)} &
W_{\!wt} = 2W_{\!wb} \\
= \frac{F_{\!q}}{A_{w}}$&$\sigma_{wb}
= \frac{M_{bx}}{W_{\!wbx}}$&$\tau_{wt}
= \frac{M_t}{W_{\!wt}}$\\ \hline Rechteck & \multicolumn{2}{c|}{$A_w = 2a(b+t)$} &$W_{\!wbx}
= \frac{(t+a)(b+a)^3-(t-a)(b-a)^3}{6(b+a)}$&$W_{\!wt} = 2abt$\\ \cline{1-5} Kreis & \multicolumn{2}{c|}{$A_w = \pi da$} &$W_{\!wb} = \frac{\pi[(d+a)^{4} -(d-a)^4]}{32(d+a)}$&$W_{\!wt} = 2W_{\!wb}$\\ \end{tabular} \end{document}  Addendum: An alternative with considering Mico comment below and use amsmath package for \dfrac{...}{...} is: \documentclass[12pt]{article} \usepackage[a4paper, vmargin = 0.8cm, hmargin = 1cm]{geometry} \usepackage[utf8]{inputenc} \usepackage{cellspace} % for "\extrarowheight" macro \setlength\cellspacetoplimit{5pt} \setlength\cellspacebottomlimit{3pt} \usepackage[low-sup]{subdepth} % subscript positioning \usepackage{amsmath} \begin{document} \noindent \scriptsize \setlength\tabcolsep{3pt} \begin{tabular}{@{} c|c|c|Sc|c @{}} Querschnitt & Zug/Druck & Schub & Biegung & Torsion \\ \hline Spannung &$\sigma_w = \dfrac{F}{A_{w}}$&$\tau_{w} = \dfrac{F_{q}}{A_{w}}$&$\sigma_{wb} = \dfrac{M_{bx}}{W_{wbx}}$&$\tau_{wt} = \dfrac{M_t}{W_{wt}}$\\ \hline Rechteck & \multicolumn{2}{c|}{$A_w = 2a(b+t)$} &$W_{wbx} = \dfrac{(t+a)(b+a)^3-(t-a)(b-a)^3}{6(b+a)}$&$W_{wt} = 2abt$\\ \cline{1-5} Kreis & \multicolumn{2}{c|}{$A_w = \pi da$} &$W_{wb} = \dfrac{\pi\left[(d+a)^{4} -(d-a)^4\right]}{32(d+a)}$&$W_{wt} = 2W_{wb}$\\ \end{tabular} \end{document}  • This is pretty neat solution, unfortunately the code isn't working in my current document though (No issues in a fresh one). So while I'm not able to use it here, I'm surely going to apply this technique to future one! – Skydiver May 7 '17 at 19:03 • @Skydiver, the code is very standard. If you have in preamble of your document loaded in my MWE used packages (in comparison to your MWE is new only subdepth), the solution should work. Since your real preamble is not known, I can't see what could be cause of your problem. – Zarko May 7 '17 at 19:14 This fits the normal text width for article; using \mfrac from nccmath the fractions are not so unbearably small. \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{array,booktabs} \usepackage{nccmath} \begin{document} \begin{table}[htp] \centering \footnotesize \addtolength{\tabcolsep}{-2pt} \begin{tabular}{@{}lcccc@{}} \toprule Querschnitt & Zug/Druck & Schub & Biegung & Torsion\\ \midrule Spannung &$\sigma_w = \mfrac{F}{A_w}$&$\tau_{w}= \mfrac{F_q}{A_w}$&$\sigma_{wb} = \mfrac{M_{bx}}{W_{wbx}}$&$\tau_{wt} = \mfrac{M_t}{W_{wt}}$\\ \addlinespace Rechteck & \multicolumn{2}{c}{$A_w = 2a(b+t)$} &$W_{wbx} = \mfrac{(t+a)(b+a)^3-(t-a)(b-a)^3}{6(b+a)}$&$W_{wt} = 2abt$\\ \addlinespace Kreis & \multicolumn{2}{c}{$A_w = \pi da$} &$W_{wb} = \mfrac{\pi\left[(d+a)^4 -(d-a)^4\right]}{32(d+a)}$&$W_{wt} = 2W_{wb}\$\\
\bottomrule
\end{tabular}

\end{table}

\end{document}