When answering this question: Using fancyhdr to create an image based header and footer
I needed to get the distance from the left edge of the paper to the beginning of \textwidth
and the distance from the end of \textwidth
to the right edge of the paper. For the distance from the left edge I used \oddsidemargin + \hoffset + 1in
to adjust \headwidth
via \fancyhfoffset
and it put the start of the header on the left edge of the paper. For the distance from the right edge, I thought it was \evensidemargin + \marginparwidth + \marginparsep
, but this resulted in the header overshooting the right edge of the page. It appears the correct distance is \evensidemargin + \marginparwidth - \marginparsep
.
I think I am missing something about how \marginparsep
(or some other page "margin") works.
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{calc}
\fancypagestyle{plain}{%
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhf{}
\fancyhead[L]{\hrulefill{}}%
\fancyhead[R]{\hrulefill{}}%
\fancyfoot[L]{\hrulefill{}}%
\fancyfoot[R]{\thepage}%
}
\fancyhfoffset[L]{\oddsidemargin + \hoffset + 1in}
\fancyhfoffset[R]{\evensidemargin + \marginparwidth - \marginparsep}
\pagestyle{plain}
\begin{document}
First page
\clearpage
Second page
\end{document}