无法显示页码

无法显示页码

我目前用的是这个:

\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}

然后临时文件是我从 overleaf 获得的,它是这样的:

\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}}
}

我意识到这很可能与临时文件有关,但我不知道该怎么做或如何修复它。我的目标是能够在右侧写一个带有页码的标题(例如:第 1/2 页)。

干杯。

答案1

指令

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

第 19 行temp.cls导致了问题:它告诉 LaTeX 将通常为标题块保留的区域用作文本块的一部分。

两种建议的补救措施:

  • 提供更大的顶部边距,例如,

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

或者

  • 指示几何包为标题组留出一些材料:

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

最后一点:删除(或注释掉)\pagestyle{empty}类文件第 29 行的指令。这不是强制要求的,但删除代码杂乱总是明智的。

答案2

当您加载包时,您只需在主文件中替换lastpage即可。\fancyhead[R]{\thepage}\fancyhead[R]{\thepage/\pageref*{LastPage}}

相关内容