2

I want to remove the dot after the numbering of theorems, definitions etc. within the amsthm package. (So I get Theorem 1.1 instead of Theorem 1.1.) (EDIT: I want to remove the dot from the theorems themselfs)
I am using both the hyperref and the cleveref packages, both of which pose problems. I already found a solution to the hyperref package here Remove dot after theorem with amsthm and hyperref, but when using the cleveref package, the dot reappears.

MWE:

\documentclass[a4paper,12pt,oneside]{scrbook}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}[chapter]

\usepackage{xpatch} \makeatletter \AtBeginDocument{\xpatchcmd{@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}} \makeatother

\begin{document}

\chapter{Hello}

\begin{theorem} World \end{theorem}

\end{document}

which outputs
enter image description here
How can i remove that dot?

Xoriun
  • 161
  • Do you want to remove it from the references or also from the theorem itself? – Bernard Jul 20 '21 at 20:19
  • @Bernard from the Theorem itself – Xoriun Jul 20 '21 at 20:42
  • Well, this is quite easy with the ntheorem package: you just code \theorem{separator{} before declaring your theorems, definitions, &c. – Bernard Jul 20 '21 at 20:47
  • @Bernard the ntheorem package gives me an error: ! Package ntheorem Error: Theorem style plain already defined. – Xoriun Jul 20 '21 at 20:57
  • Did you load both amsthm and ntheorem? – Bernard Jul 20 '21 at 21:04
  • yes, I did. When I only use the ntheorem package, I don't even need the \theorem{separator{}}. However I then run into difficulties, since I use quite some features from amsthm. – Xoriun Jul 20 '21 at 21:14

2 Answers2

4

cleveref changes \@thm making the linked solution not work anymore. Adding \tracingpatches before you attempt to patch \@thm will reveal that the "search pattern [is] not found in [the] replacement text."

The following updates the patches when using cleveref:

enter image description here

\documentclass{scrbook}

\usepackage{amsthm} \usepackage{hyperref} \usepackage{cleveref}

\newtheorem{theorem}{Theorem}[chapter]

\usepackage{xpatch} \makeatletter % Patch to accommodate for \begin{theorem}[...] \AtBeginDocument{\xpatchcmd{\cref@thmoptarg}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}} % Patch to accommodate \begin{theorem} (without an optional argument) \AtBeginDocument{\xpatchcmd{\cref@thmnoarg}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}} \makeatother

\begin{document}

\chapter{Hello}

\begin{theorem} World \end{theorem}

\end{document}

My (rough) process for identifying the updates patches:

  • Add a \typeout{success} and \typeout{failure} to the <success> and <failure> in the patch:

    \xpatchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
    

    This will allow you to examine the .log and see whether the patch worked or failed.

  • If it failed, add \tracingpatches before the patches are made and see what the .log outputs. Is the search pattern still the same? Did the macro change?

  • Look at the actual macro being patched to see what it is defined as using \show. In my case, \show\@thm.

  • From there, follow any subsidiary macro definitions to see find out where the changes should be applied to your original \xpatchcmd.

    In this case, \@thm conditioned on an optional argument, and it was clearly introduced by cleveref since the two subsidiary macros were \cref@thmoptarg and \cref@thmnoarg.

Werner
  • 603,163
2

Since you're using amsthm, you would need to define a new theorem style:

\newtheoremstyle{nodot}
  {}{} % Default space above and below
  {\itshape}{} % italic body unindented
  {\bfseries}{} % bold theorem head, no dot after
  { }{} % normal space between theorem head and body, default head spec

The full details can be had by typing texdoc amsthm at a command line.

Don Hosek
  • 14,078