## XeLaTeX: change font for headers and footers

I’ve noticed that headers and footers of the documents, generated by XeLaTeX, use some other font instead of Helvetica. After digging into the LaTeX code, the problem is solved.

Finding 1: the LaTeX’s output procedure uses \reset@font.

Finding 2: this command defined in latex.ltx as:

``\let\reset@font\normalfont``

Idea 1: So, I should re-define \normalfont to switch to the desired font (\switchtomainfont is a command defined through the XeLaTeX-specific command \newfontface):

``\let\normalfont\switchtomainfont``

But it didn’t help. It looked like the command was not called at all.

Finding 4: actually, in runtime \reset@font is defined as:

``\protect\normalfont``

But it should make no difference.

Finding 5: activating macrotracing, I found that my \normalfont was expanded as:

``````
\reset@font ->\protect \normalfont
\normalfont  ->\usefont \encodingdefault \familydef
ault \seriesdefault \shapedefault \relax
``````

What? Why this expansion instead of what expected?

Finding 6: \reset@font uses not “\normalfont” but “\normalfont “. Command name includes the space at the end!

Solution:

``````
\let\normalfont\switchtomainfont
\expandafter\let\csname normalfont \endcsname\switchtomainfont
``````

Hint: maybe use of \setromanfont would fix my problem before it appears, but I can’t make this command working on my Linux system. But as far as I remember, it worked under Mac.

### 2 Responses to “XeLaTeX: change font for headers and footers”

1. Enrico Gregorio Says:

The definition of \normalfont is through \DeclareRobustCommand, which actually defines two commands: \normalfont and \normalfont~ (with a space at the end, I’ll use the ~ in order to show it). And the definition of “\normalfont” is “\protect\normalfont~”.

I don’t know about \switchtomainfont, but I guess that definining it with \DeclareRobustCommand will avoid the ugly mess.

2. Oleg Says:

Thanks for the suggestion, I’ll try it next time I have this problem!