1

I have the following table and I am trying to align the 2016 and 2017 values. At the moment the code creates a straight line joining the 2016 and 2017 values. I am trying to get it to look like the "2015" column.

Here is how it looks now: (I just want to copy the 2015 part upto 2018...)

enter image description here

I think it uses \usepackage{booktabs} and \usepackage{multirow} and \let\mc\multicolumn

LaTeX code:

\begin{table}
\caption{Linear Support Vector Machine}

\begin{tabular}{r rrrr rrrr rrrr rrrr}
\toprule
 & \mc3c{2015} 
 & \mc3c{2016}
 & \mc2c{2017}
 & \mc2c{2018} \\
 \cmidrule(r){2-5}
 \cmidrule{6-9} 
 \cmidrule(l){10-13}
 \cmidrule(l){14-16}
  Class & Precision &Recall &F1 &Support & Precision &Recall &F1 &Support & Precision &Recall &F1 &Support & Precision &Recall &F1 &Support\\
\midrule
Growth &  &  &  &  &  &  &  &  &  &  &  &\\
Neutral &  &  &  &  &  &  &  &  &  &  &  &\\
Negative &  &  &  &  &  &  &  &  &  &  &  &\\ 
 &  &  &  &  &  &  &  &  &  &  &  &\\
Total Acc &  &  &  &  &  &  &  &  &  &  &  &\\
\bottomrule
\end{tabular}
\end{table}
2
  • Please extend your code fragment to an MWE! We need to know what is \mc, layout of your document etc.
    – Zarko
    Commented Aug 4, 2019 at 22:51
  • 1
    Now your table has 17 columns and I really doubt that it can fit in text width. For help you we also need some tip, what is in your empty cells? Numbers? Please fill one row of the table body. Regarding cmidrule try the following:\cmidrule(l){2-5}\cmidrule(l){6-9}\cmidrule(l){10-13}\cmidrule(l){14-17}
    – Zarko
    Commented Aug 4, 2019 at 23:11

1 Answer 1

4

The following seems more in line with what you're after:

enter image description here

\documentclass{article}

\usepackage[landscape]{geometry}% To make the table fit
\usepackage{booktabs}
\let\mc\multicolumn

\begin{document}

\begin{table}
  \caption{Linear Support Vector Machine}

  \begin{tabular}{ r *{4}{r} *{4}{r} *{4}{r} }
    \toprule
    & \mc{4}{c}{2015} & \mc{4}{c}{2016} & \mc{4}{c}{2017} \\
    \cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
    Class & 
      Precision & Recall & F1 & Support &   % 2015
      Precision & Recall & F1 & Support &   % 2016
      Precision & Recall & F1 & Support \\  % 2017
    \midrule
    Growth    \\
    Neutral   \\
    Negative  \\
              \\
    Total Acc \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

\cmidrule(lr){X-Y} shortens the \cmidrule on the left and right between columns X and Y.

You must log in to answer this question.

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