不含枚举的部分

不含枚举的部分

我通过输入 section * 来声明没有编号的节,但会根据级别显示一个编号,如图所示。我希望用 section * 声明的节没有编号,这里是当前代码。

\documentclass[svgnames,french,english,12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{anysize}
\marginsize{22mm}{14mm}{12mm}{25mm}
\usepackage{colortbl} 
\usepackage{fancybox}
\usepackage[explicit]{titlesec}
\titleformat{\section}[block]{\sffamily\Large\bfseries\color{white}}%
{}{0em}{\colorbox{RoyalBlue!90}{\parbox{\dimexpr\linewidth-2\fboxsep}{\thesection\enspace #1}}}

\titleformat{\subsection}[block]{\sffamily\Large\bfseries\color{white}}%
{}{0em}{\colorbox{RoyalBlue!30}{\parbox{\dimexpr\linewidth-2\fboxsep}{\thesubsection\enspace #1}}}

\titleformat{\subsubsection}{\sffamily\large\bfseries\color{RoyalBlue}}{\thesubsubsection\enspace #1}{1em}{}[{\color{black}\titlerule[1.5pt]}]
\usepackage{tikz}
\usepackage{kpfonts}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=black] (0,0) rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
              rounded corners=20pt,inner sep=11pt,
              fill=MidnightBlue]
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
\begin{document}
\chapter{Chapitre 1}
\section*{section without numerotation }
\section{section 1}
\section{section 2}
\section{section without numerotation''}
\end{document}

这是我生成 pdf 文件时得到的结果。

在此处输入图片描述

感谢您的帮助 !

答案1

将其添加到您的代码中:

\titleformat{name=\section, numberless}[block]{\sffamily\Large\bfseries\color{white}}%
{}{0em}{\colorbox{RoyalBlue!90}{\parbox{\dimexpr\linewidth-2\fboxsep}{#1}}}

相关内容