如何减少 cls 文件中各部分之间的间距?

如何减少 cls 文件中各部分之间的间距?

我正在参考 Github 上的 Mcdowell CV Latex 模板来制作我的简历,但我有以下问题需要回答:

  1. 两个部分之间的空间对我来说太大了(我猜这是 LaTeX 中文章文档的默认距离) 在此处输入图片描述 所以我尝试添加
\usepackage[compact]{titlesec}         % you need this package
\titlespacing{\section}{0pt}{0pt}{0pt} % this reduces space between (sub)sections to 0pt, for example
\AtBeginDocument{%                     % this will reduce spaces between parts (above and below) of texts within a (sub)section to 0pt, for example - like between an 'eqnarray' and text
  \setlength\abovedisplayskip{0pt}
  \setlength\belowdisplayskip{0pt}}

tex文件中,但是没有起作用。然后我检查了文件mcdowellcv.cls,发现“section”没有定义间距,他cvsection自己写了一个新的“”。

我的问题是:如何调整节和小节之间的间距?

这里我包含了tex模板和cls文件代码,你也可以查看https://github.com/dnl-blkv/mcdowell-cv

mcdowellcv.cls

\ProvidesClass{mcdowellcv}[2017/06/18 v1.2.0 McDowell CV class]

% Set up the fonts according to options
\def\mainfontsize{11pt}
\def\mainfontface{Times New Roman}

\DeclareOption{calibri}{%
  \def\mainfontface{Calibri}
}

\ProcessOptions\relax

% Set font size and paper type
\LoadClass[letterpaper,\mainfontsize]{article} 

% Set document margins
\usepackage[left=0.75in,top=0.6in,right=0.75in,bottom=0.6in]{geometry} 

% Set font face
\usepackage{fontspec}
\setmainfont[SmallCapsFeatures={Renderer=Basic},
Ligatures={TeX, NoCommon, NoDiscretionary}]{\mainfontface}

% Remove paragraph indentation
\usepackage[parfill]{parskip} 

% Required for boldface (\bf and \bfseries) tabular columns
\usepackage{array} 

% Required for ifthenelse statements
\usepackage{etoolbox} 

% Suppress page numbers
\pagestyle{empty} 

% Flexible tables
\usepackage{tabu}

% For custom margins
\usepackage{changepage}

% To customize lists
\usepackage{enumitem}
% Remove left margin from lists, suppress vertical item separation and set top 
% separation to a negative value to suppress a single parskip before lists
\setlist{leftmargin=*, noitemsep, topsep=-1\parskip}

% For adjusting spacing based on the platform used
\usepackage{ifthen}
\usepackage{ifplatform}

% For spcaed small caps
\usepackage{microtype}

\DeclareMicrotypeSet*{smallcapsi} { 
    encoding = {OT1,T1,T2A,LY1,OT4,QX,T5,TS1,EU1,EU2},
    shape = {sc*,si,scit}
}

%--------------------------------------------------------------------------------
%                                    Constants                                  -
%--------------------------------------------------------------------------------

\ifthenelse{\equal{\platformname}{\notwindowsname}}{
    \def\namespaceskip{0.575em}
    \def\afterheaderspace{1.1pt}
    \def\beforesectionheaderspace{5pt}
    \def\sectionheadermargin{6pt}
    \def\beforesectionheaderhrulespace{2.85pt}
    \def\sectionheaderhrlueheight{0.518pt}
    \def\aftersectionheaderspace{-5.8pt}
    \def\aftersinglelinesubsectionheaderspace{-20.25pt}
    \def\afterdoublelinesubsectionheaderspace{-11.75pt}
    \def\aftermultilinesubsectionheaderspace{-7.75pt}
    \def\afteremptysubsectionheaderspace{1.25pt}
    \def\subsectionmargin{9pt}
    \def\aftersubsectionspace{2.1pt}
}{
    \def\namespaceskip{0.4em}
    \def\afterheaderspace{3pt}
    \def\beforesectionheaderspace{4.75pt}
    \def\sectionheadermargin{6pt}
    \def\beforesectionheaderhrulespace{3pt}
    \def\sectionheaderhrlueheight{0.5pt}
    \def\aftersectionheaderspace{-4pt}
    \def\aftersinglelinesubsectionheaderspace{-18.5pt}
    \def\afterdoublelinesubsectionheaderspace{-10pt}
    \def\aftermultilinesubsectionheaderspace{-6pt}
    \def\afteremptysubsectionheaderspace{3pt}
    \def\subsectionmargin{9pt}
    \def\aftersubsectionspace{4pt}
}

