如何在 \cventry 中插入多个段落

如何在 \cventry 中插入多个段落

语法如下\cventry

\cventry{1}{2}{3}{4}{5}{desc}

如何在一个desc部分中插入多个段落。而且看起来cventry不会跨越多页,这会让简历看起来不协调。

答案1

对于第一个问题,无需重新定义任何内容,您只需\endgraf在所需的段落分隔符处使用即可:

\cventry{1}{2}{3}{4}{5}{desc .... \endgraf descr ...}

示例输出

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

\moderncvstyle{casual} 
\moderncvcolor{blue}   

\usepackage{lipsum} %Just for dummy text

\name{John}{Doe}
\title{Resum\'e title}  

\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  \endgraf Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.} 

\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{\lipsum[1-10]}
\end{document}

对于分页符,您需要重新定义\cventry。在此过程中,您也可以允许在描述中使用普通的段落分隔符(通过将其设为“长”命令)。下面的方法是将\cventrys 定义为通过 pakcage 自定义的特殊列表中的项目enumitem。如果这会干扰 的其他用途,\cventry那么您可以定义一个新命令\longcventry和 ,并\longcvitem使用以下定义并保持原始定义不变。

示例输出

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

\moderncvstyle{casual} 
\moderncvcolor{blue}   

\usepackage{enumitem}

\renewcommand{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    .\strut%
    \ifthenelse{\equal{#7}{}}{}%
    {\newline{\small\strut #7 \par}}}}

\renewcommand{\cvitem}[3][.25em]{%
  \begin{mycvlist}
    \item[#2] #3
    \end{mycvlist}
    \addvspace{#1}}

\newlist{mycvlist}{description}{1}
\setlist[mycvlist]{labelwidth=\hintscolumnwidth,labelsep=\separatorcolumnwidth,leftmargin=!,align=right,font=\normalfont}

\usepackage{lipsum} %Just for dummy text

\name{John}{Doe}
\title{Resum\'e title}  

\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  \par Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.  Description
text that is long and stretches over several lines.} 

\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{\lipsum[1-10]}
\end{document}

需要重新定义的原因是,标准cventry构建了tabular,然后将描述部分放在 中minipage,但是 和tabularminipage不会跨页。

添加 如果需要长标签,那么您需要使用稍微更复杂的定义将\cvitem标签包裹在框中并确保里面的文本右对齐:

\renewcommand{\cvitem}[3][.25em]{%
  \begin{mycvlist}
    \item[{\parbox[t][\baselineskip]{\hintscolumnwidth}{\raggedleft #2}}] #3
    \end{mycvlist}
    \addvspace{#1}}

不幸的是,enumitem没有包含此标准选项。以下是采用 moderncv 较新样式的代码,第一行末尾没有句号。

多页样本

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

\moderncvstyle{casual}
\moderncvcolor{blue}

\usepackage{enumitem}

\renewcommand{\cventry}[7][.25em]{%
  \cvitem[#1]{#2}{%
    {\bfseries#3}%
    \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
    \ifthenelse{\equal{#5}{}}{}{, #5}%
    \ifthenelse{\equal{#6}{}}{}{, #6}%
    \strut
    \ifthenelse{\equal{#7}{}}{\par\vspace{-0.8\baselineskip}}{%
    \newline\small\strut #7 \par}}}

\renewcommand{\cvitem}[3][.25em]{%
  \begin{mycvlist}
    \item[{\parbox[t][\baselineskip]{\labelwidth}{\raggedleft #2}}] #3
    \end{mycvlist}
    \addvspace{#1}}

\newlist{mycvlist}{description}{1}
\setlist[mycvlist]{labelwidth=\hintscolumnwidth,labelsep=\separatorcolumnwidth,align=right,leftmargin=!,font=\normalfont}

\usepackage{lipsum} %Just for dummy text

\name{John}{Doe}
\title{Resum\'e title}

\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{\lipsum[2]}

\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{}

\cventry{year--year, year--year and year--year}{Degree}{Institution}{City}{\textit{Grade}}{\lipsum[1-10]}
\end{document}

答案2

我知道回答得非常晚,但我发现 Andrew 的回答非常出色。我遇到的唯一问题是,第一个参数和的第一个参数中的部分文本\cventry位于\cvitem左边距内。发生这种情况是因为这些参数中的文本比分配的宽度长。我通过更改对齐选项解决了这个问题。我更改了

\setlist[mycvlist]{labelwidth=\hintscolumnwidth,labelsep=\separatorcolumnwidth,leftmargin=!,align=right,font=\normalfont}

\setlist[mycvlist]{labelwidth=\hintscolumnwidth,labelsep=\separatorcolumnwidth,leftmargin=!,align=parleft,font=\normalfont}

对于许多人来说这似乎微不足道,但作为一个相当新的用户,这对我来说并不明显。

相关内容