# Formatting counter in section, subsection and subsubsection

I want to show a counter with subsubsection-level headers and remove the final dot from the section counter, subsection and subsubsection (assuming you can assign a counter to subsubsection) by employing the book class, but without the help of packages. This is because I am creating my own class using the file book.cls.

More specifically I want

1.1 Section
1.1.1 Subsection
1.1.1.1 Subsubsection


1.1. Section
1.1.1. Subsection
1.1.1.1. Subsubsection


Is it possible to achieve this?

• Writing a class of one's own is tedious and requires some fundamental knowledge on LaTeX. You're trying to reinvent the wheel, most likely – user31729 Feb 17 at 18:13
• @ChristianHupfer On the other hand, a lot of “advertisements” (introductory tutorials, etc) for LaTeX suggest that the way to modify the overall appearance of a document is to write your own class. So... users can hardly be blamed for trying to do exactly that. – ShreevatsaR Feb 17 at 18:43
• @ShreevatsaR: Well, that's the fault of those other sources of course. It's however really blindsighted to believe that beginners of LaTeX can do it on their own. 99.99% can't. Period. – user31729 Feb 17 at 18:51
• @ChristianHupfer - But do we know whether Joan is a beginner? :-) – Mico Feb 17 at 19:00
• @Joan - Do take the spirit of Christian H's comments to heart: Many LaTeX packages have been around for a long time and are quite stable, meet specific formatting needs very well, and tend to be well debugged. Rather than re-invent the wheel, so to say, by coming up with your own code, you may want to look into what various packages can do for you and load some packages with judiciously chosen options. For sure, it makes little sense to ignore the capabilities of packages such as geometry, amsmath and amssymb, caption, siunitx, natbib, hyperref, or cleveref, to name but a few. – Mico Feb 17 at 19:13

You wrote,

Just insert the instruction

\setcounter{secnumdepth}{3}


in the preamble. The default value of this counter for the book class is 2, meaning that only subsection headers (and thus also section and chapter and part headers) get numbered.

\setcounter{tocdepth}{3}


in the preamble. (You can probably guess that the default value of this counter is 2.)

You also wrote,

[I want to] remove the final dot from the section counter, subsection and subsubsection

The format without a final dot is actually the default in the book document class. In a comment, you've indicated that you employ the babel package with the language option spanish. Indeed, this setting overrides the book default, i.e., it affixes dots to section, subsection, and subsubsection numbers. To override this language-specific setting, one needs to load the babel package with the additional option es-nosectiondot:

\usepackage[spanish,es-nosectiondot]{babel}


or, equivalently, write

\usepackage[spanish.nosectiondot]{babel}


For more information on this subject, see the posting How to remove dot after section number in ToC with babel's spanish? For more information on what the spanish language option of the babel package does and how the resulting, language-specific settings can be modified, type

texdoc babel-spanish


at a command prompt. The user guide document that will open up is written in Spanish -- no problem for you, right? :-)

An MWE (minimum working example):

\documentclass{book}
\setcounter{secnumdepth}{3} % default for book class: 2
\usepackage[spanish,es-nosectiondot]{babel} % suppress affixed dots
\begin{document}
\chapter{One}
\section{One.One}
\subsection{One.One.One}
\subsubsection{One.One.One.One}
\end{document}

• I'm not using any package other than babel, inputenc and fontenc, it's weird because all I did was collect the file code book.cls. Do you know in which part of the file can I verify this? – Joan Feb 17 at 16:08
• @Joan - Which language(s) do you employ with babel? And, which TeX distribution (and which vintage) do you use? – Mico Feb 17 at 16:54
• spanish for babel and TeX Live. – Joan Feb 17 at 16:57
• @Joan - Indeed, that setting will add a dot after section, subsection, and subsubsection numbers. I edited my answer to give an instruction on what to do -- basically, one also needs to pass the option es-nosectiondot to babel. – Mico Feb 17 at 18:30
• @Joan - Did you notice how I updated my answer about two hours ago? In the updated answer, I recommend changing \usepackage[spanish]{babel} to \usepackage[spanish,es-nosectiondot]{babel}. This gets rid of the dot that's affixed to section, subsection, and subsubsection numbers. – Mico Feb 17 at 21:24