如何将 moderncv \social[linkedin] 从 http 更改为 https?

如何将 moderncv \social[linkedin] 从 http 更改为 https?

你好,我是 LaTeX 的新手,我很喜欢它!

moderncv我有一个指向我的 Linkedin 个人资料的链接。但是,此链接是http,我想将其更改为https

例子

    \documentclass[11pt,a4paper,sans]{moderncv}
    \moderncvstyle{casual}
    \moderncvcolor{blue}
    \usepackage[scale=0.75]{geometry}

    \name{John}{Doe}
    \social[linkedin]{reidhoffman}

    \begin{document}

    \makecvtitle

    \section{Education}
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}                        {Description}

    \end{document}

我尝试按照说明自定义链接修复 LinkedIN (国际配置文件) 的“moderncv”的“\social”命令但它不接受 https。

如果你需要一个最小的工作示例,只需使用默认模板moderncv即可http://www.pirbot.com/mirrors/ctan/macros/latex/contrib/moderncv/examples/template.tex。 提前致谢!

答案1

通过“更新” documentclass 命令来修复\href{}{}此页面的使用问题:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{casual}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}

% Added these lines (until `\makeatother` that belongs to documentclass `moderncv.cls`)
\makeatletter
\RenewDocumentCommand{\social}{O{}O{}m}{%
  \ifthenelse{\equal{#2}{}}%
    {%NEXT LINE CHANGED FROM ORIGINAL
      \ifthenelse{\equal{#1}{linkedin}}{\collectionadd[linkedin]{socials}{\protect\href{https://www.linkedin.com/in/#3}{#3}}}{}%
      \ifthenelse{\equal{#1}{twitter}} {\collectionadd[twitter]{socials} {\protect\httplink[#3]{www.twitter.com/#3}}}    {}%
      \ifthenelse{\equal{#1}{github}}  {\collectionadd[github]{socials}  {\protect\httplink[#3]{www.github.com/#3}}}     {}%
    }
    {\collectionadd[#1]{socials}{\protect\httplink[#3]{#2}}}}
\makeatother
    \name{John}{Doe}
    \social[linkedin]{reidhoffman}


    \begin{document}

    \makecvtitle

    \section{Education}
    \cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}                        {Description}

\end{document}

答案2

您只需定义一个新命令,\httpslink例如

% makes a https hyperlink
% usage: \httpslink[optional text]{link}
\newcommand*{\httpslink}[2][]{% <=======================================
  \ifthenelse{\equal{#1}{}}%
    {\href{https://#2}{#2}}%
    {\href{https://#2}{#1}}}

然后您只需改变调用\httplink即可\httpslink获得所需的结果。

请参阅以下 MWE(重要的代码更改以 标记<======):

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

\moderncvstyle{casual}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

% makes a https hyperlink
% usage: \httpslink[optional text]{link}
\newcommand*{\httpslink}[2][]{% <=======================================
  \ifthenelse{\equal{#1}{}}%
    {\href{https://#2}{#2}}%
    {\href{https://#2}{#1}}}

% adds a social link to one's personal information (optional)
% usage: \social[<optional type>][<optional url>]{<account name>}
% where <optional type> should be either "linkedin", "twitter" or "github"
\RenewDocumentCommand{\social}{O{}O{}m}{% <=============================
  \ifthenelse{\equal{#2}{}}%
    {%
      \ifthenelse{\equal{#1}{linkedin}}{\collectionadd[linkedin]{socials}{\protect\httpslink[#3]{www.linkedin.com/in/#3}}}{}% <==========================================
      \ifthenelse{\equal{#1}{twitter}} {\collectionadd[twitter]{socials} {\protect\httpslink[#3]{www.twitter.com/#3}}}    {}% <=====================
      \ifthenelse{\equal{#1}{github}}  {\collectionadd[github]{socials}  {\protect\httpslink[#3]{www.github.com/#3}}}     {}% <=====================
    }
    {\collectionadd[#1]{socials}{\protect\httpslink[#3]{#2}}}}


\name{John}{Doe}
\social[linkedin]{reidhoffman}


\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}                        {Description}

\end{document}

这给了你想要的结果:https://www.linkedin.com/in/reidhoffman。请注意,我改变了旧的协议httplink,以便httpslink为所有其他可能性命令\social添加社交链接到你的简历......

相关内容