删除目录前的 0 章

删除目录前的 0 章

我想删除目录前的 0,还有第 0 章和规则。

在此处输入图片描述

使用的代码是:

\documentclass[a4paper,12pt,towside]{book} 
\usepackage{setspace}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage[square,numbers]{natbib}
\usepackage[english,french]{babel}
\usepackage{textgreek}
\usepackage[explicit]{titlesec}

\usepackage{xcolor}

\usepackage{kantlipsum}% only dummy text <<<
\newlength\chapnumb
\setlength\chapnumb{3cm}

\titleformat{\chapter}[block] {
    \normalfont\sffamily}{}{0pt} {
    \parbox[b]{\chapnumb}{
        \fontsize{120}{110}\selectfont\thechapter}
    \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{
        \raggedleft
        \hfill{\LARGE#1}\\
        \rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt}
    }
}

\titleformat{name=\chapnumb,numberless}[block]
{\normalfont\Huge\sffamily}{}{0pt}
{\parbox[b]{\chapter}{%
        \mbox{}}%
    \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{%
        \raggedleft%
        \hfill{\LARGE#1}\\
        \rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt}}}
    
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{14pt} % regler l'espace entete/paragraph
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}

\fancyhf{}
\fancyhead[RO]{\makebox[0pt][l]{
        \colorbox{teal}{\makebox[\textwidth][l]{\bfseries\textcolor{white}{\thepage}\enskip}}\hspace*{0em}}} % numéro de page dans l'en-tête alterné, \textbf : gras,
\fancyhead[LE]{\makebox[0pt][r]{\colorbox{teal}{\makebox[\textwidth][r]{\bfseries\textcolor{white}{\thepage}}}\hspace*{0em}}} 
\fancyhead[LO]{ \textbf{\chaptername~\thechapter{}. \nouppercase{\leftmark}}} % changed <<<<<<<<<<
\fancyhead[RE]{ \textbf{\chaptername~\thechapter{}. \nouppercase{\leftmark}}} % changed <<<<<<<<<<

\renewcommand{\headrulewidth}{0.5pt}

%============== Bibliography ref ==============
\usepackage[sectionbib]{chapterbib}
\addto{\captionsfrench}{\renewcommand{\bibname}{Références}}

\begin{document}


\frontmatter
\newpage
\tableofcontents




%%%%%%%%%%%%%%%% CHAPITRES %%%%%%%%%%%%%%%%
\mainmatter
\setcounter{page}{1}
\include{chp1/chp1_main}
\include{chp2/chp2_main}
\include{chp3/chp3_main}

\end{document}

答案1

定义两个\fancypagestyle,一个表示frontmatter没有章节编号,另一个表示mainmatter您现在拥有的章节编号。

顺便说一句,我合并了LO和,RE因为它们是相同的。并且我将两种页面样式的通用定义保留在了之外\fancypagestyle。但是,如果您愿意,也可以在两者中复制它们。

另外,在\titleformat无数中你混淆\chapter\chapnumb

\documentclass[a4paper,12pt,towside]{book} 
\usepackage{setspace}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage[square,numbers]{natbib}
\usepackage[english,french]{babel}
\usepackage{textgreek}
\usepackage[explicit]{titlesec}

\usepackage{xcolor}

\usepackage{kantlipsum}% only dummy text <<<
\newlength\chapnumb
\setlength\chapnumb{3cm}

\titleformat{\chapter}[block] {
    \normalfont\sffamily}{}{0pt} {
    \parbox[b]{\chapnumb}{
        \fontsize{120}{110}\selectfont\thechapter}
    \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{
        \raggedleft
        \hfill{\LARGE#1}\\
        \rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt}
    }
}

\titleformat{name=\chapter,numberless}[block]
{\normalfont\Huge\sffamily}{}{0pt}
{\parbox[b]{\chapnumb}{%
        \mbox{}}%
    \parbox[b]{\dimexpr\textwidth-\chapnumb\relax}{%
        \raggedleft%
        \hfill{\LARGE#1}\\
        \rule{\dimexpr\textwidth-\chapnumb\relax}{0.4pt}}}
    
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength{\headheight}{14pt} % regler l'espace entete/paragraph
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}}

\fancyhf{}
\fancyhead[RO]{\makebox[0pt][l]{
        \colorbox{teal}{\makebox[\textwidth][l]{\bfseries\textcolor{white}{\thepage}\enskip}}\hspace*{0em}}} % numéro de page dans l'en-tête alterné, \textbf : gras,
\fancyhead[LE]{\makebox[0pt][r]{\colorbox{teal}{\makebox[\textwidth][r]{\bfseries\textcolor{white}{\thepage}}}\hspace*{0em}}} 

\fancypagestyle{mainmatter}{
  \fancyhead[LO,RE]{ \textbf{\chaptername~\thechapter{}. \nouppercase{\leftmark}}} % changed <<<<<<<<<<
  \renewcommand{\headrulewidth}{0.5pt}
}

\fancypagestyle{frontmatter}{
  \fancyhead[LO,RE]{ \textbf{\nouppercase{\leftmark}}} % changed <<<<<<<<<<
  \renewcommand{\headrulewidth}{0pt}
}

%============== Bibliography ref ==============
\usepackage[sectionbib]{chapterbib}
\addto{\captionsfrench}{\renewcommand{\bibname}{Références}}

\begin{document}

\pagestyle{frontmatter}
\frontmatter
\newpage
\tableofcontents

%%%%%%%%%%%%%%%% CHAPITRES %%%%%%%%%%%%%%%%
\mainmatter
\pagestyle{mainmatter}
\setcounter{page}{1}
\include{chp1/chp1_main}
\include{chp2/chp2_main}
\include{chp3/chp3_main}

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容