Moderncv:cvitem 后的额外垂直空间

Moderncv:cvitem 后的额外垂直空间

\cvitem在下一个之后和之前产生了额外的垂直空间\section。有没有比使用 更好的方法来解决这个问题\vspace*{-6mm}?问题如下所示,位于“技能”和“语言”部分之间。

平均能量损失

梅威瑟:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic} % banking, casual, classic, empty, oldstyle options  
\moderncvcolor{blue}   % black, blue, green, grey, orange, purple, red options  
\usepackage[scale=0.85]{geometry} % default scale=0.7. height= scale * layoutheight

\firstname{John}
\familyname{Doe}
\title{R\'esum\'e}     % optional

\begin{document}
\makecvtitle
\section{Professional Experience}
    \cventry{Year--Year}{Intern}{Company}{Nowhere}{State}{
        \begin{itemize}
            \item Did something important here.
        \end{itemize}}

% problem with vertical space-------------------------------------------------
\section{Education}
    \cventry{06/11}{Bachelor of Arts \LaTeX}{University of \LaTeX}{}{\textit{4.0/4.0}}{}
%\vspace*{-6mm} %this will fix vertical spacing for \moderncvstyle{classic}, but create vertical spacing issues for other \moderncvstyle{xyz}.

% problem with vertical space -------------------------------------------------
\section{Skills}
    \cvitem[-1.2em]{}{
        \begin{itemize}
            \item \LaTeX
        \end{itemize}}
%\vspace*{-6mm} %this will fix vertical spacing for \moderncvstyle{classic}, but create vertical spacing issues for other \moderncvstyle{xyz}.

\section{Languages}
    \cvitem{}{
        \begin{itemize}
            \item TeX-speak
        \end{itemize}}
% \cvitem{}{job description text here}

\end{document}

我的问题与此类似: moderncv 中章节标题前的垂直空格 但我无法成功实施在那里找到的解决方案。

与此类似: 如何在 moderncv 中的“itemize”后删除多余的空格? 但这个答案对我来说不起作用。

答案1

在序言中添加以下几行:

\makeatletter
\@ifpackageloaded{moderncvstyleclassic}{%
\let\oldsection\section%
\renewcommand{\section}[1]{\leavevmode\unskip\vspace*{-\baselineskip}\oldsection{#1}}%
}{%
}
\makeatother

\section仅当您选择样式时才会应用重新定义,classic因此如果您想更改样式,则不会遇到任何问题。

为了获得更好的间距,现在选择包含列表-0.5em-1.2em不是\cventry

梅威瑟:

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic} % banking, casual, classic, empty, oldstyle options
\moderncvcolor{blue}   % black, blue, green, grey, orange, purple, red options
\usepackage[scale=0.85]{geometry} % default scale=0.7. height= scale * layoutheight

\firstname{John}
\familyname{Doe}
\title{R\'esum\'e}     % optional

\makeatletter
\@ifpackageloaded{moderncvstyleclassic}{%
\let\oldsection\section%
\renewcommand{\section}[1]{\leavevmode\unskip\vspace*{-\baselineskip}\oldsection{#1}}%
}{%
}
\makeatother

\begin{document}
\makecvtitle
\section{Professional Experience}
    \cventry{Year--Year}{Intern}{Company}{Nowhere}{State}{
        \begin{itemize}
            \item Did something important here.
        \end{itemize}}

% problem with vertical space-------------------------------------------------
\section{Education}
    \cventry{06/11}{Bachelor of Arts \LaTeX}{University of \LaTeX}{}{\textit{4.0/4.0}}{}
%\vspace*{-6mm} %this will fix vertical spacing for \moderncvstyle{classic}, but create vertical spacing issues for other \moderncvstyle{xyz}.

% problem with vertical space -------------------------------------------------
\section{Skills}
    \cvitem[-0.5em]{}{
        \begin{itemize}
            \item \LaTeX
        \end{itemize}}
%\vspace*{-6mm} %this will fix vertical spacing for \moderncvstyle{classic}, but create vertical spacing issues for other \moderncvstyle{xyz}.

\section{Languages}
    \cvitem[-0.5em]{}{
        \begin{itemize}
            \item TeX-speak
        \end{itemize}}
% \cvitem{}{job description text here}

\end{document} 

输出:

在此处输入图片描述

相关内容