Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm currently using the mdframed package for a custom environment for my master's thesis. In rare cases, the environment shows some rather strange behaviour — the correctly split environment (i.e. the two, or sometimes even three parts) skips a page!

What I mean by that is, that the environment gets split as it should be, into two or sometimes three parts. However, the first part is not printed on the page were it should be, but on the next page. The second part is then printed on the subsequent page, and so on.

I've been trying to re-create this behaviour for a MWE, but I haven't succeeded yet. I cannot post the LaTeX code of my thesis, but I could post part of the PDF which shows this unwanted behaviour.

The definition of my custom environment might help though — it is largely based on an answer to one of my other questions (see Combining `tikzpicture` and `lstlisting`).

\usepackage[framemethod=TikZ]{mdframed}

\makeatletter
\def\mdf@@codeheading{Default}%
\define@key{mdf}{title}{%
   \def\mdf@@codeheading{#1}
}

\mdfdefinestyle{nicebox}{%
 innertopmargin=16pt,
 innerbottommargin=8pt,
 middlelinewidth=.8pt,
 outerlinewidth=4pt,outerlinecolor=white,
 innerleftmargin=10pt,
 innerrightmargin=10pt,
 leftmargin=-4pt,rightmargin=-4pt,
 skipabove=\topskip,
 skipbelow=\topskip,
 roundcorner=4pt,
 singleextra={\node[draw, fill=white, thick, anchor=west, xshift=10pt+1pt, font=\bfseries] at (O|-P) {\csname mdf@@codeheading\endcsname \space \theboxnumber};},
 firstextra={\node[draw, fill=white, thick, anchor=west, xshift=10pt+1pt, font=\bfseries] at (O|-P) {\csname mdf@@codeheading\endcsname \space \theboxnumber};}
}

\newenvironment{boxenv}[2]{%
  \incboxnumber
  \label{#2}
  \bigskip
  \mdframed[style=nicebox,title={#1}]
}{\endmdframed}
share|improve this question
    
I don't quite understand your question. Can you post a picture of what is happening? –  dustin May 17 '13 at 19:03
2  
Of course you get the a bad break. The firstextra material isn't in the calculation of the page dimension. Whether you defined the material as overlay you you must modify the dimension splittopskip. –  Marco Daniel May 17 '13 at 19:07
    
@dustin I uploaded the PDF to my webspace (redpanda.nl/BoxSplines.pdf), see Example 3.18 on page 12. –  Ailurus May 17 '13 at 19:22
1  
@Ailurus Marco Daniel will probably be your best resource for this issue. –  dustin May 17 '13 at 19:27
1  
Can you drop me an email with your tex files? –  Marco Daniel May 17 '13 at 21:09

1 Answer 1

up vote 4 down vote accepted

The OP dropped me an email.

The height of the defined node isn't part of the calculation and so there is an extra vertical skip which results to an unwanted page break. The easiest way to fix this issue is by adding the option overlay to the node definition. In this way the extra vertical skip is ignored.

share|improve this answer

Your Answer

 
discard

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.