3

How can I align the contents of a multirow cell top the top?

Here's an MWE:

\documentclass{article}
\usepackage{array,multirow,booktabs,fullpage}

\begin{document}\begin{center}
\begin{tabular}{c>{\bfseries}l>{\itshape}clc>{\bfseries}l>{\itshape}cl}
\toprule
\multirow{1}{*}{\LARGE\bfseries A} & foo  & n. & lorem ipsum dolor sit &
\multirow{1}{*}{\LARGE\bfseries B} & foo  & n. & consectetur adipiscing elit \\
& bar  & v. & Maecenas sed purus       & & bar  & v. & at ipsum placerat luctus \\
& baz  & p. & Nullam luctus id tellus  & & baz  & p. & Ut ac ultricies neque \\
& qux  & v. & Aenean consequat commodo & & qux  & v. & in sodales metus ultrices \\
& buux & n. & Phasellus tincidunt      & & quux & n. & vitae pulvinar nisi mollis \\
\bottomrule
\end{tabular}\end{center}\end{document}

enter image description here

As you can see, what I've done is use the multirow command, but only set a row span of 1. This more or less gets me what I want: "hanging" letters, but with a couple of costs. First, I get a lot of Overfull \vbox warnings. The second is that the tops of the large letters are not actually precisely aligned:

enter image description here

2 Answers 2

2

I just uploaded a new version of multirow to CTAN. It should be available in a few days. If you want it now, just send me an email (you can find a working email address in multirow.sty).

With the new version you can give a positioning parameter [t] to \multirow to give it a top alignment. However, this will align the baselines of the letters, not the top. To align the tops you have to give it a fixup argument, that is the difference of the heights of the A and the f. This can be done as follows:

\usepackage{calc}
\newlength{\shiftdown}
\setlength{\shiftdown}{\heightof{f}-\heightof{\LARGE\bfseries A}}

and then

\multirow[t]{5}{*}[\shiftdown]{\LARGE\bfseries A} & foo  & n. & lorem ipsum dolor sit &
\multirow[t]{5}{*}[\shiftdown]{\LARGE\bfseries B} & foo  & n. & consectetur adipiscing elit \\
1

multirow command has two optional parameters:

\multirow{nrow}[njot]{width}[vmove]{contents}

the second one vmove helps you to adjust the vertical alignment.

\documentclass{article}
\usepackage{array,multirow,booktabs,fullpage}

\begin{document}\begin{center}
\begin{tabular}{c>{\bfseries}l>{\itshape}clc>{\bfseries}l>{\itshape}cl}
\toprule
\multirow{1}{*}[2pt]{\LARGE\bfseries A} & foo  & n. & lorem ipsum dolor sit &
\multirow{1}{*}[2pt]{\LARGE\bfseries B} & foo  & n. & consectetur adipiscing elit \\
& bar  & v. & Maecenas sed purus       & & bar  & v. & at ipsum placerat luctus \\
& baz  & p. & Nullam luctus id tellus  & & baz  & p. & Ut ac ultricies neque \\
& qux  & v. & Aenean consequat commodo & & qux  & v. & in sodales metus ultrices \\
& buux & n. & Phasellus tincidunt      & & quux & n. & vitae pulvinar nisi mollis \\
\bottomrule
\end{tabular}
\end{center}
\end{document}

enter image description here

2
  • Is there a way to calculate the vmode parameter, so that its value is a function of the size of the font? I want to be able to generalize the code as much as possible.
    – junius
    Commented Sep 27, 2016 at 8:33
  • @KevinKeith Sorry, but I don't know any automatic solution.
    – Ignasi
    Commented Sep 27, 2016 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .