[Tex/LaTex] Left and right text in header without Fancyhdr

fancyhdrheader-footer

Is there a way to write a header with left- and right-aligned text without using the package Fancyhdr?

Best Answer

I defined some macros for easier access to the headers. You have to use the twoside option of the documentclass to actually distinguish between odd and even pages (without all pages are treated as odd).

\documentclass[twoside]{article}
% Use some ridicolouosly small paper for demonstration
\usepackage[a6paper]{geometry}

\makeatletter
\newcommand\oddhead[1]{\gdef\@oddhead{\reset@font#1}}
\newcommand\evenhead[1]{\gdef\@evenhead{\reset@font#1}}
\newcommand\oddfoot[1]{\gdef\@oddfoot{\reset@font#1}}
\newcommand\evenfoot[1]{\gdef\@evenfoot{\reset@font#1}}
\makeatother

\oddhead{\hfil Some header on odd pages\hfil}
\evenhead{\hfil Some header on even pages\hfil}
\oddfoot{\hfil Some footer on odd pages\hfil}
\evenfoot{\hfil Some footer on even pages\hfil}

\begin{document}

Odd page

\clearpage

Even page

\end{document}

enter image description here

enter image description here