4

I'm trying to align my header to the right side but it is not going all the way to the right.

enter image description here

Here is a minimal example (I'm including my margins in case that is part of the problem? I honestly have no idea):

\documentclass[11pt]{article}

\usepackage{blindtext}
\usepackage{nopageno}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{header}
\renewcommand{\headrulewidth}{0pt}

\textwidth=7in
\textheight=9.5in
\topmargin = -.25 in
\hoffset=-1in
\voffset=-0.5in
\parskip = 0.1in
\parindent = 0.0in

\begin{document}

\blindtext

\end{document}
3
  • 2
    Use \usepackage{showframe} and you could see how wrong are your margins setup. Use geometry to setup margins.
    – Sigur
    Commented May 14, 2015 at 8:43
  • @Sigur the geometry package was exactly what I needed, thank you so much!
    – a cast
    Commented May 14, 2015 at 8:54
  • @a cast, Welcome! Use the search filed here on TEX.SE. There are many good examples.
    – Sigur
    Commented May 14, 2015 at 8:57

2 Answers 2

5

You should set \pagestyle{fancy} after having set the page parameters, because fancyhdr uses the current text width for preparing its headers and footers.

I recommend using geometry, though: probably

\usepackage[textwidth=7in,textheight=9.5in]{geometry}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{header}
\renewcommand{\headrulewidth}{0pt}

is sufficient for your needs.

Above all, never set \hoffset and \voffset: they are thought for making corrections in case the output driver needs them.

0

This often happens (at least on my side) when you set a different page geometry for the title page.

If, you set pagestyle{fancy} and all the header specifications already in the preamble, then the your header specification are for the default geometry. If you change your page geometry afterwards, all the header settings will be skewed. Therefore, I recommend a specifing in a newcommand and calling it when your page properties are set and done.

You must log in to answer this question.

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