问题
如何从目录中排除自定义标题命令(分段命令)?请注意,我不想简单地继承\paragraph
,因为它是为额外的更深层次的分段保留的。
例子
我想创建一个名为的部分\minisec
,titlesec
即
- 编号,但不显示数字(为将来可能做出的有关编号的决定)。
- 它没有出现在目录中。
- 它低于
\paragraph
示例代码
\titleclass{\minisec}{straight}[\paragraph]
\newcounter{minisec}
\setcounter{secnumdepth}{5}
\titleformat{\minisec}[hang]{\normalsize\bfseries}{}{0pt}{#1}
\titlespacing*{\minisec}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\newcommand{\minisecautorefname}{minisec}
答案1
下面的例子解决了所有三个问题(代码包括注释):
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{hyperref}
\titleclass{\minisec}{straight}[\paragraph]
\newcounter{minisec}
% Change 0pt to a positive value once the representation for the counter has been established
\titleformat{\minisec}[hang]
{\normalsize\bfseries}{\theminisec}{0pt}{#1}
\titlespacing*{\minisec}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\newcommand{\minisecautorefname}{minisec}
% minisecs will be numebered
\setcounter{secnumdepth}{5}
% minisecs won't appear in the ToC
\setcounter{tocdepth}{4}
% Provisional empty definition for the counter representation
\renewcommand\theminisec{}
% Settings for the bookmarks and the ToC entries (change the second
% and third arguments of \@dottedtocline if minisecs should go to the ToC)
\makeatletter
\def\toclevel@minisec{5}
\def\l@minisec{\@dottedtocline{5}{3.8em}{3.2em}}
\makeatother
\begin{document}
\tableofcontents
\section{A test section}
In \autoref{sec:minitest} we have an example of
\subsection{A test subsection}
\subsubsection{A test subsubsection}
\paragraph{A test paragraph}
\minisec{A test minisec}
\label{sec:minitest}
\end{document}