# Why does color cause a vertical shift?

this TeX-source

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

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

...

\end{document}


when compiled with XeLaTeX, will cause this 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:

any hints why that should be so? any fixes?

• Have you tried \textcolor{<color>}{<content>}? – azetina Jun 15 '14 at 16:55

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}
\fancyfoot[C]{\thepage}
\fancyfoot[LE,RO]{\textcolor{DarkRed}{\large\leftmark}}
\fancyfoot[LO,RE]{xxx}