7

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}

1 Answer 1

11

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

enter image description here

Does that help?

1
  • 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?
    – StrongBad
    Commented Jan 26, 2012 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .