我有一个简单的文档,主要由一些部分(不是乳胶部分)组成,其中包含一个表格,后面跟着一些逐项列出的项目,以及它们之间的一些 v 空间。
我发现要让文档按我想要的方式显示,我必须手动设置这些“部分”之间的 vspace,通常是在不同的设置下。
以下是一个例子:
\documentclass[letterpaper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\RequirePackage{fix-cm}
\usepackage{paralist}
\usepackage{fancyhdr}
\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%
\usepackage[hyphenbreaks]{breakurl}
\usepackage[hyphens]{url}
\usepackage{etoolbox}
\usepackage[table,RGB]{xcolor}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\usepackage{booktabs}
\usepackage[
top = 1.10cm,
bottom = 1.25cm,
left = 1.4cm,
right = 1.4cm]{geometry}
\usepackage{titlesec}
\makeatletter
\newcommand\semilarge{\@setfontsize\semiLarge{12.22}{15.38}}
\newcommand\semiLarge{\@setfontsize\semiLarge{13.22}{17.38}}
\makeatother
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\cfoot{}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}{}[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section{0pt}{1pt plus 4pt minus 2pt}{-3pt plus 2pt minus 2pt}
\begin{document}
\sloppy
\section*{Section heading 1}
\large{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. }
\section*{Section heading 2}
\vspace{2mm}
\begin{tabular}{@{}p{14.8cm} p{4cm}}
\textbf{Word - Phrase} & 08/2015 - 07/2016
\end{tabular}
\vspace{-3.8mm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\vspace{0.7mm}
\kern-\parskip\begin{compactitem}\setlength{\itemsep}{0.7mm}
\item[--] Lorem ipsum dolor sit amet, consectetur adipiscing elit
\item[--] Lorem ipsum dolor sit amet, consectetur adipiscing elit
\end{compactitem}\kern-\parskip
\vspace{2mm}
\begin{tabular}{@{}p{14.8cm} p{4cm}}
\textbf{Word - Phrase} & 08/2015 - 07/2016
\end{tabular}
\vspace{-3.8mm}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\vspace{1.5mm}
\kern-\parskip\begin{compactitem}\setlength{\itemsep}{1mm}
\item[--] dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur ex ea commodo consequat.
\item[--] laboris nisi ut aliquip ex ea aliquip ex ea commodo consequat.
\item[--] eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\end{compactitem}\kern-\parskip
\end{document}
在第二个“部分”中,我列出的项目和表格之间的垂直空间比上一节中的要大一倍多。其他时候,我还必须调整表格前后的垂直空间,以使我的文档“美观地”显示。
我确信这不是解决这个问题的正确方法。
有没有办法在文档开始处设置“部分”的间距,而不必在整个文档中手动调整它,并且每当我所做的更改增加表格或逐项项目的大小时?
答案1
您可能需要调整间距。每次发现需要负间距时,请休息一下:一定出了问题。
\documentclass[letterpaper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage[table,RGB]{xcolor}
\usepackage{booktabs}
\usepackage[
top = 1.10cm,
bottom = 1.25cm,
left = 1.4cm,
right = 1.4cm,
headheight=13.6pt,
]{geometry}
\usepackage{titlesec}
\usepackage{parskip}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\pagestyle{fancy}
\cfoot{}
\renewcommand{\headrulewidth}{0pt}
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\newcommand{\period}[2]{\par\makebox[\textwidth][s]{\mbox{\bfseries #1}\hfill\mbox{#2}}\par}
\newenvironment{myitemize}{\begin{itemize}[nosep,label=--]}{\end{itemize}}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}
{}
[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section
{0pt}
{1pt plus 4pt minus 2pt}
{3pt plus 2pt minus 2pt}
\begin{document}
\sloppy
\section*{Section heading 1}
{\large Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur.\par}
\section*{Section heading 2}
\period{Word -- Phrase}{08/2015 - 07/2016}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
\begin{myitemize}\setlength{\itemsep}{0.7mm}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit
\end{myitemize}
\period{Word - Phrase}{08/2015 - 07/2016}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\begin{myitemize}\setlength{\itemsep}{1mm}
\item dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur
ex ea commodo consequat.
\item laboris nisi ut aliquip ex ea aliquip ex ea commodo consequat.
\item eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\end{myitemize}
\end{document}
添加
在原作者的抱怨之后,我添加了一个新版本,当然使用了更简洁的输入法,这样我们就可以将其与原始输出进行比较。可以进行更多自定义,而且更容易,因为人们只需处理定义,而不是手动添加空格并猜测输出。
\documentclass[letterpaper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage[table,RGB]{xcolor}
\usepackage{booktabs}
\usepackage[
top = 1.10cm,
bottom = 1.25cm,
left = 1.4cm,
right = 1.4cm,
headheight=13.6pt,
]{geometry}
\usepackage{titlesec}
\definecolor{darkjunglegreen}{rgb}{0.0, 0.26, 0.15}
\pagestyle{fancy}
\cfoot{}
\renewcommand{\headrulewidth}{0pt}
\newcommand{\greenuline}[1]{{\color{darkjunglegreen}\uline{{\color{black}#1}}}}
\newcommand{\period}[2]{%
\par\addvspace{\medskipamount}%
\makebox[\textwidth][s]{\mbox{\bfseries #1}\hfill\mbox{#2}}%
\par\addvspace{\medskipamount}%
}
\newenvironment{myitemize}
{%
\begin{itemize}[noitemsep,label=--,topsep=\smallskipamount]%
}
{\end{itemize}}
\newenvironment{largetext}
{\par\addvspace{\medskipamount}\large}
{\par\addvspace{\smallskipamount}}
\setlength{\parindent}{0pt}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection}
{1em}
{}
[\color{darkjunglegreen}{\titlerule[2pt]}]
\titlespacing\section
{0pt}
{\baselineskip}
{3pt plus 2pt minus 2pt}
\begin{document}
\sloppy
\section*{Section heading 1}
\begin{largetext}
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur.
\end{largetext}
\section*{Section heading 2}
\period{Word -- Phrase}{08/2015 - 07/2016}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
\begin{myitemize}\setlength{\itemsep}{0.7mm}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit
\end{myitemize}
\period{Word - Phrase}{08/2015 - 07/2016}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\begin{myitemize}\setlength{\itemsep}{1mm}
\item dolore eu fugiat nulla pariatur dolore eu fugiat nulla pariatur
ex ea commodo consequat.
\item laboris nisi ut aliquip ex ea aliquip ex ea commodo consequat.
\item eu fugiat nulla pariatur dolore eu fugiat nulla pariatur.
\end{myitemize}
\end{document}