减少 \makecvtitle 下的差距

减少 \makecvtitle 下的差距

我使用 documentclassmoderncv来写简历。我的问题是如何减少 下方的垂直间隙\makecvtitle

梅威瑟:

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

\firstname{John} 
\familyname{Smith} 

\address{123 Broadway}{City, State 12345}
\mobile{(000) 111 1111}

\begin{document}

\makecvtitle 
% reducing gap between the title and section
\section{Education}
% reducing gap here
\section{Experience}

\end{document}

答案1

\makecvtitle检查文件中命令的定义后moderncvheadii.sty,你会看到,在命令的末尾添加了一个空格2.5em。与其更改,\makecvtitle不如添加命令\vspace{-2.5em}来删除这个空格(我不要建议这样做!)。

两个部分之间的间隙在命令中定义\section(参见两种改变间隙的可能性,用 标记,对于第一种可能性,我通过仅添加而不是 来<======减小间隙):.5ex2.5ex

\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{.5ex}% <==================== change 2.5ex for your needs
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
  %            ^^^^^^^^^^^^^^  <========= change value 1ex for your needs 

在下面的 MWE 中我们需要使用\makeatletter\makeatother因为上面的定义使用了@

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

\moderncvstyle{casual} % head 2, body 1, foot 1

\makeatletter
\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{.5ex}% <==================== change 2.5ex for your needs
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
  %            ^^^^^^^^^^^^^^  change value 1ex for your needs
\makeatother


\firstname{John} 
\familyname{Smith} 

\address{123 Broadway}{City, State 12345}
\mobile{(000) 111 1111}


\begin{document}

\makecvtitle 
% reducing gap between the title and section
\vspace{-2.5em} % 1.25em 2.5em <====================================
\section{Education}
% reducing gap here
\cventry{year--year}{Degree-2}{Institution-3}{City-4}{\textit{Grade}-5}{Description-6}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\section{Experience}
\section{Example}

\end{document}

生成以下 pdf 文件:

生成的 pdf

相关内容