I defined a custom environment that allows me to define mathematical problem statements and puts them in a box. Since I have quite a few of them in my report, I decided to properly caption them, which also allows me to refer back to the problems with cleveref.
Here is my code [1]:
\usepackage{xparse}
\usepackage{xcolor}
\usepackage{caption}
\usepackage{cleveref}
\definecolor{problemgray}{gray}{0.9}
\DeclareCaptionType{problem}[Problem][List of Problems]
\crefname{problem}{Problem}{Problems}
\Crefname{problem}{Problem}{Problems}
\newsavebox{\tmpbox}
\NewDocumentEnvironment{problembox}{mo}{%
\noindent%
\begin{lrbox}{\tmpbox}%
\begin{minipage}{0.9\textwidth}%
\par\noindent%
}{%
\end{minipage}\end{lrbox}%
\begin{center}%
\captionof{problem}{#1}%
\vspace{0.25em}%
\setlength{\fboxsep}{0.5em}
\colorbox{problemgray}{\usebox{\tmpbox}}%
\ifthenelse{\equal{#2}{}}{
%
}{
\label{#2}%
}
\end{center}
}
The format is thus: \begin{problembox}{<problem caption>}[<optional label>].
In this way, the problems are currently numbered per chapter, e.g. Problem 2.1, Problem 2.2, etc. However, most of my problems build upon each other.
Thus my question,
How can I get caption to continuously number custom floats rather than per chapter?
[1] Note that I lied: The boxes are actually not floats, but I could make them floats the way I set them up. I just wanted to have a captioned but fixed environment.
Bonus question: How can I allow page breaks within a problem using my code?
framed. – Marco Daniel May 20 '13 at 11:36