3

I have a problem with one large table, and I could finally narrow it down by reducing the preamble and commenting out some lines.

The Problem:

I have a table defined like that (please see the MWE below for the full LaTeX code to reproduce my problem!):

\begin{sidewaystable}[htbp]
\caption{caption}
\centering

\begingroup

\setlength{\tabcolsep}{2pt}
\footnotesize
\newcolumntype{L}{>{\raggedright\arraybackslash}X}


\begin{tabularx}{\textwidth}{|>{\raggedright\arraybackslash}p{2.0cm}*{14}{|L}|}
\hline
  & & & & & & & & & & & & & \\
  \multicolumn{1}{|r|}{Z}    & \multicolumn{3}{X|}{A} & \multicolumn{2}{X|}{{B}} & \multicolumn{1}{X|}{C} & \multicolumn{2}{X|}{D} & \multicolumn{1}{X|}{E} & \multicolumn{1}{X|}{F} & \multicolumn{1}{X|}{G} & \multicolumn{1}{X|}{H} & \multicolumn{1}{X|}{I} & \multicolumn{1}{X|}{J} \bigstrut\\
 \hline

  \hline
\end{tabularx}
\endgroup
\end{sidewaystable}%

Screenshot:

you can see on the left side how I'd expect it to be (with columns with equal width) and on the right side how it is.

Problem

Approach for solution

My knowledge with LaTeX is not sufficient for solving that, but the following aspects seem to be relevant:

  • in TeXLive 2011 it worked and after upgrading to TeXLive 2014 it does not work any more, so there seems to be a change which made the pdfLaTeX output change.
  • if I remove the line \areaset[8mm]{15.5cm}{25.2cm}, it seems to work, so there is a conflict between the areaset and the table definition.
  • I have some other tables in the same file which are set up in a similar way and which do not cause any problems

Minimal working example:

\documentclass[11pt, a4paper,  %Schriftgröße 11Pkt, Papierformat DIN A4  
twoside, autooneside, %doppelseitiges Layout, automatische Anpassung der Kopfzeile bei einseitigem Layout
headinclude, footinclude=false, %Parameter für Satzspiegelberechnung: Kopfzeile miteinbeziehen, Fußzeile ausschließen
%tocleft, listsleft, % Verzeichnisse ohne Einzug
numbers=noenddot, %kein Punkt hinter Überschriftennummern - plötzlich waren sie da in rev 74, vermutlich nach update von TeXLive
toc=flat, tocdepth=
listof=totoc, bibliography=totoc, %TOC enthält Abb.- und Tab.-Verz. und Literaturverz.
captions=tableheading, captions=nooneline, headsepline, parskip=half, %Tabellenüberschrift über Tabellen, Trennlinine unter Kopfzeile, (halber) Abstand zwischen Absätzen
footnotes=multiple %, draft
]{scrbook}


%%%% SEITENFORMAT %%%%
\areaset[8mm]{15.5cm}{25.2cm} %Explizite Festlegung der Bindekorrektur [] und des Satzspiegels {Breite}{Höhe}
%\raggedbottom

%%%% {PACKAGES} %%%%
\usepackage[UKenglish, ngerman]{babel} %Sprachpakete Brit. Englisch, Deutsch Neue Rechtschreibung
\usepackage[latin1]{inputenc}
\usepackage[TS1, T1]{fontenc} %Kodierungen für Text 1 und Text Symbols
\usepackage[ngerman, iso]{isodate} %Formatierung von Datumsangaben nach ISO
\usepackage{pdflscape} %erlaubt Setzen von Einzelseiten im Querformat
\usepackage{xspace}
%\usepackage[]{ragged2e} % kein Problem bei Tabellenspalten mit >{\raggedright}, siehe http://www.tug.org/TUGboat/tb28-3/tb90hoeppner.pdf Option "raggedrightboxes" funktioniert leider nicht, da dann auch captions raggedright gesetzt werden und neue Zeilen in captions falsch eingerückt sind


