I'm trying to make a header on every page with text above and below the header rule, so that it looks something like this:

                                  header text above line
                                  header text below line

[body of page]

Is this possible with fancyhdr? Or is there another way to do this?

I realize this may not be aesthetically pleasing, but I'm trying to emulate another document (not made with LaTeX).


Try this, with fancyhdr:

\fancyhead[RE,RO]{text above\\\hrulefill\\text below}

If desired, switch left and right. You will need to play with the headheight and the line skips in the header, and related dimensions.

  • This almost works. I end up with two horizontal lines, but I can remove the default one with \renewcommand{\headrulewidth}{0pt}, and then I get the desired result. Thanks! – Eric Sep 18 '16 at 22:29
  • Right! You need to remove the default line. When I use fancyhdr, I start by zeroing or emptying everything and building up from there. – user103221 Sep 18 '16 at 23:12

You can set one header item using a tabular with a single paragraph column that is the width of \textwidth:

enter image description here



\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0pt}% Remove header rule
  \begin{tabular}{ @{} p{\textwidth} @{} }
    \hfill Header text above line \\
    \hfill Header text below line
\setlength{\headheight}{24.4pt}% Should be at least 24.4pt




Here is a solution with titleps, a tabular environment and booktabs:

\documentclass[12pt,twoside, a4paper]{article}
\usepackage{array, booktabs, graphicx}
\sethead[][\begin{tabular}{@{}>{\raggedright\small\arraybackslash}p{\textwidth}@{}}header text above line\\\midrule header text below line\end{tabular}][]%
{}{\begin{tabular}{@{}>{\raggedleft\small\arraybackslash}p{\textwidth}@{}}header text above line\\\midrule header text below line\end{tabular}}{}




enter image description here

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.