Page LayoutDouble Rule in Header

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
niner
Posts: 7
Joined: Thu Aug 04, 2011 2:10 am

Double Rule in Header

Post by niner »

Hi, I use package 'fancyhdr' and I noticed that I can add a headrule in the header section. I learned that I can change the thickness of the line, and from fnacyhdr manual, I can change the \headrule from solid line to a dotted line. However, I don't understand the command used in the above change. Now I want to have the \headrule like this.
=========================================
two-line style, solid line, the above one is thicker than the bottom one, with 1pt vertical space in between.

Is this possible to achieve? How to change the \headrule for this purpose?

I've looked up in Internet but I can't find a solution. Please help me. Any comment is appreciated. Thank you.
Last edited by niner on Fri Aug 12, 2011 2:55 am, edited 1 time in total.
Niner@Taiwan

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Double Rule in Header

Post by localghost »

You have to dig in the code of the fancyhdr package and pick up the relevant part for the definition of the rule.

Code: Select all

\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{fancyhdr}
\usepackage{blindtext}

\makeatletter
\def\headrule{{%
  \if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
  \hrule\@height\headrulewidth\@width\headwidth\vskip2pt%
  \hrule\@height\headrulewidth\@width\headwidth\vskip-\headrulewidth\vskip-4pt
}}
\makeatother
\pagestyle{fancy}

\begin{document}
  \blinddocument
\end{document}
The blindtext package is only for creating dummy text. It is not part of the solution.


Best regards and welcome to the board
Thorsten
niner
Posts: 7
Joined: Thu Aug 04, 2011 2:10 am

Double Rule in Header

Post by niner »

Thank you Thorsten. Your code solved my problem. I slightly modified the code to generate a double-line, different thickness header and footer. Please find below about the code I used.

Thank you again, Thorsten. :)

Code: Select all

\documentclass[11pt,english]{report}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{fancyhdr}
\usepackage{blindtext}

\makeatletter
\def\headrule{{%
  \if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
  \hrule\@height\footrulewidth\@width\headwidth\vskip1pt%
  \hrule\@height\headrulewidth\@width\headwidth\vskip-\headrulewidth\vskip-4pt
}}
%
\def\footrule{{%
  \if@fancyplain\let\footrulewidth\plainfootrulewidth\fi
  \vskip-\footruleskip\vskip-\footrulewidth
  \hrule\@height\headrulewidth\@width\headwidth\vskip1pt%
  \hrule\@height\footrulewidth\@width\headwidth\vskip\footruleskip
}}
\makeatother
\pagestyle{fancy}
%
\renewcommand{\headrulewidth}{1.5pt}
\renewcommand{\footrulewidth}{0.5pt}
%
\begin{document}
  \blinddocument
\end{document}
Niner@Taiwan
kswaibk
Posts: 1
Joined: Fri May 31, 2013 11:38 am

Double Rule in Header

Post by kswaibk »

Thanks Thorsten.

Solved my big problem that lasted for days, Mine required two head rules, the top being very thin compared to the thick one at the bottom, so this is what i used to get them into my latex fancy head. I simply added this code to my preamble.

Code: Select all

\def\headrule{{%
 \if@fancyplain\let\headrulewidth \plainheadrulewidth \fi
\hrule\@height\headrulewidth height 0.5pt\@width\headwidth\vskip2pt %
\hrule\@height\headrulewidth height 3pt \@width \headwidth\vskip-\headrulewidth\vskip-4pt %height2pt
}}
Note the addition of thickness e.g. height 3pt.
Post Reply