1

I'm trying to place my page numbers on the left on even pages and on the right on odd ones. As far as I understand the following code should do exactly this, but my page numbers are all on the right side.

\documentclass[11pt]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\thepage}
\fancyhead[OR]{\thepage}

\begin{document}
foo
\newpage
bar
\newpage
bat
\end{document}
4

You have to choose a document class that have different left and right pages. Either use the book or report class, or add the option twoside to the article class.

Be aware that the option twoside also triggers the flushbottom setting, which means that the the page content is vertically stretched so that the lines flush at the bottom of the page. This may lead to nasty white space between paragraphs, or above sections, tabulars and figures. Therefore, consider to use the \raggedbottom command in your preamble.

If you have footnotes in your document, you will see that \raggedbottom places the footnotes in a fixed distance from the bottom of the text, which is not nice. You can avoid this by either use scrartcl (from KOMA-script) instead of \article, or load the package footmisc with the option bottom:

enter image description here

\documentclass[twoside, 11pt]{article}
\usepackage[bottom]{footmisc}               %% Treat footnotes correctly
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\thepage}
\fancyhead[OR]{\thepage}
\raggedbottom                               %% Avoid nasty vertical white space

\begin{document}
foo
\newpage
bar
\newpage
bat
\end{document}
|improve this answer|||||

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.