# How to get figure counter to follow theorem counter?

I am trying to get my figure to counter to follow my theorem counter. I created a few different environments: lemma, example, definitions, etc. I have gotten all of them to follow my theorem counter.

The numbering goes Chapter.Section.theorem. So it will go like this:

Chapter 2 "The Second Chapter"

Section 2.1 The First Section

Definition 2.1.1 - First Definition

Theorem 2.1.2 - The First Theorem

Section 2.2 The Second Section

Chapter 3 "The Third Chapter"

etc...

However, the figures don't seem to follow the counter. The first figure (in section 2.4) is number Figure 2.3 ... So I'm trying to get it to fall in line with the rest so that it would look like:

Example 3.2.5 - The Example

Figure 3.2.6 - The Figure for Example 3.2.5

Any suggestions? I put all the code that I think is applicable below. Let me know if you need more/something else...

\documentclass{thesis} %This is my school's self-made document class

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\newtheorem{example}[theorem]{Example}

%\let\c@theorem\c@figure
%\makeatother

\begin{document}

\begin{figure}
\caption{The Figure}
\end{figure}

\end{document}


I've attempted the \let\c@theorem\c@figure but that doesn't seem to work.

• Figures are always numbered independently from theorem-like environments. Do you really want to change this standard? – yo' Aug 11 '14 at 18:24
• Moreover, figures are floats, while theorems are not. So, you may end up with a different order in terms of the numbering and the actual placement of content on the page. – Werner Aug 11 '14 at 18:57
• The only way is to get around the issue Werner stated is drop the floating feature of figure – user31729 Aug 11 '14 at 22:01
• @tohecz Well, if figures are always numbered independently, then maybe I don't want to change that standard. Although I do like the fact that everything in my paper is enumerated and can be found based on the number of the current object. So if I reference a figure, I know exactly where it can be found. I've found that this simplifies everything greatly! Why doesn't everyone do that?? – Bark Jr. Aug 11 '14 at 22:08
• @tohecz Additionally, the standard way of doing it seems to give two different figures the same call number. I have two Figure 2.4's in my paper (in two different sections: one in 2.4 and one in 2.7 ... I assume this is incorrect and not standard, right?? – Bark Jr. Aug 11 '14 at 22:34

A proposition:

1. Don't use floating figures, remove \begin{figure}...\end{figure} around the graphics and caption
2. Use caption package and \captionof{figure}{foo text} instead of standard \caption command
3. Redefine the figure output command \thefigure to obtain the \thetheorem.\arabic{figure} output
4. (Optional) Use a resetting of figure counter by theorem, i.e. @addtoreset{figure}{theorem} If this is not wanted, just comment that line

\documentclass{book} % can't use thesis.cls here, since unknown!!!

\usepackage{caption}%
\usepackage[demo]{graphicx}%
\usepackage{amsthm}%

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\newtheorem{example}[theorem]{Example}

%\let\c@theorem\c@figure
%\makeatother

\makeatletter
\makeatother

\let\StandardTheFigure\thefigure
\renewcommand{\thefigure}{\thetheorem.\arabic{figure}}

\begin{document}

\chapter{My first chapter}

\section{The very first section}%

\begin{theorem}
$$E = m c^2$$
\end{theorem}

\begin{center}
\includegraphics{somefig}
\captionof{figure}{The Figure}
\end{center}

\begin{theorem}
$$E^2 = p^2 c^2 + \left({m c^2}\right)^2$$
\end{theorem}

\begin{center}
\includegraphics{somefig}
\captionof{figure}{Another figure}%
\end{center}

\end{document}


• Oh my gosh! Wonderful. Thank you! Additionally, is there any way to get the above to be Theorem 1.1.1, Figure 1.1.2, Theorem 1.1.3, Figure 1.1.4, etc... ? – Bark Jr. Aug 11 '14 at 22:32
• @BarkJr.Sure, just comment out @\addtoreset{figure}{theorem} or delete that line completely. The figure number will be reset then per chapter or per section, that depends on the class settings – user31729 Aug 11 '14 at 22:36