无法在修改的 moderncv /cventry 中逐项列出

无法在修改的 moderncv /cventry 中逐项列出

当我尝试在 中itemize更新时出现此错误:\cventrymoderncv

Use of \@@array doesn't match its definition. \end{itemize}}

我的修改后的cventry样子如下:

\renewcommand*{\cventry}[7][.25em]{
    \begin{tabular}{@{}>{\raggedleft}p{.2\textwidth-\tabcolsep}p{.8\textwidth-\tabcolsep}@{}}%
        {\bfseries #2} & {\bfseries #3} \\%
        {\itshape #5} & {\itshape #4}\\%
        \ifthenelse{\equal{#7}{}}%
        {\end{tabular}}%
    {{} & {#7}\\\end{tabular}}%
\par\addvspace{#1}}

这就是我想要做的:

\cventry{2016--2019}{Did this and that, including these tasks:%
    \begin{itemize}%
        \item 1;
        \item 2, with sub-items:
        \begin{itemize}%
            \item Sub-item (a)
            \item Sub-item (b)
        \end{itemize}
        \item item 3.
\end{itemize}}
}

我确实呼喊\usepackage{array}

我尝试了@gonzalo-medina 在这篇文章中提出的替代方案:moderncv cventry 中的项目符号列表

它们对我不起作用。我一直收到相同的错误。这可能是因为我使用的是修改版的\cventry


@mensch 请求的更新

这是可编译的代码片段:

\documentclass[11pt,a4paper,sans]{moderncv}   
\moderncvstyle{banking}          
\moderncvcolor{blue}      
\usepackage[scale=0.80]{geometry}
%__________________________________________________________________________________
% Customization:
%\usepackage{fontspec}%Rendering must be done with XeLatex, not with PDFLatex.
\renewcommand\rmdefault{cmr} %Sets roman default font to Computer Modern
\usepackage{microtype}
\usepackage{array}
%This is @gonzalo-medina's suggestion:
\usepackage{enumitem}
%The following resets the way of cv entries:
\usepackage{array}
\setlength{\tabcolsep}{1ex}
\renewcommand*{\cventry}[7][.25em]{
\begin{tabular}{@{}>{\raggedleft}p{.2\textwidth-\tabcolsep}p{.8\textwidth-\tabcolsep}@{}}%
    {\bfseries #2} & {\bfseries #3} \\%
    {\itshape #5} & {\itshape #4}\\%
    \ifthenelse{\equal{#7}{}}%
    {\end{tabular}}%
{{} & {#7}\\\end{tabular}}%
\par\addvspace{#1}}
%__________________________________________________________________________________
% personal data
\name{Carl}{Sagan}
\title{\large \textbf{Populists Buster}}                 
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
%\begin{CJK*}{UTF8}{gbsn}                          % to typeset your resume in Chinese using CJK
%-----       resume       ---------------------------------------------------------
\makecvtitle
\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}[label=\textbullet]%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \begin{itemize}%
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \begin{itemize}
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
    \end{itemize}
  \item Sub-achievement (c);
  \end{itemize}
\item Achievement 3.
\end{itemize}
}
\cventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2}

\end{document}

moderncv我正在使用其提供的最新软件包运行它CTAN 仓库在这里

答案1

我认为存在误解和错误的代码行,但让我们一步一步来:

1.误解

命令的标准定义 \cventry

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

仅对于最后一个参数(#7)才使用小页面,允许您使用itemize等。

因此,对于您使用的命令,cventry您必须结束表格并在 minipage 参数 7 ( #7) 内打印:

\newcommand*{\mycventry}[7][.25em]{
\begin{tabular}{@{}>{\raggedleft}p{.2\textwidth-\tabcolsep}p{.8\textwidth-\tabcolsep}@{}}%
    {\bfseries #2} & {\bfseries #3} \\%
    {\itshape #5} & {\itshape #4}\\%
    \end{tabular} % <===================================================
    \ifx&#7&%%
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}% else <=============
    \fi
\par\addvspace{#1}}

2. 代码错误

您在命令中使用的代码\cventy

\ifthenelse{\equal{#7}{}}%
{\end{tabular}}%

返回错误,请使用

\ifx&#7&%%
        \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}% else <=============
        \fi

我在这里展示了更正后的代码。

因此,使用以下 MWE(请注意,我定义了一个新命令,\mycventry以便能够使用表格和插入列表显示\cventry类的原始代码moderncv和新定义的命令之间的差异\mycventry):

\documentclass[11pt,a4paper,sans]{moderncv}   
\moderncvstyle{banking}          
\moderncvcolor{blue}      
\usepackage[scale=0.80]{geometry}
%__________________________________________________________________________________
% Customization:
%\usepackage{fontspec}%Rendering must be done with XeLatex, not with PDFLatex.
\renewcommand\rmdefault{cmr} %Sets roman default font to Computer Modern
\usepackage{microtype}
\usepackage{array}
%This is @gonzalo-medina's suggestion:
\usepackage{enumitem}
%The following resets the way of cv entries:
\usepackage{array}
\setlength{\tabcolsep}{1ex}

\newcommand*{\mycventry}[7][.25em]{% <==================================
\begin{tabular}{@{}>{\raggedleft}p{.2\textwidth-\tabcolsep}p{.8\textwidth-\tabcolsep}@{}}%
    {\bfseries #2} & {\bfseries #3} \\%
    {\itshape #5} & {\itshape #4}\\%
    \end{tabular} % <===================================================
    \ifx&#7&%% <========================================================
    \else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}%
    \fi
\par\addvspace{#1}}
%__________________________________________________________________________________
% personal data
\name{Carl}{Sagan}
\title{\large \textbf{Populists Buster}}                 
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
%\begin{CJK*}{UTF8}{gbsn}                          % to typeset your resume in Chinese using CJK
%-----       resume       ---------------------------------------------------------
\makecvtitle
\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}[label=\textbullet]%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \begin{itemize}%
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \begin{itemize}
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
    \end{itemize}
  \item Sub-achievement (c);
  \end{itemize}
\item Achievement 3.
\end{itemize}
}
\mycventry{year--year}{Job title}{Employer}{City}{}{Description line 1\newline{}Description line 2} % <==========
\mycventry{year--year}{Job title}{Employer}{City}{}{General description no longer than 1--2 lines.\newline{}% <=============
Detailed achievements:%
\begin{itemize}[label=\textbullet]%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \begin{itemize}%
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \begin{itemize}
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
    \end{itemize}
  \item Sub-achievement (c);
  \end{itemize}
\item Achievement 3.
\end{itemize}
}
\end{document}

您将获得以下 pdf,且没有任何错误消息:

生成的 pdf

相关内容