# Inexplicable vertical border behavior in a simple table

The code below prints the picture below, and I cannot figure out why the vertical borders act like they do. Obviously, I would like the line to go from the toprule to the bottomrule, but for some reason one line goes past the bottomrule while two of them don't start until row number two.

Can anyone help me modify the code to make it look alright? I am in a bit of a rush.

Thank you very much.

\begin{center}
\captionof{table}{Results from running the main model for different scenarios}
\begin{tabular}{l|ccc|c|ccc|ccc}
\toprule
& \multicolumn{3}{c}{\textbf{Weights}}
& \textbf{Obj.}
& \multicolumn{3}{c}{\textbf{Weighted pen.}}
& \multicolumn{3}{c}{\textbf{Total pen.}} \\
\textbf{Variation}           & 1   & 2   & 3  & \textbf{value}  & 1 & 2 & 3  & 1 & 2 & 3\\
\cmidrule(r){1-11}
Even weights          & 1/3   & 1/3   & 1/3   & 55.67  & 26.67 & 4.33   & 24.67 & 80    & 13    & 74\\
Emphasised 1          & 1/2   & 1/4   & 1/4   & 60.75 & 36   & 4.25  & 20.5 & 72    & 17    & 82\\
Emphasised 2          & 1/4   & 1/2   & 1/4   & 44.5  & 21   & 4.5   & 19   & 84    & 9     & 76\\
Emphasised 3          & 1/4   & 1/4   & 1/2   & 60.25 & 20   & 8.25  & 32   & 80    & 33    & 64\\
No lunch              & 1/3   & 1/3   & 1/3   & 43    & 21   & 2.67  & 19.33& 63    & 8     & 58 \\
No R\&D on lab 4      & 1/3   & 1/3   & 1/3   & 27    & 1.33 & 3.67  & 22   & 4     & 11    & 66 \\
New lab of type 3     & 1/3   & 1/3   & 1/3   & 49    & 24   & 5     & 20   & 72    & 15    & 60 \\
\bottomrule
\label{tab:scenariotable}
\end{tabular}
\end{center}

• You are missing | in the argument to \multicolumn; the \label command is misplaced, it should go next to \caption outside tabular – egreg Dec 14 '15 at 15:39
• Egreg, I love you! – jnrk Dec 14 '15 at 15:42

You're missing the | specifiers in the argument to \multicolumn. Also \label is misplaced: it should go just after \caption.

I recommend you not trying to place big tables with center and \captionof: leave them float.

Here's a fixed code, with another version, without vertical rules and with siunitx for better alignment of the numbers.

\documentclass{article}
\usepackage{siunitx,booktabs}
\usepackage{caption}

\begin{document}

\begin{table}
\centering

\caption{Results from running the main model for different scenarios}\label{tab:scenariotable}

\begin{tabular}{l|ccc|c|ccc|ccc}
\toprule
& \multicolumn{3}{c|}{\textbf{Weights}}
& \textbf{Obj.}
& \multicolumn{3}{c|}{\textbf{Weighted pen.}}
& \multicolumn{3}{c}{\textbf{Total pen.}} \\
\textbf{Variation}           & 1   & 2   & 3  & \textbf{value}  & 1 & 2 & 3  & 1 & 2 & 3\\
\cmidrule(r){1-11}
Even weights          & 1/3   & 1/3   & 1/3   & 55.67  & 26.67 & 4.33   & 24.67 & 80    & 13    & 74\\
Emphasised 1          & 1/2   & 1/4   & 1/4   & 60.75 & 36   & 4.25  & 20.5 & 72    & 17    & 82\\
Emphasised 2          & 1/4   & 1/2   & 1/4   & 44.5  & 21   & 4.5   & 19   & 84    & 9     & 76\\
Emphasised 3          & 1/4   & 1/4   & 1/2   & 60.25 & 20   & 8.25  & 32   & 80    & 33    & 64\\
No lunch              & 1/3   & 1/3   & 1/3   & 43    & 21   & 2.67  & 19.33& 63    & 8     & 58 \\
No R\&D on lab 4      & 1/3   & 1/3   & 1/3   & 27    & 1.33 & 3.67  & 22   & 4     & 11    & 66 \\
New lab of type 3     & 1/3   & 1/3   & 1/3   & 49    & 24   & 5     & 20   & 72    & 15    & 60 \\
\bottomrule
\end{tabular}

\end{table}

\begin{table}
\centering

\caption{Results from running the main model for different scenarios}\label{tab:scenariotablebetter}

