3

I have the following table. I would like centering the table on the top to avoid blank space after column 6. Thanks in advance for your help.

This is my code :

\documentclass[12pt]{article}
\usepackage{graphicx,subfigure}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[justification=centering]{caption}
\usepackage{booktabs}

\begin{document}
\begin{table}[t]\caption{Titre} \centering
\makebox[\textwidth]{%
\resizebox{17cm}{!} {
\begin{tabular}{lccccccc}
\toprule
\cmidrule(r){2-2}   \cmidrule(r){3-7}              
&     (1)     &    (2)    &     (3)      &   (4)    &   (5)    &   (6)          \\
& A & B & C & D  &  E &  F     \\
\cmidrule(r){2-2}   \cmidrule(r){3-7} 
Variable  &  1 & 1 & 1 & 1 & 1 & 1   \\
\cmidrule(r){2-2}   \cmidrule(r){3-7}   
& \\                    
&     (7)     &    (8)    &     (9)      &   (10)    &   (11)    &   (12)      & (13)    \\
& E & F&  G & K  & L &  M & N  \\ 
\cmidrule(r){2-2}  \cmidrule(r){3-3} \cmidrule(r){4-6} \cmidrule(r){7-8}
Variable & 2 & 2 & 2 & 2 & 2 & 2 & 2\\
\cmidrule(r){2-2}  \cmidrule(r){3-3} \cmidrule(r){4-6} \cmidrule(r){7-8}  \bottomrule
\end{tabular}
}
}
\end{table}
\end{document}

enter image description here

  • Welcome to TeX.SX! Why are you using that \makebox\resizebox combination? – TeXnician May 1 '17 at 11:49
  • 1
    Is splitting of your table into two tables, first with 7 and second with 8 columns and than both centered in table environment acceptable option? Why you resize table? As it is, it can be fit in text width. – Zarko May 1 '17 at 12:29
2

As has already been pointed out in the comments, you need to provide two separate tabular environments if you want to center them horizontally with regard to each other. And, by all means, get rid of the \resizebox and \makebox directives.

enter image description here

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{booktabs}

\begin{document}
\begin{table}[t]\caption{Titre} 
\centering

\begin{tabular}{@{} l*{6}{c} @{}}
\toprule             
& (1) & (2) & (3) & (4) & (5) & (6) \\
& A & B & C & D & E & F     \\
\cmidrule(lr){2-2}   \cmidrule(l){3-7} 
Variable  &  1 & 1 & 1 & 1 & 1 & 1   \\ 
\bottomrule
\end{tabular}

\medskip % or: \bigskip, ...
\begin{tabular}{@{} l*{7}{c} @{}}  
\toprule  
& (07) & (08) & (09) & (10) & (11) & (12) & (13) \\
& E & F & G & K & L & M & N  \\ 
\cmidrule(lr){2-2}  \cmidrule(lr){3-3} \cmidrule(lr){4-6} \cmidrule(l){7-8}
Variable & 2 & 2 & 2 & 2 & 2 & 2 & 2\\
\bottomrule
\end{tabular}

\end{table}
\end{document}
0

Mi approach is also two separate tabular, but making them look just like one, with 1-6 and 7-13 columns of the same width, that seem closer that you tried. As the question is tagged with tabularx for some reason, this approach use it, but with fewer horizontal lines.

mwe

\documentclass[12pt]{article}
\usepackage{graphicx,subfigure,tabularx}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[justification=centering]{caption}
\usepackage{booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}[t]\caption{Titre} 
\centering
\begin{tabularx}{.8\linewidth}{m{4em}YYYYYY}\toprule 
 & (1) & (2) & (3) & (4) & (5) & (6) \\
 & A & B & C & D & E & F \\
\cmidrule(rl){2-2} \cmidrule(rl){3-7} 
Variable & 1 & 1 & 1 & 1 & 1 & 1 \\
\\%\midrule
\end{tabularx}
\begin{tabularx}{.8\linewidth}{m{4em}YYYYYYY} 
& (7) & (8) & (9) & (10) & (11) & (12) & (13) \\
& E & F& G & K & L & M & N \\ 
\cmidrule(rl){2-2} \cmidrule(rl){3-3} \cmidrule(rl){4-6} \cmidrule(rl){7-8}
Variable & 2 & 2 & 2 & 2 & 2 & 2 & 2\\\bottomrule
\end{tabularx} 
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.