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}
  • 2
    Use \usepackage{showframe} and you could see how wrong are your margins setup. Use geometry to setup margins. – Sigur May 14 '15 at 8:43
  • @Sigur the geometry package was exactly what I needed, thank you so much! – a cast May 14 '15 at 8:54
  • @a cast, Welcome! Use the search filed here on TEX.SE. There are many good examples. – Sigur May 14 '15 at 8:57
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.