在节或章标题前插入 \S

在节或章标题前插入 \S

我想\S在乳胶中将符号放在章节/部分/小节标题前面。(例如,类似于 Munkres 的 Topology 中的章节标题)。

我们如何尽可能简单地做到这一点以使其看起来不错,即使其\S与部分标题的计数器具有相同的大小和相似的字体样式?

答案1

这是一个不需要加载任何 (LaTeX) 包的解决方案。它通过修改低级 LaTeX 宏来工作\@seccntformat。注释掉(或注释掉)各种\newcommand指令以满足您的需要。

在下面的屏幕截图中,请注意子小节级别的编号没有以段落符号 为前缀,§因为相关\newcommand指令当前已被注释掉。

在此处输入图片描述

\documentclass{article}

\makeatletter
%% See pp. 26f. of 'The LaTeX Companion,' 2nd. ed.
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
    {\csname the#1\endcsname\quad}%      default
    {\csname #1@cntformat\endcsname}}%   individual control
\newcommand{\section@cntformat}{\S\thesection\quad}
\newcommand{\subsection@cntformat}{\S\thesubsection\quad}
%\newcommand{\subsubsection@cntformat}{\S\thesubsubsection\quad}
%\newcommand{\paragraph@cntformat}{\S\theparagraph\quad}
%\newcommand{\subparagraph@cntformat}{\S\thesubparagraph\quad}
\makeatother % changes @ back to a special character

\begin{document}
\section{A}
\subsection{AA}
\subsubsection{AAA}
\end{document} 

答案2

以下是如何使用 实现此目的的演示titlesec。请参阅包文档中的详细信息。对于标题,您可以使用易于使用的titleps包,对于目录,您titletoc可以使用来自同一包的 。

\documentclass[11pt, a4paper]{article}
\usepackage[utf8]{inputenc}%
\usepackage{fourier, erewhon}
\usepackage[svgnames]{xcolor}
\usepackage{titlesec}

\titleformat{\section}[block]{\filcenter\color{IndianRed}\scshape\bfseries\Large}{§\,\thesection.}{0.5em}{}
\titlespacing*{\section}{0pt}{8ex}{6ex}
\setcounter{section}{3}

\begin{document}

It was not a very difficult question to answer, as there was only one road through the wood, and the two finger-posts both pointed along it. ‘I’ll settle it,’ Alice said to herself, ‘when the road divides and they point different ways.’

But this did not seem likely to happen. She went on and on, a long way, but wherever the road divided there were sure to be two finger-posts pointing the same way, one marked ‘TO TWEEDLEDUM’S HOUSE’ and the other ‘TO THE HOUSE OF TWEEDLEDEE.’

‘I do believe,’ said Alice at last, ‘that they live in the same house! I wonder I never thought of that before--But I can’t stay there long. I’ll just call and say “how d’you do?” and ask them the way out of the wood. If I could only get to the Eighth Square before it gets dark!’ So she wandered on, talking to herself as she went, till, on turning a sharp corner, she came upon two fat little men, so suddenly that she could not help starting back, but in another moment she recovered herself, feeling sure that they must be.

\section{Tweedledum \& Tweedledee }

They were standing under a tree, each with an arm round the other’s neck, and Alice knew which was which in a moment, because one of them had ‘DUM’ embroidered on his collar, and the other ‘DEE.’ ‘I suppose they’ve each got “TWEEDLE” round at the back of the collar,’ she said to herself.

They stood so still that she quite forgot they were alive, and she was just looking round to see if the word “TWEEDLE” was written at the back of each collar, when she was startled by a voice coming from the one marked ‘DUM.’

‘If you think we’re wax-works,’ he said, ‘you ought to pay, you know. Wax-works weren’t made to be looked at for nothing, nohow!’

‘Contrariwise,’ added the one marked ‘DEE,’ ‘if you think we’re alive, you ought to speak.’\end{document}

在此处输入图片描述

相关内容