margins and text position

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{\footrulewidth}{0pt}
\fancyhf{}
\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}


The layout package gives you a graphical display and listing of your current layout parameters:

\documentclass[letterpaper,11pt]{article}
\usepackage[margin=1.5in]{geometry}

\usepackage{layout}

\begin{document}

\layout

\end{document}


shows

Does that help?

• It shows the problem. Is the distance between the right edge of the margin notes and the edge of the paper \evensidemargin or is it just some unnamed leftover space? Jan 26, 2012 at 17:07