如何在文本中嵌入小节标题,如下图所示?在大多数标准 latex 模板中,会有一个间隙
1.2韦伊函数域猜想
在这个部分...
我尽量避免这种情况,因为我觉得这样会让事情变得混乱。我仍然希望在章节标题前留出空隙,并在小节标题前留出一小段空白,如下图所示。
编辑:根据要求,这里有一个显示问题的最小工作示例:
\documentclass[12pt]{article}
\begin{document}
\section{Section}
Text A
\subsection{Subsection}
There are two problems with this working example: the subsection is not part of this paragraph (and the letters are not the same size as the letters here), and the gap between Text A and the subsection is too large.
\end{document}
下面是我将其通过 TeXmaker 处理后得到的图片:
我很高兴改变我正在使用的文档类别。
答案1
如果要重现图片中的输出,请使用amsart
。
\documentclass[12pt]{amsart}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{remark}[theorem]{Remark}
\begin{document}
Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.
\section{Section title}
Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.
\subsection{Subsection title}
Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.
\begin{theorem}
A theorem statement. A theorem statement. A theorem statement.
A theorem statement. A theorem statement.
\end{theorem}
\begin{remark}
A remark. A remark. A remark. A remark. A remark.
\end{remark}
Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.
\subsection{Another subsection title}
Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.
\end{document}
答案2
在article
(没有包)中,章节宏都\@startsection
在内部使用。\@startsection
采用 6 个参数来控制章节标题的外观:
\@startsection
{<sectioning name>}
{<sectioning level>}
{<horizontal indent from left>}
{<vertical skip pre>}
{<skip post>}
{<font choice>}
虽然上面的大多数参数都是不言自明的,但其中两个参数表现得有些特殊:
<vertical skip pre>
决定标题后的段落是否缩进。如果为正数或 0,则后面的段落将正常缩进;如果为负数,则将抑制缩进。无论哪种方式,都将使用此值的绝对值进行垂直跳过。<skip post>
控制标题是否显示为插入标题,如果为正数,则标题后将出现垂直跳跃,并显示标题。如果为负数或 0,则标题将为插入标题,这将是标题和同一行中的文本之间的水平跳跃。
因此,解决了这个问题后,我们现在可以重新定义\subsection
为输入标题。
\renewcommand\subsection
{%
\@startsection
{subsection}
{2}
{\z@}
{3.25ex \@plus 1ex \@minus .2ex}
{-1em}
{\normalfont\normalsize\bfseries}%
}
如果我们从级别开始进行这种格式化\subsection
,我们也应该\subsubsection
以相同的方式重新定义。进行这些重新定义的完整文档:
\documentclass[]{article}
\makeatletter
\renewcommand\subsection
{%
\@startsection
{subsection}
{2}
{\z@}
{3.25ex \@plus 1ex \@minus .2ex}
{-1em}
{\normalfont\normalsize\bfseries}%
}
\renewcommand\subsubsection
{%
\@startsection
{subsubsection}
{3}
{\z@}
{3.25ex \@plus 1ex \@minus .2ex}
{-1em}
{\normalfont\normalsize\bfseries}%
}
\makeatother
\usepackage{duckuments}
\begin{document}
\section{This is a section}\blindduck
\subsection{This is a subsection}\blindduck
\subsubsection{This is a subsubsection}\blindduck
\paragraph{This is a paragraph}\blindduck
\end{document}
答案3
使用titlesec
和article
:
\documentclass[12pt]{article}
\usepackage{titlesec}
\titleformat{\subsection}[runin]{\normalsize\bfseries}{\thesubsection}{5pt}{}
\begin{document}
\section{Section}
Text A
\subsection{Subsection}
There are two problems with this working example: the subsection is not part of this paragraph (and the letters are not the same size as the letters here), and the gap between Text A and the subsection is too large.
\end{document}