3

I'd like to have dot at end of the number of chapter and at the end of the number of theorem.

I tried to use something like that:

\documentclass{report}
\usepackage{amsthm}

\newtheorem{definition}{Definicja}[chapter]

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

\begin{document}

    %EDIT
    \tableofcontents
    %END EDIT

    \chapter{Chapter}
    \section{Section}
    \begin{definition}
        Some content
    \end{definition}    
\end{document}

but theorem looks like this (two dots):
enter image description here

How to remove this dot in theorem after number of chapter and add dot at end of the theorem. It should be: Definicja 2.1.

  • 2
    Welcome to TeX SX! Don't do it this way. Any reference to Chapter 2 will appear as Chapter 2.. For a standard document class, you might use \usepackage{titlesec} \titlelabel{\thetitle.\quad} instead. – Bernard Jul 19 '16 at 11:12
  • 2
    Welcome to TeX.SE! Please extend your code sniped to small, complete document with start \documentclass{...} and end with \end{document} which will demonstrate your problem. By the way, the \renewcommand{\thesubsection}` probably should be \renewcommand{\thesubsection}{\thechapter\arabic{section}\arabic{subsection}.}` – Zarko Jul 19 '16 at 11:13
  • @Bernard I tried your solution and dot at end of the number of the chapter did not appear. – Kedrzu Jul 20 '16 at 5:33
  • @Zarko I've just changed post according to your suggestion – Kedrzu Jul 20 '16 at 5:34
4

To add a dot after the chapter number in the title of the chapter only, you need to patch \@makechapterhead:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\thechapter}% <search>
  {\thechapter.}% <replace>
  {}{}% <success><failure>
\makeatother

To add a dot after the (any) sectional number in its title only, you can update \@seccntformat:

\makeatletter
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother

The default display for a theorem defined under amsthm is to end its number with a dot.

Here is a complete minimal example highlighting the above:

enter image description here

\documentclass{report}

\usepackage{amsthm}

\newtheorem{definition}{Definicja}[chapter]

%\renewcommand{\thechapter}{\arabic{chapter}}% Default
%\renewcommand{\thesection}{\thechapter.\arabic{section}}% Default

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
  {\thechapter}% <search>
  {\thechapter.}% <replace>
  {}{}% <success><failure>
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother

\begin{document}

\setcounter{chapter}{6}% Just for this example
\chapter{Chapter}

\setcounter{section}{7}% Just for this example
\section{Section}

\setcounter{definition}{8}% Just for this example
\begin{definition}
Some content
\end{definition}

\end{document}
|improve this answer|||||
  • Thanks, generally works, but I have one more issue, there is no dots in table of content after number of chapter/section/subsection. – Kedrzu Jul 20 '16 at 6:18
  • @Kedrzu: If you're using etoolbox as in my answer, you can also add \patchcmd{\numberline}{\hfil}{.\hfil}{}{} to the preamble. If you're not using etoolbox, you can add \makeatletter \renewcommand{\numberline}[1]{\hb@xt@\@tempdima{#1.\hfil}} \makeatother. Similar changes can be applied using tocloft, or by writing the . when writing the ToC-entry... – Werner Jul 20 '16 at 6:25
  • Thanks, a lot! I just have found here another solution, with tocloft: \renewcommand{\cftsecaftersnum}{.} \renewcommand{\cftchapaftersnum}{.}. Accepted as answer, unfortunetly I have no rights to vote. – Kedrzu Jul 20 '16 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.