0

I can't seem to get the numbers of my theorems back in my custom theorem environment, some help would be appreciated:

\documentclass[10pt,a4paper]{article}


\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{hyperref,nameref}

\makeatletter
\declaretheoremstyle[
spaceabove=6pt, 
spacebelow=6pt, 
headfont=\normalfont\bfseries, 
notefont=\em\mdseries, 
notebraces={(}{)}, 
headpunct={},
bodyfont=\itshape, 
headformat=\NAME\ \NOTE\\\@afterheading,
]{theorem}
\makeatother

\declaretheorem[style=theorem,
numbered=yes,
name=Theorem, 
refname={theorem,theorem}, 
Refname={Theorem,Theorems}]{theorem}

\begin{document}


\section{First section}
\begin{theorem}
First theorem
\end{theorem}

\begin{theorem}
Second theorem
\end{theorem}

\section{Second section}

\begin{theorem}
Third theorem
\end{theorem}

\end{document}

1 Answer 1

2

You simply format to add the \NUMBER command:

\documentclass[10pt,a4paper]{article}

\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{hyperref,nameref}

\makeatletter
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
headfont=\normalfont\bfseries,
notefont=\em\mdseries,
notebraces={(}{)},
headpunct={},
bodyfont=\itshape,
headformat=\NAME\,\textcolor{red}{\NUMBER}\NOTE\\\@afterheading,
]{theorem}
\makeatother

\declaretheorem[style=theorem,
numbered=yes,
name=Theorem,
refname={theorem,theorem},
Refname={Theorem,Theorems}]{theorem}

\begin{document}


\section{First section}
\begin{theorem}[First trial]
First theorem
\end{theorem}

\begin{theorem}
Second theorem
\end{theorem}

\section{Second section}

\begin{theorem}
Third theorem
\end{theorem}

\end{document} 

enter image description here

5
  • Thank you! So if I want to use the same theoremstyle for theorems and say propositions I would need to create a copy of the style whithout the number command?
    – WrabbitW
    Apr 8, 2019 at 22:02
  • Because you don't want them to be numbered?
    – Bernard
    Apr 8, 2019 at 22:06
  • Yes, my question should have been: Is there a way to put the \NUMBER command in the \declaretheorem instead of \declaretheoremstyle.
    – WrabbitW
    Apr 8, 2019 at 22:15
  • It seems the headformat key is known only to \declaretheoremstyle, so I think it isn't possible. See the keys known to \declaretheorem in §3.2 of the documentation, pp. 14-15.
    – Bernard
    Apr 8, 2019 at 22:23
  • Okay merci beaucoup pour votre aide!
    – WrabbitW
    Apr 8, 2019 at 22:36

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.