Replace \cline with \cmidrule throughout document

I have several tables that are automatically outputted by a statistical package, with \cline commands for groups of column headers. I'm including these tables using \input in a larger document, and I'd like to convert all of the \cline calls to the more attractive \cmidrule. Obviously I can manually change them, but this will get tedious if I have to re-generate the tables.

I've tried \renewcommand{\cline}[1]{\cmidrule(lr){#1}}, but this does something strange.

\documentclass{article} \usepackage{booktabs}  \renewcommand{\cline}[1]{\cmidrule{#1}} \begin{document} \begin{table}[!tbp]  {\centering \begin{tabular}{lrrcrrcrr} \toprule \multicolumn{1}{l}{\bfseries }&\multicolumn{2}{c}{\bfseries Group1}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 2}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 3}\tabularnewline \cline{2-3} \cline{5-6} \cline{8-9} \multicolumn{1}{l}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}\tabularnewline \midrule \bottomrule \end{tabular}}  \end{table}  \end{document} 

Replace \cline with \cmidrule throughout document

I'll note that creating the extra empty columns to give space between the clines is an artifact of the stats package, which I unfortunately can't avoid without a lot more work.

Replay

The commands look ahead to check for a following command on the same row so you need something with the "expected" definition of \cmidrule. Using \let works here.

Replace \cline with \cmidrule throughout document

\documentclass{article}
\usepackage{booktabs}

\let\cline\cmidrule
\begin{document}
\begin{table}[!tbp]

{\centering
\begin{tabular}{lrrcrrcrr}
\toprule
\multicolumn{1}{l}{\bfseries }&\multicolumn{2}{c}{\bfseries Group1}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 2}&\multicolumn{1}{c}{\bfseries }&\multicolumn{2}{c}{\bfseries Group 3}\tabularnewline
\cline{2-3} \cline{5-6} \cline{8-9}
\multicolumn{1}{l}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{Name}&\multicolumn{1}{c}{Name (\$)}\tabularnewline
\midrule
\bottomrule
\end{tabular}

}

\end{table}

\end{document}

Category: rules Time: 2016-07-28 Views: 0
Tags: rules booktabs

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.201 (s). 12 q(s)