Legrand 橙皮书模板:未编号章节*标题获得编号

Legrand 橙皮书模板:未编号章节*标题获得编号

我的书的未编号章节(chapter*)有问题。我得到了下图中所示的内容:

在此处输入图片描述

章节周围的框在右侧打开了,这不是我想要的。我尝试修复这个问题;现在章节标题周围的框关闭了,但我现在面临一个新问题:在未编号的章节 (chapter*) 之前出现 0(零),而未编号的章节应该没有任何数字。

我现在得到的结果可以在下图中看到:

在此处输入图片描述

\documentclass[12pt]{book}
\usepackage[paperwidth=20cm, paperheight=29cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz}  %%
\usetikzlibrary{arrows.meta, calc, chains, positioning, babel}
\definecolor{ocre}{RGB}{70,50,212} %

\makeatletter
\renewcommand{\@seccntformat}[1]{\llap{\textcolor{ocre}{\csname the#1\endcsname}\hspace{1em}}}                    
\renewcommand{\section}{\@startsection{section}{1}{\z@}
{-4ex \@plus -1ex \@minus -.4ex}
{1ex \@plus.2ex }
{\normalfont\large\sffamily\bfseries}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
{-3ex \@plus -0.1ex \@minus -.4ex}
{0.5ex \@plus.2ex }
{\normalfont\sffamily\bfseries}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
{-2ex \@plus -0.1ex \@minus -.2ex}
{.2ex \@plus.2ex }
{\normalfont\small\sffamily\bfseries}}                        
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}
{-2ex \@plus-.2ex \@minus .2ex}
{.1ex}
{\normalfont\small\sffamily\bfseries}}

%----------------------------------------------------------------------------------------
%   CHAPTER HEADINGS
%----------------------------------------------------------------------------------------

% A switch to conditionally include a picture, implemented by Christian Hupfer
\newif\ifusechapterimage
\usechapterimagetrue
\newcommand{\thechapterimage}{}%
\newcommand{\chapterimage}[1]{\ifusechapterimage\renewcommand{\thechapterimage}{#1}\fi}%
\newcommand{\autodot}{.}

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

\def\@makeschapterhead#1{%
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white, 
%fill opacity=0.5,
inner sep=15pt]{%
  \huge\sffamily\bfseries\color{black}\strut\thechapter\autodot~%
  \parbox[t]{14cm}{\raggedright#1\strut}};

\end{tikzpicture}};
\end{tikzpicture}
\par\vspace*{270\p@}}
\makeatother

\begin{document}

\tableofcontents % Print the table of contents itself

\chapter*{Préambule}

\chapter*{Bibliographie}

\end{document}

答案1

\thechapter\autodot~从定义中删除\@makeschapterhead

\documentclass[12pt]{book}
\usepackage[paperwidth=20cm, paperheight=29cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\definecolor{ocre}{RGB}{70,50,212} %

\makeatletter  
\def\@makeschapterhead#1{%
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\draw[anchor=west] (\Gm@lmargin,-9cm) node [line width=2pt,rounded corners=15pt,draw=ocre,fill=white, 
%fill opacity=0.5,
inner sep=15pt]{%
\huge\sffamily\bfseries\color{black}\strut\parbox[t]{14cm}{\raggedright#1\strut}};
\end{tikzpicture}};
\end{tikzpicture}
\par\vspace*{270\p@}}
\makeatother

\begin{document}
\tableofcontents
\end{document}

在此处输入图片描述

相关内容