I am trying to create boxes spanning over multiple pages considered as floats.
I defined boxes as floats which I can refer to using a \DeclareFloatingEnvironment
. It works well.
I find a way to create box spanning multiple pages using the mdframed
package. Thanks to boxes spanning several pages.
Captioning an mdframed box without making unbreakable is close but does not entirely answer my request since it does not encapsulate the box inside a floating environment I can refer to.
Here is a MWE that shows what I tried so far. The last box will not split:
\documentclass{article}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
fileext=lob,
listname={List of boxes},
name=Box,
placement=htp,
]{myBox}
\usepackage{fancybox}
\newenvironment{encadrement}[1][\textwidth]
{\begin{Sbox}
\centering
\begin{minipage}{#1}}
{\end{minipage}
\end{Sbox}
\fbox{\TheSbox}}
\usepackage{mdframed}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{myBox}
\caption{A small box \label{box:smallBox}}
\begin{encadrement}
\blindtext
\end{encadrement}
\end{myBox}
I can here refer to the Box~\ref{box:smallBox}.
\blindtext
A big box follows, but it has no caption nor label:
\begin{mdframed}
\Blindtext
\end{mdframed}
\blindtext
% The following box will not split as I'd like
\begin{myBox}
\caption{A big box \label{box:bigBox}}
\begin{mdframed}
\Blindtext
\end{mdframed}
\end{myBox}
\end{document}
\captionof{figure}{my caption}
from the caption package.myBox
environment ...\captionof{figure}{....}
it will be numbered in sequence with figures (or use table or listings or whatever other counter you are using)