9

I am reading the document for titlesec package. There is a command called \titlelabel{<lable-format>} and the document says:

"Changes the label format in sections, subsections, etc. A \thetitle command is provided which is respectively \thesection, \thesubsection, etc. The default value in standard classes is..."

I am wondering about what \thetitle, \thesection, \thesubsection do.

egreg
  • 1,121,712
Xanh
  • 91

1 Answers1

8

The commands \thesection, \thesubsection, etc. are commands of any standard document class that show the actual formatted numeration for \section, \subsection, etc. as. I mean that could print some like "3.3" or "III.c" depending of how they are defined.

For example, in the article document class by default \thesection is defined as \@arabic\c@section than mean \arabic{section} (here section without \ is the name of the counter) whereas for \thesubsection is \thesection .\@arabic \c@subsection (i.e, \arabic{section}.\arabic{subsection}), etc.

The \thetitle is a wildcard to the above comnands of the titlesec package, so after a \section{} will be \csname thesection\endcsname and after a \subsection{} will be \csname thesubsection\endcsname, etc. You can see in the next MWE how \thetitle change to be equal to \thesection or the \thesubsection depending on its position into the text:

\documentclass{article}
\usepackage{titlesec}
\titlelabel{\thetitle\quad---\quad} % "original" format beside \thetitle
\begin{document}
\section{First section}
This is the section \thesection \\
This is the subsection \thesubsection \\
This is the title \thetitle
\section{Second  section}
This is the section \thesection \\
This is the subsection \thesubsection \\
This is the title \thetitle
\subsection{First subsection}
This is the section \thesection \\
This is the subsection \thesubsection \\
This is the title \thetitle
\end{document}

mwe

Fran
  • 80,769
  • I'm not understanding the documentation's "section, subsection, etc." comment. Does this mean I can redefine the sections known as "\chapter" and/or "\part" or only "\section" and "\subsection" ? – user12711 Jan 10 '16 at 19:32
  • 1
    @user12711 ? Yes, you can redefine almost anything in LaTeX (if that is a good idea is another issue) . – Fran Jan 10 '16 at 19:56
  • I mean, "can I use the titlesec command called \titlelabel to change \chapter title labels, or is it specifically designed to be used with sections below the chapter section level, i.e., section, subsection, paragraph and subparagraph?" (I'd like to add some psfont dingbat \ding{etc} decorations before the word "CHAPTER" and after the section (number) ) – user12711 Jan 10 '16 at 20:16
  • 2
    @user12711 I see. No, \titlelabel is for label format in sections and inferior levels, but you can use \titleformat, e.g. \titleformat{\chapter}[hang]{\centering\bfseries\huge}{\S\ Chapter \thechapter\ \S}{1em}{ --- }[\hrule]. Run texdoc titlesec for more information. – Fran Jan 10 '16 at 20:59