有没有什么办法可以摆脱我的 \vspace{} 黑客攻击?

有没有什么办法可以摆脱我的 \vspace{} 黑客攻击?

我正在用 TeX 从头创建我的简历,并且遇到了多条导致格式不一致的隐形线条。

我有这个命令可以根据分隔元素创建项目符号列表:

\ExplSyntaxOn

\NewDocumentCommand{\makeitemize}{O{,} m}{
  \begin{itemize}
  \xyz_make_items:nn {#1} {#2}
  \end{itemize}
 }

\seq_new:N \l_xyz_input_seq
\cs_new_protected:Npn \xyz_make_items:nn #1 #2{
  \seq_set_split:Nnn \l_xyz_input_seq {#1} {#2}
  \seq_map_inline:Nn \l_xyz_input_seq {\item ##1}
 }

\ExplSyntaxOff

问题是,即使我已经添加了代码,但\setlist{nolistsep,leftmargin=*}我的列表下面仍然有空间,所以我不得不将其更改为:

\ExplSyntaxOn

\NewDocumentCommand{\makeitemize}{O{,} m}{
  \begin{itemize}
  \xyz_make_items:nn {#1} {#2}
  \end{itemize}
  \vspace{-2ex}% remove extra space
 }

\seq_new:N \l_xyz_input_seq
\cs_new_protected:Npn \xyz_make_items:nn #1 #2{
  \seq_set_split:Nnn \l_xyz_input_seq {#1} {#2}
  \seq_map_inline:Nn \l_xyz_input_seq {\item ##1}
 }

\ExplSyntaxOff

可编译示例:

变种

\ProvidesClass{cv}[2015/06/20 v1.0 CV class]

%----------------------------------------------------------------------------------------
%   Class and packages
%----------------------------------------------------------------------------------------

\LoadClass[10pt,a4paper]{article} % Font size and paper type

\RequirePackage[left=0.63in,top=0.5in,right=0.63in,bottom=0.5in]{geometry} % Document margins
\RequirePackage{fontspec}
\RequirePackage{relsize}
\RequirePackage{xcolor}
\RequirePackage[parfill]{parskip} % Remove paragraph indentation
\RequirePackage{titlesec}
\RequirePackage{enumitem}
\RequirePackage{xparse}
\RequirePackage{titlesec}
\RequirePackage[none]{hyphenat}
\usepackage{setspace}

%----------------------------------------------------------------------------------------
%   Metrics and fonts
%----------------------------------------------------------------------------------------

\setlist{nolistsep,leftmargin=*}

\setstretch{1.2} % for custom spacing
\pagestyle{empty} % Suppress page numbers

%----------------------------------------------------------------------------------------
%   Colours
%----------------------------------------------------------------------------------------

\definecolor{main}{HTML}{000000}
\definecolor{secondary}{HTML}{A6A6A6}

%----------------------------------------------------------------------------------------
%   Variables
%----------------------------------------------------------------------------------------

\newdimen{\defaultlinespacing}
%\setlength{\defaultlinespacing}{12.5pt}

\setlength{\headsep}{0pt}
\setlength{\topsep}{0pt}
\setlength{\parskip}{0pt}
\setlength{\partopsep}{0pt}

%----------------------------------------------------------------------------------------
%   Commands
%----------------------------------------------------------------------------------------

\DeclareRobustCommand{\smallcaps}[1]{\addfontfeature{LetterSpace=12.5}\scshape\MakeLowercase{#1}}

\ExplSyntaxOn

\NewDocumentCommand{\makeitemize}{O{,} m}{
  \begin{itemize}
  \xyz_make_items:nn {#1} {#2}
  \end{itemize}
 }

\seq_new:N \l_xyz_input_seq
\cs_new_protected:Npn \xyz_make_items:nn #1 #2{
  \seq_set_split:Nnn \l_xyz_input_seq {#1} {#2}
  \seq_map_inline:Nn \l_xyz_input_seq {\item ##1}
 }

\ExplSyntaxOff

\newcommand{\cvSection}[1]{ % name
  \section*{#1}
}

\newcommand{\cvSubsection}[5]{ % name, country, year, title, description list
 \subsection{\textbf{#1, #2} \hfill \textcolor{secondary}{#3}\\ \textit{#4}}
 \makeitemize[;]{#5}
  }

\newcommand{\cvProjectSubsection}[3]{ % name, year, description
 \subsection{\textbf{#1} \hfill \textcolor{secondary}{#2}\\ #3}
  }

\newcommand{\cvLeadershipSubsection}[2]{ % description, year
 \subsection{#1 \hfill \textcolor{secondary}{#2}}
  }

\newcommand{\cvSkillsSubsection}[2]{ % level, skills
 \textbf{#1:} #2
  }

%----------------------------------------------------------------------------------------
%   Formatting
%----------------------------------------------------------------------------------------

\titleformat{\section}         % Customise the \section command 
  {\large\bfseries}
  {}{0ex}
  {{\titlerule[0.75pt]}\\[-1ex]\smallcaps}                           % Can be used to insert code before the heading
  [\color{secondary}{\titlerule[0.25pt]}]                 % Inserts a horizontal line after the heading

\titleformat{\subsection}
  {}
  {}{0pt}
  {}

\titlespacing*{\section}
    {0pt}%   {0pt}
    {0pt}%   {6pt}
    {0pt}%   {2pt}

\titlespacing*{\subsection}
  {0pt}%{0pt}
  {0pt}%{2pt}
  {0pt}%{-4pt}

变种

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass{cv}

\begin{document}

%----------------------------------------------------------------------------------------
%   EDUCATION SECTION
%----------------------------------------------------------------------------------------

\cvSection{Education}
\cvSubsection
{University of X}{Y}{Fall 2010 -- Present}{blablabla}
{
blablabla;
blablablablablablablablabla;
blablablablablabla
}

%----------------------------------------------------------------------------------------
%   WORK EXPERIENCE SECTION
%----------------------------------------------------------------------------------------

\cvSection{Experience}
\cvSubsection{Z}{Y}{Jan 2015 -- Present}{Software Developer}
{
blablabla;
blablablablablablablablabla;
blablablablablablablablabla;
blablablablablablablablabla;
blablablablablabla
}

\end{document}

答案1

您看到的空间是由章节标题而不是列表造成的。

更改\titleformat

\titleformat{\section}         % Customise the \section command
  {\large\bfseries\vspace{-\baselineskip}}
  {}
  {0ex}
  {\hrule\smallcaps\strut}
  [\color{secondary}{\titlerule[0.25pt]}] % Inserts a horizontal line after the heading

为了树立示例,我删除了说明\setstretch{1.2}并在逐项列表后添加了一个段落,以显示间距是正常的。

我还使用 Linux Libertine 作为字体,因为默认的 Latin Modern 缺少粗体小写字母。

在此处输入图片描述

相关内容