2

Consider the following example:

\documentclass{article}

\usepackage{siunitx}
\DeclareSIUnit[mode = text]\kroner{kr.}

\usepackage{booktabs,multirow}
\newcommand*\mr[2]{\multirow{#1}{*}{#2}}
\newcommand*\mc[2]{\multicolumn{#1}{c}{#2}}
\newcommand*\specialcell[2][c]{%
  \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}


\begin{document}

\begin{tabular}{
  l
  S[table-format = 3]
  S[table-format = 2.2]
}
 \toprule
    \mr{2}{\specialcell{Dansk\\ honning}}
  & \mc{2}{$1$~b{\ae}ger}       \\
    \cmidrule{2-3}               
  & \mc{1}{Masse~(\si{\g})}
  & \mc{1}{Pris~(\si{\kroner})} \\
 \midrule
    Almindelig
  & 450 & 14.95 \\
 \bottomrule
\end{tabular}

\end{document}

output

How do I vertically center Dansk honning relativt to the first two lines?

I've come to the conclusion that the problem occurs because some space is added around \cmidrule.

1 Answers1

1

You can adjust the placement of the multirow content by approximately -(\aboverulesep + \belowrulesep)/2. -0.4ex seems to be OK. In addition, I replaced your \multirow{2}{*}{\specialcell{…}} command with the \multirowcell command from makecell, which does the same thing, and can be further customised (font, horizontal and vertical alignment, ect.):

\documentclass{article}

\usepackage{siunitx}
\DeclareSIUnit[mode = text]\kroner{kr.}

\usepackage{booktabs,multirow}
\newcommand*\mc[2]{\multicolumn{#1}{c}{#2}}
\usepackage{makecell}

\begin{document}

\begin{tabular}{
  l
  S[table-format = 3]
  S[table-format = 2.2]
}
 \toprule
    \multirowcell{2}[-0.4ex]{Dansk\\honning}
  & \mc{2}{$1$~b{\ae}ger} \\
    \cmidrule{2-3}
  & \mc{1}{Masse~(\si{\g})}
  & \mc{1}{Pris~(\si{\kroner})} \\
 \midrule
    Almindelig
  & 450 & 14.95 \\
 \bottomrule
\end{tabular}

\end{document} 

enter image description here

Bernard
  • 271,350
  • You say that the adjustment should be approximately -(\aboverulesep + \belowrulesep)/2 but is the thickness of the rule itself then taken into account? – Svend Tveskæg Dec 21 '14 at 13:21
  • 1
    You're right, I didn't take it into account, but I don't think you'll see the difference: half the default \cmidrulewidth will be 0.015em. Moreover the adjustment might vary according to ascenders, descenders, mixed lowercase and uppercase letters or not. The adjustment required by the eye is not necessarily exactly the geometric midpoint between the two lines. – Bernard Dec 21 '14 at 13:32
  • Good point; I'll leave it at -0.4ex. – Svend Tveskæg Dec 21 '14 at 13:38