3

I'm trying to make this table to fit to \textwidth. The first column has column type X from tabu package which should make it work. But it does not. Adding the "to \textwidth" option dosen't have any effect. What's the clue? Here is my MWE:

\documentclass[12pt,a4paper,BCOR5mm]{scrbook}

%Tabellen & Listen
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage{lipsum}

\newcommand\rota[1]{\rotatebox{90}{#1\ }}
\newcommand*\dimension[2]{\multicolumn{#1}{D}{\rota{#2}}}
\newcommand*\charakteristik[1]{\multicolumn{1}{C}{\rota{#1}}}

\begin{document}
This text has normal textwidth.
\lipsum[1]

%\begin{spacing}{0.8}
\newlength{\sep}
\setlength{\sep}{1.5pt}
\setlength{\tabcolsep}{\sep}
\setlength{\extrarowheight}{5pt}

%/Fonts#Sizing_text
\newcolumntype{O}{>{\small}X[l]}
\newcolumntype{D}{>{\small}c}
\newcolumntype{C}{>{\scriptsize}c}

\definecolor{Gray}{gray}{0.9}
\newcolumntype{W}{>{\columncolor{white}}C}
\newcolumntype{G}{>{\columncolor{Gray}}C}

\begin{longtabu}{O*{22}{WG}W}
\toprule
& \dimension{6}{Plattform} & \dimension{3}{Multi-User} 
& \dimension{2}{Export} & \dimension{2}{Import} 
& \dimension{4}{Benutzerführung} & \dimension{2}{Sprachen}
& \dimension{3}{Kollaboration} & \dimension{3}{Kosten} 
& \dimension{3}{Support} & \dimension{3}{Registrierung} 
& \dimension{2}{Canvas Typen} & \dimension{2}{Custom Canvas} 
& \dimension{10}{Finanzübersicht}\\ 
\cmidrule(r{1.5pt}){1-10} 
\cmidrule(l{1.5pt}r{1.5pt}){11-20} 
\cmidrule(l{1.5pt}r{1.5pt}){21-30} 
\cmidrule(l{1.5pt}r{1.5pt}){31-40} 
\cmidrule(l{1.5pt}){41-46} 

& \charakteristik{Windows} & \charakteristik{Mac} 
& \charakteristik{Linux} & \charakteristik{Webbrowser} 
& \charakteristik{iOS} & \charakteristik{Android}
& \charakteristik{keine} & \charakteristik{seriell} 
& \charakteristik{parallel}& \charakteristik{Daten} 
& \charakteristik{Grafik}& \charakteristik{kein} 
& \charakteristik{Daten}& \charakteristik{Daten} 
& \charakteristik{Grafik}& \charakteristik{kein} 
& \charakteristik{Daten}& \charakteristik{Windows} 
& \charakteristik{Mac} & \charakteristik{Linux} 
& \charakteristik{Webbrowser} & \charakteristik{iOS} 
& \charakteristik{Android}& \charakteristik{keine} 
& \charakteristik{seriell} & \charakteristik{parallel}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten}& \charakteristik{Daten} 
& \charakteristik{Daten}& \charakteristik{Daten} 
& \charakteristik{Grafik} \\ \midrule

1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
Long name that can be word wraped if needed & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x \\
\end{longtabu}
\end{document}

2 Answers 2

2

Here is a version that keeps the dynamic X columns using ltablex. Don't use tabu as there is no further support for the package.

\documentclass[12pt,a4paper,BCOR5mm]{scrbook}

%Tabellen & Listen
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ltablex}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage{ragged2e}  %% to allow hyphenation with raggedright
\usepackage{lipsum}

\newcommand\rota[1]{\rotatebox{90}{#1\ }}
\newcommand*\dimension[2]{\multicolumn{#1}{D}{\rota{#2}}}
\newcommand*\charakteristik[1]{\multicolumn{1}{C}{\rota{#1}}}

\begin{document}
This text has normal textwidth.
\lipsum[1]

%\begin{spacing}{0.8}
\newlength{\sep}
\setlength{\sep}{1.5pt}
\setlength{\tabcolsep}{\sep}
\setlength{\extrarowheight}{5pt}

%/Fonts#Sizing_text
%\newcolumntype{O}{>{\small}X[0.5cm,l,m]}
\newcolumntype{D}{>{\small}c}
\newcolumntype{C}{>{\scriptsize}c}

\definecolor{Gray}{gray}{0.9}
\newcolumntype{W}{>{\columncolor{white}}C}
\newcolumntype{G}{>{\columncolor{Gray}}C}

{%% <---- group that keeps definitions local
\renewcommand\tabularxcolumn[1]{>{\RaggedRight\small\arraybackslash}m{#1}} %% COMMENT
\keepXColumns
\begin{tabularx}{\textwidth}{X*{22}{WG}W}
\toprule
& \dimension{6}{Plattform} & \dimension{3}{Multi-User}
& \dimension{2}{Export} & \dimension{2}{Import}
& \dimension{4}{Benutzerführung} & \dimension{2}{Sprachen}
& \dimension{3}{Kollaboration} & \dimension{3}{Kosten}
& \dimension{3}{Support} & \dimension{3}{Registrierung}
& \dimension{2}{Canvas Typen} & \dimension{2}{Custom Canvas}
& \dimension{10}{Finanzübersicht}\\
\cmidrule(r{1.5pt}){1-10}
\cmidrule(l{1.5pt}r{1.5pt}){11-20}
\cmidrule(l{1.5pt}r{1.5pt}){21-30}
\cmidrule(l{1.5pt}r{1.5pt}){31-40}
\cmidrule(l{1.5pt}){41-46}

& \charakteristik{Windows} & \charakteristik{Mac}
& \charakteristik{Linux} & \charakteristik{Webbrowser}
& \charakteristik{iOS} & \charakteristik{Android}
& \charakteristik{keine} & \charakteristik{seriell}
& \charakteristik{parallel}& \charakteristik{Daten}
& \charakteristik{Grafik}& \charakteristik{kein}
& \charakteristik{Daten}& \charakteristik{Daten}
& \charakteristik{Grafik}& \charakteristik{kein}
& \charakteristik{Daten}& \charakteristik{Windows}
& \charakteristik{Mac} & \charakteristik{Linux}
& \charakteristik{Webbrowser} & \charakteristik{iOS}
& \charakteristik{Android}& \charakteristik{keine}
& \charakteristik{seriell} & \charakteristik{parallel}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten} & \charakteristik{Grafik}
& \charakteristik{kein} & \charakteristik{Daten}
& \charakteristik{Daten}& \charakteristik{Daten}
& \charakteristik{Daten}& \charakteristik{Daten}
& \charakteristik{Grafik} \\ \midrule

1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
Long name that can be word wraped if needed & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x & x \\
\end{tabularx}
}%%<--- group ends
\end{document}

enter image description here

0
4

No idea why tabu doesn't shrink that column, but this makes your table fit:

 \begin{longtabu}{>{\small}p{1.6cm}*{22}{WG}W}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .