Sign up ×
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.

Using mweclass LaTeX class (report based) is writing a document as follows:

\author{J. Doe}
  % LaTeX code ...

In the header there must be a headrule on each page at a fixed offset in height.

But... when there are any g, q, p etc. letters in the text above (chapter or section names) the headrule is distanced correctly. Otherwise, the headrule is "attaching" to the text.

In a mweclass.cls I have this code for the mwetest pagestyle:

  \setlength\fancy@headwidth       {\mwe@textwidth}%
  \renewcommand\headrulewidth      {\mwe@headrulewidth}%
  \renewcommand\footrulewidth      {0pt}%
  \renewcommand\footruleskip       {0pt}%
  \def\f@ncyorh{\rightmark~\ \ \ \ \ ~\thepage}%
  \def\f@ncyelh{\thepage~\ \ \ \ \ ~\leftmark}%
  \def\chaptermark##1{\markboth{##1\ -- \ \thechapter}{}}%
  \def\sectionmark##1{\markright{\thechapter.\arabic{section}\ --\ ##1}}%

Some code is taken from distributed fancyhdr.sty, version 3.2, lines 432-435. The \mwe@textwidth and \mwe@headrulewidth are calculated OK by the mweclass class before.

The problem is probably something to do with the baseline in letters. The headrule keeps attaching/detaching from the chapter / section names above, whether the text contains letters whose shape in the font prolongs below the baseline; or not.

  1. Is there a way to insert invisible (that are not typeset) letters in a text? If there were, an easy workaround is to put a q in chapter and section names.
  2. What is wrong? Except this mobile headrule, the header is but OK.

I appreciate any reply or suggestions.

share|improve this question
How much experience do you have in writing new document classes? When you use some pieces of code from fancyhdr, why don't you simply include the package? It solves your problem. – yo' Mar 21 '12 at 19:44
Welcome to TeX.SE. We consider the questions a "wiki" material and therefore we don't include "Thanks" in the questions. You can thank the answers by up-voting them and accepting the one you find best. – yo' Mar 21 '12 at 19:50
Sorry I am a day late answering. Indeed you puzzled me: "When you use some ... package?" I mean, what if macros change names? Though fancyhdr is basic. I write document classes but I don't know \strut? I use LaTeX, and I haven't seen \phantom? Yet, I manage to put \protect there? Once I decided to switch from googling to parsing code directly, I gained more trust. I really liked how fancyhdr did the @odd/@even, so instead of many howtos, I dropped in. What cannot change my using TeX is that I can calculate page lengths, and have a clear text language for it; like breathing air. – sjb Mar 22 '12 at 19:40
Hey! It wasn't meant as any offense, and if you felt like that, I apologize. I asked for your experience because serious breaking in some advanced packages like fancyhdr needs extended experience with writing your own low-level macros, because it helps you a lot understand what's going on in the package. Unless I needed some really really complicated tweaking, I always included the package and tweaked it afterwards. – yo' Mar 23 '12 at 9:45

2 Answers 2

up vote 3 down vote accepted

You can put \strut command: it inserts a piece of nothing of the \height and \depth as large as the largest letters in current font, but having no \width.

share|improve this answer
Ok, it works like this: \def\chaptermark##1{\markboth{##1\strut\ -- \ \thechapter}{}} \def\sectionmark##1{\markright{\thechapter.\arabic{section}\ --\ ##1\strut}} – sjb Mar 21 '12 at 20:55

Invisible characters are made with \phantom{txt}, \hphantom{txt} or \vphantom{txt}. The first takes width and height, the second width only and the third height only into account.

share|improve this answer
Ok, it works like \chapter{Name\protect\vphantom{p}}. – sjb Mar 21 '12 at 20:59

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.