6

I managed to make a multicolumn table, but it looks ugly and need some fix.

  1. How to move the label "Min width" in the center?
  2. How to give more space between the first and second row?

enter image description here

\documentclass[11pt, twocolumn]{article}

\usepackage{booktabs}

\begin{document}

\begin{table}[ht]
\caption{String}
\centering 
\begin{tabular}{c | cc | cc }
\toprule
Min width  & \multicolumn{2}{|c|}{$fp_{c}$} &
\multicolumn{2}{|c}{$fp_{bf}$} \\ \cline{2-5}
 & theory & exp & theory & exp  \\
\midrule
1 & 0.23\% & 0.21\% & 0.04\% & 0.065\% \\
2 & 0.085\% & 0.087\% & 0.0015\% & 0.0020\% \\
3 & 0.032\% & 0.026\% & $5.5\times 10^{-4}$\% & 0\% \\
4 & 0.012\% & 0.011\% & $2.1\times 10^{-4}$\% & 0\% \\
\bottomrule
\end{tabular}
\label{tbl:fp_probabilities}
\end{table}

\end{document}
3
  • The multicol tag is wrong here, since it is connected to another concept. You need the \multirows command from multirow package
    – user31729
    Sep 5, 2014 at 0:19
  • @ChristianHupfer - You must have editing rights by now on this site -- just go ahead and correct the tags as you see fit.
    – Mico
    Sep 5, 2014 at 1:57
  • @Mico: Of course I could have edited it myself, but I wanted to leave it to the OP
    – user31729
    Sep 5, 2014 at 6:40

5 Answers 5

6

Of course, remove vertical lines. For spacing properly the headers, as others stated, use booktabs, no doubt. For the multirow cell "Min width" is better use a \parbox or a minipage sice there are only a column of single digits. Also it is better add some space to the caption, that without additional packages can be done tuning \belowcaptionskip.

On the other hand, make the table simple as possible. If all your data are percentages, you can show information in the headers of each column, but it is better if you simply use the caption for that.

With respect to the columns, may be is better add some spacing between columns 3 and 4 to distinguish the two groups of data. A simple way is add an empty column or play with the column separators (@{}).

Finally, in this example I prefer do not follow decimal alignment because the uneven decimal columns in this case do not help too munch to distinguish numbers above or below 1 (waiting opposing views in 3, 2 ...) :)

enter image description here

\documentclass[11pt, twocolumn]{article}
\usepackage{booktabs,multirow}
\setlength{\belowcaptionskip}{5pt} 

\begin{document}


\begin{table}[ht]
\caption{String (\%)} 
\centering 
\begin{tabular}{cccccc} %  
\toprule
\multirow{2}{*}{
\parbox[c]{.2\linewidth}{\centering Min width}}
  & \multicolumn{2}{c}{$fp_{c}$} &&
\multicolumn{2}{c}{$fp_{bf}$} \\ 
\cmidrule{2-3} \cmidrule{5-6}

 & {\centering theory} & {exp.} && {theory} & {exp.}  \\
\midrule
1 & 0.23  & 0.21  && 0.04               & 0.065 \\
2 & 0.085 & 0.087 && 0.0015             & 0.0020 \\
3 & 0.032 & 0.026 && $5.5\times10^{-4}$ & 0 \\
4 & 0.012 & 0.011 && $5.5\times10^{-4}$ & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
3

Here is a possible solution. I used siunitx to have a vertical alignment of numbers in columns and a simplified typing of scientific notation, makecell to have multirow cells that allow for line breaking and to have less tight rows, caption for a correct vertical spacing betwen caption and table. Also I added some color, and deleted vertical rules: this is bad typographical practice.

