5

Please look at this table:

enter image description here

1) I don't understand why the line \cmidrule(lr){2-3} does not go right above the start of "Advertisement".

2) I don't understand why the 69% is not aligned with the 3 values above.

Can someone please help me correct these two points?

This is my code (I include my full preamble in case it's because of a conflict between packages):

\documentclass[12pt]{article}
\usepackage{setspace,amsmath,graphicx,float}
\usepackage[english]{babel}
\usepackage[natbibapa]{apacite}
\usepackage{boldline}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{url}
\usepackage{fancyhdr}
\usepackage{changepage}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{newtxtext, newtxmath}
\usepackage{eurosym}
\usepackage{nameref}
\usepackage[nottoc]{tocbibind}
\usepackage[bottom]{footmisc} 
\edef\restoreparindent{\parindent=\the\parindent\relax}
\usepackage{parskip}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{threeparttable}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, calc, positioning, quotes, shapes, patterns}
\usepackage[margin=1cm]{caption}
\captionsetup[figure]{skip=18pt}
\usepackage[labelfont=bf]{caption}
\usepackage{etoolbox}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage{nccmath}    

\begin{document}
\begin{table}[h]
\caption[Gross profit ratio for Axel Springer and ProSiebenSat.1]{Gross profit ratio for Axel Springer and ProSiebenSat.1 per side.}
\centering
\begin{threeparttable}  
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}} c c c c}
\toprule
  & \multicolumn{2}{c}{Axel Springer} & \multicolumn{2}{c}{ProSiebenSat.1} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
                             & Advertisement & Circulation & Advertisement & Viewers \\
\midrule
Revenue (A)                      & 1,089         & 1,313       & 1834          & 0       \\[1ex]
Variable costs (B)               & 338           & 407         & 1265          & 0       \\[1ex]
Gross profit (A - B)             & 751           & 906         & 569           & 0       \\[1ex]
Gross profit ratio (A - B) / A   & 69\%          & 69\%        & 31\%          & -       \\
\bottomrule
\end{tabular*}
\begin{tablenotes}
\raggedright
\item \textit{Note}: Adapted from Axel Springer and ProSiebenSat.1's income statement in 2004. All numbers in million Euro.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 
  • 2
    You've asked LaTeX not to do those things. cmidrule with (lr) will not fill the entire column width; try removing the (lr). The column with 69% you've asked to be centered. – Hugh Mar 4 '17 at 15:22
  • 1
    Delete (lr) for full line and replace {l@{\extracolsep{\fill}} c c c c } with {l@{\extracolsep{\fill}} l l l l} or {l@{\extracolsep{\fill}} r r r r} for aligning. – Bobyandbob Mar 4 '17 at 15:38
  • Ohh, got it thank you! Just something else I don't understand: When I remove (lr) from the left group, and write instead (r), everything looks as I want. However, as you can see above, the right group has the (lr) in it and looks fine. Why is that? – Malganas Mar 4 '17 at 15:38
  • 1
    Because the width of column 2-3 (is bigger). – Bobyandbob Mar 4 '17 at 15:43
5

You're misplacing \extracolsep{\fill}:

\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{newtxtext, newtxmath}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{table}[h]

\caption[Gross profit ratio for Axel Springer and ProSiebenSat.1]
  {Gross profit ratio for Axel Springer and ProSiebenSat.1 per side.}

\begin{threeparttable}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}\hspace{\tabcolsep}}
  l
  c
  c
  c
  c
  @{\hspace{\tabcolsep}}
}
\toprule
  & \multicolumn{2}{c}{Axel Springer} & \multicolumn{2}{c}{ProSiebenSat.1} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
  & Advertisement & Circulation & Advertisement & Viewers \\
\midrule
Revenue (A)                      & 1,089         & 1,313       & 1834          & 0       \\
\addlinespace
Variable costs (B)               & 338           & 407         & 1265          & 0       \\
\addlinespace
Gross profit (A - B)             & 751           & 906         & 569           & 0       \\
\addlinespace
Gross profit ratio (A - B) / A   & 69\%          & 69\%        & 31\%          & --      \\
\bottomrule
\end{tabular*}
\begin{tablenotes}
\raggedright
\item \textit{Note}: Adapted from Axel Springer and ProSiebenSat.1's income statement 
      in 2004. All numbers in million Euro.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

(I changed the hyphen into an en-dash.)

enter image description here

Probably I'd omit the padding at the left and right. Here's the code just for the tabular; not that the second \cmidrule should only be trimmed at the left and that the second \multicolumn should have c@{}.

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  c
  c
  c
  c
  @{}
}
\toprule
  & \multicolumn{2}{c}{Axel Springer} & \multicolumn{2}{c@{}}{ProSiebenSat.1} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
  & Advertisement & Circulation & Advertisement & Viewers \\
\midrule
Revenue (A)                      & 1,089         & 1,313       & 1834          & 0       \\
\addlinespace
Variable costs (B)               & 338           & 407         & 1265          & 0       \\
\addlinespace
Gross profit (A - B)             & 751           & 906         & 569           & 0       \\
\addlinespace
Gross profit ratio (A - B) / A   & 69\%          & 69\%        & 31\%          & --      \\
\bottomrule
\end{tabular*}

enter image description here

  • Sorry for the delay, needed some time to see what you mean with "padding". Thank you, this worked! – Malganas Mar 4 '17 at 15:49
1

When working with tabular* environments along with @{\extracolsep{\fill}} statements, I almost invariably find that it's best to set the length variable \tabcolsep to 0pt. That way, LaTeX is given maximal freedom to find the optimal amount of intercolumn whitespace. A very nice side-effect of this approach is that it becomes unnecessary to apply any left- and/or right-hand trimming of lines drawn via \cmidrule.

Another comment: To increase the readability of the table contents, it would be useful to align the numbers on their (implicit) decimal markers rather than center them. This observation is applied to the first three data columns of the code shown below.

enter image description here

\documentclass[12pt]{article}
%% I've omitted all preamble instructions that aren't relevant for the example at hand.
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{newtxtext,newtxmath}
\usepackage[margin=1cm,labelfont=bf]{caption}
\captionsetup[figure]{skip=18pt}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}[h!]
\sisetup{table-format=4.0,group-minimum-digits=4,group-separator={,}} % <-- new
\setlength\tabcolsep{0pt}  % <-- new

\caption[Gross profit ratio for Axel Springer and ProSiebenSat.1]{%
  Gross profit ratio for Axel Springer and ProSiebenSat.1 per side.}
%\centering %% redundant  
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} lSSSc}
\toprule
& \multicolumn{2}{c}{Axel Springer} & \multicolumn{2}{c}{ProSiebenSat.1} \\
\cmidrule{2-3} \cmidrule{4-5}  % no trimming necessary
& {Advertisement} & {Circulation} & {Advertisement} & Viewers \\
\midrule
Revenue $(A)$                & 1089 & 1313 & 1834 & 0 \\[1ex]
Variable costs $(B)$         & 338  & 407  & 1265 & 0 \\[1ex]
Gross profit $(A - B)$       & 751  & 906  & 569  & 0 \\[1ex]
Gross profit ratio $(A-B)/A$ &{69\%}&{69\%}&{31\%}& {--}\\
\bottomrule
\end{tabular*}

\medskip\raggedright\footnotesize
\textit{Note}: Adapted from Axel Springer and ProSiebenSat.1's 
income statement in 2004. All numbers in million euro.
\end{table}
\end{document} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.