Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have received a booktabs bug report of \cmidrules that disappear when coloured rules are used inside beamer (together with colortbl). The problem can be illustrated with the following simple code and looks like an interaction between the beamer colour setup and \leaders. In the normal Latex classes the code is fine.

I know to little about the inner workings of beamer and hope there is someone here who can help or that can give a workaround. Note that the colour need to be grouped inside booktabs to prevent leaking.

EDIT: In an e-mail Michael Palmer suggested the addition of a \kern at the end of the grouping. This seems to work but the question is WHY?

Note: The standard tabular \cline also disappears inside beamer when the line color is set with the \arrayrulecolor of the colortbl package. So this is now also David Carlisle's problem :-)

Beamer class

\documentclass{beamer}
\newcommand\tfillA[3]{\makebox[#1]{#2\leaders\hrule\hfill#3}}
\newcommand\tfillB[3]{\makebox[#1]{\color{red}#2\leaders\hrule\hfill#3}}
\newcommand\tfillC[3]{\makebox[#1]{#2{\color{red}\leaders\hrule\hfill}#3}}
\newcommand\tfillD[3]{\makebox[#1]{#2{\color{red}\leaders\hrule\hfill\kern0pt}#3}}%<--Edit

\begin{document}
\begin{frame}
    INSIDE BEAMER CLASS\par\smallskip
    \tfillA{2cm}{A}{B}: Works fine without colour\par
    \tfillB{2cm}{A}{B}: Works fine with ungrouped colour\par
    \tfillC{2cm}{A}{B}: Rule disappears with grouped colour\par
    \tfillD{2cm}{A}{B}: Rule reappears with kern at end ?????
\end{frame}
\end{document}

enter image description here

Article class

\documentclass{article}
\usepackage{xcolor}
\newcommand\tfillA[3]{\makebox[#1]{#2\leaders\hrule\hfill#3}}
\newcommand\tfillB[3]{\makebox[#1]{\color{red}#2\leaders\hrule\hfill#3}}
\newcommand\tfillC[3]{\makebox[#1]{#2{\color{red}\leaders\hrule\hfill}#3}}

\begin{document}
    INSIDE ARTICLE CLASS\par\smallskip
    \tfillA{2cm}{A}{B}: Works fine without colour\par
    \tfillB{2cm}{A}{B}: Works fine with colour  everywhere\par
    \tfillC{2cm}{A}{B}: Works fine with grouped colour
\end{document}

enter image description here

share|improve this question
3  
this also works: \makebox[#1]{#2{\color{red}\hrulefill}#3} I suppose a problem with \leaders –  Herbert Feb 20 '13 at 15:05
1  
@Herbert: The problem is that the \cmidrule in booktabs (and the standard \cline) uses \leaders internally. The colortbl package has the same problem inside beamer –  Danie Els Feb 20 '13 at 15:14
    
the definition of \hrulefill also uses the \kern\z@. I have no idea why it is important for beamer. –  Herbert Feb 20 '13 at 15:22
    
\null also works. –  bloodworks Feb 20 '13 at 15:29
    
a \kern after \leaders is usually to protect it from \unskip As for the note I might look but colortbl documentation says not to use \cline so any behaviour is user error. –  David Carlisle Feb 20 '13 at 21:10
show 1 more comment

1 Answer

up vote 16 down vote accepted

Beamer, for whatever reason, redefines the latex color command \reset@color to do an unskip. That normally removes preceding white space, which you can save and restore with \lastskip but unfortunately \lastkip and \unskip "work" with \leaders but \lastskip only saves the glue component and so no record that there are leaders there is possible in classic tex (or etex).

All LaTeX \leader commands have a trailing \kern or box to prevent this, otherwise several standard commands including \newline which similarly do an \unskip would destroy \dotfill etc. (The LaTeX definition of \dotfill adds this, the original plain TeX one does not have it).

So while it is a bit surprising that Beamer does this, it is generally the case that a leaders followed by unknown commands ought to have the \kern there. \reset@color is inserted by \aftergroup at the closing } which is why the problem only affects the version that closes the group immediately after the leader. One could argue (not unreasonably) that \reset@color should not be an "unknown" command. Obviously it would be easy to patch it not to do that but without knowing the details of beamers workings and why it was changed, that may not be the best thing to do.

share|improve this answer
    
It looks then if a trailing \kern\z@ to protects against unskips is the best option to safeguard the code. It also works for colortbl if you add it to \@cline. –  Danie Els Feb 21 '13 at 1:17
1  
See this answer of mine for an explanation of why beamer does this. In short, the overlay commands add \pdfliterals that would influence \lastskip without the \unskip business. So the \kern\z@ after the leader seems to be the way to go. (Ping, @Danie.) –  Hendrik Vogt Feb 21 '13 at 11:51
    
Is there already a solution for this, with a patch or so? –  cacamailg Apr 9 '13 at 13:30
    
@cacamailg as discussed there isn't a patch required you just need to define your command so that the leaders is followed by \kern0pt or \mbox{} or anything else that will protect it from \unskip –  David Carlisle Apr 9 '13 at 13:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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