删除部分编号,但在LaTeX的目录中显示该编号

Mit*_*ali 1 latex

我是LateX的新手。我知道如何通过使用\section*{heading}而不是删除节号\section{heading}。但是,当我在目录中显示节标题时,它不会打印节号。我希望在下面显示的目录中的“项目简介”和“公司简介”之前显示部分编号。

表中的内容

hba*_*rts 5

titlesec软件包对于修改章节标题非常有用。一个重要的命令是\titleformat,在手册第4页上进行了介绍。该命令如下所示:

\titleformat{?command?}[?shape?]{?format?}{?label?}{?sep?}{?before-code?}[?after-code?]
Run Code Online (Sandbox Code Playgroud)

在这里,我们要更改\section命令,即<command>is \section。该<shape>设置是可选的-我们将保留默认值。在中<format>,我们定义标题的格式。的默认\section值为\normalfont\Large\bfseries,因此我们将其设置为该值。如果要更改外观,可以在此处进行。现在,有趣的部分是:<label>节号-我们不想将其打印出来,因此我们将该字段留空。的<sep>是标签和标题之间的分离,这应该是零,如果我们没有一个标签。最后,通过<before-code>和,<after-code>我们可以添加应该在打印标题之前或之后运行的任何代码。我们也不需要。因此,我们的命令是:

\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}
Run Code Online (Sandbox Code Playgroud)

在这里,对此进行了演示:

\documentclass{article}

\usepackage{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{}{0pt}{}

\begin{document}

\tableofcontents

\section{Introduction to Company}
This is the company.

\section{Introduction to Project}
My project is very nice.

\end{document}
Run Code Online (Sandbox Code Playgroud)

结果文件