\documentclass[11pt, twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[x11names]{xcolor}
\usepackage{colortbl}
\usepackage{booktabs, caption}
\captionsetup{labelfont = sc}
\setlength\cmidrulewidth{1.2\lightrulewidth}
\usepackage{multirow, makecell}
\usepackage{siunitx}
\sisetup{table-figures-exponent=1, table-sign-exponent=true}
\setcellgapes{4pt}\makegapedcells

\begin{document}

\begin{table}[ht]
\caption{String}
\centering
\begin{tabular}{c*{2}{S[table-format=1.3]}@{\qquad}*{2}{S[table-format=1.4]}}
\arrayrulecolor{Tomato3}\toprule
& \multicolumn{2}{c}{$fp_{c}$} & \multicolumn{2}{c}{$fp_{bf}$} \\
\arrayrulecolor{LightSteelBlue3}
\cmidrule(lr{2em}){2-3}\cmidrule(r){4-5}
\multirowcell{-3}{Min\\ width} & {theory (\%)} & {exp(\%)} & {theory(\%)} & {exp(\%)} \\
\cmidrule(lr{2em}){2-3}\cmidrule(r){4-5}
1 & 0.23 & 0.21 & 0.04 & 0.065 \\
2 & 0.085 & 0.087 & 0.0015 & 0.0020 \\
3 & 0.032 & 0.026 & \num{5.5 e-4} & 0 \\
4 & 0.012 & 0.011 & \num{2.1 e-4} & 0 \\
\arrayrulecolor{Tomato3}\bottomrule
\end{tabular}
\label{tbl:fp_probabilities}
\end{table}

\end{document} 

enter image description here

0
2

Always avoid vertical lines in booktabs since the commands provided by booktabs work correctly only in absence of vertical rules. Also you need multirow package and you can improve the table by inserting the % sign in headings and align numbers at the . floating point. With these in mind, you can get this table:

enter image description here

The modified code is:

\documentclass[11pt, twocolumn]{article}
\usepackage{booktabs,multirow}
\begin{document}

\begin{table}[!ht]
\centering
\caption{String}
\begin{tabular}{@{}c*{2}{r@{.}l}{c}*{2}{r@{.}l}@{}}
\toprule
\multirow{2}{*}{Min width} & \multicolumn{4}{c}{$fp_{c}$} && \multicolumn{4}{c}{$fp_{bf}$}\tabularnewline
\cmidrule{2-5} \cmidrule{7-10}
 & \multicolumn{2}{l}{theory \%} & \multicolumn{2}{l}{exp \%} && \multicolumn{2}{l}{theory \%} & \multicolumn{2}{l}{exp \%}\tabularnewline
\midrule
1 & 0&23  & 0&21  &&  0&04                & 0&065  \tabularnewline
2 & 0&085 & 0&087 &&  0&0015              & 0&0020 \tabularnewline
3 & 0&032 & 0&026 &&  5&$5\times 10^{-4}$ & 0&0    \tabularnewline
4 & 0&012 & 0&011 &&  2&$1\times 10^{-4}$ & 0&0    \tabularnewline
\bottomrule
\end{tabular}
\label{tbl:fp_probabilities}
\end{table}

\end{document}

Note: Pay attention to the table width as you are using twocolumn. Otherwise use either sidewaystable or make the table occupy both columns

5
  • What does your column setup code do that couldn't be achieved more easily as *{4}{l}?
    – Mico
    Sep 5, 2014 at 1:59
  • We don't have any 4 consecutive left aligned columns. The only repetitive form is r@{.}l isn't it?
    – AboAmmar
    Sep 5, 2014 at 2:08
  • The screenshot makes it look like there are four data columns whose contents are left-aligned, doesn't it?
    – Mico
    Sep 5, 2014 at 2:12
  • We have @{.} separating two columns, so we can't combine them in single alignment. Besides, if we use l@{.}l and it happens that one of the numbers has 2 digits to the left of the ., we get wrong alignment
    – AboAmmar
    Sep 5, 2014 at 2:26
  • I guess my point is that instead of creating 8 columns (with pairs of columns joined by the decimal marker) and splitting the numbers in the table into integer and decimal components, wouldn't it be easier to leave the numbers alone and employ either the dcolumn package or the siunitx package to provide a column type that performs alignment on the decimal marker?
    – Mico
    Sep 5, 2014 at 2:35
2

Here's a proposed solution which (a) makes more consistent use of the macros of the booktabs package (no \cline, but a couple of \cmidrules), (b) uses the S column type of the siunitx package to align the numbers on the decimal markers, (c) simplifies the content of the table by moving the common unit information ((%)) into a separate header row, and (d) deliberately does not break the string "min width" across two rows, in order to preserve a visual balance between the first column that contains the labels and the remaining columns that contain the data.

Separately, loading the caption package automatically inserts a bit of vertical whitespace between the caption and the tabular. Finally, as others have already remarked, simply don't use vertical lines in a table, regardless of whether you use the booktabs package or not: A well-designed table should be able to make do without the vertical bars and will, almost certainly, look a whole lot better than one with vertical bars.

enter image description here

\documentclass[11pt, twocolumn]{article}
\usepackage{booktabs,siunitx,caption}
\sisetup{table-format=1.4,tight-spacing=true}
\begin{document}
\begin{table}[ht]
\caption{String} \label{tbl:fp_probabilities}
\centering 
\begin{tabular}{@{} c *{4}{S} @{}}  % 1 'c' column, 4 'S' columns
\toprule
Min width  & \multicolumn{2}{c}{$fp_{c}$} &
\multicolumn{2}{c}{$fp_{bf}$} \\ 
\cmidrule(lr){2-3} \cmidrule(l){4-5}
 & {theory} & {exp} & {theory} & {exp}  \\
 & {(\%)} & {(\%)} & {(\%)} & {(\%)} \\
\midrule
1 & 0.23 & 0.21 & 0.04 & 0.065 \\
2 & 0.085 & 0.087 & 0.0015 & 0.0020 \\
3 & 0.032 & 0.026 & \num{5.5e-4} & 0 \\
4 & 0.012 & 0.011 & \num{2.1e-4} & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
0

the same thing. however, \multirows command and package multirow is to be used as suggested by Christian Hupfer Code

\documentclass[11pt, twocolumn]{article}

\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}
\begin{document}

\begin{table}[h]
\caption{String}
\centering 
\begin{tabular}{c | cc | cc }
\toprule
\multirow{5}{*}{Min width} & \multicolumn{2}{|c|}{$fp_{c}$} &
\multicolumn{2}{|c}{$fp_{bf}$} \\ 
& & \\ \cline{2-5}
& & &\\
&theory & exp& theory & exp  \\ 
& & &\\
\midrule
1 & 0.23\% & 0.21\% & 0.04\% & 0.065\% \\
2 & 0.085\% & 0.087\% & 0.0015\% & 0.0020\% \\
3 & 0.032\% & 0.026\% & $5.5\times 10^{-4}$\% & 0\% \\
4 & 0.012\% & 0.011\% & $2.1\times 10^{-4}$\% & 0\% \\
\bottomrule
\end{tabular}
\label{tbl:fp_probabilities}
\end{table}
\end{document}

space

2
  • Please remember to indent lines of LaTeX code by four spaces so that they can get pretty-printed by the site's software. Indenting the lines in this manner is achieved easily by simply highlighting them and clicking on the {} button in the ribbon above the editing window.
    – Mico
    Sep 5, 2014 at 1:54
  • You should always avoid vertical rules in booktabs to have it working correctly.
    – AboAmmar
    Sep 5, 2014 at 1:58

You must log in to answer this question.

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