4

I have a table like:

\begin{table}[!htbp]
\begin{scriptsize}
\centering
\setlength\tabcolsep{3pt}
\begin{tabular}[m]{|m{2cm}|*{17}{c}|c|}
\hline
\multirow{3}{*}{Model} & 
\multicolumn{17}{c|}{APE Thresholds (\%)} & \multirow{3}{*}{Best} \\ \cline{2-18}
& 0.01 & 0.05 & 0.1 & 0.25 & 0.5 & 1 & 2 & 5 & 7.5 & 10 & 15 & 30 & 40 & 50 & 75 & 100 & None \\\hline
Open dfasdfadsfaa 
& 35 & 40 & 55 & 25 & 40 & 35 & \\
Closed 
& 25 & 50 & 35 & 40 & 45 &  \\ \hline
\end{tabular}
\caption{Hyperparameter Optimisation: APE Threshold - Words \& Depgram Features}
\label{table2}
\end{scriptsize}
\end{table}

Which looks like:

enter image description here

As you can see, there is a gap to the right of the word Best, which should be the end of the table.

What am I doing wrong/how can I improve this table? I had to set up the tab column separation to very small.

3 Answers 3

3

The easiest way to improve the table is to give it a more "open" look -- by removing all vertical lines and using the line-drawing macros of the booktabs package for the horizontal lines. To assure that the tabular material takes up the entire available text block width, use a tabular* environment. And, as it appears to be necessary to render the table using \scriptsize, reduce the font size of the caption as well; in the example below, I use one of the facilities of the caption to set the font size of the caption.

enter image description here

\documentclass{article}
\usepackage{array,booktabs,caption,ragged2e}
\begin{document}

\begin{table}[!htbp]
\captionsetup{size=footnotesize}
\scriptsize
\setlength\tabcolsep{0pt} % let tabular* figure out intercolumn whitespace

\begin{tabular*}{\textwidth}{>{\RaggedRight}p{2cm} @{\extracolsep{\fill}}*{18}{c}}
\toprule
Model & \multicolumn{17}{c}{APE Thresholds (\%)} & Best \\ 
\cmidrule{2-18}
& 0.01 & 0.05 & 0.1 & 0.25 & 0.5 & 1 & 2 & 5 & 7.5 & 10 & 15 & 30 & 40 & 50 & 75 & 100 & None \\
\midrule
Open dfasdfadsfaa
& 35 & 40 & 55 & 25 & 40 & 35 & \\
Closed
& 25 & 50 & 35 & 40 & 45 &  \\ 
\bottomrule
\end{tabular*}

\caption{Hyperparameter Optimisation: APE Threshold---Words \& Depgram Features}
\label{table2}
\end{table}

\end{document}
3

even the columns are empty, you alwas need to set all ampersands. because you didn't do this, the last cell, which end with vertical line, never appear ...

\documentclass{article}
\usepackage{array,multirow}

\begin{document}
\begin{table}[!htbp]
\begin{scriptsize}
\centering
\setlength\tabcolsep{2pt}
\begin{tabular}[m]{|m{2cm}|*{17}{c}|c|}
\hline
\multirow{3}{*}{Model} &
\multicolumn{17}{c|}{APE Thresholds (\%)} & 
    \multirow{3}{*}{Best} \\ \cline{2-18}
& 0.01 & 0.05 & 0.1 & 0.25 & 0.5 & 1 & 2 & 5 & 7.5 & 10 & 15 & 30 & 40 & 50 & 75 & 100 & None &    \\\hline
Open dfasdfadsfaa
& 35 & 40 & 55 & 25 & 40 & 35 & & & & & & & & & & & &  \\
Closed
& 25 & 50 & 35 & 40 & 45 & & &  & & & & &  & & & & & \\ \hline
\end{tabular}
\caption{Hyperparameter Optimisation: APE Threshold - Words \& Depgram Features}
\label{table2}
\end{scriptsize}
\end{table}
\end{document}

enter image description here

Addendum: off-topic of your question, but mybe you consider to design table without vertical lines. With employing rules from booktabs package you can obtain:

\documentclass{article}
\usepackage{array, booktabs, tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage{showframe}% for showing page layout
\renewcommand*\ShowFrameColor{\color{green!50}}

\begin{document}
    \begin{table}[htb]
    \small
    \centering
\setlength\tabcolsep{3pt}
    \begin{tabularx}\textwidth}{>{\raggedright}X*{18}{c}}
    \toprule
        & \multicolumn{17}{c}{APE Thresholds (\%)} &   
                            \\  \cmidrule(lr){2-18}
\centering  Model   
        & 0.01 & 0.05 & 0.1 & 0.25 & 0.5 &  1 &  2 & 5 
        & 7.5  & 10   & 15  & 30   & 40  & 50 & 75 & 100 
        & None & Best       \\  \midrule
Open dfas dfads faa
        & 35   & 40   & 55  & 25   & 40  & 35 &    & 
        &      &      &     &      &     &    &    & 
        &      &            \\  \addlinespace
Closed
        & 25   & 50   & 35  & 40   & 45  &    &    &  
        &      &      &     &      &     &    &    & 
        &      &            \\ \bottomrule
\end{tabularx}
\caption{Hyperparameter Optimisation: APE Threshold - Words \& Depgram Features}
\label{table2}
    \end{table}
\end{document}

enter image description here

Observe the changes between above MWE and your code:

  • even in editor the ampersands are positioned such, that it is easy to recognize columns and see, if are all present
  • scriptsize is not an environemt, so use it as command. Inside group (defined by table environment) it has influence only on table content
  • the use of multirow package isn't necessary
  • assed package tabularx is exploited for fit table to text width.
  • by reducing \tabcolsep to 2pt and used tabularx table environment enable to increase font size used in table to \small
1
  • Off-topic :-) -- Both tabular environments appear to be wider than the text block. Any suggested remedies?
    – Mico
    Sep 8, 2016 at 15:46
2

Please observe the solution only for the part of table in question. Changing 3 to 2 in \multirow gives a better effect. If you want also final vertical line in the rest of your table, you should add proper number of &'s.

\documentclass{article}

\usepackage{array}
\usepackage{multirow}
\begin{document}

\begin{table}[!htbp]
\begin{scriptsize}
\centering
\setlength\tabcolsep{3pt}
\begin{tabular}[m]{|m{2cm}|*{17}{c}|c|}
\hline
\multirow{2}{*}{Model} & 
%\multicolumn{17}{c|}{APE Thresholds (\%)} & \multirow{3}{*}{Best} \\ \cline{2-18}
\multicolumn{17}{c|}{APE Thresholds (\%)} & \multirow{2}{*}{Best} \\ \cline{2-18}
& 0.01 & 0.05 & 0.1 & 0.25 & 0.5 & 1 & 2 & 5 & 7.5 & 10 & 15 & 30 & 40 & 50 & 75 & 100 & None &\\\hline
Open dfasdfadsfaa 
& 35 & 40 & 55 & 25 & 40 & 35 & \\
Closed 
& 25 & 50 & 35 & 40 & 45 &  \\ \hline
\end{tabular}
\caption{Hyperparameter Optimisation: APE Threshold - Words \& Depgram Features}
\label{table2}
\end{scriptsize}
\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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