宏修改,改变 ModernCV

宏修改,改变 ModernCV

我正在重新学习 LaTeX,但感觉就像从头开始一样。我的经验仅限于使用模板撰写数学论文,坦率地说,那是几年前的事了。为了刷新我的 LaTeX 技能,我一直在重新制作我的简历并起草一些教学辅助工具。我目前的问题围绕 ModernCV 中的宏(2015/07/28 v2.0.0 现代简历及信件文档类,如在 CTAN 上所发现的)。

a) \cventry 宏的最后一行 是\par\addvspace{#1}做什么的?这是添加垂直空间的一种非常特殊的方法,所以我很好奇它的作用。

b) 如何调整宏中文本换行的边界(即限制为列)?我不理解这里的结构,也找不到很好的解释(也许是因为缺乏适当的术语)。我能够以一种黑客的方式获得不错的结果,通过添加参数条目\cventry(默认情况下有 7 个,使用和修改增加到 8 个\renewcommand)并手动将长行拆分为两个参数(与换行相比)。

\sectionc)与之关联的线条如何\subsection延伸以覆盖整个页面宽度(它们无法到达文档/文本的右边缘)?我在查看类文件时无法确定它们是如何定义的。它们应该随文档边距缩放(对我来说)似乎很自然,但事实并非如此。

以下是序言的简化版本、我的修改和问题。

\documentclass[11pt,letterpaper,sans]{moderncv}
\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[scale=0.81, margins=0.5in]{geometry}

