![目录问题](https://linux22.com/image/312046/%E7%9B%AE%E5%BD%95%E9%97%AE%E9%A2%98.png)
我有以下代码,问题是目录不起作用,它没有使用章节标题,而是只有一个“目录”标题。如何修复它?
\documentclass[a4paper, 12pt]{article}
\usepackage[protrusion=true,expansion=true]{microtype}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[margin=0.98in]{geometry}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.15}
\makeatletter
\renewcommand\@biblabel[1]{\textbf{#1.}}
\renewcommand{\@listI}{\itemsep=0pt}
\renewcommand{\maketitle}{
\begin{flushright}
{\LARGE\@title}
\vspace{50pt}
{\large\@author}
\\\@date
\vspace{40pt}
\end{flushright}
}
\title{\textbf{Lysine Price-Fixing Conspiracy}\\
Causes and the aftermath}
\author{\textsc{aaa}}
\date{\today}
\begin{document}
\maketitle
\newpage
\tableofcontents
\newpage
\section*{Abstract}
Morbi tempor congue porta. Proin semper, leo vitae faucibus dictum, metus mauris lacinia lorem, ac congue leo felis eu tu
\newpage
\vspace{30pt}
\section*{Introduction}
This statement requires citation \cite{heu}; this one does too
%------------------------------------------------
\section*{Section Name}
C
\section*{Conclusion}
Fusce in nibh augue. Cum sociis natoque penatibus et magnis dis is ac blandit eget, dignissim quis nunc.
\begin{enumerate}
\item First numbered list item
\item Second numbered list item
\end{enumerate}
Donec luctus tincidunt mauris, non ultrices ligula aliquam id. Se
\newpage
\begin{thebibliography}{99}
\addcontentsline{toc}{chapter}{Bibliografia}
\bibitem{beaman} Juliusz Beaman, \textit{Morbidity of the Jolly
function}, Mathematica Absurdica, 117 (1965) 338--9.
\end{thebibliography}
\end{document}
答案1
您已使用命令的星号形式禁用目录中的条目\section
。删除星号并指定不应通过计数器对章节进行编号secnumdepth
。
并且级别chapter
不适用于班级article
。
例子:
\documentclass[a4paper, 12pt]{article}
\setcounter{secnumdepth}{0}
\begin{document}
\tableofcontents
\newpage
\section{Abstract}
Morbi tempor congue porta. Proin semper, leo vitae faucibus dictum, metus
mauris lacinia lorem, ac congue leo felis eu tu
\section{Introduction}
\section{Section Name}
\section{Conclusion}
\begin{thebibliography}{99}
\addcontentsline{toc}{section}{Bibliografia}
\bibitem{beaman} Juliusz Beaman, \textit{Morbidity of the Jolly
function}, Mathematica Absurdica, 117 (1965) 338--9.
\end{thebibliography}
\end{document}
在目录中添加用于部分级别的点
以下示例修补了\l@section
,它负责格式化目录中的节条目。 点设置取自\@dottedtocline
:
\documentclass[a4paper, 12pt]{article}
\usepackage{etoolbox}
\makeatletter
\patchcmd\l@section{%
\nobreak\hfil\nobreak
}{%
\nobreak
\leaders\hbox{%
$\m@th \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$%
}%
\hfill
\nobreak
}{}{\errmessage{\noexpand\l@section could not be patched}}
\makeatother
\setcounter{secnumdepth}{0}
\begin{document}
\tableofcontents
\newpage
\section{Abstract}
Morbi tempor congue porta. Proin semper, leo vitae faucibus dictum, metus
mauris lacinia lorem, ac congue leo felis eu tu
\section{Introduction}
\section{Section Name}
\subsection{Subsection Name}
\section{Conclusion}
\begin{thebibliography}{99}
\addcontentsline{toc}{section}{Bibliografia}
\bibitem{beaman} Juliusz Beaman, \textit{Morbidity of the Jolly
function}, Mathematica Absurdica, 117 (1965) 338--9.
\end{thebibliography}
\end{document}