3

I'm trying to use fancyhdr to make a multiple line header with the following format:

Left Header     Center Header
--------------------------------------------
                                 Right Header
                      ----------------------

Where the --- represent a horizontal line.

Basically I would like the left header to be a line under the other two, plus a separating line between both headers.

Is there a way to do so using redefining the headrule command?

5
  • Welcome! Please post a small, complete document illustrating the problem you are having implementing this. At the same time, please clarify your question. Do you really want the left header to be repeated below right?
    – cfr
    Nov 24, 2015 at 3:33
  • What content should be placed in the Left Header, Center Header and Right Header, respectively?
    – Werner
    Nov 24, 2015 at 3:39
  • @Werner There should be an Image on Left Header, some text on Center Header and section name on Right Header, still my problem is with the middle horizontal line and the right justified horizontal end line
    – PeCosta
    Nov 24, 2015 at 3:43
  • @cfr No, it was a mistake, I meant Right Header
    – PeCosta
    Nov 24, 2015 at 3:45
  • Please provide some code. Not only does it make it easier to answer, it also makes it much less likely that the answer won't actually work for you.
    – cfr
    Nov 24, 2015 at 3:49

1 Answer 1

4

There's a lot you can do in the headers. I've set the Left Header as-is, while the Center Header and Right Header is set using a tabular of fixed width. The advantage of using a tabular is that you can use its \hlines for rules:

enter image description here

\documentclass{article}

\usepackage{fancyhdr,lipsum}

\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\fancyhead[L]{Left Header}
\fancyhead[C]{\begin{tabular}[t]{@{}p{\textwidth}@{}}
  \hfill Center Header \hfill \strut \\
  \hline
\end{tabular}}
\fancyhead[R]{\begin{tabular}[t]{@{}p{.5\textwidth}@{}}
  \strut \\
  \strut \hfill \leftmark \\
  \hline
\end{tabular}}
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{25pt}

\begin{document}

\section{First section}
\lipsum[1-10]

\end{document}

Horizontal alignment is achieved using appropriately-placed\hfills, while vertical alignment is achived by the insertion of \struts.

The \headheight adjustment depends on the contents. In my case fancyhdr suggested to it to be at least 24.4pt, so I set it to 25pt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .