在文章类中,如果更改了章节标题的样式,目录中的内容标题的样式也会更改。如何防止这种情况发生?
\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
\usepackage{tikz}
\usepackage{titlesec}
\usepackage[english]{babel}
\begin{document}
\titleformat{\section}[block]%
{
\tikz[overlay] \shade[left color=blue!20,right color=white] (0,-1ex) rectangle (\textwidth,1em);}%
{\thesection}%
{1em}%
{}
\tableofcontents
\newpage
\section{Introduction}
\section{Limitations of Existing System}
\section{Problem Definition}
\section{Architecture of Proposed System}
\section{Novelty of the Work}
\section{Hardware / Software Tools}
\section{Gnatt Chart}
\section{References}
\end{document}
答案1
三种不同的选择;使用哪一个取决于您的实际文档和需求:
重新定义后
\tableofcontents
:\documentclass[12pt,a4paper]{article} \usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry} \usepackage{tikz} \usepackage{titlesec} \usepackage[english]{babel} \begin{document} \tableofcontents \newpage \titleformat{\section}[block]% { \tikz[overlay] \shade[left color=blue!20,right color=white] (0,-1ex) rectangle (\textwidth,1em);}% {\thesection}% {1em}% {} \section{Introduction} \section{Limitations of Existing System} \section{Problem Definition} \section{Architecture of Proposed System} \section{Novelty of the Work} \section{Hardware / Software Tools} \section{Gnatt Chart} \section{References} \end{document}
定义两个命令;一个用于标准部分,另一个用于修改部分;这样您就可以随意在样式之间切换:
\documentclass[12pt,a4paper]{article} \usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry} \usepackage{tikz} \usepackage{titlesec} \usepackage[english]{babel} \newcommand\ModSection{% \titleformat{\section}[block]% { \tikz[overlay] \shade[left color=blue!20,right color=white] (0,-1ex) rectangle (\textwidth,1em);}% {\thesection}% {1em}% {} } \newcommand\StdSection{% \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {} } \begin{document} \tableofcontents \newpage \ModSection \section{Introduction} \section{Limitations of Existing System} \section{Problem Definition} \section{Architecture of Proposed System} \section{Novelty of the Work} \section{Hardware / Software Tools} \section{Gnatt Chart} \section{References} \end{document}
定义一个具有默认格式设置的变体,以
numberless
应用于带星号的部分(例如 ToC、LoF、LoT):\documentclass[12pt,a4paper]{article} \usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry} \usepackage{tikz} \usepackage{titlesec} \usepackage[english]{babel} \titleformat{\section}[block]% { \tikz[overlay] \shade[left color=blue!20,right color=white] (0,-1ex) rectangle (\textwidth,1em);}% {\thesection}% {1em}% {} \titleformat{name=\section,numberless} {\normalfont\Large\bfseries} {} {0em} {} \begin{document} \tableofcontents \newpage \section{Introduction} \section{Limitations of Existing System} \section{Problem Definition} \section{Architecture of Proposed System} \section{Novelty of the Work} \section{Hardware / Software Tools} \section{Gnatt Chart} \section{References} \end{document}
与您的问题无关,但请注意,对于跨越多行的标题,您当前的修改格式设置不会表现良好。