1

I'm trying to get the left heading to appear at the top left corner of the header, but I cannot seem to get it moved there. How can this be achieved using fancyhdr? I tried updating

\lhead{\textbf{Citation:}}

to

\lhead{\textbf{Citation:} \vfill}

With no success (among many other unsuccessful attempts)

\documentclass{article}
\usepackage{lipsum}
\usepackage{layout}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[showframe]{geometry}


%\setlength{\hoffset}{} 
\setlength{\oddsidemargin}{0pt}
\setlength{\hoffset}{-.41in}
\setlength{\textwidth}{7.52in}
\setlength{\marginparsep}{3in}
\setlength{\headsep}{\baselineskip}
\setlength{\headheight}{1in}
\setlength{\topmargin}{0pt}
\setlength{\voffset}{-.5in}

\pagestyle{fancy}

%HEADING TO SHIFT TO TOP
\lhead{\textbf{Citation:}}
\rhead{Page \thepage of \pageref{LastPage}}

\begin{document}
    \lipsum[1-2]
\end{document}

enter image description here

Thanks!

3
  • Instead of setting the page geometry using \setlength, you should use the functionality provided by geometry. Then, if you wish to raise content into place, use \raisebox{<len>}[0pt][0pt]{<stuff>}.
    – Werner
    Feb 28, 2018 at 5:24
  • @Werner, \raisebox will mostlikely solve my issue. Why is it inadvisable to use \setlength to modify the doc?
    – DJK
    Feb 28, 2018 at 5:49
  • That functionality is provided by geometry, so if you're loading geometry, use it.
    – Werner
    Feb 28, 2018 at 5:54

2 Answers 2

4

A simple \parbox, specifying it height, will do the job. Since you load the package, I converted your layout specifications to geometry as well as I could (the horizontal parameters are inconsistent: are you sure you want a \marginparsepof 3 inches?):

\documentclass{article}
\usepackage{lipsum}
\usepackage{layout}
\usepackage{fancyhdr}
\usepackage{lastpage}

\usepackage[headheight = 1in, headsep = \baselineskip, top = 1.5in, , left = 0.59in, textwidth = 7.52 in, showframe]{geometry}
\pagestyle{fancy}

%HEADING TO SHIFT TO TOP
\lhead{ \parbox[][\headheight][t]{2cm}{\textbf{Citation:}}}
\rhead{\parbox[][\headheight][b]{2cm}{\raggedleft Page\,\thepage{} of \pageref{LastPage}}}

\begin{document}

    \lipsum

\end{document} 

enter image description here

4
  • \vtop to \dimexpr \headheight-\baselineskip\relax {...} also works. Feb 28, 2018 at 17:25
  • Sure, but that's a plain TeX construction.
    – Bernard
    Feb 28, 2018 at 18:37
  • This also shifts the Page counter up, on the right header. I need that value positioned at the bottom. Also, just out of curiosity, is there any advantage to using \parbox vs raisebox?
    – DJK
    Feb 28, 2018 at 20:13
  • @DJK: I've updated the code. Another \parbox[}[\headheight][b] was enough. As to your question, with \raisebox, you have to calculate by how much you raise, which depends on what you raise (fontsize, multiline or not, &c.)
    – Bernard
    Feb 28, 2018 at 20:57
1

Since you want to leave the baseline in place, use \raisebox.

Note, if you add too much space, fancyhdr will increase \headheight, possibly every page.

\documentclass{article}
\usepackage{lipsum}
\usepackage{layout}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage[showframe]{geometry}


%\setlength{\hoffset}{} 
\setlength{\oddsidemargin}{0pt}
\setlength{\hoffset}{-.41in}
\setlength{\textwidth}{7.52in}
\setlength{\marginparsep}{3in}
\setlength{\headsep}{\normalbaselineskip}% \baselineskip changes depending on the font size
\setlength{\headheight}{1in}
\setlength{\topmargin}{0pt}
\setlength{\voffset}{-.5in}

\pagestyle{fancy}

%HEADING TO SHIFT TO TOP
\lhead{\raisebox{\dimexpr \headheight-\baselineskip}{\textbf{Citation:}}}
\rhead{Page \thepage~of \pageref{LastPage}}

\begin{document}
    \lipsum[1-2]
\end{document}
3
  • Thanks for the answer! I may have not made this clear sorry, but I need only the left header shifted to the top of the header, This moves the rule and page numbering to the top as well
    – DJK
    Feb 28, 2018 at 5:05
  • Done. I was actually try to avoid \raisebox as too obvious. Feb 28, 2018 at 17:27
  • Ha, I guess you have much to learn about a language when something is too obvious
    – DJK
    Feb 28, 2018 at 20:14

You must log in to answer this question.

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