Centralização vertical do texto em múltiplas linhas na tabela ao usar \cmidrule

Centralização vertical do texto em múltiplas linhas na tabela ao usar \cmidrule

Considere o seguinte exemplo:

\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}

saída

Como centralizo verticalmente Dansk honningem relação às duas primeiras linhas?

Cheguei à conclusão de que o problema ocorre porque algum espaço é adicionado ao redor \cmidrule.

Responder1

Você pode ajustar o posicionamento do conteúdo multilinha em aproximadamente -(\aboverulesep + \belowrulesep)/2. -0.4exparece estar bem. Além disso, substituí seu \multirow{2}{*}{\specialcell{…}}comando pelo \multirowcellcomando demakecell, que faz a mesma coisa e pode ser ainda mais personalizado (fonte, alinhamento horizontal e vertical, etc.):

\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} 

insira a descrição da imagem aqui

informação relacionada