TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


    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 ?????

enter image description here

Article class


    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

enter image description here

share|improve this question
this also works: \makebox[#1]{#2{\color{red}\hrulefill}#3} I suppose a problem with \leaders – Herbert Feb 20 '13 at 15:05
@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
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
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

Your Answer


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.