![目录的标题前面有“0”,我找不到删除它的方法](https://linux22.com/image/431042/%E7%9B%AE%E5%BD%95%E7%9A%84%E6%A0%87%E9%A2%98%E5%89%8D%E9%9D%A2%E6%9C%89%E2%80%9C0%E2%80%9D%EF%BC%8C%E6%88%91%E6%89%BE%E4%B8%8D%E5%88%B0%E5%88%A0%E9%99%A4%E5%AE%83%E7%9A%84%E6%96%B9%E6%B3%95.png)
我必须使用模仿 Microsoft Word 模板的某种格式。为此,我创建了一个 Latex 文档,一切正常,但出于某种神秘原因,标准命令
\renewcommand{\contentsname}{Table of contents }
\tableofcontents
在目录标题前生成一个数字 0:
我如何获得标准行为(无数字)?
该文件起始部分的代码是
\documentclass[10pt,a4paper,twoside,onecolumn]{report}
%%\include{def} %% <-- where is 'def.tex'?
% FONTS
\usepackage{fontspec}
\setmainfont{Calibri}
\usepackage{graphicx,setspace,xcolor,titlesec,fancyhdr} % <-- need to load these packages
\pagestyle{fancy}
\fancypagestyle{plain}
\fancyhead{}
\fancyfoot{}
\fancyfoot[EL]{\textcolor{gray}{ATHENA: Adaptive high-speed
turbomachinery for mini-energy harvesting systems}}
\fancyfoot[ER]{\textcolor{gray}{\thepage}}
\definecolor{white}{rgb}{1.0, 1.0, 1.0}
\definecolor{NWOGreen}{RGB}{24,101,124}
\newcommand{\colorchapter}[1]{%
\colorbox{white}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thechapter\ #1}}}
\titleformat{name=\chapter}[block]
{\normalfont\LARGE\bfseries\color{NWOGreen}}
{}
{0pt}
{\colorchapter}
\titleformat{\section}
{\bfseries\color{NWOGreen}}{\thesection}{1em}{}
\begin{document}
\pagenumbering{roman}
\renewcommand{\contentsname}{Table of contents}
\tableofcontents
\newpage
\pagenumbering{arabic}
\chapter{Contact details}
\section{Main applicant}
\section{Co-applicant}
\section{Title}
\section{Keywords}
\clearpage
\chapter{Summary}
\section{Research summary}
\section{Utilisation summary}
\section{Summary NWO domain for AES website and online in ISAAC}
\end{document}
答案1
用两个参数定义\colorchapter
,并定义numberless
的变体\chapter
。
\documentclass[10pt,a4paper,twoside,onecolumn]{report}
% FONTS
\usepackage{fontspec}
\setmainfont{Calibri}
\usepackage{graphicx,setspace,xcolor,titlesec,fancyhdr} % <-- need to load these packages
\pagestyle{fancy}
\fancypagestyle{plain}
\fancyhf{}
\fancyfoot[EL]{\textcolor{gray}{ATHENA: Adaptive high-speed
turbomachinery for mini-energy harvesting systems}}
\fancyfoot[ER]{\textcolor{gray}{\thepage}}
\definecolor{white}{rgb}{1.0, 1.0, 1.0}
\definecolor{NWOGreen}{RGB}{24,101,124}
\newcommand{\colorchapter}[2]{%
\colorbox{white}{\parbox{\dimexpr\textwidth-2\fboxsep}{#1#2}}}
\titleformat{name=\chapter}[block]
{\normalfont\LARGE\bfseries\color{NWOGreen}}
{}
{0pt}
{\colorchapter{\thechapter\quad}}
\titleformat{name=\chapter,numberless}[block]
{\normalfont\LARGE\bfseries\color{NWOGreen}}
{}
{0pt}
{\colorchapter{}}
\titleformat{\section}
{\bfseries\color{NWOGreen}}
{\thesection}
{1em}
{}
\begin{document}
\pagenumbering{roman}
%\renewcommand{\contentsname}{Table of contents} % do you need this?
\tableofcontents
\clearpage
\pagenumbering{arabic}
\chapter{Contact details}
\section{Main applicant}
\section{Co-applicant}
\section{Title}
\section{Keywords}
\chapter{Summary}
\section{Research summary}
\section{Utilisation summary}
\section{Summary NWO domain for AES website and online in ISAAC}
\end{document}
答案2
这段代码有效,即使我不太明白所有命令的作用,通过在 \tableofcontents 之后重新定义 \titleformat 我获得了想要的结果
\documentclass[10pt,a4paper,twoside,onecolumn]{report}
% FONTS
\usepackage{fontspec}
\setmainfont{Calibri}
\usepackage{graphicx,setspace,xcolor,titlesec,fancyhdr} % <-- need to load these packages
\pagestyle{fancy}
\fancypagestyle{plain}
\fancyhead{}
\fancyfoot{}
\fancyfoot[EL]{\textcolor{gray}{ATHENA: Adaptive high-speed
turbomachinery for mini-energy harvesting systems}}
\fancyfoot[ER]{\textcolor{gray}{\thepage}}
\definecolor{white}{rgb}{1.0, 1.0, 1.0}
\definecolor{NWOGreen}{RGB}{24,101,124}
\titleformat{name=\chapter}[block]
{\normalfont\LARGE\bfseries\color{NWOGreen}}
{}
{0pt}
{}
\titleformat{\section}
{\bfseries\color{NWOGreen}}{\thesection}{1em}{}
\begin{document}
\pagenumbering{roman}
\renewcommand{\contentsname}{Table of contents}
\tableofcontents
\newpage
\pagenumbering{arabic}
\newcommand{\colorchapter}[1]{%
\colorbox{white}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thechapter\ #1}}}
\titleformat{name=\chapter}[block]
{\normalfont\LARGE\bfseries\color{NWOGreen}}
{}
{0pt}
{\colorchapter}
\chapter{Contact details}
\section{Main applicant}
\section{Co-applicant}
\section{Title}
\section{Keywords}
\clearpage
\chapter{Summary}
\section{Research summary}
\section{Utilisation summary}
\section{Summary NWO domain for AES website and online in ISAAC}
\end{document}
如果有人能帮忙编写一个优雅而整洁的代码,那将会帮助很多人,因为我们可以向我们的资助机构提供一个模板,目前该模板仅提供使用 MS Word 模板的可能性