2

I know, that it is possible to add dot after the chapter / section / subsection number. But if I use

\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}

(as in this solution: How to add a dot after the section number?), then I have too many dots in the case of number of figure / theorem etc. For example, if I apply

\documentclass[10pt]{book}
\usepackage{amsmath,amssymb,amsthm}

\usepackage[chapter]{algorithm}

\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}

\newtheorem{defin}{Def.}[chapter]
\newtheorem{tw}[defin]{Th.}

\begin{document}

\chapter{New chapter}

\begin{defin}
Some definition
\end{defin}

\begin{algorithm}
\caption{Some algorithm}
\end{algorithm}

\begin{figure}[hptb]
\caption{Some caption}
\end{figure}

\section{New section}

\begin{defin}
Some definition
\end{defin}


\end{document}

then I have enter image description here

How could I remove the unnecessary dots in 1..1 and similar numbers? Thank you in advance for your answer. Edit: I have realized, that my question can be put in other way. Is this possible to add dots, but only: 1. in the case of titles of chapters / sections etc. 2. and in the case of table of contents, but not for other references?

errenay
  • 71
  • 3
    You should really apply the period (dot) to the target counter, e.g., \renewcommand{\thealgorithm}{\thechapter.\arabic{algorithm}}. – barbara beeton Dec 16 '19 at 16:48

2 Answers2

0

It seems, that instead of this code

\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}
\renewcommand{\thesubsection}{\thesection\arabic{subsection}.}

I should use

\usepackage{titlesec}
\titlelabel{\thetitle .\quad}
\usepackage[dotinlabels]{titletoc}

But I'm still looking for the answer in the case of chapters.

errenay
  • 71
  • Please don't answer your question. Instead, Edit your question. –  Apr 20 '19 at 14:41
  • @ferahfeza Self-answers are fine. In this case, though, I’d agree that an edit is better. This is only a partial answer, and the author still hopes for a more complete one, but it makes the question appear to have been answered. – Davislor Aug 12 '20 at 17:18
0

Patch \@seccntformat, \floatc@ruled and \@makechapterhead to add the period.

Also add \@ both in \@seccntformat and in the \newtheorem with Def. or the period would produce extended end-of-sentence space.

\documentclass[10pt]{book}
\usepackage{amsmath,amssymb,amsthm}

\usepackage[chapter]{algorithm} \usepackage{etoolbox}

\makeatletter \renewcommand{@seccntformat}[1]{\csname the#1\endcsname.@\quad} \patchcmd{@makechapterhead}{\thechapter}{\thechapter.}{}{} \patchcmd{\floatc@ruled}{#1}{#1.@}{}{} \makeatother

\newtheorem{defin}{Def.@}[chapter] \newtheorem{tw}[defin]{Th.}

\begin{document}

\chapter{New chapter}

\begin{defin} Some definition \end{defin}

\begin{algorithm} \caption{Some algorithm} \end{algorithm}

\begin{figure}[hptb] \caption{Some caption} \end{figure}

\section{New section}

\begin{defin} Some definition \end{defin}

\end{document}

enter image description here

egreg
  • 1,121,712