重新定义 moderncv header、headheight

重新定义 moderncv header、headheight

我目前正在使用该moderncv软件包编写简历。但是,我想在每一页上都使用页眉。在第一页上,我想使用选项打印照片(目前已注释掉),因此,使用\makecvtitle,我想在后续页面上打印不带照片的页眉。为此,我用 关闭了第一页,并使用和从文件中获取的命令\clearpage优化了页眉。我唯一无法重现的是页眉的正确高度。实际上,我不太明白它在中是如何定义的,以及如何将它包含在我的页眉定义中。有人能帮帮我吗?fancyhdrmoderncvheadi.stymoderncvheadi.sty

编辑

我知道,我可以调用例如\makecvhead。但如果后面有多个页面,我需要手动进行每个分页。例如,\makecvhead当打印出版物列表时,这是不可能的。为了澄清这一点,我想在每一页上打印页眉。.bib file

\documentclass[a4paper, 11pt, sans, details]{moderncv}
\moderncvtheme{classic}
%
\title{Dr. of blub}
\firstname{John}
\familyname{Doe}
\address{Awesome street 00}{01234 Kleingibtsnicht}{}
\mobile{0815-4711}
\phone{0815-4712}
\email{[email protected]}
%\photo[64pt]{JMP_photo.jpg}
\extrainfo{* 01.02.1899 in Somewhere}
%
\begin{document}
%
\makecvtitle
%
\section{job experience}
%
  \cventry{1900 -- 2000}{I was}{here}{and}{did}{something}
%
\section{Some knowledge I got}
%
\closesection
%
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%
% redefine header
%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\lhead{%
    \begin{minipage}[b]{\makecvheadnamewidth}%
      \if@left\raggedright\fi%
      \if@right\raggedleft\fi%
      \namestyle{\@firstname\ \@lastname}%
      \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
    \end{minipage}
        }%
%
\rhead{%
    \addressfont\color{color2}%
      \if@left\begin{tabular}[b]{@{}r@{}}\fi%
      \if@right\begin{tabular}[b]{@{}l@{}}\fi%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
      \end{tabular}
            }
\makeatother
%
\section{some more great knowledge}
%
\closesection
%
\end{document}

输出

第一页 在此处输入图片描述 第二页 在此处输入图片描述

答案1

您在第二页和后续页面的代码中唯一遗漏的就是定义使用的标题的长度,例如:

\setlength{\headheight}{70pt} 

使用此命令,标题的高度将为 70 pt(将其更改为您需要的高度),用于显示您的个人信息,这也适用于您的 bib 文件。您没有提供参考书目,因此请使用您自己的代码尝试...

完成 MWE:

\documentclass[a4paper, 11pt, sans, details]{moderncv}
\moderncvtheme{classic}
%
\title{Dr. of blub}
\firstname{John}
\familyname{Doe}
\address{Awesome street 00}{01234 Kleingibtsnicht}{}
\mobile{0815-4711}
\phone{0815-4712}
\email{[email protected]}
\photo[64pt]{JMP_photo.jpg}
\extrainfo{* 01.02.1899 in Somewhere}
%

\begin{document}
%
\makecvtitle
%
\section{job experience}
%
  \cventry{1900 -- 2000}{I was}{here}{and}{did}{something}
%
\section{Some knowledge I got}
%
\closesection
%
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%
% redefine header
%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\lhead{%
    \begin{minipage}[b]{\makecvheadnamewidth}%
      \if@left\raggedright\fi%
      \if@right\raggedleft\fi%
      \namestyle{\@firstname\ \@lastname}%
      \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
    \end{minipage}
        }%
%
\rhead{%
    \addressfont\color{color2}%
      \if@left\begin{tabular}[b]{@{}r@{}}\fi%
      \if@right\begin{tabular}[b]{@{}l@{}}\fi%
        \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
        \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
        \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
        \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
        \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
      \end{tabular}
            }
\makeatother
\setlength{\headheight}{70pt} % <=======================================
%
\section{some more great knowledge}
%
\closesection
%
\end{document}

您将获得第二页结果(请注意,我取消了对您的命令的注释\photo):

生成第二页

答案2

我不知道为什么你重新定义了整个命令,因为你能够使用该命令在每一页之前创建页眉\makecvhead,而我只是\photo在第一个页眉之后取消了该命令的定义。

\documentclass[a4paper, 11pt, sans, details]{moderncv}
\moderncvtheme{classic}
%
\title{Dr. of blub}
\firstname{John}
\familyname{Doe}
\address{Awesome street 00}{01234 Kleingibtsnicht}{}
\mobile{0815-4711}
\phone{0815-4712}
\email{[email protected]}
\photo[64pt]{example-image}
\extrainfo{* 01.02.1899 in Somewhere}
%
\begin{document}
%
\makecvtitle
%
\section{job experience}
%
  \cventry{1900 -- 2000}{I was}{here}{and}{did}{something}
%
\section{Some knowledge I got}
%
\closesection
%
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%
% redefine header
%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\@photo\undefined
\makecvhead
\section{some more great knowledge}
%
\closesection
%
\end{document}

在此处输入图片描述

相关内容