# Vertical alignment problem with \arraystretch and m column definition

For some reason, in m{} columns, once \arraystretch pushes row height above the text height, the text ceases to be absolutely aligned. Instead, the first line is centered vertically and the rest fall below it. Any thoughts on why this is and/or how to fix it?

\documentclass{article}
\usepackage{array}
\begin{document}
\renewcommand{\arraystretch}{4}
\noindent\begin{tabular}{m{3in}c}
\hline
[19:21] time to take the tree outside\newline
[19:21] but I just let him back in! &
[19:21] time to take the tree outside\\
\hline
\end{tabular}
\end{document}


Okay, here's the more complete version.

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\newcommand{\ccol}{\centering\arraybackslash}
\renewcommand{\tabularxcolumn}[1]{>{\ccol}m{#1}}
\begin{document}
\renewcommand{\arraystretch}{4}
\noindent\begin{tabularx}{\textwidth}{m{2.1in}X}
\hline
[19:21] time to take the tree outside\newline
[19:21] but I just let him back in! &
[19:21] time to take the tree outside\\
\hline
\end{tabularx}


\end{document}

-
Your modified example (that now includes tabularx) compiles fine for me with both lines vertical centered, similar to the output in my answer. Is this not the case for you? – Werner Jan 16 '12 at 6:06
Except that there is more space above the text than below it. The text is centered relative to the text in other cells, but not within the cells themselves. – volfied Jan 16 '12 at 18:48

## 1 Answer

This is the default behaviour when using \arraystretch. The reason for this is that the contents inside a tabular (or array) is set with the traditional \baselineskip in mind, with the additional horizontal rule, making it seem like the entries are not vertically centered within each row. Modifying (increasing) \arraystretch exaggerates this apparent mis-alignment.

I would suggest inserting blank lines above/below the rows that need "air" like in the following MWE:

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\setlength{\parindent}{0pt}% No paragraph indent
\newcommand{\ccol}{\centering\arraybackslash}
\renewcommand{\tabularxcolumn}[1]{>{\ccol}m{#1}}
\begin{document}
\textbullet~No modification of \verb|\arraystretch|: \par
\begin{tabularx}{\linewidth}{m{2.1in}X}
\hline
[19:21] time to take the tree outside\newline
[19:21] but I just let him back in! &
[19:21] time to take the tree outside\\
\hline
\end{tabularx} \par\medskip

\textbullet~\verb|\arraystretch=4| \par
\renewcommand{\arraystretch}{4}%
\begin{tabularx}{\linewidth}{m{2.1in}X}
\hline
[19:21] time to take the tree outside\newline
[19:21] but I just let him back in! &
[19:21] time to take the tree outside\\
\hline
\end{tabularx} \par\medskip

\textbullet~\verb|\arraystretch=1| \par
\renewcommand{\arraystretch}{1}%
\begin{tabularx}{\linewidth}{m{2.1in}X}
\hline \\ \\\mbox{}%
[19:21] time to take the tree outside\newline
[19:21] but I just let him back in! &
[19:21] time to take the tree outside \\ \\ \\
\hline
\end{tabularx}
\end{document}


Note that using square brackets to start a new line in a tabular could lead to problems when inserting empty rows, since \\ is a control sequence that takes an optional argument: \\[<len>]. To avoid this, I've inserted an empty \mbox{} after \\ (in the last tabular) otherwise TeX would try to perform \\[19:21], and 19:21 is not a valid TeX length.

-
Unfortunately, I don't think either of those are going to work for my circumstance. I'm pretty far into a number of lengthy documents and have too many circumstances where either wouldn't cut it. Making them both m{}'s aligns them relatively, but not absolutely. There's more space above. I can't insert parboxes into every table and I can't insert one into the column definition because I'm using tabularx, with X redefined as an m{} column. It seems like such tables should work right off, but they don't. Must be something about how tabularx uses them. Thanks for the suggestions, though. – volfied Jan 16 '12 at 2:00
@AndrewHoward: It would help if you include a full minimal example that illustrates this as part of your original post, including the necessary requirements that you want to enforce. That way solutions can be tailored to accommodate this. – Werner Jan 16 '12 at 2:05
Of course. My apologies. Originally, I didn't realize anything else would be relevant. Let's see... – volfied Jan 16 '12 at 2:08
Awesome! So insert the same number of extra lines as the text takes up to begin with? – volfied Jan 17 '12 at 5:05
@AndrewHoward: Or however many you want. I'm not sure of your eventual usage. – Werner Jan 17 '12 at 5:15