Is there any way to create a (multiline!) header on odd pages and no header at all on even pages?
It should look like this:
My code so far:
\documentclass[a4paper, twoside, 12pt]{article} \usepackage[utf8]{inputenc} \usepackage[a4paper, includeheadfoot, left=2cm, top=2cm, right=2cm, bottom=2cm]{geometry} \usepackage{fancyhdr} \usepackage{etoolbox} \usepackage{ifthen} \usepackage{showframe} \fancyhead{} \fancyhead[ol]{COURSE} \fancyhead[or]{ \begin{tabular}{ c c } NAME & NO \\ NAME1 & xxx \\ NAME2 & yyy \\ \end{tabular} } \begin{document} ... \end{document}
My issues:
(1) Fancyhdr warning: \headheight is too small.
The first page is messed up because the \headheight is by default 12pt but should be 44pt in this case. Is there any way to calculate this automatically? I would like to avoid typing "44pt" manually.
(2) Even pages leave empty space for headers and include a horizontal rule.
Even though the header on even pages is empty, the space is not available for the text. I would like to start the text immediately after the 2cm margin so that no trace of the header is left on even pages.
I've been looking for a solution to this simple problem for hours now and any help would be appreciated!
EDIT: I don't care about the footer, it would be nice to have the option to include or disable page numbers as well.
Best Answer
Since you have to define the
\headheight
at the begining of the code within geometry package irredeemably, this will stablish that same height for the header throughout the document.To change that, you can define a
\newgeometry
with the\headheight
equal to0pt
at the begining of even pages, but you have to redefine your previous geometry in the next page again. This is a manual procedure, but I don't know another way to do that.Here I post you some code. As you can see, I have defined two styles with
\fancypagestyle
, one for even pages and another one for de odd ones. If you want to disable the numbering of the pages, just remove the\fancyfoot
and\renewcommand\footrulewidth
lines inside each style.I don't know any way to avoid calculate this manually. Just compile your document and wait for the log message referring to the
\headheight
and set that lenght as minimum.