%--------------------------------------------------------------------------------
%                            Header Setup and Printing                          -
%--------------------------------------------------------------------------------

% Address
\makeatletter

\newcommand\address[1]{\def\@address{#1}}
\address{}

\newcommand\printaddress{
    \small{\@address}
}

\makeatother

% Name
\makeatletter

\newcommand\name[1]{\def\@name{#1}}
\name{}

\newcommand\printname{
    \typeout {kokoko}
    \typeout \spaceskip
    \spaceskip \namespaceskip \relax
    \textbf{\LARGE\textls[110]{\textsc{\@name}}}
}

\makeatother

% Contacts
\makeatletter

\newcommand\contacts[1]{\def\@contacts{#1}}
\contacts{}

\newcommand\printcontacts{
    \small{\@contacts}
}

\makeatother

\makeatletter
\newcommand\makeheader{
    \begin{center}
        \begin{tabu} to 1\textwidth { X[l,m] X[2,c,m] X[r,m] }
            \printaddress & \printname & \printcontacts \\
        \end{tabu}  
    \end{center}
    \vspace*{\afterheaderspace}
}
\makeatother

%--------------------------------------------------------------------------------
%                            Sections and Subsections                           -
%--------------------------------------------------------------------------------

% Print a section header
\makeatletter
\newenvironment{cvsection}[1]{
    \vspace*{\beforesectionheaderspace}
    % Set text margins to equal \tabcolsep (6pt by default)
    \begin{adjustwidth}{\sectionheadermargin}{\sectionheadermargin}
        \textsc{\textbf{#1}}
    \end{adjustwidth}
    \vspace*{\beforesectionheaderhrulespace}
    \hrule height \sectionheaderhrlueheight
    \vspace*{\aftersectionheaderspace}
}{}
\makeatother

% Print a subsection
\makeatletter
% Define toggles checking if titles were defined
\newtoggle{lefttitledefined}
\newtoggle{centertitledefined}
\newtoggle{righttitledefined}

\newenvironment{cvsubsection}[4][1]{
    \notblank{#2}{\toggletrue{lefttitledefined}}{}
    \notblank{#3}{\toggletrue{centertitledefined}}{}
    \notblank{#4}{\toggletrue{righttitledefined}}{}
    \ifboolexpr{togl {lefttitledefined} or togl {centertitledefined} or togl {righttitledefined}}{
        \begin{tabu} to 1\textwidth { X[l,p] X[c,p] X[r,p] }
            \textbf{#2} & \textbf{#3} & \textbf{#4} \\
        \end{tabu}
        % Add space according to the specidied number of lines
        \ifnumcomp{#1}{=}{1}{\vspace*{\aftersinglelinesubsectionheaderspace}}{
            \ifnumcomp{#1}{=}{2}{\vspace*{\afterdoublelinesubsectionheaderspace}}{
                \vspace*{\aftermultilinesubsectionheaderspace}
            }
        }
    }{
        \vspace*{\afteremptysubsectionheaderspace}
    }
    \togglefalse{lefttitledefined}
    \togglefalse{centertitledefined}
    \togglefalse{righttitledefined}
    \begin{adjustwidth}{\subsectionmargin}{\subsectionmargin}
}
{
    \end{adjustwidth}
    \vspace*{\aftersubsectionspace}
}
\makeatother

文本模板

% The font could be set to Windows-specific Calibri by using the 'calibri' option
\documentclass[]{mcdowellcv}

% For mathematical symbols
\usepackage{amsmath}

% Set applicant's personal data for header
\name{Gayle L. McDowell}
\address{123 Spruce St, Apt 35 \linebreak Philadelphia PA 19103}
\contacts{(555) 555-1212 \linebreak [email protected]}

\begin{document}

    % Print the header
    \makeheader

    % Print the content
    \begin{cvsection}{Employment}
        \begin{cvsubsection}{Software Engineer, Intern}{Apple Computer}{Summer 2004}
            iChat AV            
            \begin{itemize}
                \item Reduced time to render the user’s buddy list by 75\% by implementing prediction algorithm.
                \item Implemented iChat integration with OS X Spotlight Search by creating tool which extracts metadata from saved chat transcripts and provides metadata to a system-wide search database.
                \item Redesigned chat file format and implemented backwards compatibility for search.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Lead Student Ambassador}{Microsoft Corporation}{Fall 2003 -- Spring 2005}  
            \begin{itemize}
                \item Promoted to Lead Student Ambassador in Fall 2004; supervised 10 -- 15 Student Ambassadors.
                \item Created and taught Computer Science course, CSE 099: Software Design and Development.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Head Teaching Assistant}{University of Pennsylvania}{Fall 2001 -- Spring 2005}     
            \begin{itemize}
                \item Courses: Advanced Java III, Software Engineering, Mathematical Foundations of Computer Science I \& II.
                \item Promoted to Head TA in Fall 2004; led weekly meetings and supervised four other TAs.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Software Design Engineer, Intern}{Microsoft Corporation}{Summers 2001 -- 2003}
            Visual Studio Core (Summer 2003)        
            \begin{itemize}
                \item Implemented a user interface for the VS open file switcher (ctrl-tab) and extended it to tool windows.
                \item Created service to provide gradient across VS and VS add-ins. Optimized service via caching.
            \end{itemize}
            Programmer Productivity Research Center (Summers 2001, 2002)
            \begin{itemize}
                \item Built app to compute similarity of all methods in a code base; reduced time from $O(n^2)$ to $O(n\ log\ n)$. 
                \item Created test case generation tool which creates random XML docs from XML Schema.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Education}
        \begin{cvsubsection}{Philadelphia, PA}{University of Pennsylvania}{Fall 2000 -- May 2005}
            \begin{itemize}
                \item M.S.E. in Computer and Information Science, May 2005. GPA: 3.6
                \item B.S.E. in Computer Science Engineering with Minor in Mathematics, May 2005.  In-major GPA: 3.4.
                \item Graduate Coursework: Software Foundations; Computer Architecture; Algorithms; Artificial Intelligence; Comparison of Learning Algorithms; Computational Theory.
                \item Undergraduate Coursework: Operating Systems; Databases; Algorithms; Programming Languages; Comp. Architecture; Engineering Entrepreneurship; Calculus III.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Technical Experience}
        \begin{cvsubsection}{Projects}{}{}
            \begin{itemize}
                \item \textbf{Multi-User Drawing Tool} (2004). Electronic classroom where multiple users can view and simultaneously draw on a “chalkboard” with each person’s edits synchronized.  C++, MFC
                \item \textbf{Synchronized Calendar} (2003 – 2004). Desktop calendar with globally shared and synchronized calendars, allowing users to schedule meetings with other users.  C\#.NET, SQL, XML
                \item \textbf{Operating System} (2002).  UNIX-style OS with scheduler, file system, text editor and calculator. C
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Additional Experience and Awards}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item \textbf{Instructor (2003 – 2005):} Taught two full-credit Computer Science courses; average ratings of 4.8 out of 5.0.
                \item \textbf{Third Prize, Senior Design Projects:} Awarded 3rd prize for Synchronized Calendar project, out of 100 projects.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Languages and Technologies}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
                \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

\end{document}

答案1

\cvsection在类文件中你可以找到例如这样的环境定义:

\newenvironment{cvsection}[1]{
    \vspace*{\beforesectionheaderspace} % <=======================================
    % Set text margins to equal \tabcolsep (6pt by default)
    \begin{adjustwidth}{\sectionheadermargin}{\sectionheadermargin}
        \textsc{\textbf{#1}}
    \end{adjustwidth}
    \vspace*{\beforesectionheaderhrulespace}
    \hrule height \sectionheaderhrlueheight
    \vspace*{\aftersectionheaderspace} 
}{}

\beforesectionheaderspace以及这样的定义:

\def\beforesectionheaderspace{5pt}

对于环境cvsubsection和 的定义也是如此\aftersubsectionspace。根据您的需要使用新值(我0pt为每个值选择了新值,但您也可以使用负值...)...

因此您只需要在序言中为它们定义另一个值,例如:

% \vspace*{\beforesectionheaderspace}
\def\beforesectionheaderspace{0pt} % <================================== 5pt
% \vspace*{\aftersubsectionspace}
\def\aftersubsectionspace{0pt} % <====================================== 4pt

完整的 MWE

%% The MIT License (MIT)
%%
%% Copyright (c) 2015 Daniil Belyakov
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
%% in the Software without restriction, including without limitation the rights
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the Software is
%% furnished to do so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in all
%% copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
%% SOFTWARE.

% The font could be set to Windows-specific Calibri by using the 'calibri' option
\documentclass[]{mcdowellcv}

% For mathematical symbols
\usepackage{amsmath}

% Set applicant's personal data for header
\name{Gayle L. McDowell}
\address{123 Spruce St, Apt 35 \linebreak Philadelphia PA 19103}
\contacts{(555) 555-1212 \linebreak [email protected]}

% \vspace*{\beforesectionheaderspace}
\def\beforesectionheaderspace{0pt} % <================================== 5pt
% \vspace*{\aftersubsectionspace}
\def\aftersubsectionspace{0pt} % <====================================== 4pt


\begin{document}

    % Print the header
    \makeheader

    % Print the content
    \begin{cvsection}{Employment}
        \begin{cvsubsection}{Software Engineer, Intern}{Apple Computer}{Summer 2004}
            iChat AV            
            \begin{itemize}
                \item Reduced time to render the user’s buddy list by 75\% by implementing prediction algorithm.
                \item Implemented iChat integration with OS X Spotlight Search by creating tool which extracts metadata from saved chat transcripts and provides metadata to a system-wide search database.
                \item Redesigned chat file format and implemented backwards compatibility for search.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Lead Student Ambassador}{Microsoft Corporation}{Fall 2003 -- Spring 2005}  
            \begin{itemize}
                \item Promoted to Lead Student Ambassador in Fall 2004; supervised 10 -- 15 Student Ambassadors.
                \item Created and taught Computer Science course, CSE 099: Software Design and Development.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Head Teaching Assistant}{University of Pennsylvania}{Fall 2001 -- Spring 2005}     
            \begin{itemize}
                \item Courses: Advanced Java III, Software Engineering, Mathematical Foundations of Computer Science I \& II.
                \item Promoted to Head TA in Fall 2004; led weekly meetings and supervised four other TAs.
            \end{itemize}
        \end{cvsubsection}

        \begin{cvsubsection}{Software Design Engineer, Intern}{Microsoft Corporation}{Summers 2001 -- 2003}
            Visual Studio Core (Summer 2003)        
            \begin{itemize}
                \item Implemented a user interface for the VS open file switcher (ctrl-tab) and extended it to tool windows.
                \item Created service to provide gradient across VS and VS add-ins. Optimized service via caching.
            \end{itemize}
            Programmer Productivity Research Center (Summers 2001, 2002)
            \begin{itemize}
                \item Built app to compute similarity of all methods in a code base; reduced time from $O(n^2)$ to $O(n\ log\ n)$. 
                \item Created test case generation tool which creates random XML docs from XML Schema.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Education}
        \begin{cvsubsection}{Philadelphia, PA}{University of Pennsylvania}{Fall 2000 -- May 2005}
            \begin{itemize}
                \item M.S.E. in Computer and Information Science, May 2005. GPA: 3.6
                \item B.S.E. in Computer Science Engineering with Minor in Mathematics, May 2005.  In-major GPA: 3.4.
                \item Graduate Coursework: Software Foundations; Computer Architecture; Algorithms; Artificial Intelligence; Comparison of Learning Algorithms; Computational Theory.
                \item Undergraduate Coursework: Operating Systems; Databases; Algorithms; Programming Languages; Comp. Architecture; Engineering Entrepreneurship; Calculus III.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Technical Experience}
        \begin{cvsubsection}{Projects}{}{}
            \begin{itemize}
                \item \textbf{Multi-User Drawing Tool} (2004). Electronic classroom where multiple users can view and simultaneously draw on a “chalkboard” with each person’s edits synchronized.  C++, MFC
                \item \textbf{Synchronized Calendar} (2003 – 2004). Desktop calendar with globally shared and synchronized calendars, allowing users to schedule meetings with other users.  C\#.NET, SQL, XML
                \item \textbf{Operating System} (2002).  UNIX-style OS with scheduler, file system, text editor and calculator. C
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Additional Experience and Awards}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item \textbf{Instructor (2003 – 2005):} Taught two full-credit Computer Science courses; average ratings of 4.8 out of 5.0.
                \item \textbf{Third Prize, Senior Design Projects:} Awarded 3rd prize for Synchronized Calendar project, out of 100 projects.
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

    \begin{cvsection}{Languages and Technologies}
        \begin{cvsubsection}{}{}{}  
            \begin{itemize}
                \item C++; C; Java; Objective-C; C\#.NET; SQL; JavaScript; XSLT; XML (XSD) Schema 
                \item Visual Studio; Microsoft SQL Server; Eclipse; XCode; Interface Builder
            \end{itemize}
        \end{cvsubsection}
    \end{cvsection}

\end{document}

然后会给出以下结果 pdf:

生成第一页

相关内容