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.

I am using the fancyhdr package and I want to have a thicker line under my header and I want to have it colored, but my problem is, that this 2 commands:

\renewcommand{\headrule}{\vbox to 0pt{\hbox

Do not work together? So how can I get a more thicker line which is also colored?

Here is the complete code:


\geometry{left=4cm,right=3cm, top=2cm, bottom=2cm} 

\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}







\fancyhead[L]{ \textcolor{headercolor}\leftmark \text{ }\textcolor{headercolor}{\thesection}}
%\renewcommand{\headrule}{\vbox to 0pt{\hbox
 test test\\ test test    

share|improve this question
Don't sent "complete code" which includes files we don't have. Sent a small example that we can compile and so use for tests. Also use fancyhdr instead of fancyheadings which is obsolete. –  Ulrike Fischer Sep 3 '12 at 15:05
I now merged your two accounts together. You should be able to edit your question again and comment to answers to it. Please consider registering an account to avoid this hassle in the future. Or, at least, try to keep one unregistered account (Cookies enabled?). –  Martin Scharrer Sep 3 '12 at 17:19
add comment

1 Answer 1

You need to incorporate \headrulewidth inside your redefinition of \headrule, since \hrulefill uses a different width rule:

\renewcommand{\headrulewidth}{2pt}% 2pt header rule
\renewcommand{\headrule}{\hbox to\headwidth{%
  \color{headercolor}\leaders\hrule height \headrulewidth\hfill}}

Here's an informal MWE that uses the above technique to construct the page style myheader:

enter image description here

\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{fancyhdr}% http://ctan.org/pkg/fancyhdr
  \fancyhf{}% Clear all headers/footers
  \fancyhead[C]{My header}% Header Centred
  \fancyfoot[C]{-\thepage-}% Footer Centred
  \renewcommand{\headrulewidth}{2pt}% 2pt header rule
  \renewcommand{\headrule}{\hbox to\headwidth{%
    \color{red}\leaders\hrule height \headrulewidth\hfill}}
  \renewcommand{\footrulewidth}{0pt}% No footer rule
share|improve this answer
add comment

Your Answer


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.