4

I would like to add a list of theorems to my document so I have included thmtools. This gives a list of theorems but in the following format.

1.1 Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

1.2 Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1.3 Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

I'd like to instead have it look something like this:

Theorem 1.1. For a right angle triangle, $x^2 + y^2 = z^2$ . . . . . . . . . . . . . . . 24

Theorem 1.2. $\sin^2(\theta) + \cos^2(\theta) = 1$ . . . . . . . . . . . . . . . . . . . . . 25

Theorem 1.3. Some other theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

I have worked out the following:

\makeatletter
\def\ll@theorem{%
  {\bf \thmt@thmname~ \protect\numberline{\thetheorem.~}} %
  Theorem Body goes here...
}
\def\l@thmt@theorem{} 
\makeatother

Which gives me this:

Theorem 1.1. Theorem Body goes here... . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Theorem 1.2. Theorem Body goes here... . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Theorem 1.3. Theorem Body goes here... . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

I'm just struggling to work out how to replace Theorem Body goes here... with the TeX between \begin{theorem} and \end{theorem}

And here is an example compilable document

\documentclass{article}

\usepackage{amsthm, thmtools}
\newtheorem{theorem}{Theorem}[section]




\makeatletter
\def\ll@theorem{%
  {\bf \thmt@thmname~ \protect\numberline{\thetheorem.~}} %
  Theorem Body goes here...
}
\def\l@thmt@theorem{} 
\makeatother


\begin{document}
\title{Test}

\listoftheorems


\section{Section A}

\begin{theorem}
For a right angle triangle, $x^2 + y^2 = z^2$
\end{theorem}

\begin{proof}
Proof...
\end{proof}

\begin{theorem}
$\sin^2(\theta) + \cos^2(\theta) = 1$
\end{theorem}

\begin{proof}
Proof...
\end{proof}

\section{Section B}

\begin{theorem}
Some other theorem
\end{theorem}

\begin{proof}
Proof...
\end{proof}


\end{document}

Cheers

Anthony

4
  • Welcome to TeX.SX! Please provide a working, compilable document, not only fragments
    – user31729
    Jun 21, 2016 at 15:27
  • Hi, I have added a full document - let me know if anything further is required? Cheers
    – Anthony
    Jun 23, 2016 at 15:00
  • (not related) why Theorem1.1, Theorem1.2 ? 1.1, 1.2 isn't suffisant? since all are theorems.
    – touhami
    Jun 23, 2016 at 21:42
  • I am thinking of including corollaries too, but thought I'd work how to do it with just theorems first.
    – Anthony
    Jun 24, 2016 at 11:07

1 Answer 1

5

Grabbing the theorem 'BODY', i.e. the content between \begin{theorem}...\end{theorem} can be done with \RenewEnviron and the \BODY command.

The \RenewEnviron command defines theorem to be a wrapper around the original version (which has been stored before into \let\theorem@@orig and \let\theorem@@origend command).

The package environ provides the \BODY command that contains anything between \begin{foo}...\end{foo} if foo is an environment made up with NewEnviron or \RenewEnviron.

This \BODY command can be used in \ll@theorem then!

\documentclass{article}

\usepackage{amsthm, thmtools}
\newtheorem{theorem}{Theorem}[section]

\usepackage{environ}


\makeatletter
\def\ll@theorem{%
  {\bfseries \thmt@thmname~ \protect\numberline{\thetheorem.~}} %
  \BODY% 
}
\def\l@thmt@theorem{} 
\makeatother


\makeatletter
\let\theorem@@orig\theorem
\let\theorem@@origend\endtheorem
\RenewEnviron{theorem}{%
  \theorem@@orig%
  \BODY%
}[\theorem@@origend]
\makeatother


\title{Test}

\begin{document}

\listoftheorems


\section{Section A}

\begin{theorem}
For a right angle triangle, $x^2 + y^2 = z^2$
\end{theorem}

\begin{proof}
Proof...
\end{proof}

\begin{theorem}
  $\sin^2(\theta) + \cos^2(\theta) = 1$
\end{theorem}

\begin{proof}
  Proof...
\end{proof}

\section{Section B}

\begin{theorem}
Some other theorem
\end{theorem}

\begin{proof}
Proof...
\end{proof}


\end{document}

enter image description here

2
  • Thanks for a great solution :) Just a slight addition, I noticed that the Theorem Body wasn't appearing in the tex (using Thesis class). It was just showing ""Theorem 2.1. Proof. Proof...."" To fix this add \BODY to the RenewEnviron command: \RenewEnviron{theorem}{ \theorem@@orig \BODY }[\theorem@@origend]
    – Anthony
    Jul 7, 2016 at 11:44
  • @Anthony: Thanks for notifying me -- I posted a different version -- the screenshot had the \BODY however.
    – user31729
    Jul 8, 2016 at 15:47

You must log in to answer this question.

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