Latex 如何使第*章、第*节和第*小节出现在目录中

Latex 如何使第*章、第*节和第*小节出现在目录中,latex,Latex,我需要制作一份PDF文档,其中我需要一些“章节”(及其章节和小节)不编号,但仍包含在ToC中 这是我的硕士论文。我使用book document类,因为我不喜欢回忆录默认值 如果使用\chapter*,则从ToC中删除该章节。但我必须在ToC中也有这些。此外,标题(花式)不会随\chapter*更改 本论文的总体结构如下: \maketitle %% A custom one \frontmatter \tableofcontents \listoftables \listoffigures

我需要制作一份PDF文档,其中我需要一些“章节”(及其章节和小节)不编号,但仍包含在ToC中

这是我的硕士论文。我使用book document类,因为我不喜欢回忆录默认值

如果使用
\chapter*
,则从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
如何使
\chapter*
\section*
\subsection*
出现在ToC中并修改标题

致以最良好的祝愿, 曼努埃尔

更新:我想我可能使用了一些干扰页眉和页脚生成方式的软件包。的答案得到了问题第一部分的回答:我现在有了关于TOC的\章*s

这是我的全部序言:

\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

我不认为有专门的命令可以做到这一点。但是你可以用

  \addcontentsline{toc}{chapter}{#1}
将其添加到TOC。顺便说一句,我在\chapter*和fancy方面没有问题,所以我使用了:

\newcommand\chap[1]{%
  \chapter*{#1}%
  \addcontentsline{toc}{chapter}{#1}}

\setcounter{secnumdepth}{-1}

如果您在book类中使用\chapter{}etc的un星号版本,那么这对我来说是一个解决方案。如果您想要一个可链接的ToC以及我的解决方案,Hyperref也可以工作。确保编译两次,使其在ToC和内联上都能工作

然而不幸的是,你的序言扼杀了我的TexStudio试图检查它是否适用于你的确切代码,但我有信心

二手TeXstudio 2.6.2(SVN 4110M) 使用Qt4.8.5版,使用Qt4.8.5R编译
在64位Windows 7上,我遇到了同样的问题,并通过smilingthax的回答和评论解决了这个问题。由于只使用
\leftmark
\rightmark
不起作用,这里有一个命令,您可以使用它来(i)使章节无编号(ii)将其添加到TOC和(iii)具有正确的页眉

\newcommand\chap[1]{
    \chapter*{#1}
    \addcontentsline{toc}{chapter}{#1}
    \markboth{#1}{#1}}
分段(和分段)的相同工程:


关于这一问题,已在以下网站上多次询问和回答:

我将复制到最后一个问题,因为它演示了一种不同于此问题现有答案的技术:重新定义
\section
,这样
\section*
的唯一效果就是跳过打印节号。即使在从您无法控制的包的内部发出剖切命令时,这也会起作用


[…]重新定义
\section
,以便在使用星号版本时捕获并设置条件。在找到
\section*
后,按照
\section
的方式发出,但通过适当设置计数器
secnumdepth
来移除数字打印机制

为(重新)定义可能具有
s
tarred版本以及
o
optional参数的命令提供了一个简单的界面

\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

(要对
\chapter
\subsection
等执行相同的操作,请适当搜索和替换
部分
,并调整用于
secnumdepth
的临时值)

这几乎可以按预期工作。我有TOC上的章节,但标题没有更新。我有一个\chap{Introduction},但是该章的页面会得到“图的列表”标题。请尝试添加\chaptermark{1}resp\leftmark/\rightmark。另见:谢谢大家。我用\chaptermark和\phantomsection解决了所有问题。
\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