0

I want to have custom format of chapters, which follows:

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

I have found out that the title for ToC behaves like chapter. Is it possible to have the title for ToC as the default style and all the other chapters as my customized style (the code above)?

Here is my 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}

The title of ToC shows as titletoc1 but I want it like titletoc2

Thanks all!

2
  • We cannot read your mind: please provide a MWE, otherwise it's difficult to help you. You've been around long enough on TeX.SE to know this! :)
    – marquinho
    Nov 25, 2023 at 14:21
  • MWE added, I hope it's not too long :)
    – JoudaBouda
    Nov 25, 2023 at 14:37

1 Answer 1

1

Just issue the \titleformat command after \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}
1
  • Oh thanks, I thought that ´\titleformat´ must be placed in the preamble.
    – JoudaBouda
    Nov 25, 2023 at 15:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .