使用 titlesec 在各节之间设置间距

使用 titlesec 在各节之间设置间距

在我的 LyX 序言中(尽管我不认为这与 LyX 相关)我有以下内容:

\titleformat{\paragraph}[runin]
{\normalfont\bfseries\scshape}
{\theparagraph}{1em}{}[. \ ]
\titlespacing{\paragraph}{0pt}{10pt}{0pt}

\titleformat{\subparagraph}
{\normalfont}
{\thesubparagraph}{.5em}{}
\titlespacing{\subparagraph}{10pt}{8pt}{0pt}

在通常的文本块之后,段落环境会按预期放置 10pt 空间;但是,在分段, 它不是。

我错过了什么?

在此处输入图片描述

编辑:导出的 LyX 代码:

\documentclass[oneside,english]{book}
\usepackage{libertine-type1}
\usepackage{helvet}
\usepackage{beramono}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[paperwidth=36pc,paperheight=54pc]{geometry}
\geometry{verbose,tmargin=6pc,bmargin=9pc,lmargin=6pc,rmargin=6pc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsthm}
\usepackage{amsmath}

\makeatletter
\numberwithin{equation}{section}
\numberwithin{figure}{section}

\usepackage{fmtcount}

\usepackage[tracking=false]{microtype}

\usepackage{xcolor}
\usepackage{titlesec}

\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\normalfont\color{gray}}
{\normalsize\MakeUppercase{\textls[400]{\chaptertitlename}} \textls[400]{\NUMBERstring{chapter}}}
{0pt}
{\vspace{1pt}%
\LARGE\scshape\color{darkgray}}



\titleformat{\paragraph}[runin]
{\normalfont\bfseries\scshape}
{\theparagraph}{1em}{}[. \ ]
\titlespacing{\paragraph}{0pt}{10pt}{0pt}


\titleformat{\subparagraph}
{\normalfont}
{\thesubparagraph}{.5em}{}
\titlespacing{\subparagraph}{10pt}{10pt}{4pt}

\AtBeginDocument{
  \def\labelitemi{\(\cdot\)}
}

\makeatother

\usepackage{babel}
\begin{document}

\title{Titlesec Problem}

\maketitle

\chapter{Titlesec Spacing}


\paragraph*{Philosophy}

Game before slam. Always. Until it is settled in which strain we expect
to play, control-bidding does not apply.


\paragraph*{Paragraph}

Lorem ipsum dolor sit amet, rebum laudem fabulas has ne. An vix oratio
adipisci nominati. Mea et tale quaeque appareat, te nam viris congue,
ex nonumes reformidans per. Ea mei graeco electram, in vix sumo liber
graecis. Aliquip intellegat an pri, no usu tritani legendos.


\paragraph*{Another Paragraph}

Tation mollis prodesset has at. Iudico patrioque mei no, sed at solum
labore impetus. Mel virtute singulis ea, nec ut utinam iuvaret ancillae,
vix consetetur referrentur ei. Ut mei legere omittam imperdiet, quod
simul cum eu, vix justo blandit ut.

Ei sit modus aperiam persequeris, ei viris veritus cum. Cibo nominati
ne quo. Viris integre ut per. Ne assentior vituperatoribus usu. Eam
nullam numquam te.


\subparagraph*{(1) Subparagraph}


\subparagraph*{(2) Another subparagraph}


\paragraph*{Paragraph}

Dicit dolores torquatos eos in. Vel labitur abhorreant ne. Ei vis
harum dolore, eam ea altera nusquam mediocritatem. Nostrud senserit
voluptatum cum ea, vix ei expetendis scriptorem.

Ea viderer oblique neglegentur nec. Sea saepe laboramus honestatis
ex, tamquam contentiones eu qui. Augue electram periculis eu cum,
in pri nobis verterem. Mel te falli dictas. Et splendide quaerendum
vel, aeque ludus labores ne quo, option intellegat duo ei. Posse inciderint
nam te.
\end{document}

答案1

runin我正在扩展@user11232 的回答:该问题已通过在格式部分中指定可选参数得到解决subparagraph

\titleformat{\subparagraph}[runin]
{\normalfont}
{\thesubparagraph}{.5em}{}
\titlespacing{\subparagraph}{10pt}{10pt}{4pt}

这可确保此类标题的格式和间距正确subparagraph。默认选项的间距不同,因为通常设置为,block这适用于居中标题

在此处输入图片描述

相关内容