After stripping away hundreds of line of code to reach this MWE, I found that my "A «box» was supposed to be here" seemed to be caused by a \renewcommand{\headrule} in conjunction with fancyhdr.

Moreover, the error goes away if I delete \leaders from the \box specification.

This redefinition was something that I cobbled together at some point, undoubtedly inspired by examples I didn't fully understand.

I'd appreciate insight into why I'm getting this error and how to rewrite it to squash that error.

        \hbox to\headwidth{\leaders\rule[5pt]{\headwidth}{0.4pt}\hfill}%
%       \hbox to\headwidth{\rule[5pt]{\headwidth}{0.4pt}\hfill}%
Hello, world.

P.S., the error message isn't really "«box»" but rather the « and » should be replaced with less-than and greater-than signs. Those were rejected when I entered them here.

  • What do you want to achieve? That would be a better question. A header rule? A special header rule? Please enlighten us.
    – Werner
    Commented Nov 3, 2018 at 3:04
  • @Werner, I currently have, and like: a headrule and a footrule, each spanning exactly the width of the text. I use the optional argument of \rule to fine-tune the vertical position of each rule. I also set a color for these rules (though I removed that from the MWE because it wasn't causing trouble). Commented Nov 3, 2018 at 3:13

1 Answer 1


Note that the rule is set in vertical mode and that's where you're running into problems with your \hbox to \headwidth (which is similar to \makebox[\headwidth]) approach.

This is what fancyhdr's \headrule looks like (using \show\headrule):


Apart from the condition an \hrule is inserted and the rule thickness is underdone (vertically). I would just replicate the behaviour using something like

  \vskip -5pt % Move head rule up by 5pt
  \hrule \@height 0.4pt \@width \headwidth % Place head rule
  \vskip \dimexpr-0.4pt + 5pt\relax % Remove space inserted by raise and rule
  • That does the trick! I shouldn't have left my \color{blue} out of my MWE. I'm not sure where to put that in the context of your solution? Commented Nov 3, 2018 at 6:06
  • 1
    @JimRatliff: Try this code. The group doesn't seem to be necessary here, but it's always good to limit the scope of something that might have a broader impact (like \color, here).
    – Werner
    Commented Nov 3, 2018 at 6:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .