3

If I number theorems by sections, then amsthm numbers the first theorem in the first section as

Theorem 1.1.

How can I change this to

Theorem 1-1

?

4
  • A quick method is \makeatletter \renewcommand{\@thmcountersep}{-} \makeatother Sep 23 at 16:57
  • @barbarabeeton Many thanks Barbara! Unfortunately, in my case, this does not seem to work.
    – 220284
    Sep 23 at 18:23
  • 1
    What have you tried? Please provide an MWE (from \documentclass... to \end{document}) that we can compile that shows what you have done and what the problem is. Why should we have to try and guess your code? Sep 23 at 18:33
  • As I write below, what Mico proposes works just fine. That's good enough for me.
    – 220284
    Sep 23 at 18:39

1 Answer 1

5

If you've set up a theorem-like environment called, say, theorem, via

\newtheorem{theorem}{Theorem}[section]

then all you need to add is the instruction

\renewcommand\thetheorem{\thesection-\arabic{theorem}}

As per @barbarabeeton's comment, if you want to change the numbering style for all theorem-like environments, it would actually be much easier to execute

\makeatletter 
\renewcommand{\@thmcountersep}{-} 
\makeatother

in the preamble.


If, in addition, you also want to suppress the . ("dot", aka "full stop") after the composite theorem number, I suggest you execute the following code in the preamble:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother

A full MWE (minimum working example):

enter image description here

\documentclass{amsart} % or some other suitable docuemnt class
%% \usepackage{amsthm} % not needed if 'amsart' doc. class is in use

\usepackage{etoolbox}
\makeatletter
\renewcommand{\@thmcountersep}{-} % per @barbarabeeton's suggestion
\patchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{} % optional
\makeatother

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\begin{document}
\setcounter{section}{3}
\begin{theorem} Bla bla bla. \end{theorem}
\begin{definition} Ble ble ble. \end{definition}
\end{document}
2
  • Many thanks Mico! Barbara's solution does not work in my case. I don't know why. Modifying the \thetheorem command does however work. Another method to remove the final dot is to use a custom theoremstyle.
    – 220284
    Sep 23 at 18:29
  • @220284 - The \patchcmd{\@thm}{...}{...}{}{} method suggested above is certainly a global-scople method. I would advocate the \newtheoremstyle route if I wanted to remove the dot just for some theorem-like environments but not for all.
    – Mico
    Sep 23 at 20:01

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.