TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Can you make your first example a fully compilable document as is already the case for the second. – Peter Grill Jan 25 '12 at 20:46
up vote 2 down vote accepted

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.

share|improve this answer
That works for me. Thanks! – jkeirstead Jan 26 '12 at 9:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.