und wieder bin ich etwas schlauer...
jedoch fehlt mir nun noch eine schöne Umsetzung mit variabler Startspalte und mit dem üblichen Zeileinumbruch
Die unterschiedliche Eingabe
\\ nach der 2. Zeile in der ersten Tabelle
und das etwas unschöne Ergebnis
komische Ausrichtug in der 2.Zeile/3.Spalte der zweiten Tabelle
wird hoffentlich in folgendem Minimalbeispiel deutlich
Code:
\documentclass{article}
\usepackage{array,multido,booktabs}
\makeatletter
\newcount\colNoA
\newcount\colNoB
\def\addtoks#1{\toks@=\expandafter{\the\toks@\cmidrule(lr){#1-#1}}}
\newcommand\CL[2][1]{%
\toks@={\tabularnewline}%
\colNoA=#1\relax%
\colNoB=#2\relax%
\advance\colNoB by 1%
\loop\ifnum\colNoA<\colNoB\relax
\expandafter\addtoks\expandafter{\the\colNoA}
\advance\colNoA by 1%
\repeat%
\the\toks@%
}
\makeatother
\begin{document}
\begin{tabular}{*3c}
\toprule
foo & \multicolumn{2}{c}{foo} \\
\cmidrule(lr){2-3}
& A & B \\
\cmidrule(lr){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}
1 & 111 & 222 \\
2 & 333 & 444 \\
\bottomrule
\end{tabular}
\begin{tabular}{*3c}
\toprule
foo & \multicolumn{2}{c}{foo} \\
\cmidrule(lr){2-3}
& A & B \CL{3}
1 & 111 & 222 \\
2 & 333 & 444 \\
\bottomrule
\end{tabular}
\end{document}
Lesezeichen