Text wird bei Verwendung von Multirow überschrieben, Teil II: Ausrichtung

Text wird bei Verwendung von Multirow überschrieben, Teil II: Ausrichtung

siehe Teil I:Text wird bei Verwendung von Multirow überschrieben

nun möchte ich die Überschriften der Spalten ("Abs." und "Rel.") ausrichten:

\begin{tabular}{rrr}
\rowcolor{COLORROW} \rot{textA} & \multicolumn{2}{c}{%
  \begin{tabular}[b]{@{}cc@{}}
     \rowcolor{COLORROW} \multicolumn{2}{c}{\footnotesize text2} \\
     \rowcolor{COLORROW} \footnotesize Abs. & \footnotesize Rel.
     %\rowcolor{COLORROW} \multicolumn{1}{r}{\footnotesize Abs.} & \footnotesize Rel.
  \end{tabular}}
\\

\footnotesize{ 1} & \footnotesize{  5} & \footnotesize{ 1.00\%} \\
\footnotesize{ 2} & \footnotesize{ 10} & \footnotesize{10.03\%} \\
\footnotesize{ 3} & \footnotesize{  2} & \footnotesize{ 5.00\%} \\
\footnotesize{ 4} & \footnotesize{100} & \footnotesize{ 3.50\%} \\

\end{tabular}

aber die Ausrichtung funktioniert nicht, habe auch eine Mehrspaltenformatierung versucht (siehe %\rowcolor ...)

Bildbeschreibung hier eingeben

Antwort1

Ich schlage dieses Layout unter Verwendung des SSpaltentyps von vor siunitx, wenn Sie das möchten (nicht sicher):

\documentclass{article} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{rotating}
\newcommand\rot[1]{\rotatebox{90}{\footnotesize#1}} %
\usepackage[svgnames, table]{xcolor}
\colorlet{COLORROW}{Gainsboro!70}
\usepackage{siunitx, booktabs}

    \begin{document}

{\footnotesize%
\begin{tabular}{rS[table-format=2.0]S[table-format=2.2]}
\rowcolor{COLORROW}
     & \multicolumn{2}{c}{text2\rule{0pt}{4ex}} \\
     \rowcolor{COLORROW} \rot{\rlap{textA}} & {Abs.} &{Rel.\,(\%)} \\
\addlinespace[1ex]
1 & 5 & 1.00 \\
2 & 10 & 10.03 \\
3 & 2 & 5.00 \\
4 & 100 & 3.50 \\
\end{tabular}}%

\end{document}

Bildbeschreibung hier eingeben

Antwort2

Hier ist eine kleine Variation von Bernards Lösung. Ich verwende Streben, um genügend Platz für den gedrehten Text freizuhalten.

\documentclass{scrbook}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage[english]{babel}
\usepackage{biblatex}
\usepackage{pdfpages}
\definecolor{COLORROW}{HTML}{BEBEBE}

\usepackage{rotating}
\newcommand\rot[1]{\rotatebox{90}{\footnotesize#1}}

\begin{document}

\bgroup
\sbox0{\rot{textA}}% measure size
\def\mystrut{\rule{0pt}{0.5\ht0}\rule[-0.5\dp0]{0pt}{0pt}}% note: local to group
\footnotesize
\begin{tabular}{rrr}
\rowcolor{COLORROW} \mystrut & \multicolumn{2}{c}{text2} \\
\rowcolor{COLORROW} \mystrut \smash{\usebox0} & \multicolumn{1}{c}{Abs.} & \multicolumn{1}{c}{Rel.} \\
1 & 5 & 1.00\% \\
2 & 10 & 10.03\% \\
3 & 2 & 5.00\% \\
4 & 100 & 3.50\%
\end{tabular}
\egroup

\end{document}

Demo

verwandte Informationen