\cventry 內的 \tagged 存在問題。產生錯誤(僅在某些參數中)

\cventry 內的 \tagged 存在問題。產生錯誤(僅在某些參數中)

我打算使用-packagetagging來組織我的履歷,例如,取決於我需要哪種語言。五個參數上不起作用......詭異的。\tagged{}\cventry

在隨附的 MWE 中,第一個cventry{2016}可以正常工作,但第二個則{2015}不行。有人能解決這個問題嗎?謝謝你!

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\usepackage{tagging}
\firstname{John}
\familyname{Doe}
\title{MWE}
%-----------------------------------------------
\begin{document}
\makecvtitle

\usetag{EN} %Three possible tags: EN, DE, SP

\section{Education}

\cventry{2016}
{\tagged{EN}{Mathematics}\tagged{DE}{Mathematik}\tagged{SP}{Matem\'aticas}}
{University}
{USA}
{(unfinished)}
{\tagged{EN}{Research}\tagged{DE}{Forschung} \tagged{SP}{Investigaci\'on}}

\cventry{2015}
{Pilot}
{\tagged{EN}{Academy}\tagged{DE}{Pilotschule} \tagged{SP}{Academia}} %uncommenting THIS LINE causes error
{}
{}
{}
{}

\end{document}

答案1

\cventry使用的預設定義\ifthenelse無法處理您的輸入:

預設定義

\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    .\strut%
    \ifx&#7&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi}}

改用\ifx它就可以了:

\makeatletter
\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifx&#4&\else{, {\slshape#4}}\fi%
    \ifx&#5&\else{, #5}\fi%
    \ifx&#6&\else{, #6}\fi%
    .\strut%
    \ifx&#7&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi%
  }%
}
\makeatother

完整程式碼:

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

\moderncvstyle{classic}
\usepackage{tagging} 

\makeatletter
\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifx&#4&\else{, {\slshape#4}}\fi%
    \ifx&#5&\else{, #5}\fi%
    \ifx&#6&\else{, #6}\fi%
    .\strut%
    \ifx&#7&%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi%
  }%
}
\makeatother


\firstname{John}
\familyname{Doe}
\title{MWE}


%-----------------------------------------------
\begin{document}
\makecvtitle

\usetag{EN} %Three possible tags: EN, DE, SP

\section{Education}

\cventry{2016}
{\tagged{EN}{Mathematics}\tagged{DE}{Mathematik}\tagged{SP}{Matem\'aticas}}
{University}
{USA}
{(unfinished)}
{\tagged{EN}{Research}\tagged{DE}{Forschung} \tagged{SP}{Investigaci\'on}}

\cventry{2015}
{Pilot}
{\tagged{EN}{Academy}\tagged{DE}{Pilotschule} \tagged{SP}{Academia}} %uncommenting THIS LINE causes error
{}
{}
{}
{}

\end{document}

相關內容