我在嘗試itemize
更新時收到此錯誤:\cventry
moderncv
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&%
\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&%%
\else{\newline{}\begin{minipage}[t]{\linewidth}\small#7\end{minipage}}% else <=============
\fi
\par\addvspace{#1}}
2. 程式碼錯誤
您在命令中使用的程式碼\cventy
\ifthenelse{\equal{#7}{}}%
{\end{tabular}}%
回傳錯誤,請改用
\ifx&%%
\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&%% <========================================================
\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 文件,且沒有錯誤訊息: