1

I want to create a table using cmidrule; cline does not split the line into several separate lines.

I have the following code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[referable]{threeparttablex}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{multirow}

\begin{document}
\begin{threeparttable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Comparison between two groups}
\scalebox{0.65}{\parbox{\linewidth}{%
\begin{tabular}{l l cccc  cccc cc} \hline\hline
&& \multicolumn{4}{c}{group1}  &\multicolumn{4}{c}{group2}  & \multicolumn{2}{c}{Difference in mean} \\ 
%\cline{3-6} \cline{7-10} \cline{11-12}
\cmidrule{r}{3-6} \cmidrule{r}{7-10} \cmidrule{r}{11-12}
&& obs.&mean1&std. dev. &mean2& obs.&mean1& std. dev.&mean2& mean1 diff. & mean2. diff\\
\rowgroup{ \textbf{\textit{Panel A. }}} \\
\multirow{2}{*}{\textit{Period 1}}& var1 \\
& var2 \\
\hline
\multirow{3}{*}{\textit{Period2}}& var1 \\
& var2 \\
\hline
\multirow{2}{*}{Period 3}& var1 \\
& var2 \\
\hline
\rowgroup{\textbf{\textit{Panel B. }}} \\
\multirow{2}{*}{\textit{Period 1}}& var1 \\
& var2 \\
\hline
\multirow{3}{*}{\textit{Period2}}& var1 \\
& var2 \\
\hline
\multirow{2}{*}{Period 3}& var1 \\
& var2 \\
\hline \hline
\end{tabular}
\begin{tablenotes}[flushleft]\footnotesize 
\item[1] hello
\end{tablenotes}}}
\end{threeparttable}
\end{document}

Using cline creates a table: enter image description here

The line under the first row does not break for different groups, which is not what I wanted. But if I use cmidrule to replace the cline row:

\cmidrule{r}{3-6} \cmidrule{r}{7-10} \cmidrule{r}{11-12}

It gave me different errors when I tried to complie it multiple times. One of them is "file ended while scanning use of \@writefile."

I don't know why this happens. Is it because I am using cmidrule with multirow or multicolumn? Can anybody help? Thanks!

3
  • Where's your \begin{document} and incidental end?
    – TeXnician
    Commented Feb 5, 2017 at 16:48
  • 1
    It is \cmidrule(r){3-6} \cmidrule(r){7-10} \cmidrule(r){11-12} with parentheses.
    – AboAmmar
    Commented Feb 5, 2017 at 16:52
  • I forgot to type \begin{document}.. It is before \begin{threeparttable}. The \end{document} should be after the \end{threeparttable}
    – user123818
    Commented Feb 5, 2017 at 16:57

1 Answer 1

1

Okay, your MWE is not compilable, but as far as I can see you did not correct your syntax. It works just fine, if you replace \cline{r}{1-1} with \cline(r){1-1}. A compiled example gives:

table

So here's the corrected code with \begin{document} etc.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[referable]{threeparttablex}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{graphicx}

\begin{document}
\begin{threeparttable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Comparison between two groups}
\scalebox{0.65}{\parbox{\linewidth}{%
\begin{tabular}{l l cccc  cccc cc} \hline\hline
&& \multicolumn{4}{c}{group1}  &\multicolumn{4}{c}{group2}  & \multicolumn{2}{c}{Difference in mean} \\ 
%\cline{3-6} \cline{7-10} \cline{11-12}
\cmidrule(r){3-6} \cmidrule(r){7-10} \cmidrule(r){11-12}
&& obs.&mean1&std. dev. &mean2& obs.&mean1& std. dev.&mean2& mean1 diff. & mean2. diff\\
\multirow{2}{*}{\textit{Period 1}}& var1 \\
& var2 \\
\hline
\multirow{3}{*}{\textit{Period2}}& var1 \\
& var2 \\
\hline
\multirow{2}{*}{Period 3}& var1 \\
& var2 \\
\hline
\multirow{2}{*}{\textit{Period 1}}& var1 \\
& var2 \\
\hline
\multirow{3}{*}{\textit{Period2}}& var1 \\
& var2 \\
\hline
\multirow{2}{*}{Period 3}& var1 \\
& var2 \\
\hline \hline
\end{tabular}
\begin{tablenotes}[flushleft]\footnotesize 
\item[1] hello
\end{tablenotes}}}
\end{threeparttable}
\end{document}
0

You must log in to answer this question.

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