0

Im writing a report (in LaTeX) for which a made a header using fancyhdr.

The text in my header is suppose to be black and the line is colored. However at some pages my headertext is colored as well, on pages that start with a section, but not all pages which start with a section have this issue.

Maybe I should also mention that my section titles are colored as well (also green) using sectsty.

I cant seem to find a fix, below is the code, can somebody help me please?

\documentclass[12pt]{article}
\usepackage{lipsum} 
\usepackage{fancyhdr}
\usepackage{xpatch}
\usepackage{sectsty}
\usepackage[dvipsnames]{xcolor}
%
\definecolor{ggreen}{RGB}{114, 183, 1}
%
\pagestyle{fancy}
    \rhead{Title}
    \lhead{}
    \renewcommand{\headrulewidth}{0.5pt}
    \xpretocmd\headrule{\color{ggreen}}{}{\PatchFailed}
%
    \sectionfont{\color{ggreen}\selectfont}
    \subsectionfont{\color{ggreen}\selectfont}
%
\begin{document} 
\section{title} 
\lipsum 
\end{document}
  • 4
    Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – user36296 Mar 8 at 13:26
  • Off topic: IMHO green is a bit too bright to be read in a white page. I think green!50!black or green!60!black is more okay. – The old JouleV Mar 8 at 13:29
  • 2
    To echo what @samcarter says, I can take the time to add a document around your preamble material, and am still unable to recreate your result. This means that there is more to the problem than what you have provided. This is why providing a fully working MWE is essential. – Steven B. Segletes Mar 8 at 13:42
  • 1
    @10tje Thanks for adding some code. If I add \usepackage{lipsum} \begin{document} \section{title} \lipsum \end{document} after your code fragment to get a compilable document, I don't get any coloured text. Please show us some code that allows us to reproduce the problem. – user36296 Mar 8 at 13:42
  • 1
    Your MWE produces no color in the header text. – Steven B. Segletes Mar 8 at 14:02
0

By using \rhead{\textcolor{black}{TITLE}} instead of \rhead{TITLE} the problem is solved. This however probably just overrides the underlying problem, BUT it works.

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.