2

I am using cmidrule as I have used it before, but it's giving me strange errors. Below the MWE reproduces them. What is going on?

\documentclass{beamer}

\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}

\begin{document}

\begin{frame}{MWE}
    \begin{table}[tbh!]
        \centering
        \footnotesize
        \begin{tabular}{lccccccc}
            \toprule
                        & \multicolumn{3}{c}{(1)} && \multicolumn{3}{c}{(2)} \\
                        & \multicolumn{3}{c}{\textbf{OUTCOME}} && \multicolumn{3}{c}{\textbf{OUTCOME}} \\
                        & \cmidrule{2-4} \cmidrule{6-8} \\
                        & I & II & III && I & II & III \\
           \midrule
            \bottomrule
        \end{tabular}
    \end{table}
\end{frame}

\end{document}
3
  • 1
    you are missing the \\ to end the line. Mar 29, 2022 at 14:26
  • Thanks, but does not solve the issue. Updated the MWE.
    – Papayapap
    Mar 29, 2022 at 14:27
  • 1
    You also need to get rid of the superfluous & particle before \cmidrule{2-4}. And, while you're at it, do also get rid of double-backslash immediately after \cmidrule{6-8}; it's not a syntax error, but it's a typographical error.
    – Mico
    Mar 29, 2022 at 14:33

2 Answers 2

3

The line

& \cmidrule{2-4} \cmidrule{6-8} \\

contains a syntax error (&) and a typographical error (\\).

There also seems to be no need for 8 columns when 6 will do just fine. For visual balance, I'd also omit the bold-facing of some of the header cells. Since we're dealing with a beamer document, there's no point in using a table float to encase the tabular material. To finish things off, here's an excerpt from section 2 of the user guide of the booktabs package (emphasis added by me):

enter image description here

Thus, use either \midrule or \bottomrule, but not both.


Here's how I would be tempted to reconfigure your table -- note the absence of whitespace padding on the left- and right-hand sides.

enter image description here

\documentclass{beamer}
\usepackage{booktabs}
\begin{document}
\begin{frame}{MWE}
    % don't use figure and table floats in beamer docs
    %%\begin{table} 
    \begin{center}
    \begin{tabular}{@{} *{6}{c} @{}}
    \toprule
    \multicolumn{3}{@{}c}{(1)}     & \multicolumn{3}{c@{}}{(2)}     \\
    \multicolumn{3}{@{}c}{OUTCOME} & \multicolumn{3}{c@{}}{OUTCOME} \\
    \cmidrule(r){1-3} \cmidrule(l){4-6} 
    I & II & III & I & II & III \\
    \midrule
    aaa & bbb & ccc & ddd & eee & ggg \\
    \bottomrule
    \end{tabular}
    \end{center}
    %%\end{table}
\end{frame}
\end{document}
3
  • 1
    wow a lot of useful advice in here. I did not get the thing about the double rules. I thought this applied to not doing "\hline\hline". What do you mean? Deleting the \midrule?
    – Papayapap
    Mar 29, 2022 at 16:25
  • 1
    And funny, I am also an economist.. our best journal love the double rules ;)
    – Papayapap
    Mar 29, 2022 at 16:27
  • 1
    Welcome, fellow economist! :-) About the double-rule thing: My layout preference is to keep things as simple and uncluttered as possible. A single horizontal rule provides all the visual separation you'll ever need -- hence, no need to provide two horizontal rules. I'd use \bottomrule unless there's an excellent reason for using \midrule. (I can't think of one for the table at hand...)
    – Mico
    Mar 29, 2022 at 16:50
2

Try this code (with the rules after the \\.

\documentclass{beamer}

\usepackage{booktabs}
\usepackage{multicol}
\usepackage{multirow}

\begin{document}
    
    \begin{frame}{MWE}
        \begin{table}[tbh!]
            \centering
            \footnotesize
            \begin{tabular}{lccccccc}
                \toprule
                & \multicolumn{3}{c}{(1)} && \multicolumn{3}{c}{(2)} \\
                & \multicolumn{3}{c}{\textbf{OUTCOME}} && \multicolumn{3}{c}{\textbf{OUTCOME}} \\\cmidrule{2-4} \cmidrule{6-8}
                &  \\
                & I & II & III && I & II & III \\
                \midrule
                \bottomrule
            \end{tabular}
        \end{table}
    \end{frame}
    
\end{document}

a

0

You must log in to answer this question.

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