小节编号问题:

小节编号问题:

我希望小节从 开始,1.1.1而不是它的编号从 开始1.1.0,问题出在哪里,请注意,我使用了renewcommand允许您自定义书籍或任何类别的部分,它适用于小节,但不适用于小节。

代码如下:

% !TeX program = xelatex
\documentclass[openany,12pt]{scrbook}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[tmargin=1.5cm,bmargin=1.5cm,rmargin=1.8cm,lmargin=1.8cm]{geometry}
\frenchbsetup{IndentFirst=false}
\usepackage{tcolorbox}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}


\newtcolorbox{titlecolorbox}[1]{
    coltext=white,
    colframe=black,
    colback=black,
    boxrule=0pt,
    arc=0pt,
    notitle,
    width=4.8em,
    height=2.4ex,
    before=\hfill
}
\titleformat{\chapter}[display]
  {\huge}
  {}
  {2pt}
  {\begin{titlecolorbox}{}
  {\large\MakeUppercase{\chaptername}}
  \end{titlecolorbox}
  \vspace*{-3.08ex}\textcolor{black}{\noindent\rule{\textwidth}{0.5pt}}
  \parbox[b]{\dimexpr\textwidth-4.8em\relax}{\raggedright\MakeUppercase{#1}}{\hfill\fontsize{70}{60}\selectfont\textcolor{blue}{\thechapter}}
  }
  []
  
  

\titleformat{\section}[display]
  {\Large}
  {}
  {0pt}
  {\parbox[b]{\dimexpr\textwidth\relax}{\textcolor{blue}{\thesection}\quad\raggedright\textcolor{blue}{\bfseries{#1}}}}


  \titleformat{\subsection}[display]
  {\large}
  {}
  {0pt}
  {\textcolor{cyan}{\thesubsection}\quad\raggedright\textcolor{cyan}{\textbf{#1}}}
  
  \titleformat{\subsubsection}[display]
  {\normalsize}
  {}
  {0pt}
  {\textcolor{cyan}{\thesubsubsection}\quad\raggedright\textcolor{cyan}{\textbf{#1}}}
  
\renewcommand\thechapter{\Roman{chapter}}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
\begin{document}
\chapter{Chapter  :}
\section{section  :}
bla bla bla bla....
\subsection{subsection :}
bla bla bla bla....
\subsubsection{subsubsection :}
bla bla bla bla....
\end{document}

在此处输入图片描述

您对如何解决以下问题有什么想法吗?

答案1

使用 KOMA-Script 类,您可以使用

\setcounter{secnumdepth}{\subsubsectionnumdepth}
\setcounter{tocdepth}{\subsubsectiontocdepth}

获取编号的小节以及小节的目录条目。

补充说明:

  1. \thesection等的重新定义\thesubsection是没有必要的。 重新定义\thechapter就足够了。
  2. 不要使用titlesec带有 KOMA-Script 类的包!

建议:

\documentclass[
  open=any,fontsize=12pt,
  numbers=noenddot% <- added
]{scrbook}
\usepackage[french]{babel}
\frenchbsetup{IndentFirst=false}

\usepackage[T1]{fontenc}
\usepackage[vmargin=1.5cm,hmargin=1.8cm]{geometry}
\usepackage{tcolorbox}% loads packages tikz, xcolor, graphicx, ...
\usepackage{fix-cm}% make font scalable

\setcounter{secnumdepth}{\subsubsectionnumdepth}
\setcounter{tocdepth}{\subsubsectiontocdepth}
\renewcommand\thechapter{\Roman{chapter}}

\newtcolorbox{titlecolorbox}[1]{
    coltext=white,
    colframe=black,
    colback=black,
    boxrule=0pt,
    arc=0pt,
    notitle,
    width=4.8em,
    height=2.4ex,
    before=\myhrulefill{.5pt}
}
\newcommand\myhrulefill[2][0pt]{\leavevmode\leaders\hrule height #2 depth #1\hfill\kern0pt}

\renewcommand\chapterlinesformat[3]{%
  \begin{titlecolorbox}{}\large\MakeUppercase{\chaptername}\end{titlecolorbox}\medskip
  \parbox[b]{\dimexpr\textwidth-4.8em\relax}{\raggedright\MakeUppercase{#3}}\hfill#2
}

\renewcommand{\chapterformat}{{\usekomafont{chapternumber}{\thechapter\autodot}}}
\renewcommand{\sectionformat}{{\usekomafont{headingnumber}{\thesection\autodot\quad}}}
\renewcommand{\subsectionformat}{{\usekomafont{headingnumber}{\thesubsection\autodot\quad}}}
\renewcommand{\subsubsectionformat}{{\usekomafont{headingnumber}{\thesubsubsection\autodot\quad}}}

\newkomafont{headingnumber}{\mdseries}
\newkomafont{chapternumber}{\usekomafont{headingnumber}\fontsize{70}{60}\selectfont\color{blue}}
\addtokomafont{disposition}{\normalfont\bfseries}
\addtokomafont{chapter}{\normalfont\huge}
\addtokomafont{section}{\Large\color{blue}}
\addtokomafont{subsection}{\large\color{cyan}}
\addtokomafont{subsubsection}{\normalsize\color{cyan}}

\begin{document}
\tableofcontents
\chapter{Chapter :}
\section{section :}
bla bla bla bla ...
\subsection{subsection :}
bla bla bla bla ...
\subsubsection{subsubsection :}
bla bla bla bla ...
\end{document}

在此处输入图片描述

相关内容