\renewcommand*{\cventry}[8][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
      {\bfseries #4} & {\bfseries #5} \\ % #4 = {institution/employer}; #5 = {localization}
      {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\ % #3 = {degree/job title} ;#6 = {optional: comment/job description}; #2 = {years}
  \end{tabular*}%
  \ifx&#7&%
    \else{\\\vbox{\small#7}}\fi%
  \ifx&#8&%
    \else{\vspace{-2pt}\\\vbox{\small#8}}\fi%    
  \par\addvspace{#1}}

\newcommand*{\cvpdentry}[4][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r} %
      {\bfseries #2} & {\bfseries #3} \\ %
  \end{tabular*}%
  \ifx&#4&%
    \else{\\\vbox{\small#4}}\fi%
  \par\addvspace{#1}}

\begin{document}
\section{Education}
\subsection{Academic}
\begin{itemize}

\item\cventry[] %[spacing]
{December 2012} %{years}
{Master of Science in Important Subject} %{degree/job title}
{Land Grant University} %{institution/employer}
{Universitytown, ST} %{localization}
{summa magna cum laude} %{optional: grade/...}
{If this text section is too lengthy, it will overlap with the column containing the city and date(s).}{ How do I limit its length and force it to wrap prior to entering the right tabular structure?} %{optional: comment/job description}
\end{itemize}

\subsection{Professional Development}

\begin{itemize}
\item{\cvpdentry
{Premier Technological University}
{Premier, ST}
{Certificate of Oft-Used New Technology, Difficult Additional Coursework (HS6900), Proof of Updated Skills}}
\end{itemize}

\end{document}

答案1

您给出的代码中存在一些误解和错误。但让我们一步一步地看一下。

  1. 问题一:\par\addvspace{#1},起什么作用? 新的宏\cventry定义如下\renewcommand*{\cventry}[7][.25em],也就是说,它有可选参数(第一个参数#1,取预定义的值.25em)和非可选参数#2- #7。命令\par开始一个新段落,\addvspace{#1}然后命令添加长度为 的垂直空间#1,通常是(预定义).25em。这确保所有文本彼此之间的距离相同。

  2. 因此,您必须使用\cventry[0pt]...您习惯的命令\cventry[]...来摆脱多余的空间。

  3. 问题b:如何调整宏中文本换行的边界(即限制为列)?正如您已经在谈论列一样——您确实需要——使用表格来完成\cventry\cvpdentry。这意味着,您可以在\ifx&#7&或内添加第二个表格\ifx&#4&,以使第一列不重叠。相反,您l在表格中使用的列使用p{15cm}列:\begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}%。对于命令,\cvpdentry我们得到以下代码:

    %\cvpdentry[addvspace]{institution/employer}{localization}{optional: comment/job description}
    \newcommand*{\cvpdentry}[4][.25em]{
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r} % <======
          {\bfseries #2} & {\bfseries #3} \\ %
      \end{tabular*}\par% <=================================================
      \ifx&#4&%
        \else{%
          \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}% <========= 
            {\small#4} & \\
          \end{tabular*}%
        }%
      \fi%
      \par\addvspace{#1}%
    }
    

    您是否注意到,我删除了您的第 8 个参数,现在不再需要它了……

  4. 问题c:如何扩展与 \section 和 \subsection 相关的行以覆盖整个页面的宽度(它们无法到达文档/文本的右边缘)?我担心这是个误解……这里真正的问题是您正在使用\item插入项目符号。但现在\textwidth您的表格的正确计算失败了。您必须像这样重新计算正确的表格宽度:(\textwidth-\labelwidth-\labelsep这里的“标签”是使用的项目符号)。在下面的 MWE 中,我在 commad 中显示了正确的计算\cventry,如您在生成的 pdf 屏幕截图中看到的那样。

  5. margins包裹选项geometry错误,必须是margin……

请仔细查看以下 MWE(重要的代码更改或添加的代码以 标记<=========):

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

\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[%
  scale=0.81, margin=0.5in, % <========================================= margin
  showframe                 % <=========== to visualize typing area and margins
]{geometry} 
%\cventry[addvspace]{years}{degree/job title}{institution/employer}{localization}{optional: grade/...}{optional: comment/job description}
\renewcommand*{\cventry}[7][.25em]{ % <=================================
  \begin{tabular*}{\textwidth-\labelwidth-\labelsep}{p{15cm}@{\extracolsep{\fill}}r}% <=======
      {\bfseries #4} & {\bfseries #5} \\ % #4 = {institution/employer}; #5 = {localization}
      {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\ % #3 = {degree/job title} ;#6 = {optional: comment/job description}; #2 = {years}
  \end{tabular*}\par%
  \ifx&#7&%
    \else{%
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}%  
        {\small#7} & \\
      \end{tabular*}%
    }%
  \fi%
  \par\addvspace{#1}%
}

%\cvpdentry[addvspace]{institution/employer}{localization}{optional: comment/job description}
\newcommand*{\cvpdentry}[4][.25em]{
  \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r} % <======
      {\bfseries #2} & {\bfseries #3} \\ %
  \end{tabular*}\par% <=================================================
  \ifx&#4&%
    \else{%
      \begin{tabular*}{\textwidth}{p{15cm}@{\extracolsep{\fill}}r}% <========= 
        {\small#4} & \\
      \end{tabular*}%
    }%
  \fi%
  \par\addvspace{#1}%
}

\name{John}{Doe} % <====================================================


\begin{document}
\section{Education Education Education Education Education Education 
  Education Education Education Education Education}
\subsection{Academic Academic Academic Academic Academic Academic 
  Academic Academic Academic}
\begin{itemize}

\item\cventry[0pt]                       %[spacing] <===================
{December 2012}                          %{years}
{Master of Science in Important Subject} %{degree/job title}
{Land Grant University}                  %{institution/employer}
{Universitytown, ST}                     %{localization}
{summa magna cum laude}                  %{optional: grade/...}
{If this text section is too lengthy, it will overlap with the column 
  containing the city and date(s). How do I limit its length and force 
  it to wrap prior to entering the right tabular structure?} %{optional: comment/job description}
\end{itemize}

\subsection{Professional Development}

\begin{itemize}
\item{\cvpdentry[0pt] % <===============================================
  {Premier Technological University Premier Technological University 
    Premier Technological University Premier Technological University}
  {Premier, ST}
  {Certificate of Oft-Used New Technology, Difficult Additional 
    Coursework (HS6900), Proof of Updated Skills}%
}
\end{itemize}

\end{document}

以及生成的pdf:

生成的 pdf

相关内容