我需要生成一个PDF文档,其中我需要一些"章节"(以及它的章节和小节)是非编号的,但仍包含在ToC中.
这是我的硕士论文.我正在使用书籍文档类,因为我不喜欢回忆录默认值.
如果我使用\chapter*,那么LaTeX将从ToC中删除该章节.但我要求在ToC中也有这些.此外,标题(花式)不会改变\chapter*.
论文的总体结构是:
\maketitle %% A custom one
\frontmatter
\tableofcontents
\listoftables
\listoffigures
\chapter*{Abstract}
\chapter*{Introduction} %% This "chapter" presents the whole thesis
\mainmatter
%% Here the real chapters are written
\appendix
%% Appendixes here
%% bibliography
Run Code Online (Sandbox Code Playgroud)
如何制作\chapter*,\section*和\subsection*出现在ToC中并修改标题?
最好的问候,曼努埃尔.
更新:我想我可能正在使用一些干扰页眉和页脚生成方式的包.smilethax的答案让问题的第一部分得到了回应:我现在在TOC上有我的\章节*.
这是我的完整序言:
\usepackage[sort&compress,round,semicolon]{natbib}
\usepackage{babel}
\usepackage{setspace}
%% inputenc so we can write in spanish
\usepackage[utf8]{inputenc}
\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in PDF
\usepackage{ifthen}
%% \usepackage{float} % float configuration
%% \floatplacement{figure}{TH} % place figures here definitely
%% fontenc so we can use TrueType fonts
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{garamond}
\usepackage{graphicx}
\usepackage{titlesec}
\usepackage[table]{xcolor}
%% Custom colors
\definecolor{blue}{rgb}{0.2,0.2,0.95}
\definecolor{green}{rgb}{0.2,0.95,0.2}
\definecolor{red}{rgb}{0.95,0.2,0.2}
\definecolor{cyan}{rgb}{0,0,0.95}
\definecolor{ligthred}{rgb}{1, 0, 0}
\definecolor{black}{rgb}{0, 0, 0}
\definecolor{shade}{HTML}{D4D7FE} %light blue shade
% Margins
\usepackage[left=0.9in,top=1in,right=0.7in,bottom=1in]{geometry}
\usepackage[pdftex, colorlinks=true, citecolor=ligthred,
urlcolor=blue]{hyperref}
\widowpenalty9000
\clubpenalty7000
\usepackage{titlesec}
\newcommand{\bigrule}{\titlerule[0.5mm]}
\renewcommand{\rmdefault}{bch}
\titleformat{\chapter}[display]
{\bfseries\Huge}
{\garamond
% DESCOMENTAR PARA SUBIR LOS CAPITULOS
\vspace{-1.125in} \titlerule \filleft
\Large\chaptertitlename\ \Large\thechapter}{0mm}
{\filleft}[\vspace{0.5mm} \bigrule]
\let\cite=\citep
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} %% Clears all headers
% admonition (specially marked topic)
\providecommand{\DUadmonition}[2][class-arg]{%
% try \DUadmonition#1{#2}:
\ifcsname DUadmonition#1\endcsname%
\csname DUadmonition#1\endcsname{#2}%
\else
\begin{center}
\fbox{\parbox{0.9\textwidth}{#2}}
\end{center}
\fi
}
% title for topics, admonitions and sidebar
\providecommand*{\DUtitle}[2][class-arg]{%
% call \DUtitle#1{#2} if it exists:
\ifcsname DUtitle#1\endcsname%
\csname DUtitle#1\endcsname{#2}%
\else
\smallskip\noindent\textbf{#2}\smallskip%
\fi
}
% error admonition title
\providecommand*{\DUtitleerror}[1]{\DUtitle{\color{red}#1}}
% fieldlist environment
\ifthenelse{\isundefined{\DUfieldlist}}{
\newenvironment{DUfieldlist}%
{\quote\description}
{\enddescription\endquote}
}{}
% legend
\ifthenelse{\isundefined{\DUlegend}}{
\newenvironment{DUlegend}{\small}{}
}{}
%%% Fallback definitions for Docutils-specific commands
% numeric or symbol footnotes with hyperlinks
\providecommand*{\DUfootnotemark}[3]{%
\hyperlink{#2}{\textsuperscript{#3}}\raisebox{1em}{\label{#1}}%
}
\providecommand{\DUfootnotetext}[4]{%
\begingroup%
\renewcommand{\thefootnote}{%
\protect\hyperlink{#2}{#3}}%
\protect\raisebox{1em}{\protect\label{#1}}%
\footnotetext{#4}%
\endgroup%
}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\newlength{\DUtablewidth} % internal use in tables
\usepackage{tikz}
\usepackage{bbding}
\usetikzlibrary{arrows,fit}
\usepackage{amsmath,bm,times}
\newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix command
\newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector command
Run Code Online (Sandbox Code Playgroud)
smi*_*hax 18
我认为不存在专门的命令.但你可以使用
\addcontentsline{toc}{chapter}{#1}
Run Code Online (Sandbox Code Playgroud)
将其添加到TOC.顺便说一句,我没有问题\章*和花哨,所以我使用:
\newcommand\chap[1]{%
\chapter*{#1}%
\addcontentsline{toc}{chapter}{#1}}
Run Code Online (Sandbox Code Playgroud)
这个问题的变体已在TeX 特定的姊妹网站上被问及并回答过多次:
\tableofcontents不列出未编号的章节\section*{something}不从目录中删除的情况下使用?\section*,使其行为与除了省略数字之外完全相同\section我将复制维尔纳对最后一个问题的答案,因为它演示了与该问题的任何现有答案不同的技术:重新定义,\section以便唯一的效果\section*是跳过打印节号。即使从您无法控制的包内部发出分段命令,这也将起作用。
[...] 重新定义\section以捕获并确定何时使用带星号的版本。找到后\section*,就像您一样发出它\section,但通过适当的计数器设置删除数字打印机制secnumdepth。
xparse提供了一个简单的界面,用于(重新)定义可能具有starred 版本以及o可选参数的命令。
\usepackage{xparse}
\let\oldsection\section
\makeatletter
\newcounter{@secnumdepth}
\RenewDocumentCommand{\section}{s o m}{%
\IfBooleanTF{#1}
{\setcounter{@secnumdepth}{\value{secnumdepth}}% Store secnumdepth
\setcounter{secnumdepth}{0}% Print only up to \chapter numbers
\oldsection{#3}% \section*
\setcounter{secnumdepth}{\value{@secnumdepth}}}% Restore secnumdepth
{\IfValueTF{#2}% \section
{\oldsection[#2]{#3}}% \section[.]{..}
{\oldsection{#3}}}% \section{..}
}
\makeatother
Run Code Online (Sandbox Code Playgroud)
(要对\chapter、\subsection等执行相同的操作,请适当搜索和替换section,并调整用于 的临时值secnumdepth。)
| 归档时间: |
|
| 查看次数: |
66736 次 |
| 最近记录: |