如何在本地更改章节标题,即仅适用于一章(目录)

如何在本地更改章节标题,即仅适用于一章(目录)

我想要自定义章节格式,如下所示:

\titleformat{\chapter}[display]
  {\centering\normalfont\Huge\bfseries}
  {}{0pt}
  {\titlerule\vspace{1ex}\filcenter}
  [\vspace{.75ex}{\titlerule}]

我发现目录的标题与章节的行为类似。是否可以将目录的标题设为默认样式,而将所有其他章节设为我的自定义样式(上面的代码)?

这是我的 MWE:

\documentclass[14pt,twoside]{extbook}
\usepackage[utf8]{inputenc}
\usepackage[main=czech,slovak]{babel}
\usepackage{xcolor}
\usepackage{nameref}
\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkbordercolor = {white},
    linkcolor = {black},
    breaklinks
}
\usepackage[hang,flushmargin]{footmisc}
\raggedbottom
\usepackage{titletoc}
%\usepackage{sectsty}
\addtolength{\textheight}{47mm}
\addtolength{\textwidth}{22mm}
\addtolength{\oddsidemargin}{-1mm}
\addtolength{\evensidemargin}{-15mm}
\addtolength{\topmargin}{-23mm} 

\emergencystretch 1em

\usepackage[labelfont=bf]{caption}

\setlength{\parindent}{.7pt}
\date{}
\title{Proceedings: 3.7.202X--4.7.202X}
\author{}
\usepackage{titlesec}
% https://tex.stackexchange.com/questions/136527/section-numbering-without-numbers

\titleformat{\section}[block]
  {\normalfont\Large\bfseries\filcenter}   % The style of the section title
  {}                             % a prefix
  {0pt}                          % How much space exists between the prefix and the title
  {}    % How the section is represented
  
\titleformat{\subsection}
  {\normalfont\large\bfseries}   % The style of the subsection title
  {}                             % a prefix
  {0pt}                          % How much space exists between the prefix and the title
  {}    % How the subsection is represented

% https://tex.stackexchange.com/questions/702239/adjustment-of-title-of-chapter-in-extbook

\titleformat{\chapter}[display]
  {\centering\normalfont\Huge\bfseries}
  {}{0pt}
  {\titlerule\vspace{1ex}\filcenter}
  [\vspace{.75ex}{\titlerule}]

% toc
  \titlecontents{section}[0em]
{\vskip 0.5ex}%
{\hspace{5mm}\bfseries}% numbered sections formatting
{ }% unnumbered sections formatting
{ }

\setcounter{tocdepth}{2}

% https://tex.stackexchange.com/questions/10188/table-of-contents-with-additional-description-of-entries

\makeatletter
\newcommand*\l@sectioninfo{\@dottedtocline{1}{5mm}{1cm}}
\def\@nodottedtocline#1#2#3#4#5{%
  \ifnum #1>\c@tocdepth \else
    \vskip \z@ \@plus.2\p@
    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
     \parindent #2\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima #3\relax
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {#4}\nobreak
     \leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{\,}\mkern \@dotsep
        mu$}\hfill
     \nobreak
     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor }%
     \par}%
  \fi}
\makeatother
\def\sectioninfo#1{%
    \addcontentsline{toc}{sectioninfo}{%
    \noexpand\numberline{}#1}%
}

% https://tex.stackexchange.com/questions/94729/how-to-customize-chapter-heading-style

%-------------------------------------

\begin{document}
    \pagestyle{plain}
        \maketitle  
    \tableofcontents
\clearpage 

\setlength{\parindent}{.7cm}

\chapter*{Introduction} 

\begin{center}
    \section{the first headline}\label{sek_13}\sectioninfo{name surname}
    \setcounter{figure}{0} \setcounter{table}{0}\setcounter{footnote}{0}
    \medskip    
    \textsc{name surname\footnote{organisation; [email protected]}}
 
\end{center}

\medskip

\noindent \emph{here goes the abstract}

 \subsection*{intro}      
\noindent Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

 \subsection*{next}

Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\clearpage

\begin{center}
    \section{the second headline}\label{sek_14}
    \setcounter{figure}{0} \setcounter{table}{0}\setcounter{footnote}{0}
    \medskip    
    \textsc{name surname\footnote{organisation; [email protected]}}
  
\end{center}

\medskip

\noindent \emph{here goes the abstract}

 \subsection*{intro}

\noindent Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

 \subsection*{next}

Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\clearpage

    \cleardoublepage

   \begin{center}
    \section{the first headline}\label{dil_1}
    \setcounter{figure}{0} \setcounter{table}{0}\setcounter{footnote}{0}
    \medskip    
    \textsc{name surname\footnote{organisation; [email protected]}}
  
\end{center}

\medskip

\noindent \emph{here goes the abstract}

 \subsection*{intro}

\noindent Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

 \subsection*{next}

Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\clearpage

\begin{center}
    \section{the second headline}\label{dil_2}
    \setcounter{figure}{0} \setcounter{table}{0}\setcounter{footnote}{0}
    \medskip    
    \textsc{name surname\footnote{organisation; [email protected]}}
  
\end{center}

\medskip

\noindent \emph{here goes the abstract}

 \subsection*{intro}

\noindent Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

 \subsection*{next}

Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.

\clearpage


\end{document}

ToC 的标题显示为titletoc1但我想要的是titletoc2

谢谢大家!

答案1

只需发出\titleformat命令 \tableofcontents

\documentclass{book}
\usepackage{titlesec}

\begin{document}

\tableofcontents

\titleformat{\chapter}[display]
  {\centering\normalfont\Huge\bfseries}
  {}{0pt}
  {\titlerule\vspace{1ex}\filcenter}
  [\vspace{.75ex}{\titlerule}]

\chapter{Foo}
\chapter{Bar}

\end{document}

相关内容