0

I declare sections without numbering by typing section *, but a number is displayed according to the level, as shown in the figure. I want sections declared with section * to have no number here is the current code.

\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}

And this what i get when generate a pdf file .

enter image description here

Thank you for your help !

  • In some way off topic. But I think that you have a misconception about \section{...} and \section*{...}. The latter isn't simply a section without numbering. It's more correct to say that it is a section that doesn't increment the counter of sections. Of course, usually you display a \section*{...} but if what you really want is to don't display numbering you should follow other ways. – gvgramazio Jun 8 '18 at 12:27
1

Add this to your code:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.