1

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}
\addto\captionsspanish{%
    \renewcommand{\tablename}%
    {Tabla}%
}

\makeatletter
 %%add prefix Figura/Tabla in LoF/LoT
 \long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\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
Sebastiano
  • 54,118
Joan
  • 479
  • Related: https://tex.stackexchange.com/questions/202928 and https://tex.stackexchange.com/questions/24439. – Dr. Manuel Kuehner Feb 21 '19 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 '19 at 19:36
  • It was/is a proposal - nothing more. I am pretty sure (just an assumption), that this is not a first-of-its-kind question :). – Dr. Manuel Kuehner Feb 21 '19 at 19:51
  • 1
    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 '19 at 19:54
  • @Mico - I added to my question what I really want, don't worry about (c). Thanks. – Joan Feb 21 '19 at 20:01
  • @Joan - What about the numbers in front of figure and table captions in the body of the text: Should a dot get affixed to those numbers as well? – Mico Feb 21 '19 at 20:03
  • @Mico - Yes, I also want the dot to be reflected in the caption of the figures and tables instead of the two points that appear by default. Thanks again. – Joan Feb 21 '19 at 20:07
  • 1
    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 '19 at 20:24
  • The idea of ​​not using packages is because I am creating my own class as a thesis requirement, and one of the requirements is not to use any package. – Joan Feb 21 '19 at 20:30
  • 1
    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 '19 at 20:35
  • I'm certainly using some basic packages like babel, fontenc and inputenc, but I'm trying my best not to use packages in things that can be modified with some ease in the class book – Joan Feb 21 '19 at 20:41
  • @Joan - I guess you know better which "things ... can be modified with some ease". – Mico Feb 21 '19 at 21:03
  • @Mico - I have clear things that I want to modify, but I do not know if it is easy to do without the help of packages, that is why the question. – Joan Feb 21 '19 at 21:07

2 Answers2

3

(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.

enter image description here

enter image description here

enter image description here

enter image description here

\documentclass{book}
\usepackage[spanish,es-nosectiondot]{babel}
\addto\captionsspanish{%
   \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}
Mico
  • 506,678
  • 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 '19 at 19:31
  • +1: Is titlesec also considered "well debugged"? – Dr. Manuel Kuehner Feb 21 '19 at 20:39
  • 1
    @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 '19 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 '19 at 21:02
  • @Mico - maybe it's helpful to another user. – Joan Feb 21 '19 at 22:00
1

Is this different from what you want?

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

\usepackage{titlesec}
\titlelabel{\thetitle\quad}

\begin{document}

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

\end{document}

enter image description here

  • I'm trying to do it without the use of packages. – Joan Feb 21 '19 at 20:14
  • @Joan Where do you state this in your question? Maybe I overread it. – Dr. Manuel Kuehner Feb 21 '19 at 20:15
  • I did not say it in my question because I was following the previous post and in fact it is so I want to do it, that is, without the use of packages, but you are right. – Joan Feb 21 '19 at 20:18
  • @Joan I recommend spending more time in preparing a good/precise question. This is not easy in the beginning :). It is also related to spanish I think. Maybe add this too to the title. In addition, your MWE doesn't look very minimal to me. – Dr. Manuel Kuehner Feb 21 '19 at 20:20
  • Your code suppresses the dots after the numbers in the sectioning headers, but not in the ToC. Also, it doesn't seem to affect the appearance of figure and table captions, either in the body of the document or in the LoF and LoT, respectively. – Mico Feb 21 '19 at 20:47
  • 1
    @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 '19 at 20:48
  • 1
    @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 '19 at 20:50
  • 1
    Yeah, our work is evidently nothing but a disappointment to the OP. Sigh. Get a good night's rest! – Mico Feb 21 '19 at 21:01