这是我正在使用的代码
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{mathtools, amsmath, amsthm}
\usepackage{fancyhdr}
\usepackage{todonotes}
\usepackage{pgfornament}
\usepackage{pgfpages}
\usepackage[margin=1in]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{fontawesome}
\usepackage{pgfornament}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage[titles]{tocloft}
\titleformat{\section}{\Large\bfseries\color{blue}}{\faBook}{1em}{\thesection.}
\titleformat{\subsection}{\large\bfseries\color{black}}{\faAngleRight}{1em}{\thesubsection.}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{Page \thepage}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhead[C]{\pgfornament[width=2cm]{88}}
\begin{document}
\title{Hello All}
\author{XYZ}
\date{\today}
\maketitle
\listoftodos
\tableofcontents
\section{Introduction}
\end{document}
我得到 0.To Do list 和 0. Content。我该如何摆脱它们并只保留 1.Introduction?
答案1
改编
- 我删除了本示例不需要的包
您可以使用以下方式定义节和小节的格式:
\titleformat{\section}{\Large\bfseries\color{blue}}{\faBook}{1em}{\thesection.}
\titleformat{\subsection}{\large\bfseries\color{black}}{\faAngleRight}{1em}{\thesubsection.}
由于标题“待办事项列表”和“内容”被放置为section*
,因此它们会受到影响。如果您将这两\titleformat
行都放在 下方,\tableofcontents
则只会影响以下章节和子章节。
结果
代码
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{todonotes}
\usepackage[margin=1in]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{fontawesome}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage[titles]{tocloft}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{Page \thepage}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhead[C]{\pgfornament[width=2cm]{88}}
\begin{document}
\title{Hello All}
\author{XYZ}
\date{\today}
\maketitle
\listoftodos
\tableofcontents
\titleformat{\section}{\Large\bfseries\color{blue}}{\faBook}{1em}{\thesection.}
\titleformat{\subsection}{\large\bfseries\color{black}}{\faAngleRight}{1em}{\thesubsection.}
\section{Introduction}
\end{document}