4

I've typeset the following table:

Table output

As you can see, I've split the table horizontally because it makes the data fit better on a letter-sized sheet of paper. This way, the table can easily float at the top or bottom of the page. This all works fine.

My question is about the best way to create that space between the two halves of the table. I saw that this guide to tables uses an extra column with an \hphantom{abc} in that column. The phantom element seemed very ugly to me, so I substituted a \quad space. However, I'm still wondering if the extra column is the best way to do this.

So, what is the standard way to typeset such a table?


MWE:

\documentclass{standalone}

\usepackage{booktabs}
\usepackage{siunitx}

\newcommand{\mean}[0]{\bar}

\begin{document}
\begin{tabular}{rSSSSScrSSSSS}
  \toprule
  {Hour} & {$x_1$} & {$x_2$} & {$x_3$} & {$\mean x$} & {$R$} & \quad & {Hour} & {$x_1$} & {$x_2$} & {$x_3$} & {$\mean x$} & {$R$} \\
  \cmidrule{1-6} \cmidrule{8-13}
  1 & 0.36 & 0.39 & 0.36 & 0.370 & 0.03 && 11 & 0.36 & 0.32 & 0.36 & 0.347 & 0.04 \\
  2 & 0.33 & 0.35 & 0.30 & 0.327 & 0.05 && 12 & 0.38 & 0.47 & 0.35 & 0.400 & 0.12 \\
  3 & 0.51 & 0.41 & 0.42 & 0.447 & 0.10 && 13 & 0.29 & 0.45 & 0.39 & 0.377 & 0.16 \\
  4 & 0.42 & 0.37 & 0.34 & 0.377 & 0.08 && 14 & 0.44 & 0.38 & 0.43 & 0.417 & 0.06 \\
  5 & 0.39 & 0.38 & 0.38 & 0.383 & 0.01 && 15 & 0.38 & 0.37 & 0.37 & 0.373 & 0.01 \\
  6 & 0.33 & 0.41 & 0.45 & 0.397 & 0.12 && 16 & 0.31 & 0.43 & 0.38 & 0.373 & 0.12 \\
  7 & 0.43 & 0.39 & 0.41 & 0.410 & 0.04 && 17 & 0.39 & 0.49 & 0.35 & 0.410 & 0.14 \\
  8 & 0.41 & 0.32 & 0.32 & 0.350 & 0.09 && 18 & 0.43 & 0.36 & 0.38 & 0.390 & 0.07 \\
  9 & 0.37 & 0.42 & 0.36 & 0.383 & 0.06 && 19 & 0.40 & 0.45 & 0.32 & 0.390 & 0.13 \\
  10 & 0.26 & 0.42 & 0.32 & 0.333 & 0.16 && 20 & 0.40 & 0.40 & 0.32 & 0.373 & 0.08 \\
  \midrule
  \multicolumn{13}{r}{%
    $\mean{\mean x} \approx 0.3813$
    \qquad
    $\mean R = 0.0835$
  } \\
  \bottomrule
\end{tabular}
\end{document}
3
  • 1
    A vertical rule may come in handy; or just @{\hspace{1em}}; or even just two adjadcent different tables. By the way, you may like the output of \cmidrule(lr){1-6}\cmidrule(lr){7-12} without the need of faking the space in the middle.
    – Manuel
    Nov 1 '14 at 3:40
  • 2
    @Manuel Thanks for your comment. (1) I tend to follow booktabs.pdf's advice to "[n]ever, ever use vertical rules" (p. 3). (2) I considered using an @-expression, but it seems somewhat odd that it inserts the space into the following cell instead of between columns. It also doesn't work with \cmidrule(lr), probably for this precise reason. (3) \cmidrule(lr) does look quite promising. The space is less than I would like, though.
    – wchargin
    Nov 1 '14 at 4:34
  • Do not follow that advise blindly, in this case you want to clear that you are definitely breaking the table, that vertical rule would mean a break. @{..} doesn't add anything inside any column, it adds between columns.
    – Manuel
    Nov 1 '14 at 7:45
3