%Pakete für Zusatzfunktionen
\usepackage{hyperref} %Automatisches Verlinken der PDF-Datei
\usepackage[pdftex]{graphicx} %Einbinden von Bildern und Grafiken
\usepackage{color} %Verwendung von Farbe in Text und Grafiken
%\usepackage{tikz} %Graphiken mit TikZ/PGF -> http://www.ifi.uio.no/it/latex-links/pgfmanual.pdf


%Pakete zur Verwendung von Tabellen
\usepackage{array} 
\usepackage{tabularx} 
\usepackage{longtable}
\usepackage{booktabs} %unterschiedliche Linienstärken
\usepackage{dpfloat} %für Tabellen über Doppelseiten
\usepackage{collcell} % für Definition von Spaltenformaten

\usepackage[]{rotating} % Drehen von Tabellen, Bildern, etc. ggf. Option figuresleft oder -right

\usepackage[round-mode=off, round-integer-to-decimal, round-precision=4,
    table-format = 1.2, 
    table-number-alignment=center,
    round-integer-to-decimal,
    output-decimal-marker={,},
    abbreviations=false % sonst wird \ps als Einheit definiert
    ]{siunitx} % für Einheiten (bisher nicht verwendet) und für das Formatieren von Zahlen in Tabellenspalten

%Tabellenformate (erf. array-Paket und siunitx)
%   \newcolumntype{X}{>{}S[round-precision=4, table-format=1.4]<{}}
    \newcolumntype{Y}{>{}S[round-precision=3, table-format=2.3]<{}}

    \newcolumntype{Z}{>{}S[round-precision=1, table-format=1.1]<{}} 
    \newcolumntype{A}{>{}S[round-precision=2, table-format=1.2]<{}}
    \newcolumntype{B}{>{}S[round-precision=3, table-format=1.3]<{}}
    \newcolumntype{E}{>{}S[round-precision=2, table-format=2.2]<{}}
    \newcolumntype{F}{>{}S[round-precision=3, table-format=2.3]<{}}
    \newcolumntype{J}{>{}S[round-precision=1, table-format=3.1]<{}}
    \newcolumntype{K}{>{}S[round-precision=2, table-format=3.2]<{}}

    \newcolumntype{H}{>{\lrbox0}c<{\endlrbox}@{}} %Spalte ausblenden, wird aber trotzdem von LaTeX bearbeitet, Quelle: http://tex.stackexchange.com/questions/16604/easiest-way-to-delete-a-column

%Formatierungen für Tabellen Einfluss der Parameter SDF
\usepackage{bigstrut}
\usepackage{calc}

\newcommand{\TabSchrift}{\small} %Schriftgröße  Tabellen, wird im Anhang auf footnotesize verkleinert

%\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}




\begin{document}

\begin{sidewaystable}[htbp]
\caption{caption}
\centering

\begingroup

\setlength{\tabcolsep}{2pt}
\footnotesize
\newcolumntype{L}{>{\raggedright\arraybackslash}X}


\begin{tabularx}{\textwidth}{|>{\raggedright\arraybackslash}p{2.0cm}*{14}{|L}|}
\hline
  & & & & & & & & & & & & & \\
  \multicolumn{1}{|r|}{Z}    & \multicolumn{3}{X|}{A} & \multicolumn{2}{X|}{{B}} & \multicolumn{1}{X|}{C} & \multicolumn{2}{X|}{D} & \multicolumn{1}{X|}{E} & \multicolumn{1}{X|}{F} & \multicolumn{1}{X|}{G} & \multicolumn{1}{X|}{H} & \multicolumn{1}{X|}{I} & \multicolumn{1}{X|}{J} \bigstrut\\
 \hline

  \hline
\end{tabularx}
\endgroup
\end{sidewaystable}%
\end{document}

3 Answers3

3

The problem seems to be in the combination of the \textheight, sidewaystable and tabularx environments and the X columntypes in the \multicolumns in the second row.

It works for me if I calculate the column width myself:

\documentclass[headinclude]{scrbook}
\areaset[8mm]{15.5cm}{25.2cm}

\usepackage{rotating}
\usepackage{bigstrut}

\usepackage{tabularx}
  \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\newlength\mycolwidth

% packages to show the page layout
\usepackage{layout}
\usepackage{showframe}

\begin{document}
\layout

\begin{sidewaystable}
\centering
\setlength{\tabcolsep}{2pt}
\setlength\mycolwidth{\dimexpr(\textwidth-2cm-30\tabcolsep-15\arrayrulewidth)/14\relax}
\footnotesize
\begin{tabular}{|>{\raggedright\arraybackslash}p{2.0cm}|*{14}{L{\mycolwidth}|}}
\hline
&&&&&&&&&&&&&&\\
\multicolumn{1}{|r|}{Z}    
  &\multicolumn{3}{L{3\mycolwidth}|}{A} 
  &\multicolumn{2}{L{2\mycolwidth}|}{{B}} 
  &\multicolumn{1}{L{\mycolwidth}|}{C} 
  &\multicolumn{2}{L{2\mycolwidth}|}{D} 
  &\multicolumn{1}{L{\mycolwidth}|}{E} 
  &\multicolumn{1}{L{\mycolwidth}|}{F} 
  &\multicolumn{1}{L{\mycolwidth}|}{G} 
  &\multicolumn{1}{L{\mycolwidth}|}{H} 
  &\multicolumn{1}{L{\mycolwidth}|}{I} 
  &\multicolumn{1}{L{\mycolwidth}|}{J\bigstrut}
  \\
 \hline
\end{tabular}
\end{sidewaystable}%
\end{document}

Note that the resulting \textheight is lower than 25.2cm because \areaset takes the headinclude option into account.

enter image description here


But I can use tabularx if the resulting \textheight is lower than 656pt :

\documentclass{scrbook}
\areaset{\textwidth}{655pt}
%\areaset{\textwidth}{656pt}

\usepackage{rotating}
\usepackage{bigstrut}

\usepackage{tabularx}
  \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

% packages to show the page layout
\usepackage{layout}
\usepackage{showframe}

\begin{document}
\layout

\begin{sidewaystable}
\centering
\setlength{\tabcolsep}{2pt}
\footnotesize
\begin{tabularx}{\textwidth}{|>{\raggedright\arraybackslash}p{2.0cm}|*{14}{X|}}
\hline
&&&&&&&&&&&&&&\\
\multicolumn{1}{|r|}{Z}    
  &\multicolumn{3}{X|}{A} 
  &\multicolumn{2}{X|}{{B}} 
  &\multicolumn{1}{X|}{C} 
  &\multicolumn{2}{X|}{D} 
  &\multicolumn{1}{X|}{E} 
  &\multicolumn{1}{X|}{F} 
  &\multicolumn{1}{X|}{G} 
  &\multicolumn{1}{X|}{H} 
  &\multicolumn{1}{X|}{I} 
  &\multicolumn{1}{X|}{J\bigstrut}
  \\
 \hline
\end{tabularx}
\end{sidewaystable}%
\end{document}

Note there is the same problem with book and geometry:

\documentclass{book}
\usepackage{geometry}
\geometry{textheight=655pt}
%\geometry{textheight=656pt}

I think it is only a problem of the table.

\documentclass[margin=5pt]{standalone}

\usepackage{tabularx}
  \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

\newcommand\tabularwidth{656pt}

\begin{document}

\begin{tabularx}{\tabularwidth}{|>{\raggedright\arraybackslash}p{2.0cm}|*{14}{X|}}
\hline
&&&&&&&&&&&&&&\\
\multicolumn{1}{|r|}{Z}    
  &\multicolumn{3}{X|}{A} 
  &\multicolumn{2}{X|}{{B}} 
  &\multicolumn{1}{X|}{C} 
  &\multicolumn{2}{X|}{D} 
  &\multicolumn{1}{X|}{E} 
  &\multicolumn{1}{X|}{F} 
  &\multicolumn{1}{X|}{G} 
  &\multicolumn{1}{X|}{H} 
  &\multicolumn{1}{X|}{I} 
  &\multicolumn{1}{X|}{J}
  \\
 \hline
\end{tabularx}

\end{document}

results in

enter image description here

If I change the width of the table

\newcommand\tabularwidth{656pt}

I get

enter image description here

esdd
  • 85,675
  • thank you so much! Setting the width of the tabular manually to 655 pt solves the problem. I just did not understand where this "magic" number comes from? – MostlyHarmless Jan 19 '15 at 10:36
