扩展 moderncv 社交命令

扩展 moderncv 社交命令

我写了以下代码:

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{casual}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}

\makeatletter
\newcommand\faSkype{{\FA\symbol{"F17E}}}
\makeatother

\name{John}{Doe}
\extrainfo{\href{skype:jdoe}{\faSkype{} jdoe}}

\begin{document}

\makecvtitle

\end{document}

在简历上添加可点击的 Skype 个人资料。

有没有办法扩展现有的社交命令以接受 Skype 作为可选参数,以便编写更具可读性的东西?

\social[skype]{jdoe}

答案1

现在可以这样做:

\newcommand*\skypesocialsymbol{{\FA\symbol{"F17E}}}
\social[skype][skype.com/user/jdoe]{jdoe}

您只需相应地更改 URL 即可。

答案2

序言中的以下代码可以达到这个目的!

% hlink
\makeatletter
\newcommand*{\hlink}[2][]{%
  \ifthenelse{\equal{#1}{}}%
    {\href{#2}{#2}}%
    {\href{#2}{#1}}}
\makeatother

% social
\makeatletter
\newcommand*{\facebooksocialsymbol}{\faFacebook~}
\newcommand\faSkype{{\FA\symbol{"F17E}}}
\newcommand*{\skypesocialsymbol}{\faSkype~}
\RenewDocumentCommand{\social}{O{}O{}m}{%
  \ifthenelse{\equal{#2}{}}%
    {%
      \ifthenelse{\equal{#1}{linkedin}}{\collectionadd[linkedin]{socials}{\protect\httplink[#3]{www.linkedin.com/in/#3}}}{}%
      \ifthenelse{\equal{#1}{twitter}} {\collectionadd[twitter]{socials} {\protect\httplink[#3]{www.twitter.com/#3}}}    {}%
      \ifthenelse{\equal{#1}{facebook}}{\collectionadd[facebook]{socials}{\protect\httplink[#3]{www.facebook.com/#3}}}   {}%
      \ifthenelse{\equal{#1}{github}}  {\collectionadd[github]{socials}  {\protect\httplink[#3]{www.github.com/#3}}}     {}%
      \ifthenelse{\equal{#1}{skype}}   {\collectionadd[skype]{socials}   {\protect\hlink[#3]{skype:#3}}}              {}%
    }
    {\collectionadd[#1]{socials}{\protect\httplink[#3]{#2}}}}
\makeatother

逐步解释:

创建“hlink”命令:这是必需的,因为 skype 链接不是网页链接

\makeatletter
\newcommand*{\hlink}[2][]{%
  \ifthenelse{\equal{#1}{}}%
    {\href{#2}{#2}}%
    {\href{#2}{#1}}}
\makeatother

为将要使用的符号创建命令。请注意,skype 符号不在默认的 Font Awesome 命令集中,因此需要与 facebook 符号不同的解决方案

\newcommand*{\facebooksocialsymbol}{\faFacebook~}
\newcommand\faSkype{{\FA\symbol{"F17E}}}
\newcommand*{\skypesocialsymbol}{\faSkype~}

最后,编辑原始社交命令以包含以下符号:

\RenewDocumentCommand{\social}{O{}O{}m}{%
  \ifthenelse{\equal{#2}{}}%
    {%
      \ifthenelse{\equal{#1}{linkedin}}{\collectionadd[linkedin]{socials}{\protect\httplink[#3]{www.linkedin.com/in/#3}}}{}%
      \ifthenelse{\equal{#1}{twitter}} {\collectionadd[twitter]{socials} {\protect\httplink[#3]{www.twitter.com/#3}}}    {}%
      \ifthenelse{\equal{#1}{facebook}}{\collectionadd[facebook]{socials}{\protect\httplink[#3]{www.facebook.com/#3}}}   {}%
      \ifthenelse{\equal{#1}{github}}  {\collectionadd[github]{socials}  {\protect\httplink[#3]{www.github.com/#3}}}     {}%
      \ifthenelse{\equal{#1}{skype}}   {\collectionadd[skype]{socials}   {\protect\hlink[#3]{skype:#3}}}              {}%
    }
    {\collectionadd[#1]{socials}{\protect\httplink[#3]{#2}}}}
\makeatother

相关内容