Using mweclass
LaTeX class (report
based) is writing a document as follows:
\documentclass{mweclass}
\title{MWE}
\author{J. Doe}
\begin{document}
\thispagestyle{mwetest}
\maketitle
\pagestyle{mwetest}
\chapter{One}
\section{First}
% LaTeX code ...
\end{document}
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:
\newcommand{\ps@mwetest}{%
\setlength\fancy@headwidth {\mwe@textwidth}%
\fancy@setoffs%
\renewcommand\headrulewidth {\mwe@headrulewidth}%
\renewcommand\footrulewidth {0pt}%
\renewcommand\footruleskip {0pt}%
\def\headrule{\hrule\@height\headrulewidth\@width\headwidth\vskip-\headrulewidth}%
\def\footrule{}%
\def\f@ncyorh{\rightmark~\ \ \ \ \ ~\thepage}%
\def\f@ncyelh{\thepage~\ \ \ \ \ ~\leftmark}%
\def\@oddhead{\@fancyhead\fancy@Oolh\@empty\hfil\f@ncyorh\fancy@Oorh}%
\def\@evenhead{\@fancyhead\fancy@Oelh\f@ncyelh\hfil\@empty\fancy@Oerh}%
\def\@oddfoot{}\def\@evenfoot{}%
\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.
- 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. - What is wrong? Except this mobile headrule, the header is but
OK
.
I appreciate any reply or suggestions.
fancyhdr
, why don't you simply include the package? It solves your problem.\strut
? I useLaTeX
, 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.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.