4

I've got the advice to use \thead in order to force a line break within the table header. That works perfectly but the distance to the toprule and midrule increased. It's a small difference I know but it decides whether the whole table fits on the page or not...here is my MWE of a table with \thead and one without. I removed the linebreaks for the example.

\documentclass{scrreprt}        
\usepackage{microtype}              
\usepackage[sc]{mathpazo}           
\usepackage{xfrac}                  
\usepackage{booktabs}
\usepackage{tabularx}                   
\usepackage{caption}                
\usepackage{siunitx}  
\usepackage{makecell}        


\renewcommand\theadfont{\bfseries}              

\usepackage{lipsum}

\begin{document}   

\lipsum[2]

\begin{table}[htbp]        
\caption[Uebersicht aller PV-Anlagen im Testnetz \textit{Uniwohngebiet}]{Uebersicht aller PV-Anlagen im Testnetz \textit{Uniwohngebiet}}
\label{tab:Uebersicht_PV}  
\small
\centering
\sisetup{output-decimal-marker = {.}}
\begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} S @{\extracolsep{\fill}} c @{\extracolsep{\fill}} c @{\extracolsep{\fill}} c @{}} 
\toprule
{\thead{column-1}} & {\thead{column-2}} & {\thead{column-3}}  & {\thead{column-4}} & {\thead{column-5}}\\ 
\midrule
VNBE014220                  & 3.69  & 16 & 1 & x\\
VNBE014469                  & 11.47 & 16 & 1 & \\
VNBE015412                  & 3.51  & 16 & 1 & x\\    
\bottomrule
\end{tabular*}
\end{table}

\lipsum[11]
\begin{table}[htbp]        
    \caption[Uebersicht aller PV-Anlagen im Testnetz \textit{Uniwohngebiet}]{Uebersicht aller PV-Anlagen im Testnetz \textit{Uniwohngebiet}}
    \label{tab:Uebersicht_PV}  
    \small
    \centering
    \sisetup{output-decimal-marker = {.}}
    \begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} S @{\extracolsep{\fill}} c @{\extracolsep{\fill}} c @{\extracolsep{\fill}} c @{}} 
        \toprule
        {\textbf{column-1}} & {\textbf{column-2}} & {\textbf{column-3}}  & {\textbf{column-4}} & {\textbf{column-5}}\\ 
        \midrule
        VNBE014220                  & 3.69  & 16 & 1 & x\\
        VNBE014469                  & 11.47 & 16 & 1 & \\
        VNBE015412                  & 3.51  & 16 & 1 & x\\    
        \bottomrule
    \end{tabular*}
\end{table}

\end{document}

enter image description here

2 Answers 2

3

You want to clear the marco \theadgape:

\renewcommand{\theadgape}{}

which is originally set to \gape adding vertical space around the header.

Sample output

\documentclass{scrreprt}

\usepackage{microtype}
\usepackage[sc]{mathpazo}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{siunitx}
\usepackage{makecell}

\renewcommand\theadfont{\bfseries}
\renewcommand{\theadgape}{}

\usepackage{lipsum}

\begin{document}

\lipsum[2]

\begin{table}[htbp]
\caption{Uebersicht aller PV-Anlagen im Testnetz
\textit{Uniwohngebiet}}
\label{tab:Uebersicht_PV}
\small
\centering
\sisetup{output-decimal-marker = {.}}
\begin{tabular*}{\textwidth}{@{}l @{\extracolsep{\fill}} S
  *3{@{\extracolsep{\fill}}c} @{}}
  \toprule
  {\thead{column-1}} & {\thead{column-2}} & {\thead{column-3}}
  & {\thead{column-4}} & {\thead{column-5}}\\
  \midrule
  VNBE014220                  & 3.69  & 16 & 1 & x\\
  VNBE014469                  & 11.47 & 16 & 1 & \\
  VNBE015412                  & 3.51  & 16 & 1 & x\\
  \bottomrule
\end{tabular*}
\end{table}

\end{document}
0
2

I see no reason for using \thead, which indeed adds a rather large padding.

You can simplify the input as well.

\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{microtype}
\usepackage[sc]{mathpazo}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}

\lipsum[2]

\begin{table}[htbp]
\centering
%\small

\caption{Übersicht aller PV-Anlagen im Testnetz \textit{Uniwohngebiet}}
\label{tab:Uebersicht_PV}
\sisetup{output-decimal-marker = {.}}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}} l S[table-format=2.2] c c c @{}} 
\toprule
\textbf{column-1} & {\textbf{column-2}} & \textbf{column-3}  & \textbf{column-4} & \textbf{column-5}\\ 
\midrule
VNBE014220                  & 3.69  & 16 & 1 & x\\
VNBE014469                  & 11.47 & 16 & 1 & \\
VNBE015412                  & 3.51  & 16 & 1 & x\\    
\bottomrule
\end{tabular*}
\end{table}

\end{document}

enter image description here

2
  • Thank you for simplifying the code! But how can i force a linebreak withing the header? For exmaple the header in column one should be {\thead{PV-Einspeisezähler\\ Bezeichnung SWK}}
    – P. Maino
    Commented Oct 28, 2017 at 9:41
  • @P.Maino I usually prefer a nested tabular
    – egreg
    Commented Oct 28, 2017 at 10:17

You must log in to answer this question.

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