2

I have this code:

\documentclass[11pt]{article}
\usepackage[margin=2.5cm, showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}
\captionsetup[table]{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline
    }
\renewcommand\thetable{\Roman{table}}
\begin{document}
\def\arraystretch{1.5}
\begin{table}[!htb]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Name of a table that contains no useful knowledge}}
\parbox{\linewidth}{\footnotesize\lipsum[1]\vspace{2ex}}
\medskip\small\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                l
                S[table-format=-2.2]
                *{6}{S}
                }
\toprule
\multicolumn{1}{c}{\multirow{2}{*}{Group}}&
\multicolumn{1}{c}{\multirow{2}{*}{Total}}&
\multicolumn{5}{c}{Time--Series Averages of Cross--Sectional Average Monthly Attributes}\\\cline{3-7}
\multicolumn{2}{c}{}&{Value 1}&{Value 2}&{Value 3}&{Value 4}&{Value 5}\\\midrule
All         &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Characteristic 1\\
Sub 1.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 1.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 1.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Characteristic 2\\
Sub 2.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 2.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 2.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Characteristic 3\\
Sub 3.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 3.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 3.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Characteristic 4\\
Sub 4.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 4.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Sub 4.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

which produces this table

table

For some reason Value 1 to 4 seems to be evenly distributed, but then a large amount of horizontal space appears between Value 4 and 5. I have tried to tell LaTeX to even out the distribution with the code, but with no luck. I have already read this, but I was wondering if it could be solved within the tabular* environment.

2

1 Answer 1

3

As @Zarko has already observed in a comment, the label that spans 5 columns is wider than the sum of the natural widths of the columns. I'd therefore like to suggest that you switch from the tabular* to a tabularx environment.

Separately, you may want to think about using fewer horizontal lines and more (vertical) whitespace.

enter image description here

\documentclass[11pt]{article}
\usepackage[margin=2.5cm,a4paper]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{caption,setspace,lipsum,\   
            booktabs,siunitx,tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mC[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro
\captionsetup{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline,
    skip=0.33\baselineskip
    }
\renewcommand\thetable{\Roman{table}}
\begin{document}
\begin{table}[!htb]
\sisetup{table-format=2.2}
\caption{Name of a table that contains no useful knowledge}
\parbox{\linewidth}{\footnotesize\lipsum[1]\vspace{2ex}}

\small
\begin{tabularx}{\linewidth}{@{} l *{6}{S} @{}}
\toprule
Group & \mC{Total} &
\multicolumn{5}{c@{}}{Time-Series Averages of Cross-Sectional Average Monthly Attributes}
\\
\cmidrule(l){3-7}
&&\mC{Value 1}&\mC{Value 2}&\mC{Value 3}&\mC{Value 4}&\mC{Value 5}\\
\midrule
All     &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
\addlinespace % \midrule
Characteristic 1\\
Sub 1.1 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 1.2 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 1.3 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
\addlinespace % \midrule
Characteristic 2\\
Sub 2.1 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 2.2 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 2.3 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
\addlinespace % \midrule
Characteristic 3\\
Sub 3.1 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 3.2 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 3.3 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
\addlinespace % \midrule
Characteristic 4\\
Sub 4.1 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 4.2 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
Sub 4.3 &11.11 &22.22 &33.33 &44.44 &55.55  &66.66\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
1
  • 1
    Thank you for your answer! In addition, I have split up the "Time-Series Averages of Cross-Sectional Average Monthly Attributes" into two rows, so it fits much better now.
    – Andreas
    May 2, 2018 at 7:53

You must log in to answer this question.

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