從moderncv的\cventry中刪除逗號

從moderncv的\cventry中刪除逗號

此圖片顯示了摘錄履歷使用文檔類別產生moderncv

請注意,粗體文字後面有一個逗號。這似乎是自動產生的。我怎麼才能阻止這個?

答案1

您顯示的項目是 Produce with \cventry,因此我們想要變更此巨集的定義。它定義在moderncvstyleclassic.sty.我所做的就是將其逐字複製到序言中並刪除不需要的逗號。 (在 MWE 中,我實際上複製了該行並註解掉了原始行,以使更改易於識別。

\documentclass{moderncv}
\moderncvstyle{casual}
%%%
% the following definition is from the file moderncvstyleclassic.sty
\renewcommand*{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
%   \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}% I changed this line (with comma) ...
    \ifthenelse{\equal{#4}{}}{}{ {\slshape#4}}% ... into this one (without comma).
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    .\strut%
    \ifx&#7&%
      \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}\fi}}
%%%
\firstname{John}
\familyname{Doe}
\begin{document}
\section{Education}
\cventry{December 2012}{Master of Science in Chocolatology}{University of Candyland}{Sugartown}{A+ with Golden Gummy Bear}{I am the chocolate-man.} 
\end{document}

輸出

答案2

與其自己重新定義整個指令,還可以考慮使用xpatch

\usepackage{xpatch}

\xpatchcmd\cventry{,}{}{}{}

,該行用空字串替換巨集文字中第一次出現的內容- 即刪除它。

這裡還有關於命令如何工作的很好的文檔

答案3

明顯的註釋,但如果您希望能夠在有和沒有逗號之間切換,您可以定義一個新命令,\cventrynocomma如下所示:

\newcommand*{\cventrynocomma}[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}}

答案4

從檔案 Moderncvstyleclassic.sty 中,刪除逗號和點,如下所示:

\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}}

它將從 \cventry 中刪除自動產生的逗號和點。

相關內容