3

Right now I have the following preamble

newtheorem{thm}{Theorem}[section]
\let\oldthm\thm
\renewcommand{\thm}{\oldthm\normalfont}

\newtheorem{corol}{Corollary}[section]
\let\oldcorol\corol
\renewcommand{\corol}{\oldcorol\normalfont}

\newtheorem{lem}{Lemma}[section]
\let\oldlem\lem
\renewcommand{\lem}{\oldlem\normalfont}

\newtheorem{defn}{Definition}[section]
\let\olddefn\defn
\renewcommand{\defn}{\olddefn\normalfont}

\newtheorem{exa}{Example}[section]
\let\oldexa\exa
\renewcommand{\exa}{\oldexa\normalfont}

\newtheorem{prop}{Proposition}[section]
\let\oldprop\prop
\renewcommand{\prop}{\oldprop\normalfont}

that suppresses the italic font that is used by the standard newtheorem command. I am looking to change the way these theorems, lemmas etcetera are numbered. I want to have them numbered by section, using the same counter, so for instance:

Section 1

-- Subsection 1.1

---- Theorem 1.1

---- Corollary 1.2

Section 2

-- Subsection 2.1

---- Lemma 2.1

---- Definition 2.2

Whereas right now the numbering is:

Section 1

-- Subsection 1.1

---- Theorem 1.1

---- Corollary 1.1

Section 2

-- Subsection 2.1

---- Lemma 2.1

---- Definition 2.1

I have tried using a dummy variable as an answer to another question proposed, but I haven't gotten it to work. Thanks in advance!

Edit

Here is a minimal example:

\documentclass{article}

\newtheorem{thm}{Theorem}[section]
\let\oldthm\thm
\renewcommand{\thm}{\oldthm\normalfont}

\newtheorem{corol}{Corollary}[section]
\let\oldcorol\corol
\renewcommand{\corol}{\oldcorol\normalfont}

\newtheorem{lem}{Lemma}[section]
\let\oldlem\lem
\renewcommand{\lem}{\oldlem\normalfont}

\newtheorem{defn}{Definition}[section]
\let\olddefn\defn
\renewcommand{\defn}{\olddefn\normalfont}

\newtheorem{exa}{Example}[section]
\let\oldexa\exa
\renewcommand{\exa}{\oldexa\normalfont}

\newtheorem{prop}{Proposition}[section]
\let\oldprop\prop
\renewcommand{\prop}{\oldprop\normalfont}

\begin{document}

\section{First}

\subsection{A}

\begin{thm}
Theorem
\end{thm}

\begin{corol}
Corollary
\end{corol}

\section{Second}

\subsection{B}

\begin{lem}
Lemma
\end{lem}

\begin{defn}
Definition
\end{defn}

\end{document}
4
  • 3
    Welcome to TeX.SX! Please post a MWE (compilable, but minimal code) that shows your problem to help us help you.
    – TeXnician
    Commented May 29, 2017 at 13:09
  • Sure! Just a minute.
    – Kermit
    Commented May 29, 2017 at 13:24
  • 3
    \usepackage{amsthm} and \newtheorem{definition}[thm]{Definition} should be easiest
    – user31729
    Commented May 29, 2017 at 13:36
  • @ChristianHupfer This adds an unwanted subsection to the numbering of everything that is not a theorem. Any way to remove this?
    – Kermit
    Commented May 29, 2017 at 13:38

3 Answers 3

4

With the amsthm package: When defining a new theorem, you can instruct it to use a shared counter:

\newtheorem{⟨env name⟩}[⟨shared counter⟩]{⟨text⟩}

For more details, see the amsthm documentation: "3 Theorem numbering"

\documentclass{article}

\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{corol}[thm]{Corollary}

\begin{document}

\section{sec}
\subsection{sub}
\begin{thm}
\end{thm}

\begin{corol}
\end{corol}

\section{sec}
\subsection{sub}
\begin{thm}
\end{thm}

\begin{corol}
\end{corol}

\end{document}

enter image description here

