# Remove the dot after section number in ToC [witouth any package] [duplicate]

I'm using the book class and I want to remove the final dot in the section number, i.e, I have

1. Chapter Name
1.1. Section Name
1.1.1. Subsection Name
1.1.1.1. Subsubsection Name


I want

 1. Chapter Name
1.1 Section Name
1.1.1 Subsection Name
1.1.1.1 Subsubsection Name


Looking for similar post, I found [How remove dot after section number in ToC with babel's spanish? and although the solution is very good I still have a problem: when I use the code es-nosectiondot the dot of the chapter disappears in the ToC, same is for LoF and LoT, i.e, Figure 1 (Table 1) instead Figure 1. (Table 1.), so, following the post I use the code \def\numberline#1{\hb@xt@\@tempdima{#1\if&#1&\else.\fi\hfil}}, which is useful because it solves the previous problem, but now the dot of the section, subsection and subsubsection appears in the ToC, i.e,

1. Chapter Name
1.1. Section Name
1.1.1. Subsection Name
1.1.1.1. Subsubsection Name


This is my MWE:

\documentclass{book}

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

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\renewcommand{\tablename}%
{Tabla}%
}

\makeatletter
\long\def\@caption#1[#2]#3{%
\par
{\protect\numberline{\csname fnum@#1\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{5em}}%
\let\l@table\l@figure
%%egreg's code
\def\numberline#1{\hb@xt@\@tempdima{#1\if&#1&\else.\fi\hfil}}
\makeatother

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{Chapter}
\section{Section}
\begin{table}[h]
\caption{Some table}
\centering abc
\end{table}

\begin{figure}[h]
\caption{A figure}
\centering xyz
\end{figure}
\subsection{Subsection}
\subsubsection{Subsubsection}

\end{document}


I want

ToC
1. Chapter
1.1 Section
1.1.1 Subsection
1.1.1.1 Subsubsection

LoT
Table 1.

LoF
Figure 1.

1.1 The Section
Content
1.1.1 The Subsection
Content
1.1.1.1 The Subsubsection
Content


## marked as duplicate by Dr. Manuel Kuehner, Phelype Oleinik, Sebastiano, Stefan Pinnow, MicoFeb 21 at 21:04

• – Dr. Manuel Kuehner Feb 21 at 19:15
• @Dr.ManuelKuehner - Although my question is similar, the solution is not totally useful to me. So please do not mark my post as a duplicate. – Joan Feb 21 at 19:36
• Just so I understand your objectives: You (a) do not want final dots for sectioning-related composite numbers (including in the ToC), (b) you do want final dots for the numbers of figure and table numbers (including in the LoF and LoT), and (c) you want to prefix the strings "Figura" and "Tabla", resp., to the numbers in the LoF and LoT. Is this understanding correct? – Mico Feb 21 at 19:54
• After the update in the title: Any specific reason for not wanting to use an elegant package (titlesec) that was generated for this purpose? – Dr. Manuel Kuehner Feb 21 at 20:24
• As you're employing the babel package, aren't you disregarding your own supreme requirement? Seriously, though: Many packages that are well suited to meeting your formatting objectives have been around for a long time, they are readily available with all TeX distributions, and are they are well debugged. I suggest you go back to the persons who came up with the absurd requirement that no external LaTeX packages are allowed and try to show them the errors in their ways. – Mico Feb 21 at 20:35

(I rewrote this answer from scratch after gaining a better understanding of the OP's formatting objectives.

I can't provide an answer that doesn't rely on external LaTeX packages. However, since the caption and tocloft packages have been around quite a few years, are very well debugged, and are known to work well with the book document class, I'm not going to make any apologies for employing these two packages.

I suggest you (a) keep using the instruction \usepackage[spanish,es-nosectiondot]{babel}, (b) employ the caption to change the label separator from : ("colon") to . (period) in the body of the document, and (c) employ the tocloft package to modify the appearance of figure and table entries in the LoF and LoT, respectively. You can ditch the code chunk between \makeatletter and \makeatother in your MWE, though.

\documentclass{book}
\usepackage[spanish,es-nosectiondot]{babel}
\renewcommand{\tablename}{Tabla}
\renewcommand{\listtablename}{\'Indice de tablas} % do you need this?
}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}

%% modify the separator between caption numbers and text
\usepackage{caption}
\captionsetup{labelsep=period,skip=0.333\baselineskip}

\usepackage[titles]{tocloft}
%% modify appearance of entries in LoF and LoT
\cftsetindents{figure}{0em}{5em} % how much space to set aside
\cftsetindents{table}{0em}{5em}
\renewcommand{\cftfigpresnum}{\figurename\space} % prefix material
\renewcommand{\cftfigaftersnum}{.}               % postfix material
\renewcommand{\cfttabpresnum}{\tablename\space}
\renewcommand{\cfttabaftersnum}{.}

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{Chapter}
\section{Section}
\begin{table}[h] \caption{Some table} \centering abc \end{table}
\begin{figure}[h] \caption{A figure} \centering xyz \end{figure}
\subsection{Subsection}
\subsubsection{Subsubsection}
\end{document}

• But if I remove the dot then in the LoF and LoT disappears the point of the prefix table and figure as I mentioned before. – Joan Feb 21 at 19:31
• +1: Is titlesec also considered "well debugged"? – Dr. Manuel Kuehner Feb 21 at 20:39
• @Dr.ManuelKuehner - As the code in your answer uses only a very small -- and well understood -- subset of the capabilities of the titlesec package, I'd say you're moving on very solid ground when employing the \titlelabel macro. :-) – Mico Feb 21 at 20:43
• @Joan - Do you want me to delete this answer as it quite evidently violates your no-external-packages rule and hence can't be used by you? – Mico Feb 21 at 21:02
• @Mico - maybe it's helpful to another user. – Joan Feb 21 at 22:00

Is this different from what you want?

\documentclass{book}
\usepackage[spanish]{babel}

\usepackage{titlesec}

\begin{document}

\chapter{Test}
\section{Test}
\subsection{Test}

\end{document}


• I'm trying to do it without the use of packages. – Joan Feb 21 at 20:14
• @Joan Where do you state this in your question? Maybe I overread it. – Dr. Manuel Kuehner Feb 21 at 20:15
• @Mico I fulfilled the request I'm using the book class and I want to remove the final dot in the section number in the question (and the I want code block). Maybe I missed some parts below :). I am listening to a live lecture and was a bit distracted :). For me, the question is poorly stated. – Dr. Manuel Kuehner Feb 21 at 20:48
• @Mico You don't seem to get an upvote either. Maybe we both disappoint. (I mean it funny - if that's lost in translation). Going to bed now. Bye :). – Dr. Manuel Kuehner Feb 21 at 20:50
• Yeah, our work is evidently nothing but a disappointment to the OP. Sigh. Get a good night's rest! – Mico Feb 21 at 21:01