1

I just rearrange your code: move new column type in preamble (where ti belong), remove group and strut and here is MWE:

\documentclass{article}
    \usepackage{tabularx,rotating}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \usepackage{caption}
\captionsetup{font = small}

\begin{document}
    \begin{sidewaystable}[htbp]
    \centering
\setlength{\tabcolsep}{2pt}
\footnotesize
    \caption{caption}
\begin{tabularx}{\textwidth}{|>{\raggedright\arraybackslash}p{2.0cm}|*{14}{L|}}
    \hline
    &   &   &   &   &   &   &   &   &   &   &   &   &   &           \\
\multicolumn{1}{|r|}{Z}    
    &   \multicolumn{3}{X|}{A} 
        &   \multicolumn{2}{X|}{{B}} 
            &   \multicolumn{1}{X|}{C} 
                &   \multicolumn{2}{X|}{D} 
                    &   \multicolumn{1}{X|}{E} 
                        &   \multicolumn{1}{X|}{F} 
                            &   \multicolumn{1}{X|}{G} 
                                & \multicolumn{1}{X|}{H} 
                                    & \multicolumn{1}{X|}{I} 
                                        & \multicolumn{1}{X|}{J}    \\
 \hline
\end{tabularx}
    \end{sidewaystable}%
\end{document}
Zarko
  • 296,517
  • thanks, but what do yo do with the conflicting \areaset command? – MostlyHarmless Jan 07 '15 at 11:06
  • Sorry, but in your first code i don't see \areaset macro (actually you not provide anything about your document class), so i didn't consider it. Actually, I also momentary don't see, why should be used (I'm not familiar with KOMA script bundle). Without it the result is (to me) quite satisfactory. If it is essentially, than you need help of someone, who know scrbook. From description i can conclude, that it has some clash with sidewaystable or tabularx. This you can easily check with table in normal text and with use of tabular in sidewaystable. – Zarko Jan 07 '15 at 11:49
1

enter image description here

The main error is in the dimensions set in \areaset. If you look into Table 2.2 in Coma Script Documentation (Page 10), you can pick up some correct "type area values" that are suitable for you. See the following MWE using the values \areaset[8mm]{13.125cm}{18.563cm} from the above mentioned table:

\documentclass[11pt, a4paper,  %Schriftgröße 11Pkt, Papierformat DIN A4  
twoside, autooneside, %doppelseitiges Layout, automatische Anpassung der Kopfzeile bei einseitigem Layout
headinclude, footinclude=false, %Parameter für Satzspiegelberechnung: Kopfzeile miteinbeziehen, Fußzeile ausschließen
%tocleft, listsleft, % Verzeichnisse ohne Einzug
numbers=noenddot, %kein Punkt hinter Überschriftennummern - plötzlich waren sie da in rev 74, vermutlich nach update von TeXLive
toc=flat, tocdepth=
listof=totoc, bibliography=totoc, %TOC enthält Abb.- und Tab.-Verz. und Literaturverz.
captions=tableheading, captions=nooneline, headsepline, parskip=half, %Tabellenüberschrift über Tabellen, Trennlinine unter Kopfzeile, (halber) Abstand zwischen Absätzen
footnotes=multiple %, draft
]{scrbook}


%%%% SEITENFORMAT %%%%
\areaset[8mm]{13.125cm}{18.563cm} %Explizite Festlegung der Bindekorrektur [] und des Satzspiegels {Breite}{Höhe}
%\raggedbottom

%%%% {PACKAGES} %%%%
\usepackage[UKenglish, ngerman]{babel} %Sprachpakete Brit. Englisch, Deutsch Neue Rechtschreibung
\usepackage[latin1]{inputenc}
\usepackage[TS1, T1]{fontenc} %Kodierungen für Text 1 und Text Symbols
\usepackage[ngerman, iso]{isodate} %Formatierung von Datumsangaben nach ISO
\usepackage{pdflscape} %erlaubt Setzen von Einzelseiten im Querformat
\usepackage{xspace}
%\usepackage[]{ragged2e} % kein Problem bei Tabellenspalten mit >{\raggedright}, siehe http://www.tug.org/TUGboat/tb28-3/tb90hoeppner.pdf Option "raggedrightboxes" funktioniert leider nicht, da dann auch captions raggedright gesetzt werden und neue Zeilen in captions falsch eingerückt sind


