0

I am trying to make the following table attached to the text and I happened to have some issues. Table

and MWE:

    \documentclass[11pt]{article}

    \textwidth 165mm \textheight 230mm \topmargin -5mm
    \oddsidemargin 0mm        

    \usepackage{textcomp}
    \usepackage{siunitx}
    \usepackage{booktabs}
    \usepackage{makecell, multirow}

    \usepackage{multicol}
    \setlength{\columnsep}{1cm}

    \allowdisplaybreaks
    \usepackage[export]{adjustbox}
    \usepackage{ragged2e}

    \usepackage{float}
    \usepackage{tabularx}
    \usepackage{capt-of}
    \usepackage{booktabs}
    \usepackage{array}
    \usepackage{tabu}
    \usepackage{boldline}
    \usepackage{ltablex}
    \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}       

    \begin{document}
    \pagestyle{empty}    

    \begin{table}[htb]
        \caption{Computational Results: Case III}
        \label{tab: Case III}
        \centering
        \begin{tabu} to \textwidth {X[m,c]X[m,c]X[m,c]X[m,c]}
            \toprule
            {\multirow{2}{*}{\makecell{Statistics}
            & \multicolumn{2}{c}{\makecell{A}}
            & \multicolumn{2}{c}{\makecell{B}}
            \cmidrule{2-3}\cmidrule{4-5}
            {}& {$P_{1}$} & {$P_{2}$} & {$P_{1}$} & {$P_{2}$}\\
            \midrule
            \bottomrule
        \end{tabu}
    \end{table}
    \end{document}

your workaround would be appreciated!

5
  • Your multirow macro lacks two closing braces. Try with \multirow{2}{*}{\makecell{statistics}}. Also giving full MWE that can be pasted and compiled as it is (here we have to add \begin{document} and so on) would be appreciated.
    – sztruks
    Oct 31, 2018 at 7:15
  • Well, you give a multirow instruction, and your MWE has only one row… Btw I lost time compiling your MWE, because I forgot \usepackage{tabu}
    – sztruks
    Oct 31, 2018 at 7:34
  • @sztruks I just edited the MWE. It pertains to a long paper so I tried to incorporate a MWE just to let it compile.
    – BMB
    Oct 31, 2018 at 7:44
  • 2
    Ok, your preamble is full of errors : you shouldn't load twice the same package (texcomp, url). I will clean it for you, to get rid of all packages not usefull for your MWE.
    – sztruks
    Oct 31, 2018 at 7:48
  • I think you should read something about loading packages, you have much time to save here. One package should be load only once, you can pass multiple options. Othewise you loose time (package is loaded twice or more) and options you bypassed for the first time. I think you should also separate package loading of macro settings.
    – sztruks
    Oct 31, 2018 at 8:00

1 Answer 1

1

OK, this is a MWE that works. I will explain the mistakes below.

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{tabu}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{boldline}
\usepackage{ltablex}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[htb]
   \caption{Computational Results: Case III}
   \label{tab: Case III}
   \centering
   \begin{tabu} to \textwidth {X[m,c]X[m,c]X[m,c]X[m,c]X[m,c]}
      \firsthline
      \multirow{2}{*}{\makecell{Statistics}}
      & \multicolumn{2}{c}{\makecell{A}}
      & \multicolumn{2}{c}{\makecell{B}}\\
      \cmidrule(lr){2-3}\cmidrule(lr){4-5}
      {}& {$P_{1}$} & {$P_{2}$} & {$P_{1}$} & {$P_{2}$}\\
      \midrule
      \bottomrule
   \end{tabu}
\end{table}

\end{document}

output of MWE compilation

  • You forgot one line break after the B cell
  • unwanted bracket before multicolumn and forgot to close multicolumn.
  • too few columns declared (four instead of five).
3
  • Thanks! Is it also possible to align the "statistics" in the first column with the \midrule? Now, it is positioned above the midrule.
    – BMB
    Oct 31, 2018 at 8:03
  • Sure. Read this tex.stackexchange.com/questions/316169/… or connected. You can then edit my post to center "statistics".
    – sztruks
    Oct 31, 2018 at 8:08
  • 1
    I think the makecell instruction has to be improved to center your "Statistics".
    – sztruks
    Oct 31, 2018 at 8:22

You must log in to answer this question.

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