\begin{tabular}{
@{}
l
ccc
S[table-format=2.2]
S[table-format=2.2]
S[table-format=1.2]
S[table-format=2.2]
S[table-format=2.0]
S[table-format=2.0]
S[table-format=2.0]
@{}
}
\toprule
\textbf{Variation}
& \multicolumn{3}{c}{\textbf{Weights}}
& \textbf{Obj.}
& \multicolumn{3}{c}{\textbf{Weighted pen.}}
& \multicolumn{3}{c}{\textbf{Total pen.}} \\
& {1} & {2} & {3} & {\textbf{value}}  & {1} & {2} & {3}  & {1} & {2} & {3} \\
\midrule
Even weights       & 1/3 & 1/3 & 1/3 & 55.67 & 26.67 & 4.33 & 24.67 & 80 & 13 & 74 \\
Emphasised 1       & 1/2 & 1/4 & 1/4 & 60.75 & 36    & 4.25 & 20.5  & 72 & 17 & 82 \\
Emphasised 2       & 1/4 & 1/2 & 1/4 & 44.5  & 21    & 4.5  & 19    & 84 &  9 & 76 \\
Emphasised 3       & 1/4 & 1/4 & 1/2 & 60.25 & 20    & 8.25 & 32    & 80 & 33 & 64 \\
No lunch           & 1/3 & 1/3 & 1/3 & 43    & 2 1   & 2.67 & 19.33 & 63 &  8 & 58 \\
No R\&D on lab 4   & 1/3 & 1/3 & 1/3 & 27    &  1.33 & 3.67 & 22    &  4 & 11 & 66 \\
New lab of type 3  & 1/3 & 1/3 & 1/3 & 49    & 24    & 5    & 20    & 72 & 15 & 60 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}


• The tabular environment is wider than the text block, unless that width has been increased somehow. – Mico Dec 14 '15 at 15:57
• @Mico I didn't address that aspect, as I don't know the final format. – egreg Dec 14 '15 at 15:58

Rather than figure out how to insert the "missing" vertical bars, you may want to think about structuring your table so that it has a more open look, a better-organized header and better-organized numeric data, and actually fits inside the available textblock. In the code below, I employ the S column type of the siunitx package for 7 of the data columns, and a tabular* environment so that the table occupies the full width of the available text block, but no more than that.

\documentclass{article}
\usepackage{booktabs,caption,siunitx}
% Utility macro to typeset single-column wrapped header cells:
\newcommand\mycol[1]{\smash{\begin{tabular}[t]{c} #1 \end{tabular}}}
\begin{document}
\begin{center}
\captionof{table}{Results from running the main model for different scenarios}
\label{tab:scenariotable}
\setlength\tabcolsep{0pt} % make LaTeX figure out optimal amount of intercolumn whitespace
\begin{tabular*}{\textwidth}{
l @{\extracolsep{\fill}}
*{3}{c}
*{4}{S[table-format=2.2]}
*{3}{S[table-format=3.0]} }
\toprule
Variation
& \multicolumn{3}{c}{Weights}
& {\mycol{Obj.\\value}}
& \multicolumn{3}{c}{Weighted pen.}
& \multicolumn{3}{c}{Total pen.} \\
\cmidrule{2-4} \cmidrule{6-8} \cmidrule{9-11}
& 1 & 2 & 3 & & {1} & {2} & {3} & {1} & {2} & {3}\\
\midrule
Even weights          & 1/3   & 1/3   & 1/3   & 55.67  & 26.67 & 4.33   & 24.67 & 80    & 13    & 74\\
Emphasised 1          & 1/2   & 1/4   & 1/4   & 60.75 & 36   & 4.25  & 20.5 & 72    & 17    & 82\\
Emphasised 2          & 1/4   & 1/2   & 1/4   & 44.5  & 21   & 4.5   & 19   & 84    & 9     & 76\\
Emphasised 3          & 1/4   & 1/4   & 1/2   & 60.25 & 20   & 8.25  & 32   & 80    & 33    & 64\\
No lunch              & 1/3   & 1/3   & 1/3   & 43    & 21   & 2.67  & 19.33& 63    & 8     & 58 \\
No R\&D on lab 4      & 1/3   & 1/3   & 1/3   & 27    & 1.33 & 3.67  & 22   & 4     & 11    & 66 \\
New lab of type 3     & 1/3   & 1/3   & 1/3   & 49    & 24   & 5     & 20   & 72    & 15    & 60 \\
\bottomrule
\end{tabular*}
\end{center}
\end{document}

• Wow that looks a lot better. Where would I specify a right-justification of all the numerical values in the table? – jnrk Dec 14 '15 at 17:10
• @jnrk - for simple right-alignment, use the r column type. – Mico Dec 14 '15 at 17:37
• Where should this be specified? – jnrk Dec 14 '15 at 21:29
• @jnrk - In the second argument of the tabular* environment. E.g., if you wanted the contents of all ten data columns to be right-aligned (instead of either centered or aligned on the decimal marker), you'd write \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} *{10}{r}}. – Mico Dec 14 '15 at 21:35