3

I have three fairly minor problems, but I can't seem to figure out how to fix them.

enter image description here

First Problem: Even though I have 'gaps' in my Latex editor between the semi-colon and the number after it (e.g. for the first row, I have (0.0; 0.0)), this does not show up in the table. I suspect the problem has something to do with the siunitx package.

Second Problem: Is there anyway for the 95% confidence intervals (the numbers in brackets) to be better aligned with the number above it? I'd like the numbers in brackets to be moved more to the left - possibly have the semi-colon in line with the decimal point above it.

Third Problem: Although not shown in this particular table, when I put the "-" sign, siunitx complains with a 'misplaced sign token' message. In my MWE below, I attempted to fix that, but it didn't seem to work.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{input-symbols = {( ) -}}
\begin{document}
\begin{table} [H]
\centering
\caption[Presentation of survival data for the whole sample ($N = \num{11 959}$)]
{Presentation of survival data for the whole sample ($N = \num{11 959}$).\\    [\medskipamount] Legend:
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRAE: Hazard Ratio --~Academically Excluded}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
S[table-format=1.0]
S[table-format=5.0,group-four-digits=true]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.1]
S[table-format=2.1]
@{}
}
\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} &
{\bfseries AE} & {\bfseries C} &
{\bfseries HRG} & {\bfseries HRAE}\\
& & & & & {(\%)} & {(\%)} \\
\midrule
1 & 11959 & 0 & 725 & 1619 & 0.0 & 6.1 \\ 
& & & & &  (0.0; 0.0) & (6.0; 6.1) \\
2 & 9615 & 0 & 474 & 1513 & 0.0 & 4.9 \\
& & & & &  (0.0; 0.0) & (4.0; 5.0) \\
3 & 7628 & 1271 & 335 & 966 & 16.7 & 4.4 \\
& & & & &  (16.0; 17.0) & (4.0; 5.0) \\
4 & 5056 & 2797 & 145 & 405 & 55.3 & 2.9 \\
    & & & & &  (54.0; 57.0) & (2.0; 3.0) \\
5 & 1709 & 1144 & 77 & 170 & 66.9 & 4.5 \\
    & & & & &  (65.0; 69.0) & (4.0; 5.0) \\
6 & 318 & 236 & 15 & 24 & 74.2 & 4.7 \\
    & & & & &  (65.0; 69.0) & (4.0; 5.0) \\
7 & 43 & 27 & 7 & 5 & 62.8 & 16.3 \\ 
& & & & & (48.0; 77.0) & (5.0; 27.0) \\
8 & 4 & 3 & 0 & 1 & 75.0 & 0.0 \\
& & & & &  (33.0; 117.0) & (0.0; 0.0) \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
  • 2
    I would suggest to split the problems to different questions. Makes it easier to tag and to make it available to people in need in the future. – Johannes_B Aug 24 '14 at 18:22
2

For your first problem, it's because inside each cell we're in math mode. For the second problem, I think it would be better-looking to have the confidence intervals centred in the cell; to have the semi-colon centred between numbers, I replaced it with `{\,;\,}. I do not meet the third problem with the code you give.

I also propose to put the legend at the bottom of the table, with the \ threeparttable` package, and to add some vertical space between groups of rows. So here is what I propose:

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[online]{threeparttable}
\usepackage{siunitx}
\sisetup{input-symbols = {( ) -}}

\begin{document}

\begin{table} [H]
\centering
\begin{threeparttable}
\caption{Presentation of survival data for the whole sample ($N = \num{11 959}$). }
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
S[table-format=1.0]
S[table-format=5.0,group-four-digits=true]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.1]
S[table-format=2.1]
@{}
}
\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} &
{\bfseries AE} & {\bfseries C} &
{\bfseries HRG} & {\bfseries HRAE}\\
& & & & & {(\%)} & {(\%)} \\
\midrule
1 & 11959 & 0 & 725 & 1619 & 0.0 & 6.1 \\
& & & & & {(0.0{\,;\,}0.0)} & {(6.0{\,;\,}6.1)} \\[1ex]
2 & 9615 & 0 & 474 & 1513 & 0.0 & 4.9 \\
& & & & & {(0.0{\,;\,}0.0)} & {(4.0{\,;\,}5.0)} \\[1ex]
3 & 7628 & 1271 & 335 & 966 & 16.7 & 4.4 \\
& & & & & {(16.0{\,;\,}17.0)} & {(4.0{\,;\,}5.0)} \\[1ex]
4 & 5056 & 2797 & 145 & 405 & 55.3 & 2.9 \\
    & & & & & {(54.0{\,;\,}57.0)} & {(2.0{\,;\,}3.0)} \\[1ex]