%Pakete für Zusatzfunktionen
\usepackage{hyperref} %Automatisches Verlinken der PDF-Datei
\usepackage[pdftex]{graphicx} %Einbinden von Bildern und Grafiken
\usepackage{color} %Verwendung von Farbe in Text und Grafiken
%\usepackage{tikz} %Graphiken mit TikZ/PGF -> http://www.ifi.uio.no/it/latex-links/pgfmanual.pdf


%Pakete zur Verwendung von Tabellen
\usepackage{array} 
\usepackage{tabularx} 
\usepackage{longtable}
\usepackage{booktabs} %unterschiedliche Linienstärken
\usepackage{dpfloat} %für Tabellen über Doppelseiten
\usepackage{collcell} % für Definition von Spaltenformaten

\usepackage[]{rotating} % Drehen von Tabellen, Bildern, etc. ggf. Option figuresleft oder -right

\usepackage[round-mode=off, round-integer-to-decimal, round-precision=4,
    table-format = 1.2, 
    table-number-alignment=center,
    round-integer-to-decimal,
    output-decimal-marker={,},
    abbreviations=false % sonst wird \ps als Einheit definiert
    ]{siunitx} % für Einheiten (bisher nicht verwendet) und für das Formatieren von Zahlen in Tabellenspalten

%Tabellenformate (erf. array-Paket und siunitx)
%   \newcolumntype{X}{>{}S[round-precision=4, table-format=1.4]<{}}
    \newcolumntype{Y}{>{}S[round-precision=3, table-format=2.3]<{}}

    \newcolumntype{Z}{>{}S[round-precision=1, table-format=1.1]<{}} 
    \newcolumntype{A}{>{}S[round-precision=2, table-format=1.2]<{}}
    \newcolumntype{B}{>{}S[round-precision=3, table-format=1.3]<{}}
    \newcolumntype{E}{>{}S[round-precision=2, table-format=2.2]<{}}
    \newcolumntype{F}{>{}S[round-precision=3, table-format=2.3]<{}}
    \newcolumntype{J}{>{}S[round-precision=1, table-format=3.1]<{}}
    \newcolumntype{K}{>{}S[round-precision=2, table-format=3.2]<{}}

    \newcolumntype{H}{>{\lrbox0}c<{\endlrbox}@{}} %Spalte ausblenden, wird aber trotzdem von LaTeX bearbeitet, Quelle: http://tex.stackexchange.com/questions/16604/easiest-way-to-delete-a-column

%Formatierungen für Tabellen Einfluss der Parameter SDF
\usepackage{bigstrut}
\usepackage{calc}

\newcommand{\TabSchrift}{\small} %Schriftgröße  Tabellen, wird im Anhang auf footnotesize verkleinert

%\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}




\begin{document}

\begin{sidewaystable}[htbp]
\caption{caption}
\centering

\begingroup

\setlength{\tabcolsep}{2pt}
\footnotesize
\newcolumntype{L}{>{\raggedright\arraybackslash}X}


\begin{tabularx}{\textwidth}{|>{\raggedright\arraybackslash}p{2.0cm}*{14}{|L}|}
\hline
  & & & & & & & & & & & & & \\
  \multicolumn{1}{|r|}{Z}    & \multicolumn{3}{X|}{A} & \multicolumn{2}{X|}{{B}} & \multicolumn{1}{X|}{C} & \multicolumn{2}{X|}{D} & \multicolumn{1}{X|}{E} & \multicolumn{1}{X|}{F} & \multicolumn{1}{X|}{G} & \multicolumn{1}{X|}{H} & \multicolumn{1}{X|}{I} & \multicolumn{1}{X|}{J} \bigstrut\\
 \hline

  \hline
\end{tabularx}
\endgroup
\end{sidewaystable}%
\end{document} 
AboAmmar
  • 46,352
  • 4
  • 58
  • 127