10

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?

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

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

  • I will delete my answer in a few. Yours is more elaborate. I just offered a fix without the explanation requested. – azetina Jun 15 '14 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.