[Tex/LaTex] Page number and name in the header of each page

header-footerpage-numbering

How do you enter a page number on the right-hand side of each page?

Also, is there a command so that "My name" is on the top left corner of each page except the first page?

And maybe put a bar below the two above items?

I am using document class resume.

 \documentclass[margin,line]{resume}

 \begin{document}
 \name{\Large My name} 
 \begin{resume}

 This is page 1. 

 \newpage 


 This is page 2. 

 \newpage 

 This is page 3.   

 \end{resume}
 \end{document} 

Thank you.

Best Answer

fancyhdr works with resume (which is based on article), but some adjustments are necessary:

\documentclass[margin,line]{resume}

\usepackage{kantlipsum} % to provide mock text

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\makeatletter
\fancyhead[L]{\textbf{\expandafter\@gobble\@name}}
\makeatother
\fancyhead[R]{\thepage}
\fancyheadoffset[L]{\sectionwidth}
\setlength\headheight{12pt}
\setlength\headsep{3pt}
\addtolength\topmargin{-15pt}
\AtBeginDocument{\thispagestyle{empty}}


\begin{document}

\name{\Large My name}

\begin{resume}

\kant

\end{resume}

\end{document}

Comment out the \fancyheadoffset line if you don't want that the line on the pages following page 1 are extended on the left. If you want to increase the separation between the rule and the text, modify the value of \headsep and also the value of \topmargin.

enter image description here

Note. The mysterious \expandafter\@gobble\@name is needed because \@name expands to \Large My Name, after \name{My Name}, so we have to remove the unwanted \Large command.