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.
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}
definition
,algorithm
andtheorem
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 fordefinition
,algorithm
andtheorem
, but no more than that, and in the document part itself, just add an emptyfigure
with caption, and empty/one liner theorems etc.)