I'm not sure if there's a standard way to typeset a table such as yours. In addition to keeping (a) the open look provided by the macros of the booktabs package (and an absence of all vertical rules) and (b) the decimal alignment of the numeric columns (via the S column type of the siunitx package), I would

  • get rid of the 13th, "dummy" column between the two main groups of six columns, and replace it with an instruction, in the table header, of @{\quad};

  • provide extra information about the number of significant digits in the columns, to let LaTeX typeset the numerical columns a bit more tightly;

  • use a tabular* instead of a tabular environment to assure that the table will actually fit inside the current text block. (Your code, by using the standalone document class, obscures this important aspect.) The tabular* environment takes as one of its arguments the intended width of the environment; here, I'd choose \textwidth. The somewhat complicated-looking term @{\extracolsep\fill}, along with the instruction \setlength\tabcolsep{0.1pt}, serve to make the table fit automatically.

enter image description here

\documentclass{article}
\usepackage{booktabs,siunitx}
\newcommand{\mean}[1]{\bar{#1}}

\begin{document}
\begin{table}
\sisetup{table-format=1.2}
\setlength\tabcolsep{0.1pt}
\begin{tabular*}{\textwidth}{@{} r @{\extracolsep{\fill}} 
      *{3}{S}S[table-format=1.3]S @{\quad} r 
      *{3}{S}S[table-format=1.3]S @{}}
  \toprule
  Hour & {$x_1$} & {$x_2$} & {$x_3$} & {$\mean x$} & {$R$} &   
  Hour & {$x_1$} & {$x_2$} & {$x_3$} & {$\mean x$} & {$R$} \\
  \cmidrule(r){1-6} \cmidrule{7-12}
  1 & 0.36 & 0.39 & 0.36 & 0.370 & 0.03 & 11 & 0.36 & 0.32 & 0.36 & 0.347 & 0.04 \\
  2 & 0.33 & 0.35 & 0.30 & 0.327 & 0.05 & 12 & 0.38 & 0.47 & 0.35 & 0.400 & 0.12 \\
  3 & 0.51 & 0.41 & 0.42 & 0.447 & 0.10 & 13 & 0.29 & 0.45 & 0.39 & 0.377 & 0.16 \\
  4 & 0.42 & 0.37 & 0.34 & 0.377 & 0.08 & 14 & 0.44 & 0.38 & 0.43 & 0.417 & 0.06 \\
  5 & 0.39 & 0.38 & 0.38 & 0.383 & 0.01 & 15 & 0.38 & 0.37 & 0.37 & 0.373 & 0.01 \\
  6 & 0.33 & 0.41 & 0.45 & 0.397 & 0.12 & 16 & 0.31 & 0.43 & 0.38 & 0.373 & 0.12 \\
  7 & 0.43 & 0.39 & 0.41 & 0.410 & 0.04 & 17 & 0.39 & 0.49 & 0.35 & 0.410 & 0.14 \\
  8 & 0.41 & 0.32 & 0.32 & 0.350 & 0.09 & 18 & 0.43 & 0.36 & 0.38 & 0.390 & 0.07 \\
  9 & 0.37 & 0.42 & 0.36 & 0.383 & 0.06 & 19 & 0.40 & 0.45 & 0.32 & 0.390 & 0.13 \\
  10 & 0.26 & 0.42 & 0.32 & 0.333 & 0.16 & 20 & 0.40 & 0.40 & 0.32 & 0.373 & 0.08 \\
  \midrule
  \multicolumn{12}{r @{}}{%
    $\mean{\mean x} \approx 0.3813
    \qquad
     \mean R = 0.0835$
  } \\
  \bottomrule
\end{tabular*}
\end{table}
\end{document}
2
  • I would use S[table-format=2] for both of the Hour columns. (Also, I guess that \mean R \approx 0.0835 instead of \mean R = 0.0835.) Nov 2 '14 at 21:10
  • @SvendTveskæg - Thanks. For the two columns headed by "Hour", I chose to keep the OP's preferred column type. An advantage of using r is that the separation between the material of columns 6 and 7 is maximized, which is probably desirable.
    – Mico
    Nov 2 '14 at 21:35

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.