如果有人能帮助我,我将不胜感激。如果我编译代码(参见下面的 MWE),则 cvitem 的第二个参数中写入的文本将超出右边距,直到论文的最后。我需要做什么才能在第二个参数中自动换行\cvitem
?
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\AtBeginDocument{\hypersetup{colorlinks,linkcolor=cyan,urlcolor=cyan}}
\firstname{Jane}
\familyname{Doe}
\title{Curriculum Vitae}
\address{Street}{City}{}
\mobile{Number}
\email{email}
\begin{document}
\makecvtitle
\section{Education}
\cventry
{2020--2025}
{Degree}
{University}
{Location}
{Some info including a link in my real document. The automatic linebreak works here, but not below}
{\cvitem{Item 1}{This is the description of item 1 and it is very long so I need an automatic linebreak here so the text doesn't go beyond the linewidth.}
\cvitem{Item 2}{This is the description of item 2 and it is very long so I need an automatic linebreak here which I don't know how to create.}
\cvitem{Item 3}{This is the description of item 3 and it is even longer and spans across multiple lines so I need an automatic linebreak so the text doesn't go beyond the linewidth, but I don't know how to create this.}
}
\end{document}
答案1
换行符做自动发生。问题是你缺少 的参数\cventry
,那么它会将\cvitem
s 作为参数。
从moderncv
的 GitHub 页面,的参数\cventry
为:
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description} % arguments 3 to 6 can be left empty
而你没有\textit{Grade}
。你必须有这个参数,即使它为空({}
)。
I also removed the braces that were grouping the `\cvitem`s.
如果您想改变\cvitem
s 的对齐方式,则应该增加 的值\hintscolumnwidth
并减少 的值\maincolumnwidth
。\cvitem
s 使用 排版,tabular
每列具有上述两种宽度之一。
例如,缩进Item X
be 4cm
:
\setlength{\hintscolumnwidth}{4cm}% The width of the "hints" column
\setlength{\maincolumnwidth}{\dimexpr\linewidth-\hintscolumnwidth-\separatorcolumnwidth}% Recompute the size of the remaining text.
可编译的MWE:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\AtBeginDocument{\hypersetup{colorlinks,linkcolor=cyan,urlcolor=cyan}}
\firstname{Jane}
\familyname{Doe}
\title{Curriculum Vitae}
\address{Street}{City}{}
\mobile{Number}
\email{email}
\begin{document}
\makecvtitle
\section{Education}
\cventry
{2020--2025}
{Degree}
{University}
{Location}
{\textit{Grade}}% Missing this
{Some info including a link in my real document. The automatic linebreak works here, but not below}
\setlength{\hintscolumnwidth}{4cm}
\setlength{\maincolumnwidth}{\dimexpr\linewidth-\hintscolumnwidth-\separatorcolumnwidth}
\cvitem{Item 1}{This is the description of item 1 and it is very long so I need an automatic linebreak here so the text doesn't go beyond the linewidth.}
\cvitem{Item 2}{This is the description of item 2 and it is very long so I need an automatic linebreak here which I don't know how to create.}
\cvitem{Item 3}{This is the description of item 3 and it is even longer and spans across multiple lines so I need an automatic linebreak so the text doesn't go beyond the linewidth, but I don't know how to create this.}
\end{document}