0

I have the following code for a table.

\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell, multirow}
\renewcommand\theadfont{\bfseries}

\begin{document}
    \begin{tabularx}{\textwidth}{*{2}{l} X}
    \hline

    \multirowthead{2}{Abduction}
    & \emph{Specification}
    & The proband begins in the anatomical 0-degree starting position. From there the arm
      is moved sidewards, away from the body hence, lifting the arm inside the frontal
      plane. This is done as far as possible or until the proband starts to feel pain.
    \\

    & \emph{Instructions}
    & TODO
    \\

    \hline

    \multirowthead{2}{Adduction}
    & \emph{Specification}
    & TODO
    \\

    & \emph{Instructions}
    & TODO
    \\

    \hline
\end{tabularx}
\end{document}

As you can see in the following picture the contents of the first column only get vertically centered when the cells to the aren't automatically wrapped to multiline cells. I want them to get vertically centered in both situations.

table

I tried several things.

  1. Using tabu-package doesn't change anything irrespective of the things i tried next.
  2. Don't use makecell-package and use multirow{2}{*}{...} instead. No real effect.
  3. Use multirowcell{2}{\textbf{...}} instead \multirowthead{2}. No effect.
  4. Use \multirowthead and \multirowcell with \usepackage{makecell} only. No effect.
  5. Use makecell for the long text in the last column. Puts the text in one line and removes any wrapping.
  6. Do 5 but add \\ for manual wrapping. This actually works, but this is the least desireable method, since I have to find the right spots for the line breaks myself rather than letting LaTeX wrap the cells automatically for me.

Does anybody know a way to keep the automatic wrapping but still get beautifully vertically centered multirows?

I also would like the cells in the second column to align vertically centered. Any idea how I could achieve that?

  • 1
    Change the first \multirowthead{2}{Abduction} as \multirowhead{7}{Abduction} and compile you will get what you want. – murugan May 8 '16 at 14:58
  • @murugan Nope, that's not working and it would be guessing wich number to chose to get the right centering. This wouldn't center the text automatically and most likely the centering won't be exact. Furtehmore, this is not what the multirow environment is for. – Lilo May 8 '16 at 15:10
  • 1
    The multirow environment uses the number of lines used in its argument, not the number of rows. In other words, it is made for one-lined cells. – Bernard May 8 '16 at 15:48
  • @Bernard That is what I got know too. But how would I achieve the desired behaviour anyway? – Lilo May 8 '16 at 15:50
1

Here you are. I added some vertical padding to cells, with the \makegapedcells command from makecell:

\documentclass{article}
\usepackage{tabularx}
\usepackage{makecell, multirow}
\renewcommand\theadfont{\bfseries}
\setcellgapes[t]{2pt}

\begin{document}

\makegapedcells
    \begin{tabularx}{\textwidth}{*{2}{l} X}
    \hline
    \multirowthead{7}{Abduction}
    & \emph{Specification}
    & The proband begins in the anatomical 0-degree starting position. From there the arm
      is moved sidewards, away from the body hence, lifting the arm inside the frontal
      plane. This is done as far as possible or until the proband starts to feel pain.
    \\
    & \emph{Instructions}
    & TODO
    \\
    \hline
    \multirowthead{2}{Adduction}
    & \emph{Specification}
    & TODO
    \\
    & \emph{Instructions}
    & TODO
    \\
    \hline
\end{tabularx}

\end{document} 

enter image description here

  • 2
    Which clearly shows that the terms in the first column should be at the top, rather than hanging from nowhere. Not your fault, of course. – egreg Jul 7 '16 at 23:28
  • 1
    @egreg: ‘No levitation for first columns’ is a fine slogan :o) – Bernard Jul 7 '16 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.