[Tex/LaTex] Can’t get the page numbers to show up

geometryheader-footer

I'm using this so far:

\documentclass[paper=a4,fontsize=11pt]{temp} % KOMA-article class                           
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{xfrac}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{multirow}
\pagenumbering{arabic}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\thepage}

Then the temp file is something I got from overleaf, and it goes like this:

\ProvidesClass{temp}[2016/02/01 CV]
\NeedsTeXFormat{LaTeX2e}
\DeclareOption{print}{\def\@cv@print{}}
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{scrartcl}
}
\ProcessOptions\relax
\LoadClass{scrartcl}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[default,scale=0.95]{opensans}
\usepackage[T1]{fontenc}

\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{amsmath,amsfonts,amsthm}    
\usepackage[pdftex]{graphicx}
\usepackage{wrapfig}
\usepackage[hmargin=1.25cm, vmargin=0.7cm]{geometry}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{sidecap}
\usepackage{geometry}
\usepackage{url}
\usepackage{float}

\frenchspacing              % Better looking spacings after periods
\pagestyle{empty}           % No pagenumbers/headers/footers

% Color definitions
\definecolor{date}{HTML}{666666} 
\definecolor{primary}{HTML}{191919} 
\definecolor{headings}{HTML}{025178}
\definecolor{subheadings}{HTML}{002648}


%%% Custom sectioning (sectsty package)
%%% ------------------------------------------------------------
\usepackage{sectsty}

\sectionfont{\usefont{OT1}{phv}{b}{n}\sectionrule{0pt}{0pt}{-5pt}{3pt}}
\subsectionfont{\color{headings}\usefont{OT1}{phv}{b}{n}}
\subsubsectionfont{\sectionrule{0pt}{0pt}{-5pt}{3pt}}
%%% Macros
%%% ------------------------------------------------------------
\newlength{\spacebox}
\settowidth{\spacebox}{8888888888}          % Box to align text
\newcommand{\sepspace}{\vspace*{1em}}       % Vertical space macro

\newcommand{\MyName}[1]{ % Name 
         \huge \usefont{OT1}{phv}{b}{n} \hfill \textcolor{headings}{#1}
        \par \normalsize \normalfont}


\newcommand{\NewPart}[1]{\section*{ \color{headings} \uppercase{#1}}}

\newcommand{\NewSubPart}[1]{\subsection*{\color{subheadings} \uppercase{#1}}}

\newcommand{\PersonalEntry}[2]{
        \noindent\hangindent=2em\hangafter=0 % Indentation
        \parbox{\spacebox}{        % Box to align text
        \textit{#1}}               % Entry name (birth, address, etc.)
        \hspace{1.5em} #2 \par}    % Entry value

\newcommand{\SkillsEntry}[2]{      % Same as \PersonalEntry
        \noindent\hangindent=2em\hangafter=0 % Indentation
        \parbox{\spacebox}{        % Box to align text
        \textit{#1}}               % Entry name (birth, address, etc.)
        \hspace{1.5em} #2 \par}    % Entry value    


\newcommand{\workEntry}[5]{          
        \begin{minipage}{0.08\linewidth}
        \includegraphics[width=1.2cm] {#5}
        \end{minipage}%                 
        \begin{minipage}{0.84\linewidth}  
        \noindent {\color{subheadings}\bfseries\uppercase {#1}}, {\color{subheadings}\textit{#3}}  
        \hfill  {\color{headings}\fontsize{10pt}{12pt}#2}   
        \par    
        \noindent\hangindent=2em\hangafter=0 \small #4 % Description
        \normalsize \par         
        \end{minipage}         
}

\newcommand{\TechEntry}[4]{     
        \begin{minipage}{0.08\linewidth}
            \includegraphics[height=18pt]{#4}
        \end{minipage}%                    
        \begin{minipage}{0.84\linewidth}  
        \noindent {\color{subheadings}\bfseries\uppercase {#1}} 
        \par    
        \noindent {\color{subheadings}\textit{#2}} \par 
        \noindent\hangindent=2em\hangafter=0 \small #3 % Description
        \normalsize \par         
        \end{minipage}        
 }

\newcommand{\EducationEntry}[5]{     
        \begin{minipage}{0.08\linewidth}
        \includegraphics[width=1.2cm]{#5}
        \end{minipage}%                    
        \begin{minipage}{0.84\linewidth}  
        \noindent {\color{subheadings}\bfseries\uppercase {#1}} 
        \hfill {\color{headings}\fontsize{10pt}{12pt}#2}
        \par    
        \noindent {\color{subheadings}\textit{#3}} \par 
        \noindent\hangindent=2em\hangafter=0 \small #4 % Description
        \normalsize \par         
        \end{minipage}        
 }

\newcommand{\flag}[1]{
    \includegraphics[height=9pt, width= 15pt]{#1}
}     

\newcommand{\software}[1]{
    \includegraphics[height=9pt]{#1}
}  

\newcommand{\softwareb}[1]{
    \raisebox{-.6\height}{\includegraphics[height=18pt]{#1}}
}

I realize it's most likely something to do with the temp file, but I have no idea what to do or how to fix it. My goal is to be able to write a header on the right-hand side with the page number (Ex.: Page 1/2).

Cheers.

Best Answer

The instruction

\usepackage[hmargin=1.25cm, vmargin=0.7cm]{geometry}

on line 19 of temp.cls is causing the problem: It's telling LaTeX to use the area that's usually set aside for the header block as part of the text block.

Two suggested remedies:

  • Provide a more generous top margin, say,

    \usepackage[hmargin=1.25cm, top=2cm, bottom=0.7cm]{geometry}
    

or

  • instruct the geometry package to set aside some material for the header group:

    \usepackage[hmargin=1.25cm, vmargin=0.7cm, includehead]{geometry}
    

A final observation: do delete (or comment out) the \pagestyle{empty} directive on line 29 of the class file. It's not mandatory that you do so, but removing code clutter is always advisable.

Related Question