Centre cell vertically in tabularx across multiple multiline rows

Consider this example:

\documentclass{report}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{multirow}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{document}
\begin{tabularx}{0.5\linewidth}{llX}
\multirow{2}{*}{A} & B & \lipsum[1][1-2] \\
& C & \lipsum[2][1-3]\\
\end{tabularx}
\end{document}


The output is

I have used Vertical alignment in tabularx X column type to centre cells vertically.

However, I am not pleased the way "A" is centred. It uses multirow. How to centre "A" vertically in the middle of the table?

Solution that avoids the use of multirow is also accepted.

• Maybe you can try with \multirow{8}{*}{A}. – leandriis Apr 22 '19 at 8:18
• Since you made m the underlying column type, since the cells in column 3 occupy 12 rows in all, and since one half of 12 is 6, you should replace \multirow{2}{*}{A} with \multirow{6}{*}{A}. – Mico Apr 22 '19 at 8:22
• @Mico: Wouldn't one typically use \multirow{12} in order to vertically center a cell adjacent to a cell that contains 12 lines of text? However, in the OP's case the redefinition of the X type column using \renewcommand{\tabularxcolumn}[1]{m{#1}} seems to interfere with that. – leandriis Apr 22 '19 at 8:28
• @leandriis, then I need to manually count rows. So laborious when dealing with many tables, changing text. – Viesturs Apr 22 '19 at 8:36
• @leandriis - Indeed, if the \renewcommand{\tabularxcolumn}[1]{m{#1}} directive weren't there, one would have to use 12, not 6, as the first argument of \multirow. – Mico Apr 22 '19 at 8:40

As Ulrike said in a comment, to avoid manual adjustment, nesting tabulars could be a solution.

I would put a tabular with an m column of appropriate width in the main tabular.

I added the lines just to show the "A" is vertically centered.

\documentclass{report}
\usepackage{tabularx}
\usepackage{array}
\usepackage{lipsum}
\begin{document}
\noindent\begin{tabular}{|ll}
\hline
A &
\begin{tabular}{@{}lm{.352\linewidth}@{}}
B & \lipsum[1][1-2]\\
C & \lipsum[2][1-3]\\
\end{tabular}\\
\hline
\end{tabular}

\vspace{4ex}\noindent\begin{tabularx}{.5\linewidth}{|llX}
\hline
A & B & Just for benchmark\\
\hline
\end{tabularx}
\end{document}


• In case of multiple multirow cells nesting in a nesting would be required. – Viesturs Apr 22 '19 at 9:29
• @Viesturs Yes, it may be – CarLaTeX Apr 22 '19 at 9:30

Here is a possibe solution using a minipage and a tabularx:

\documentclass{report}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{multirow}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\usepackage{calc}

\begin{document}

\begin{minipage}{2em}
A
\end{minipage}%
\begin{tabularx}{0.5\linewidth-2em}{lX}
B & \lipsum[1][1-2]  \\
C & \lipsum[2][1-3]\\
\end{tabularx}

\end{document}


In this case you can use a 1-row multicolumn as the baseline of the m-column is there. In other cases you will have to use the vmode-option described in the documentation. Imho while multirow works okay with 1-line cells it is imho rather a pain with m- and p-columns and I use it seldom.

\documentclass{report}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{multirow}
\begin{document}
% with X as p-column 5 works:
\begin{tabularx}{0.5\linewidth}{llX}
\multirow{5}{*}{A} & B & \lipsum[1][1-2] \\
& C & \lipsum[2][1-3]\\
\end{tabularx}

%X as m-column:
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{0.5\linewidth}{llX}
\multirow{1}{*}{A} & B & \lipsum[1][1-2] \\
& C & \lipsum[2][1-3]\\
\end{tabularx}
\end{document}


To center the A over both cells use a value of 8.5 or 9 works (that's the number of lines below the baseline of the first cell.

\documentclass{report}
\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{multirow}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{document}
\begin{tabularx}{0.5\linewidth}{llX}
\multirow{9}{*}{A} & B & \lipsum[1][1-2] \\
& C & \lipsum[2][1-3]\\
\end{tabularx}
\end{document}


• Where is the improvement? Apparently I was not clear in my question, but by nicely I mean "A" centred vertically in the middle of the table. I updated my question. – Viesturs Apr 22 '19 at 8:39
• Ah sorry, I added an edit. – Ulrike Fischer Apr 22 '19 at 8:51
• Now there are 6 lines above and 5 below "A". 7 works for me. This solution requires a tedious counting of lines manually. – Viesturs Apr 22 '19 at 8:55
• Yes, but the A is aligned to a line. It is up to you to decide what is visual more pleasing. And yes, it is a pain - I already wrote in the answer. I wouldn't use multirow but nested tabulars or even simple boxes for such a layout. – Ulrike Fischer Apr 22 '19 at 9:04
• it could be worthwhile to provide your solution with nested tabulars or simple boxes. – Viesturs Apr 22 '19 at 9:06