I have created simple table which purposefully has all cells, except first row and first column, blank.
\documentclass{book}
\usepackage{rotating}
\linespread{1.2}
\begin{document}
\thispagestyle{empty}
\begin{sideways}
\bgroup
\def\arraystretch{1.5}
\setlength\tabcolsep{10pt}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 & Column 5 & Column 6 & Column 7 & Column 8 & Column 9 & Column 10 & Column 11 \\
\hline
Row 2 & & & & & & & & & & \\
\hline
Row 3 & & & & & & & & & & \\
\hline
Row 4 & & & & & & & & & & \\
\hline
Row 5 & & & & & & & & & & \\
\hline
Row 6 & & & & & & & & & & \\
\hline
\end{tabular}
\egroup
\end{sideways}
\thispagestyle{empty}
\end{document}
As you can see, I have made three important changes: \linespread{1.2}
for linespacing for the rest of the document (not relevant for MWE), \def\arraystretch{1.5}
for vertical padding inside cells and \setlength\tabcolsep{10pt}
for horizontal padding inside cells.
I want to have text in the cells to be centered both vertically and horizontally. Without those three commands above, it seems to happen. However, once I add those three commands for better presentation, they seem to move text in the cells below vertical center. Examples:
Is there any way to keep those spacing/padding adjustments, but at the same time make text in the cell centered both vertically and horizontally? Also, why code of MWE creates PDF with two pages, instead of one?
Best Answer
Two solutions for vertical centring of cell contents:
makecell
package has commands for vertical padding of cell:\setcellgapes
to define a value for the padding (in preamble), and\makegapedcells
to use is in a given environment.cellspace
package works differently: it defines minimal vertical spacings between a cell and the above and below cells:\cellspacetoplimit
andcellspacebottomlimit
. You have to prefix the corresponding column specifier with the letterS
(orC
if you use thesiunitx
package).Here is a code for both ways: