I'm trying to make an mdframed environment for numbered multi-page boxes. The problem I'm having is that I can't seem to make the formatting and the numbering work as I want it to. I've tried the following two approaches.


The following code gives me the correct labelling behaviour, but I can't use the mdfdefinestyle frametitle commands to make a nice shaded box like in this example. Even worse, it won't split the box over multiple pages!

%% Define box environment as a mock theorem
% Give the box style

% Define the theorem style with amsthm
\newtheoremstyle{box}% <name>
{3pt}% <Space above>
{3pt}% <Space below>
{}% <Body font>
{}% <Indent amount>
{\bfseries}% <Theorem head font>
{\\}% <Punctuation after theorem head>
{.5em}% <Space after theorem headi>
{#1 #2: #3}% <Theorem head spec (can be left empty, meaning `normal')>

% Define the new environment

% Example usage: 
%  - xrefs works as expected
%  - formatting not ideal
%  - box won't break across multiple pages
\begin{infobox}[Box title]
blah blah


Alternatively if I try to define a newmdenv, the numbering doesn't want to work and I can't get the label in the right place. I can't post images but I basically get the counter on Box 1.0 and the xref on Box 1.1, and the "Box 1.0" part is outside of the frame.


%% set the counter for your environment

%% define the style

%% setup the environments
    frametitlefont={\bfseries Box~\theinfobox\quad},%

\chapter{Section One}
Box~\ref{box:infobox} but compare with \theinfobox
\begin{infobox}[frametitle=Some Headlinetext]


It seems like I should be able to do this with some version of the second template. After all, a framed box isn't a theorem.

  • Can you make your first example a fully compilable document as is already the case for the second. Commented Jan 25, 2012 at 20:46

1 Answer 1


This example works for me:




        frametitle={Infobox \theinfobox\ #1},
        skipabove=\baselineskip plus 2pt minus 1pt,
        skipbelow=\baselineskip plus 2pt minus 1pt,





Infobox \ref{ibx:sausage} says:

\begin{infobox}[Fried eggs]

Infobox \ref{ibx:eggs} says:



The use of \refstepcounter instead of \stepcounter makes the current value of the infobox counter available for referencing in the text.

Note that I used the current github version of mdframed to compile this example. I didn't test whether or not it works with the current ctan version, which is older.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .