如何在 moderncv 的 \extrainfo 中创建新行?

如何在 moderncv 的 \extrainfo 中创建新行?

我正在使用casualmoderncv包的 cv。

使用以下内容:

\extrainfo{
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~JohnDoe]{www.xing.com/profile/john-doe/} 
\footsymbol \httplink[\faGithub~JohnDOe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~JohnDoe]{stackoverflow.com/users/john-doe}
}

它运行正常,但是行太宽覆盖了页码。

我无法使用\newline或创建新行\\

有什么建议么?


可编译代码:

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{casual}

\renewcommand{\familydefault}{\sfdefault}

\firstname{John}
\familyname{Doe}
\title{CV}    
\address{Somewhere}
\mobile{+1 (800) 555-5555} 
\email{[email protected]} 

\extrainfo{
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~JohnDoe]{www.xing.com/profile/john-doe/} 
\footsymbol \httplink[\faGithub~JohnDOe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~JohnDoe]{stackoverflow.com/users/john-doe}
}

\begin{document}
\maketitle

\end{document}

答案1

您可以在 中放入\parbox\extrainfo如下例所示:

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{casual}

\renewcommand{\familydefault}{\sfdefault}

\firstname{John}
\familyname{Doe}
\title{CV}    
\address{Somewhere}
\mobile{+1 (800) 555-5555} 
\email{[email protected]} 

\extrainfo{%
\parbox{\linewidth}{%
\centering
\httplink[\faLinkedin~John Doe]{www.linkedin.com/in/john-doe/}
\footsymbol \httplink[\faXing~JohnDoe]{www.xing.com/profile/john-doe/}\\
\footsymbol \httplink[\faGithub~JohnDOe]{github.com/JohnDoe}
\footsymbol \httplink[\faStackOverflow~JohnDoe]{stackoverflow.com/users/john-doe}
}}

% without this you get a warning saying
% "Package Fancyhdr Warning: \footskip is too small (30.0pt):  Make it at least 58.40619pt."
% in your actual document the value might be different
\setlength\footskip{58.5pt}

\begin{document}
\maketitle

\end{document}

答案2

嗯,你的代码中有三个问题。

  1. 您没有定义\footskip获取正确放置页脚所需的长度(该值可能会根据您使用的个人信息而改变;请检查日志文件中的警告"Package Fancyhdr Warning: \footskip is too small (30.0pt):。使用您需要的值,就我而言\setlength{\footskip}{52pt}...
  2. 最后,我猜你真的想使用命令\socials而不是你使用的\extrainfo。如果你坚持使用\extrainfo作为解决方法,只需将修改\footsymbol得更短一点,那么它就不会将你提供的个人信息写入页码:

    \renewcommand*{\footsymbol}{{~~{\rmfamily\textbullet}~~}}
    

但解决您的问题的最佳方法是使用命令\social。它能够以最简单的方式(标准定义)将您的 Xing、StackOverflow、Linkedin 和 Github 信息添加到页脚中的个人数据中:

\social[linkedin]{john-doe}
\social[github]{jdoe}

对于 Stackoverflow 和 Xing,我们需要做更多:

\newcommand*{\xingsocialsymbol}{\faXing~}
\social[xing][xing.com/JohnDoe]{JohnDoe}
\newcommand*{\SOfsocialsymbol}{\faStackOverflow~}
\social[SOf][www.StackOverflow.com/profile/john.doe]{john.doe}

更改www.StackOverflow.com/profile/john.doe为您的真实数据,例如tex.stackexchange.com/users/179843

  1. 仔细查看简历中使用的链接,你会发现在标准定义中只http://使用 而不是今天使用的https://。要解决此问题,请查看我对问题的回答https://tex.stackexchange.com/a/464850/16550

通过以下 MWE,我向您展示了问题 1 和问题 2 的解决方案(参见代码中的标记<========):

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{casual}

\renewcommand{\familydefault}{\sfdefault}

\setlength{\footskip}{52pt}% <==========================================
\renewcommand*{\footsymbol}{{~~{\rmfamily\textbullet}~~}} % <===========

\firstname{John}
\familyname{Doe}
\title{CV}    
\address{Somewhere}
\mobile{+1 (800) 555-5555} 
\email{[email protected]} 

\social[linkedin]{john-doe} % <=========================================
\social[github]{jdoe}
\newcommand*{\xingsocialsymbol}{\faXing~}
\social[xing][xing.com/JohnDoe]{JohnDoe}
\newcommand*{\SOfsocialsymbol}{\faStackOverflow~}
\social[SOf][www.StackOverflow.com/profile/john.doe]{john.doe}
\social[github]{jdoe} % <===============================================

\begin{document}
\maketitle
\newpage
test
\end{document}

以及生成的 pdf 页面:

在此处输入图片描述

在您的评论中,您问“有没有办法从新行上的第一个社交开始?”。好吧,您可以在需要的\flushfoot\\命令定义中添加命令:\makecvfoot

\makeatletter
\renewcommand*{\recomputefootlengths}{%
  \setlength{\footwidth}{0.9\textwidth}}% <=============================
\renewcommand*{\makecvfoot}{%
  \recomputecvfootlengths{}%
  \fancypagestyle{plain}{%
    \fancyfoot[c]{%
      \parbox[b]{\footwidth}{%
        \centering%
        \color{color2}\addressfont%
        \vspace{\baselineskip}% forces a white line to ensure space between main text and footer (as footer height can't be known in advance)
        \ifthenelse{\isundefined{\@addressstreet}}{}{\addtofoot[]{\addresssymbol\@addressstreet}%
          \ifthenelse{\equal{\@addresscity}{}}{}{\addtofoot[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\addtofoot[~--~]{\@addresscountry}}%
          \flushfoot\@firstfootelementtrue\\}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \addtofoot{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@email}}{}{\addtofoot{\emailsymbol\emaillink{\@email}}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\addtofoot{\homepagesymbol\httplink{\@homepage}}}%
\flushfoot\\% <===================================
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
          \addtofoot{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\addtofoot{\@extrainfo}}%
        \ifthenelse{\lengthtest{\footboxwidth=0pt}}{}{\flushfoot}% the lengthtest is required to avoid flushing an empty footer, which could cause a blank line due to the \\ after the address, if no other personal info is used
        }}}
  \pagestyle{plain}}
\makeatother 

凭借全新完整的 MWE

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{casual}

\renewcommand{\familydefault}{\sfdefault}

\setlength{\footskip}{52pt}% <==========================================
%\renewcommand*{\footsymbol}{{~~{\rmfamily\textbullet}~~}} % <===========

\firstname{John}
\familyname{Doe}
\title{CV}    
\address{Somewhere}
\mobile{+1 (800) 555-5555} 
\email{[email protected]} 

\social[linkedin]{john-doe} % <=========================================
\social[github]{jdoe}
\newcommand*{\xingsocialsymbol}{\faXing~}
\social[xing][xing.com/JohnDoe]{JohnDoe}
\newcommand*{\SOfsocialsymbol}{\faStackOverflow~}
\social[SOf][www.StackOverflow.com/profile/john.doe]{john.doe}
\social[github]{jdoe} % <===============================================

\makeatletter
\renewcommand*{\makecvfoot}{%
  \recomputecvfootlengths{}%
  \fancypagestyle{plain}{%
    \fancyfoot[c]{%
      \parbox[b]{\footwidth}{%
        \centering%
        \color{color2}\addressfont%
        \vspace{\baselineskip}% forces a white line to ensure space between main text and footer (as footer height can't be known in advance)
        \ifthenelse{\isundefined{\@addressstreet}}{}{\addtofoot[]{\addresssymbol\@addressstreet}%
          \ifthenelse{\equal{\@addresscity}{}}{}{\addtofoot[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\addtofoot[~--~]{\@addresscountry}}%
          \flushfoot\@firstfootelementtrue\\}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \addtofoot{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@email}}{}{\addtofoot{\emailsymbol\emaillink{\@email}}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\addtofoot{\homepagesymbol\httplink{\@homepage}}}%
\flushfoot\\% <===================================
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
          \addtofoot{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\addtofoot{\@extrainfo}}%
        \ifthenelse{\lengthtest{\footboxwidth=0pt}}{}{\flushfoot}% the lengthtest is required to avoid flushing an empty footer, which could cause a blank line due to the \\ after the address, if no other personal info is used
        }}}
  \pagestyle{plain}}
\makeatother


\begin{document}
\maketitle
\newpage
test
\end{document}

您将获得最终的页脚:

在此处输入图片描述

要删除 linkedin 徽标前面的项目符号,您必须\@firstfootelementtrue在后面添加\flushfoot

借助新的 MWE

\documentclass[11pt,a4paper]{moderncv}

\moderncvtheme[blue]{casual}

\renewcommand{\familydefault}{\sfdefault}

\setlength{\footskip}{52pt}% 
%\renewcommand*{\footsymbol}{{~~{\rmfamily\textbullet}~~}} % 

\firstname{John}
\familyname{Doe}
\title{CV}    
\address{Somewhere}
\mobile{+1 (800) 555-5555} 
\email{[email protected]} 

\social[linkedin]{john-doe} % 
\social[github]{jdoe}
\newcommand*{\xingsocialsymbol}{\faXing~}
\social[xing][xing.com/JohnDoe]{JohnDoe}
\newcommand*{\SOfsocialsymbol}{\faStackOverflow~}
\social[SOf][www.StackOverflow.com/profile/john.doe]{john.doe}
\social[github]{jdoe} % 

\makeatletter
\renewcommand*{\makecvfoot}{%
  \recomputecvfootlengths{}%
  \fancypagestyle{plain}{%
    \fancyfoot[c]{%
      \parbox[b]{\footwidth}{%
        \centering%
        \color{color2}\addressfont%
        \vspace{\baselineskip}% forces a white line to ensure space between main text and footer (as footer height can't be known in advance)
        \ifthenelse{\isundefined{\@addressstreet}}{}{\addtofoot[]{\addresssymbol\@addressstreet}%
          \ifthenelse{\equal{\@addresscity}{}}{}{\addtofoot[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
          \ifthenelse{\equal{\@addresscountry}{}}{}{\addtofoot[~--~]{\@addresscountry}}%
          \flushfoot\@firstfootelementtrue\\}%
        \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
          \addtofoot{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@email}}{}{\addtofoot{\emailsymbol\emaillink{\@email}}}%
        \ifthenelse{\isundefined{\@homepage}}{}{\addtofoot{\homepagesymbol\httplink{\@homepage}}}%
\flushfoot\@firstfootelementtrue\\% <===================================
        \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
          \addtofoot{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
        \ifthenelse{\isundefined{\@extrainfo}}{}{\addtofoot{\@extrainfo}}%
        \ifthenelse{\lengthtest{\footboxwidth=0pt}}{}{\flushfoot}% the lengthtest is required to avoid flushing an empty footer, which could cause a blank line due to the \\ after the address, if no other personal info is used
        }}}
  \pagestyle{plain}}
\makeatother


\begin{document}
\maketitle
\newpage
test
\end{document}

你得到了想要的结果:

在此处输入图片描述

相关内容