暂时更改章节格式

暂时更改章节格式

我现在的问题是,虽然我已经弄清楚了如何控制章节和小节周围的垂直间距,但在一个章节中,我的“章节”实际上不值得提升格式。我希望使用 LaTeX 格式化它们,并使用章节编号(例如 3.1)和粗体标题,然后在同一行开始段落,就像它是一个词汇表项目一样。在 HTML 中它看起来会像这样:

<b>3.3 Profiles:</b> This worksheet contains...

我希望我应该从 titlesec 包开始。之后...有没有办法暂时重新定义\section布局(仅适用于本章),或者有没有办法将各部分重新标记为段落(或其他内容),或者其他替代方法?

答案1

以下是列表方法,使用enumerate通常为主列表级别生成单个数字(1、2、3 等)的环境。

使用此包,enumitem可以修改标签以包含章节计数器。此包为\begin{enumerate}标签添加了可选参数(还添加了许多其他选项),即\begin{enumerate}[label=xyz]

符号\arabic*用于表示当前列表编号。当前章节编号可以用 打印\thechapter(这在 LaTeX 中始终可用,在环境之外也可用,enumerate以及其他计数器等)。\thesection\thesubsection

因此,所需格式可以表示为\thechapter.\arabic*。包括粗体在内,这导致:

\begin{enumerate}[label=\textbf{\thechapter.\arabic*}]

下一步是还要为每个项目添加一个标题。据enumitem我所知,它没有提供此功能。因此,您需要编写一个小的包装器命令,该命令调用\item(生成编号标签)并在之后以粗体形式添加包装器命令的参数:

\newcommand{\itemtitle}[1]{%
\item \textbf{#1:}%
}

最后一件事是修复缩进,因为枚举列表默认是缩进的。要删除它,您可以leftmargin=*enumerate环境设置。

梅威瑟:

\documentclass{report}
\usepackage{enumitem}

\newcommand{\itemtitle}[1]{%
\item \textbf{#1:}%
}

\begin{document}
\setcounter{chapter}{2} % skip to chapter 3
\chapter{Worksheet overview}
This chapter provides all the worksheets.
\begin{enumerate}[label=\textbf{\thechapter.\arabic*}, leftmargin=*]
\itemtitle{Preliminaries} In this worksheet the basics are discussed. There are many basics so they span over multiple lines. After this you know all the basics but you don't know what comes next.
\itemtitle{What comes next} The next steps are covered in this worksheet.
\itemtitle{Profiles} This worksheet contains profiles as well as antifiles, prefiles and postfiles.
\end{enumerate}
\end{document}

结果:

在此处输入图片描述

如果您不想段落缩进,您也可以wide=0pt设置leftmargin=*

在此处输入图片描述

相关内容