# Tabular header vertical align and row height

How can I vertical align the header content (Electric Field) in my tabular, and eventually increase his row height?

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}

\newcommand{\tr}[1]{#1 &\\[22pt]}

\begin{document}
\begin{center}

\begin{tabular}{ |M{4cm}|M{4cm}|N }
\hline
\multicolumn{3}{|c|}{Electric Field} \\
\hline
\tr{Point charge & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q}{r^3} \times \vec{r}$}
\hline
\tr{Electric dipole & $\vec{E} = \dfrac{1}{2 \pi \epsilon_0} \cdot \dfrac{\vec{p}}{r^3}$}
\hline
\tr{Charged ring & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q\vec{z}}{\sqrt{(r^{2}+z^{2})^3}}$}
\hline
\end{tabular}
\end{center}
\end{document}


• \setlength{\extrarowheight}{2pt}
– user91669
Dec 21 '17 at 11:49

The following MWE contains two suggestion: The first uses invisible rules to increase the row height of only the first row, while the second is an alternative approach using \toprule, \midrule and \bottomrule from the booktabs package while avoiding all vertical lines:

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{N}{@{}m{0pt}@{}}
\newcommand{\tr}[1]{#1 &\\[22pt]}

\usepackage{booktabs}

\begin{document}
\begin{center}

\begin{tabular}{ |M{4cm}|M{4cm}|N }
\hline
\multicolumn{3}{|c|}{\rule{0pt}{2em}Electric Field\rule[-1em]{0pt}{2em}} \\
\hline
\tr{Point charge & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q}{r^3} \times \vec{r}$}
\hline
\tr{Electric dipole & $\vec{E} = \dfrac{1}{2 \pi \epsilon_0} \cdot \dfrac{\vec{p}}{r^3}$}
\hline
\tr{Charged ring & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q\vec{z}}{\sqrt{(r^{2}+z^{2})^3}}$}
\hline
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{M{4cm}M{4cm}N }
\toprule
\multicolumn{3}{c}{\rule{0pt}{2em}Electric Field\rule[-1em]{0pt}{2em}} \\
\midrule
\tr{Point charge & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q}{r^3} \times \vec{r}$}
\tr{Electric dipole & $\vec{E} = \dfrac{1}{2 \pi \epsilon_0} \cdot \dfrac{\vec{p}}{r^3}$}
\tr{Charged ring & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q\vec{z}}{\sqrt{(r^{2}+z^{2})^3}}$}
\bottomrule
\end{tabular}
\end{center}
\end{document}


For further information on how to change the row heights, you can also have a look here: Column and row padding in tables and here: Increase LaTeX table row height

A simple solution with cellspace, which lets you define minimal vertical spacing at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you use siunitx). You won't have to define this \tr command for the spacing:

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\newcolumntype{M}[1]{>{\centering\arraybackslash}S{m{#1}}}
\newcolumntype{N}{@{}m{0pt}@{}}

\newcommand{\tr}[1]{#1 &\\}

\begin{document}

\begin{center}
\begin{tabular}{ |M{4cm}|M{4cm}|N }
\hline
\multicolumn{3}{|Sc|}{Electric Field} \\
\hline
Point charge & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q}{r^3} \times \vec{r}$ & \\
\hline
Electric dipole & $\vec{E} = \dfrac{1}{2 \pi \epsilon_0} \cdot \dfrac{\vec{p}}{r^3}$ \\
\hline
Charged ring & $\vec{E} = \dfrac{1}{4 \pi \epsilon_0} \cdot \dfrac{q\vec{z}}{\sqrt{(r^{2}+z^{2})^3}}$ & \\
\hline
\end{tabular}
\end{center}

\end{document}


You can use the bigstrut package or define your own strut as \mystrut{<length in pt>} for example.

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{xcolor}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\newcommand{\mystrut}[1]{$\vcenter{\hbox{\rule{0pt}{#1pt}}}$}

\begin{document}

\begin{center}
\begin{tabular}{|M{4cm}|>{$}M{4cm}<{$}|}
\hline
\multicolumn{2}{|c|}{Electric Field\mystrut{30}}                                                                 \\ \hline
Point charge\mystrut{30}    & \vec{E} = \dfrac{1}{4\pi \epsilon_0} \cdot \dfrac{q}{r^3} \times \vec{r}           \\ \hline
Electric dipole\mystrut{30} & \vec{E} = \dfrac{1}{2\pi \epsilon_0} \cdot \dfrac{\vec{p}}{r^3}                    \\ \hline
Charged ring\mystrut{30}    & \vec{E} = \dfrac{1}{4\pi \epsilon_0} \cdot\dfrac{q\vec{z}}{\sqrt{(r^{2}+z^{2})^3}} \\ \hline
\end{tabular}
\end{center}

\end{document}