我希望小节从 开始,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}
获取编号的小节以及小节的目录条目。
补充说明:
\thesection
等的重新定义\thesubsection
是没有必要的。 重新定义\thechapter
就足够了。- 不要使用
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}