Question
In a tabular, how to ensure all rows have a vertically centered content and a height greater or equal to a given value (e.g. 0.8 cm)? (See MWE at bottom of the question). (The cell's content should not shrink or get enlarged).
Context and details
I'm writing a software that creates LaTeX documents automatically: maths worksheets for pupils. Among them, there's the "mental calculation" family of documents, where all questions are organized in a tabular of 10 or more questions.
Three columns are visible:
- the left one (number of the question),
- the middle one (the question itself, that may be one or two lines of text, sometimes a geometric figure is included, that needs more space),
- and the right one (either empty, on the first page, where pupils write their answers, or filled with the answer on the second page).
Here is how it looks like (text is in french, but you get the general idea?):
Problem
The content of the cells of the central column are roughly vertically centered, but this centering is obtained taking advantage of a bug in the array
package that is now fixed (see this question). Hence, using a newer version of array
produces vertically top aligned cells instead of vertically centered cells like in the picture above.
Nevertheless, I still would like to vertically center the content of the left and middle columns, may it be text or figures (or both).
Plus, there's a second constraint that requires to be fulfilled: I would like to ensure any row is at least 0.8 cm high (not fixed to 0.8 cm, but at least 0.8 cm) because pupils will need to write in the cells at right and the rows need to be high enough for that. Not all pupils have a tiny handwriting!
From @Bernard's answer I know the cellspace
package could help to keep the vertical alignement. So I thought maybe I could set the top and bottom space values to 0.3cm
, what would make 0.6cm
altogether (plus the height of the cell's content, so at least 0.8cm
altogether). But in cells containing geometric figures, such an extra space is not required and would add too much useless height to the cell (that would lead some tabulars to not fit into one page, only because some cells are too high).
I do not see how to use \arraystretch
to ensure a minimum height of 0.8 cm (that's only a coefficient).
Is it possible to fulfill these two constraints? It's possible to start from this example (where cells are vertically top centered if you use a recent version of array
):
\documentclass[a4paper, 12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\normalsize
\textbf{Some title}
\newline
\newline
\begin{tabular}{m{0.5 cm}>{}m{10 cm}|>{}m{4 cm}@{}m{0pt}@{}}
\hline
\textbf{1.} & $11 \times \text{?} = 9$ & & \tabularnewline [0.8cm] \hline
\textbf{2.} & $\text{?} \times \text{?} = 72$ & & \tabularnewline [0.8cm] \hline
\end{tabular}
\end{document}
Notes:
- I do not want to use another tabular package (like
longtable
,tabularx
,booktab
etc.). - I won't remove the vertical line separating the column at right because that makes a clear separation between the wording and the pupils' answers.
\arraystretch
so long as you work out what .8cm divided by the current baseline (eg 12pt) is. or just think in baselines rather than cm and specify it that way initially...\normalsize
(you can always add\showthe\baselinekip
and tex will show the value.>{\rule[-0.4cm]{0pt}{0.8cm}}m{0pt}
for the last column.@{}m{0pt}@{}
by>{\rule[-0.4cm]{0pt}{0.8cm}}m{0pt}
it has no effect (maybe because of the use of the more recentarray
version?)