moderncv 扩展 hrule

moderncv 扩展 hrule

在以下示例中,我的规则未延伸至覆盖整个文本。是否有快速的后期打包添加功能可确保部分规则延伸至右侧边距的末尾。

% ============================================
% document setup
% ============================================
\documentclass[11pt,letterpaper,sans]{moderncv}
\usepackage{enumitem}

% --------------------------------------------
% header style
% --------------------------------------------
\moderncvstyle{classic}
% style options: 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{blue}

% --------------------------------------------
% header details
% --------------------------------------------
\usepackage{import}
\name{John}{Smith}
\address{1234 Main Street}{Chicago, IL}{12345}
\phone[fixed]{+1 (123) 456-7899}
\homepage{https://github.com/john-smith}

% ============================================
% CV content
% ============================================

% --------------------------------------------
% body style
% --------------------------------------------
\moderncvstyle{banking}
% style options: 'casual' (default), 'classic', 'oldstyle' and 'banking'

% ++++++++++++++++++++++++++++++++++++++++++++
% begin
% ++++++++++++++++++++++++++++++++++++++++++++
\begin{document}
\makecvtitle

% --------------------------------------------
\section{Experience}
% --------------------------------------------
\begin{itemize}
\item[]{
\cventry{June 2017 -- September 2017} % date
{Employee} % role
{Company} % company
{City, State} % city
{important} % role title
{\begin{itemize}% main text
\item abcdefg
\item abcdefg
\item abcdefg
\end{itemize}}}

\item[]{
\cventry{June 2017 -- September 2017} % date
{Employee} % role
{Company} % company
{City, State} % city
{important} % role title
{\begin{itemize}% main text
\item abcdefg
\item abcdefg
\item abcdefg
\end{itemize}}}
\end{itemize}

% ++++++++++++++++++++++++++++++++++++++++++++
% end
% ++++++++++++++++++++++++++++++++++++++++++++
\end{document}

或者,我怎样才能干净地编辑源代码中的一行moderncvbodyi.sty来调整\hrule

答案1

banking类的样式moderncv具有特殊的布局,它基于命令的使用\cventry 没有被插入到itemize环境中。

因此它的定义如下:

\renewcommand*{\cventry}[7][.25em]{
  \begin{tabular*}{\maincolumnwidth}{l@{\extracolsep{\fill}}r}% <============
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\maincolumnwidth}% <====================================
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

itemize插入到先前计算的长度\maincolumnwidth太长的环境中。

您可以省略使用环境itemize或必须定义自己的命令\mycventry(我改为\maincolumnwidth\linewidth

\newcommand*{\mycventry}[7][.25em]{
  \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}% <=============
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\linewidth}% <=====================================
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

使用以下 MWE(首先我使用了您的方式,其次我使用了通常的方式\cventry然后\mycventry):

% ============================================
% document setup
% ============================================
\documentclass[11pt,letterpaper,sans]{moderncv}
\usepackage{enumitem}


\moderncvstyle{banking}
% style options: 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{blue}

\usepackage{showframe}

\newcommand*{\mycventry}[7][.25em]{
  \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}% <=============
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\linewidth}% <===========================
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

% --------------------------------------------
% header details
% --------------------------------------------
\usepackage{import}
\name{John}{Smith}
\address{1234 Main Street}{Chicago, IL}{12345}
\phone[fixed]{+1 (123) 456-7899}
\homepage{https://github.com/john-smith}

% ============================================
% CV content
% ============================================


% ++++++++++++++++++++++++++++++++++++++++++++
% begin
% ++++++++++++++++++++++++++++++++++++++++++++
\begin{document}
\makecvtitle

% --------------------------------------------
\section{Experience}
% --------------------------------------------
\begin{itemize}
\item[]
  \cventry{June 2017 -- September 2017} % date
  {Employee} % role
  {Company} % company
  {City, State} % city
  {important} % role title
  {\begin{itemize}% main text
     \item abcdefg
     \item abcdefg
     \item abcdefg
   \end{itemize}}

\item[]
\mycventry{June 2017 -- September 2017} % date
{Employee} % role
{Company} % company
{City, State} % city
{important} % role title
{\begin{itemize}% main text
\item abcdefg
\item abcdefg
\item abcdefg
\end{itemize}}
\end{itemize}

\section{Experience}
\cventry{June 2017 -- September 2017} % date
{Employee} % role
{Company} % company
{City, State} % city
{important} % role title
{\begin{itemize}% main text
\item abcdefg
\item abcdefg
\item abcdefg
\end{itemize}}

\mycventry{June 2017 -- September 2017} % date
{Employee} % role
{Company} % company
{City, State} % city
{important} % role title
{\begin{itemize}% main text
\item abcdefg
\item abcdefg
\item abcdefg
\end{itemize}}

% ++++++++++++++++++++++++++++++++++++++++++++
% end
% ++++++++++++++++++++++++++++++++++++++++++++
\end{document}

得到结果:

生成的 pdf

答案2

作为对已接受的优秀答案的后续跟进,我还使用了以下内容来确保其中项目的行溢出\mycvenrty能够适当结束:

\newcommand*{\mycventry}[7][.25em]{
  \begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}% <============= (original edit)
    {\bfseries #4} & {\bfseries #5}\\%
    {\itshape #3\ifthenelse{\equal{#6}{}}{}{, #6}} & {\itshape #2}\\%
  \end{tabular*}%
  \ifx&#7&%
  \else{\\%
    \begin{minipage}{\linewidth}% <============= (new edit)
      \small#7%
    \end{minipage}}\fi%
  \par\addvspace{#1}}

相关内容