latex中,如何在隐去章节序号的情况下,将章节序号现实在目录中?
时间: 2024-03-14 10:42:55 浏览: 221
在 LaTeX 中,如果需要在目录中显示章节序号,但是在正文中不显示章节序号,可以使用 `titlesec` 宏包和 `\titlecontents` 命令来实现。
具体操作步骤如下:
1. 在导言区加载 `titlesec` 和 `titletoc` 宏包。具体代码如下:
```
\usepackage{titlesec}
\usepackage{titletoc}
```
2. 使用 `\titleformat` 命令定义章节标题格式。例如,定义章节标题无编号,但是加粗和居中对齐。具体代码如下:
```
\titleformat{\chapter}[block]{\bfseries\large\filcenter}{}{0em}{}
```
3. 使用 `\titlecontents` 命令定义目录格式。例如,定义章节目录样式,包括章节序号和标题,但是章节序号不加粗。具体代码如下:
```
\titlecontents{chapter}[0em]{\bfseries}
{\contentslabel{2.3em}}{}
{\titlerule*[0.5pc]{.}\contentspage}
```
其中,`chapter` 表示章节,`[0em]` 表示左对齐,`\contentslabel{2.3em}` 表示章节序号的宽度为 `2.3em`,`\titlerule*[0.5pc]{.}\contentspage` 表示绘制横线和页码。
4. 在正文中,使用 `\tableofcontents` 命令生成目录。
完整的示例代码如下:
```
\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\titleformat{\chapter}[block]{\bfseries\large\filcenter}{}{0em}{}
\titlecontents{chapter}[0em]{\bfseries}
{\contentslabel{2.3em}}{}
{\titlerule*[0.5pc]{.}\contentspage}
\begin{document}
\tableofcontents
\chapter{Introduction}
This is the introduction.
\chapter{Conclusion}
This is the conclusion.
\end{document}
```
在上述示例代码中,章节标题无编号,但是在目录中显示章节序号。
阅读全文
相关推荐













