在尝试使用该titlesec
包格式化小节标题时,我遇到了一些麻烦。我需要格式化小节标题,以便使用命令设置的值缩进\setlength{\parindent}{[some length]}
,其中[some length]
是任意长度。
更具体地说,我想使用与此类似的东西:
...
\usepackage{titlesec}
\titleformat{\subsection}[runin]{}{}{}{}[.]
\titlespacing{\subsection}{0em}{0ex}{1em}
...
\subsection{[subsection title]} Subsection text ...
为了生成如下所示的小节标题:
[parindent-length space][subsection title]. Subsection text that is
not indented just like you would expect in a regular paragraph
答案1
以下 MWE 将展示如何\subsection
通过 缩进内容\parindent
。
\documentclass{article}
\usepackage{lipsum}
\usepackage{titlesec}
\titleformat{\subsection}[runin]{\itshape}{\thesubsection.}{3pt}{\space}[.]
\titlespacing*{\subsection}{\parindent}{1ex}{1em}
\setlength{\parindent}{4pc} % exaggerated for the example
\begin{document}
\section{Section Title}
\lipsum[1-2]
\subsection{Subsection Title}
Subsection text goes here.
Subsection text goes here.
Subsection text goes here.
Subsection text goes here.
Subsection text goes here.
\lipsum[1-2]
\end{document}
您可以看到的第二个参数\titlespacing*
被设置为\parindent
。
如果没有设置\parindent
(上面的代码只是为了强调缩进),你会得到