我正在为会议模板编写 cls 文件。
我喜欢控制节、小节、小子节等之前和之后的填充,我通过以下定义来实现:
\renewcommand{\section}{%
\@startsection{section}{1}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsection}{%
\@startsection{subsection}{2}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}{3}{0pt}{12pt}{3pt}{\normalsize\itshape}}%
这一切都很好,直到我尝试使用以下命令将缩进的段落更改为非缩进的段落,并在段落之间跳过基线:
\RequirePackage{parskip}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
但这会导致我的部分出现额外的意外填充。
关于如何仅使用 parskip 影响文本段落,有什么想法吗?
MWE 代码
纸张.tex
\documentclass{mwe}
\usepackage[utf8]{inputenc}
\title{A title}
\author{A name}
\begin{document}
\maketitle
\section{Level 1}
An important text.
Some more important text.
\subsection{Level 2}
An important text.
Some more important text.t.
\subsubsection{Level 3}
An important text.
Some more important text.
\end{document}
韋萊斯
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2017/03/03 MWE paper class]
\DeclareOption{10pt}{\OptionNotUsed}
\DeclareOption{12pt}{\OptionNotUsed}
\DeclareOption{twocolumn}{\OptionNotUsed}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[11pt,a4paper]{article}
\RequirePackage{parskip}
\renewcommand{\section}{%
\@startsection{section}{1}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsection}{%
\@startsection{subsection}{2}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}{3}{0pt}{12pt}{3pt}{\normalsize\itshape}}%
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\AtBeginDocument{%
\pagestyle{plain}
}
\endinput
答案1
我不认为标题前的空格应该小于\parskip
,因此以下内容不会减少小于 的标题前的空格\parskip
。然而,它消除了\parskip
标题后的空格:
\RequirePackage{filecontents}
\begin{filecontents*}{mwe.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2017/03/03 MWE paper class]
\DeclareOption{10pt}{\OptionNotUsed}
\DeclareOption{12pt}{\OptionNotUsed}
\DeclareOption{twocolumn}{\OptionNotUsed}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\LoadClass[11pt,a4paper]{article}
\RequirePackage{parskip}
\setlength{\parskip}{\baselineskip}% Change parskip's default
% Eliminate \parskip after section headings
\RequirePackage{xpatch}
\xpatchcmd{\@xsect}{\vskip \@tempskipa}{\vskip
\dimexpr\@tempskipa-\parskip\relax}{}{}
% Set only vertical spaces > \parskip before section headings
\xpatchcmd{\@startsection}{\addvspace\@tempskipa}{%
\ifdim \@tempskipa>\parskip
\addvspace{\dimexpr \@tempskipa-\parskip}%
\fi
}{}{}
\renewcommand{\section}{%
\@startsection{section}{1}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsection}{%
\@startsection{subsection}{2}{0pt}{12pt}{3pt}{\normalsize\bfseries}}%
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}{3}{0pt}{12pt}{3pt}{\normalsize\itshape}}%
\AtBeginDocument{%
\pagestyle{plain}
}
\endinput
\end{filecontents*}
\documentclass{mwe}
\usepackage[utf8]{inputenc}
\title{A title}
\author{A name}
\begin{document}
\maketitle
\section{Level 1}
An important text.
Some more important text.
\subsection{Level 2}
An important text.
Some more important text.t.
\subsubsection{Level 3}
An important text.
Some more important text.
\end{document}
警告:我永远不会使用这样的布局。它很丑陋,而且破坏了标题的意义。