未能在修改後的 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您必須結束表格並在小型頁參數 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文件

相關內容