3
  • There is no need for those redefs when amsthm is loaded, just use \theoremstyle{definition}
    – daleif
    Commented May 29, 2017 at 13:30
  • @daleif I just guessed the OP would use amsthm, now that there is a mwe... Commented May 29, 2017 at 13:32
  • Erh, no, that MWE does not give the replacement for the \let\oldexa\exa \renewcommand{\exa}{\oldexa\normalfont}, add some text to the theorems to see. You'll need \theoremstyle{definition} the default is plain which has an italic body which the OP clearly does not want (for some reason)
    – daleif
    Commented May 29, 2017 at 13:49
2

If, for some reason, you don't want to use amsthm, you can more simply patch \@begintheorem.

You should define one main theorem and the other ones to be subordinate to it.

\documentclass{article}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@begintheorem}{\itshape}{}{}{}
\makeatother

\newtheorem{thm}{Theorem}[section]
\newtheorem{corol}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{defn}[thm]{Definition}
\newtheorem{exa}[thm]{Example}
\newtheorem{prop}[thm]{Proposition}

\begin{document}

\section{First}

\subsection{A}

\begin{thm}
Theorem
\end{thm}

\begin{corol}
Corollary
\end{corol}

\section{Second}

\subsection{B}

\begin{lem}
Lemma
\end{lem}

\begin{defn}
Definition
\end{defn}

\end{document}

However, using amsthm is simpler:

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{corol}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{defn}[thm]{Definition}
\newtheorem{exa}[thm]{Example}
\newtheorem{prop}[thm]{Proposition}

\begin{document}

\section{First}

\subsection{A}

\begin{thm}
Theorem
\end{thm}

\begin{corol}
Corollary
\end{corol}

\section{Second}

\subsection{B}

\begin{lem}
Lemma
\end{lem}

\begin{defn}
Definition
\end{defn}

\end{document}

enter image description here

2

This is the way without amsthm, using the Coupled Counters feature from (well, my ;-)) package xassoccnt.

Define a counter group name, which is basically arbitrary, then populate the group with the relevant counter names.

I don't recommend the redefinition of the \thm etc. commands, however.

\documentclass{article}


\usepackage{xassoccnt}

\DeclareCoupledCountersGroup{TheoDefCorolLemma}

\newtheorem{thm}{Theorem}[section]
\let\oldthm\thm
\renewcommand{\thm}{\oldthm\normalfont}

\newtheorem{corol}{Corollary}[section]
\let\oldcorol\corol
\renewcommand{\corol}{\oldcorol\normalfont}

\newtheorem{lem}{Lemma}[section]
\let\oldlem\lem
\renewcommand{\lem}{\oldlem\normalfont}

\newtheorem{defn}{Definition}[section]
\let\olddefn\defn
\renewcommand{\defn}{\olddefn\normalfont}

\newtheorem{exa}{Example}[section]
\let\oldexa\exa
\renewcommand{\exa}{\oldexa\normalfont}

\newtheorem{prop}{Proposition}[section]
\let\oldprop\prop
\renewcommand{\prop}{\oldprop\normalfont}

\DeclareCoupledCounters[name=TheoDefCorolLemma]{thm,corol,lem,defn,exa,prop}


\begin{document}

\section{First}

\subsection{A}

\begin{thm}
Theorem
\end{thm}

\begin{corol}
Corollary
\end{corol}

\section{Second}

\subsection{B}

\begin{lem}
Lemma
\end{lem}

\begin{defn}
Definition
\end{defn}

\begin{prop}
Proposition foo
\end{prop}


\end{document}

enter image description here

2
  • Try \begin{thm}[Fermat]. Besides, I'm not sure what advantage this has over \newtheorem{corol}[thm]{Corollary}.
    – egreg
    Commented May 29, 2017 at 14:03
  • @egreg: The redefinition of the theorem starter macros is not the real issue here, in my point of view. The advantage is to prevent the usage of \newtheorem{foobar}[foo]{foobar} each time, but to controll its behaviour later on, with possible decoupling.
    – user31729
    Commented May 29, 2017 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .