My table needs to align its content both vertically and horizontally.
Here is the code:
\documentclass[twocolumn]{article}
\usepackage[T1]{fontenc}
\usepackage{booktabs, array}
\usepackage{lipsum}
\begin{document}
\begin{table*}
\centering
\begin{tabular}{>{\centering\arraybackslash}m{1cm}>{\centering\arraybackslash}m{1cm}}
\toprule 1 & 2 \\ \midrule 3 & 4 \\ \bottomrule
\end{tabular}
\caption{table 1}
\end{table*}
\lipsum[1-15] % filler text
\end{document}
To the best of my understanding, m
should align the contents vertically and these >{\centering\arraybackslash}
segments should align it horizontally. However, if you measure the space above the digits and the space beneath them, you will see that there is more space beneath them.
The simple task is:
- align cell content both horizontally and vertically, and
- make column width scale automatically (with its content).
I found many similar questions here, but none of them actually addresses the problem on the elementary level.
Best Answer
The classic tool is the
cellspace
package: you prefix the column specifier with the letterS
by default (orC
if you loadsiunitx
, or whatever letter you please with the[columntype=some letter]
loading option):