1

I am having a slight problem with my code. TexMaker is indicating that it is the first line of the content part (i.e. the row starting from '1') but my experience with Latex tells me it is do with the construction of the columns.

To get an idea of the table I'd like to produce, I provide the picture below:

enter image description here

Now essentially, I'm trying to combine three of these tables into one table - hopefully all the content can fit into one page. Here is my MWE

\documentclass{article}
\usepackage{booktabs}
\usepackage{siuntix}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{table} [H]
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science  faculties ($N = \num{11 959}$)]{[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount] Legend: Y: Academic Year of Study
  HRG:~Hazard Ratio --~Graduation;
  HRAE: Hazard Ratio --~Academically Excluded. \\
  95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
@{}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries HRG} &
\multicolumn{5}{c}{\bfseries HRAE}
\\ {(\%)} & {(\%)} \\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
& 
{\bfseries Commerce ($N = \num(6508)$)} & {\bfseries BCom ($N = \num(2560)$)} & {\bfseries BBusSci ($N = \num(3948)$)} & {\bfseries EBE ($N = \num(2949)$)} & {\bfseries Science ($N = \num(2502)$)} & {\bfseries Commerce)} & {\bfseries BCom} & {\bfseries BBusSci} & {\bfseries EBE} & {\bfseries Science}
\midrule
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}&   {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;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83.3 & 68.0 &79.3 &5.0 &10.2 & 2.2 &3.3 &10.3 \\
& {(73.2{\,;\,}86.5)} & {(61.1{\,;\,}85.5)} & {(75.6{\,;\,}91.0)}& {(60.5{\,;\,}75.5)}& {(64.6{\,;\,}94.0)}& {(1.4{\,;\,}8.7)}& {(1.7{\,;\,}18.7)}& {($-$0.8{\,;\,}5.3)}& {(0.5{\,;\,}6.2)} & {($-$0.7{\,;\,}24.7)} \\[1ex]
7 & 75.0& 71.4 & 77.8 & 56.0 & 50.0 &18.8 &14.3 &22.2 &12.0 &50.0 \\
& {(53.8{\,;\,}96.2)} & {(38.0{\,;\,}104.9)} & {(50.6{\,;\,}104.9)}& {(36.5{\,;\,}75.5)}& {($-$19.3{\,;\,}119.3)}& {($-$0.4{\,;\,}37.9)}& {($-$11.6{\,;\,}40.2)}& {($-$4.9{\,;\,}49.4)} & {($-$0.7{\,;\,}24.7)}& {($-$19.3{\,;\,}119.3)} \\[1ex]
8 & 100.0 & 100.0 & 0.0 & 66.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\
& {(100.0{\,;\,}100.0)} & {(100.0{\,;\,}100.0)} & {(50.6{\,;\,}104.9)}& {(13.3{\,;\,}120.0)}& {(1.2{\,;\,}1.8)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} \\
\bottomrule
\end{tabular*}
\end{table}
1
  • After correcting the name of the siunitx package and commenting out all but the headers and row 1, the first error that appears involves using \num(6508) instead of \num{6508}. Sep 20, 2015 at 14:57

2 Answers 2

5

The mistake is \num(<number>). It should be \num{<number>}. Note the braces. Also you need to have \\ before \midrule like \\\midrule after the header row. Apart from these siunitx has a spelling mistake.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{table} %[H]
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science  faculties ($N = \num{11 959}$)]{[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount] Legend: Y: Academic Year of Study
  HRG:~Hazard Ratio --~Graduation;
  HRAE: Hazard Ratio --~Academically Excluded. \\
  95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
@{}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries HRG} &
\multicolumn{5}{c}{\bfseries HRAE}
\\ {(\%)} & {(\%)} \\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
&
{\bfseries Commerce ($N = \num{6508}$)} & {\bfseries BCom ($N = \num{2560}$)} & {\bfseries BBusSci ($N = \num{3948}$)} & {\bfseries EBE ($N = \num{2949}$)} & {\bfseries Science ($N = \num{2502}$)} & {\bfseries Commerce)} & {\bfseries BCom} & {\bfseries BBusSci} & {\bfseries EBE} & {\bfseries Science}
\\\midrule
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}&   {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
2 & 0.0 & 0.0& 0.0 & 0.0& 0.0 & 3.0 &3.8 &2.5&7.3&7.5\\
 & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}&  {(2.6{\,;\,}3.5)}& {(3.0{\,;\,}4.7)}& {(2.0{\,;\,}3.0)}& {(6.2{\,;\,}8.4)}& {(6.3{\,;\,}8.7)} \\[1ex]
3 & 14.3 & 35.1 & 1.6 & 0.0 & 43.5 & 2.9 & 4.3 &2.0 &5.2 &8.0 \\
& {(13.2{\,;\,}15.3)} & {(32.8{\,;\,}37.4)} & {(1.2{\,;\,}2.1)}& {(1.2{\,;\,}1.8)}& {(41.0{\,;\,}46.1)}& {(2.3{\,;\,}3.4)}& {(3.3{\,;\,}5.3)}& {(1.5{\,;\,}2.5)}& {(4.1{\,;\,}6.2)}& {(6.6{\,;\,}9.4)} \\[1ex]
4 & 61.0 & 55.2 & 63.0 & 42.9 & 55.4 &1.7 & 2.9 &1.3&3.2 &7.5 \\
  & {(59.3{\,;\,}62.7)} & {(51.7{\,;\,}58.7)} & {(61.0{\,;\,}65.0)}& {(40.3{\,;\,}45.5)}& {(51.5{\,;\,}59.3)}& {(1.3{\,;\,}2.2)}& {(1.8{\,;\,}4.1)}& {(0.9{\,;\,}1.8)}& {(2.3{\,;\,}4.2)}& {(5.4{\,;\,}9.6)}\\[1ex]
5 & 72.5 & 63.6 & 76.0 & 57.2 &70.4 &4.4 &10.7 &2.0 &3.4 &8.3\\
 & {(69.6{\,;\,}75.4)} &{(57.7{\,;\,}69.6)} & {(72.7{\,;\,}79.2)}& {(53.2{\,;\,}61.2)}& {(64.2{\,;\,}76.6)}& {(3.1{\,;\,}5.7)}& {(6.9{\,;\,}14.5)}& {(0.9{\,;\,}3.0)}& {(1.9{\,;\,}4.8)}& {(4.5{\,;\,}12.0)}\\[1ex]
6 & 79.9 & 73.5 & 83.3 & 68.0 &79.3 &5.0 &10.2 & 2.2 &3.3 &10.3 \\
& {(73.2{\,;\,}86.5)} & {(61.1{\,;\,}85.5)} & {(75.6{\,;\,}91.0)}& {(60.5{\,;\,}75.5)}& {(64.6{\,;\,}94.0)}& {(1.4{\,;\,}8.7)}& {(1.7{\,;\,}18.7)}& {($-$0.8{\,;\,}5.3)}& {(0.5{\,;\,}6.2)} & {($-$0.7{\,;\,}24.7)} \\[1ex]
7 & 75.0& 71.4 & 77.8 & 56.0 & 50.0 &18.8 &14.3 &22.2 &12.0 &50.0 \\
& {(53.8{\,;\,}96.2)} & {(38.0{\,;\,}104.9)} & {(50.6{\,;\,}104.9)}& {(36.5{\,;\,}75.5)}& {($-$19.3{\,;\,}119.3)}& {($-$0.4{\,;\,}37.9)}& {($-$11.6{\,;\,}40.2)}& {($-$4.9{\,;\,}49.4)} & {($-$0.7{\,;\,}24.7)}& {($-$19.3{\,;\,}119.3)} \\[1ex]
8 & 100.0 & 100.0 & 0.0 & 66.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\
& {(100.0{\,;\,}100.0)} & {(100.0{\,;\,}100.0)} & {(50.6{\,;\,}104.9)}& {(13.3{\,;\,}120.0)}& {(1.2{\,;\,}1.8)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

Fitting this table inside the page is another problem.

2
  • I see your point about fitting the table inside one page being a problem. Should I definitely do landscape then? Sep 20, 2015 at 15:32
  • @Chris Seems so.
    – user11232
    Sep 20, 2015 at 15:33
4

As Harish already noted, there's no way this is going into a regular portrait page. Even with reduced font size, reduced column separation, and greatly abbreviated labels, you just can't get the 20 confidence interval values side by side without reducing your page margins to 0.75 inches or smaller.

enter image description here

versus

enter image description here

Moving to a landscape orientation with the rotating package makes things easier, even with default margins.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{rotating}
%\usepackage[margin=.75in]{geometry} % Maximum size of margins for regular table
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\begin{table}
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science  faculties ($N = \num{11 959}$)]{Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount]
  95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Graduation} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Academically Excluded}
\\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
& {C} & {BC} & {BBS} & {EBE} & {S}
& {C} & {BC} & {BBS} & {EBE} & {S} \\
& {$N = \num{6508}$} & {$N = \num{2560}$} & {$N = \num{3948}$} & {$N = \num{2949}$} & {$N = \num{2502}$}
\\
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}&   {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
\bottomrule
\end{tabular}
\end{table}

\clearpage
\begin{sidewaystable}
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science  faculties ($N = \num{11 959}$)]{Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount]
95\% confidence intervals given in parentheses below the point estimates.\\[\medskipamount]
\lipsum[1]}
\label{table:sidewaysSurvivalAll}
\begin{tabular}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Graduation} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Academically Excluded}
\\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
& {Commerce} & {BCom} & {BBusSci} & {EBE} & {Science}
& {Commerce} & {BCom} & {BBusSci} & {EBE} & {Science} \\
& {$N = \num{6508}$} & {$N = \num{2560}$} & {$N = \num{3948}$} & {$N = \num{2949}$} & {$N = \num{2502}$}
\\
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}&   {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}

I cleaned up a few other things that weren't strictly necessary (tabular*), could be made more explicit with the rotated table (hazard ratio abbreviations), or were incorrect (-- for a range of numbers, --- for a long dash), too.

You must log in to answer this question.

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