Take the 2-minute tour ×
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.

this TeX-source

\documentclass[a4paper,12pt]{book}
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LO,RE]{}
\fancyhead[LE,RO]{{\large{}\color{DarkRed}\rightmark}}
\fancyfoot[C]{\thepage}
\fancyfoot[LE,RO]{\color{DarkRed}\large{}\leftmark}
\fancyfoot[LO,RE]{xxx}
\renewcommand{\headrulewidth}{0.14mm}
\renewcommand{\footrulewidth}{0.14mm}
\setlength\headheight{6mm}

\begin{document}
\markboth{A}{B}

Yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda
yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda yadda
...

\end{document}

when compiled with XeLaTeX, will cause this output:

output

as you can see, the red A is not properly aligned with the rest of the footer. naturally i first assumed that was because of the font size, but, surprisingly, changing

\fancyfoot[LE,RO]{\color{DarkRed}\large{}\leftmark}

to

\fancyfoot[LE,RO]{\large{}\leftmark}

gives me not only (naturally) a black A, but also a properly aligned one:

output

any hints why that should be so? any fixes?

share|improve this question
    
Have you tried \textcolor{<color>}{<content>}? –  azetina Jun 15 at 16:55

1 Answer 1

up vote 8 down vote accepted

Package fancyhdr puts the elements of the footer into a \parbox[t]. At the beginning You are using \color{...}. It does not start a new paragraph, thus the first top element of the \parbox[t] is the color whatsit (\special). It is aligned with the base line of the other entries. A then goes below the color whatsit.

Solution: The color whatsit should go into the first line of the new paragraph of the marks contents, e.g.:

\leavevmode\color{...}...

Or simpler: \textcolor automatically adds \leavevmode. Also it puts a group around the text argument, thus \large can go there. Also \large does not have an argument, thus {} after \large serves no purpose.

\documentclass[12pt]{book}
\usepackage[a6paper,landscape]{geometry}% smaller image for TeX.SX
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LO,RE]{}
\fancyhead[LE,RO]{\textcolor{DarkRed}{\large\rightmark}}
\fancyfoot[C]{\thepage}
\fancyfoot[LE,RO]{\textcolor{DarkRed}{\large\leftmark}}
\fancyfoot[LO,RE]{xxx}
\renewcommand{\headrulewidth}{0.14mm}
\renewcommand{\footrulewidth}{0.14mm}
\setlength\headheight{6mm}

\begin{document}
\markboth{A}{B}

\lipsum[1-4]

\end{document}

Result

share|improve this answer
    
I will delete my answer in a few. Yours is more elaborate. I just offered a fix without the explanation requested. –  azetina Jun 15 at 17:12
    
thanks for this very detailed explanation + the fix! –  flow Jun 15 at 17:23

Your Answer

 
discard

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.