5 & 1709 & 1144 & 77 & 170 & 66.9 & 4.5 \\
    & & & & & {(65.0{\,;\,}69.0)} &{(4.0{\,;\,}5.0)} \\[1ex]
6 & 318 & 236 & 15 & 24 & 74.2 & 4.7 \\
    & & & & & {(65.0{\,;\,}69.0)} & {(4.0{\,;\,}5.0)} \\[1ex]
7 & 43 & 27 & 7 & 5 & 62.8 & 16.3 \\
& & & & & {(48.0{\,;\,}77.0)} & {(5.0{\,;\,}27.0)} \\[1ex]
8 & 4 & 3 & 0 & 1 & 75.0 & 0.0 \\
& & & & & {(33.0{\,;\,}117.0)} & {(0.0{\,;\,}0.0)} \\
\bottomrule
\addlinespace
\end{tabular*}
\begin{tablenotes}
  \item[Legend:]
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRAE: Hazard Ratio --~Academically Excluded
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

enter image description here

2

One way to solve issues #1 and #2 is to center-set the confidence intervals below the corresponding point estimates, by encasing the intervals in pairs of curly braces, {...}.

You can probably solve issue #3 by removing - (the minus symbol) from the list of "input symbols" defined in \sisetup{...}. However, since there's not a single - symbol in the table it's not possible to test out this suggestion.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{input-symbols = {( ) -}}
\begin{document}
\begin{table} 
\caption{Presentation of survival data for the full sample ($N = \num{11 959}$)} \label{table:SurvivalAll}

\medskip
Legend:
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRAE: Hazard Ratio -- Academically Excluded. 90\% confidence bands given in parentheses below the corresponding point estimates.

\medskip
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
S[table-format=1.0]
S[table-format=5.0,group-four-digits=true]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.1]
S[table-format=2.1]
@{}
}
\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} 
& {\bfseries AE} & {\bfseries C} 
& {\bfseries HRG} & {\bfseries HRAE}\\
& & & & & {(\%)} & {(\%)} \\
\midrule
1 & 11959 & 0 & 725 & 1619 & 0.0 & 6.1 \\ 
& & & & &  {(0.0; 0.0)} & {(6.0; 6.1)} \\
2 & 9615 & 0 & 474 & 1513 & 0.0 & 4.9 \\
& & & & &  {(0.0; 0.0)} & {(4.0; 5.0)} \\
3 & 7628 & 1271 & 335 & 966 & 16.7 & 4.4 \\
& & & & &  {(16.0; 17.0)} & {(4.0; 5.0)} \\
4 & 5056 & 2797 & 145 & 405 & 55.3 & 2.9 \\
    & & & & &  {(54.0; 57.0)} & {(2.0; 3.0)} \\
5 & 1709 & 1144 & 77 & 170 & 66.9 & 4.5 \\
    & & & & &  {(65.0; 69.0)} & {(4.0; 5.0)} \\
6 & 318 & 236 & 15 & 24 & 74.2 & 4.7 \\
    & & & & &  {(65.0; 69.0)} & {(4.0; 5.0)} \\
7 & 43 & 27 & 7 & 5 & 62.8 & 16.3 \\ 
& & & & & {(48.0; 77.0)} & {(5.0; 27.0)} \\
8 & 4 & 3 & 0 & 1 & 75.0 & 0.0 \\
& & & & &  {(33.0; 117.0)} & {(0.0; 0.0)} \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
0

Your minor problems can be solved

  • First Problem: use ~{} before and after ;

  • Second Problem: use \begin{tabular*}{0.95\textwidth}{@{\extracolsep{\fill}}rrrrrcc} and adjust the numbers in brackets with ~{} as shown in the code

  • Third problem: minus sign is accepted. no error message was thrown

code

\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage[online]{threeparttable}
\usepackage{siunitx}
\sisetup{input-symbols = {( ) -}}
\begin{document}

\begin{table} [h]
\centering
\begin{threeparttable}
\caption{Presentation of survival data for the whole sample ($N = \num{11 959}$). }
\label{table:SurvivalAll}
\begin{tabular*}{0.95\textwidth}{@{\extracolsep{\fill}}rrrrrcc}

\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} &
{\bfseries AE} & {\bfseries C} &
{\bfseries HRG} & {\bfseries HRAE}\\
& & & & & {(\%)} & {(\%)} \\
\midrule
1 & -11959 & 0 & 725 & 1619 & -0.0 & 6.1 \\
& & & & & {~{}(0.0{~{};~{}}0.0)} & {(6.0{~{};~{}}6.1)} \\[1ex]
2 & 9615 & 0.0 & 474 & 1513 & 0.0 & 4.9 \\
& & & & & {(0.0{~{};~{}}0.0)} & {(4.0{~{};~{}}5.0)} \\[1ex]
3 & 7628 & 1271 & 335 & 966 & 16.7 & 4.4 \\
& & & & & {~{}(16.0{~{};~{}}17.0)} & {(4.0{~{};~{}}5.0)} \\[1ex]
4 & 5056 & 2797 & 145 & 405 & 55.3 & 2.9 \\
    & & & & & {~{}(54.0{~{};~{}}57.0)} & {(2.0{~{};~{}}3.0)} \\[1ex]
5 & 1709 & 1144 & 77 & 170 & 66.9 & 4.5 \\
    & & & & & {~{}(65.0{~{};~{}}69.0)} &{(4.0{~{};~{}}5.0)} \\[1ex]
6 & 318 & 236 & 15 & 24 & 74.2 & 4.7 \\
    & & & & & {~{}(65.0{~{};~{}}69.0)} & {(4.0{~{};~{}}5.0)} \\[1ex]
7 & -43 & 27 & 7 & 5 & 62.8 & 16.3 \\
& & & & & {~{}(48.0{~{};~{}}77.0)} & {~{}~{}~{}(5.0{~{};~{}}27.0)} \\[1ex]
8 & 4 & 3 & 0.0 & 1 & 75.0 & 0.0 \\
& & & & & {~{}~{}~{}(33.0{~{};~{}}117.0)} & {(0.0{~{};~{}}0.0)} \\
\bottomrule
\addlinespace
\end{tabular*}
\begin{tablenotes}
  \item[Legend:]
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRAE: Hazard Ratio --~Academically Excluded
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

Output

answer3

  • Please remember to indent lines of LaTeX code by four spaces -- easily achieved by highlighting the lines in question with your mouse and clicking on the {} "button" in the row above the editing window -- to get them pretty-printed by the site's software. – Mico Aug 25 '14 at 5:42
  • A couple of additional comments. First: your proposed solution appears to be quite similar to the one offered by @Bernard. It might be helpful to readers if you explained some of your design choices explicitly. E.g., why choose 0.95\textwidth instead of \textwidth for the overall width of the table? Second: I wouldn't claim that there's no problem with the minus signs, quite to the contrary. Specifically, the minus signs are shown as dashes instead of as proper typographic minus signs. This can probably be fixed by removing - from the input-symbol list, right? – Mico Aug 25 '14 at 5:48
  • 1.there is no much difference between 0.95\textwidth and \textwidth – murugan Aug 25 '14 at 9:49
  • 2.input-symbol list must be removed when we use -. 3.otherwise we can use {\color{red}(11959)} for showing negative figures. 4) 95% confidence interval numbers with ; were aligned with the decimal point (.) appearing above that. – murugan Aug 25 '14 at 9:57
  • These explanations are very useful. I suggest you move them into the body of your answer, where they'll be seen more readily than when they're tucked away in a comment. – Mico Aug 25 '14 at 11:20

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.