# \cmidrule not properly horizontally aligned on the outer edges & less vertical space between text lines

I have included 2 new commands to add space between rows and space between columns (see code below) but doing so creates a misalignment of the \cmidrule (see picture below). Also, while I added space between rows it creates space between the text. Is it possible to remove this space?

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\renewcommand\arraystretch{1.2}
\renewcommand{\tabcolsep}{15pt}

\begin{document}

\begin{table}
\begin{tabular}{@{} lll @{}}
\toprule
Samples & \multicolumn{2}{l}{Observations}\\
\cmidrule(lr){2-3}
&New & Old\\
&Region   & Region \\
\midrule
Sample 1&1&5\\
Sample 2&2&6\\

\midrule[\heavyrulewidth]

\end{tabular}

\end{table}
\end{document}


• Not that it addresses the issue, but \tabcolsep is a length, and is set with \tabcolsep=15pt\relax, not \renewcommand{\tabcolsep}{15pt}. – Steven B. Segletes Jun 6 '17 at 20:21
• Also, &New & Old\\[-2pt]  will remedy the vertical spacing between "New" and "Region" – Steven B. Segletes Jun 6 '17 at 20:23
• Does \cmidrule(l{2\cmidrulekern}){2-3} provide better matching? – user31729 Jun 6 '17 at 20:29
• @Steven B. Segletes: thanks for both helpful comments. – Alan Jun 6 '17 at 21:21

The “excess” space is not unexpected, because you're setting \tabcolsep to 15pt, instead of the default 6pt.

The default amount of trimming is \cmidrulekern, at the outset 0.5em, unless you specify l{<dimen>} or r{<dimen>}. So, at 10pt size, the trimming is about the same as the default \tabcolsep (remember that space of the amount of \tabcolsep is inserted at the left and right of a column, unless countermanded by @{<tokens>}.

The problem on the right side is that you trim notwithstanding the trailing @{}, so the rule will be short of the right edge by \cmidrulekern.

The space between the header rows is due to \arraystretch being set to 1.2. You can shorten it if you set the header cells in a nested tabular with a standard \arraystretch.

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\renewcommand\arraystretch{1.2}
\setlength{\tabcolsep}{15pt}

\newcommand{\splitcell}[2][c]{%
\begingroup
\renewcommand{\arraystretch}{1}%
\begin{tabular}{@{}#1@{}}
#2
\end{tabular}%
\endgroup
}

\begin{document}

\begin{table}
\begin{tabular}{@{} lll @{}}
\toprule
Samples & \multicolumn{2}{l@{}}{Observations} \\
\cmidrule(l{\tabcolsep}){2-3}
& \splitcell[l]{New \\ Region} & \splitcell[l]{Old \\ Region} \\
\midrule
Sample 1&1&5\\
Sample 2&2&6\\
\bottomrule
\end{tabular}

\end{table}
\end{document}


Final notes: \tabcolsep must be set with \setlength, differently from \arraystretch (which is not a length, but a factor). The bottom rule should not be \midrule[\heavyrulewidth], but simply \bottomrule.

I find it useful to trim 1em from the left and not trim at all from the right side of the cmidrule. I also included Steven Segletes suggestions. Here the first code, I also made the second and the third column centered, which I think look better; also I used bottomrule for the last rule

\documentclass{article}
\usepackage{booktabs}
\usepackage{array,multirow}
\renewcommand\arraystretch{1.2}
\setlength{\tabcolsep}{15pt}

\begin{document}

\begin{table}
\begin{tabular}{@{}lcc@{}}
\toprule
Samples & \multicolumn{2}{c}{Observations}\\
\cmidrule(l{1em}){2-3}
&New & Old\\[-2pt]
&Region   & Region \\
\midrule
Sample 1&1&5\\
Sample 2&2&6\\

\bottomrule

\end{tabular}

\end{table}
\end{document}


Also, if you know the width of the column, you could try using multirow for "New region" and "old Region". It could be risky but you can try:

\documentclass{article}
\usepackage{booktabs}
\usepackage{array,multirow}
\renewcommand\arraystretch{1.2}
\setlength{\tabcolsep}{15pt}

\begin{document}

\begin{table}
\begin{tabular}{@{}lcc@{}}
\toprule
Samples & \multicolumn{2}{c}{Observations}\\
\cmidrule(l{1em}){2-3}
&\multirow{2}{1cm}{New Region} &\multirow{2}{1cm}{Old Region}\\
&   &  \\
\midrule
Sample 1&1&5\\
Sample 2&2&6\\

\bottomrule

\end{tabular}

\end{table}
\end{document}


Since you're using booktabs, you needn't reset \arraystretch manually, it does it for you. To adjust the \cmidrule, use @{\hspace{30pt}} before the second column specification and no need for (lr) settings. Notice that 30pt=2*15pt=2\tabcolsep.

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}

%\renewcommand\arraystretch{1.2}
\renewcommand{\tabcolsep}{15pt}
\begin{document}

\begin{table}
\begin{tabular}{@{}l@{\hspace{30pt}}ll@{}}
\toprule
Samples  & \multicolumn{2}{l}{Observations} \\ \cmidrule{2-3}
& New    & Old    \\
& Region & Region \\ \midrule
Sample 1 & 1      & 5      \\
Sample 2 & 2      & 6      \\
\midrule[\heavyrulewidth]
\end{tabular}
\end{table}

\end{document}


• Well, if your 30pt is expected to be 2\tabcolsep, why wouldn't you use \hspace{2\tabcolsep} directly? Anyway, @{\hspace{2\tabcolsep}} is a neat trick how to autotrim \cmidrule! Just please, do not use \renewcommand on lengths. – yo' Jun 7 '17 at 6:46