2

How to float a figure counter such that it displays section than counter with figures, theorems and definitions? e.g

Figure 1.1

Definition 1.2

Figure 1.3

Algorithm 1.4

Theorem 1.5

etc.

  • If I understand your question correctly, it has be exhaustively answered here. – Manuel Weinkauf Nov 29 '16 at 13:16
  • 3
    I think an answer to this will depend on how you define the definition, algorithm and theorem environments, so if you could make a minimal working example (MWE) it would make it possible for people to answer properly. (I.e. make a short code starting with \documentclass, containing all necessary packages and definitions for definition, algorithm and theorem, but no more than that, and in the document part itself, just add an empty figure with caption, and empty/one liner theorems etc.) – Torbjørn T. Nov 30 '16 at 3:30
  • Is there any news on this or shall this be closed? – user31729 Jan 11 '17 at 18:50
3

I've understood the question as definition, figure, algorithm etc. should either share the same counter or are stepped with each other.

I use a coupled counter approach from xassoccnt package, forming a group of coupled counters with \DeclareCoupledCountersGroupName and assigning the relevant counters to this group.

Please note that due to the floating behaviour of figure environment the order of appearance and numbering is not the same then! Consider to use something like \FloatBarrier from picins package in order to prevent this!

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{example}{Example}[section]
\newtheorem{definition}{Definition}[section]
\usepackage{blindtext}
\usepackage{chngcntr}
\usepackage{xassoccnt}

\DeclareCoupledCountersGroup{figtheoexadef}
\DeclareCoupledCounters[name=figtheoexadef]{theorem,figure,example,definition}
\counterwithin{figure}{section}

\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{Foo section}
\begin{definition}{Foo}
\blindtext
\end{definition}

\begin{figure}
\blindtext

\caption{A figure}
\end{figure}


\begin{theorem}{Foo}
\blindtext
\end{theorem}               %

\begin{example}{Foo}
\blindtext
\end{example}               %

\begin{figure}
\blindtext
\caption{Yet another figure}
\end{figure}

\section{Foobar section}

\begin{figure}
\blindtext
\caption{Another figure}
\end{figure}


\begin{theorem}{Foo}
\blindtext
\end{theorem}               %

\begin{example}{Foo}
\blindtext
\end{example}               %

\begin{figure}
\blindtext
\caption{More figures}
\end{figure}

\begin{definition}{Foo}
\blindtext
\end{definition}

\end{document}

enter image description here

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.