# Long frames in mdframed

I need to use the mdframed package with frames extending many pages, e.g. more than 20 pages.. Consider the following code:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \Repeat \prg_replicate:nn
\ExplSyntaxOff
\begin{document}
\begin{mdframed}
\Repeat{1500}{xxx\\}
\end{mdframed}
\end{document}


produces (with pdflatex) the following error

Underfull \hbox (badness 10000) in paragraph at lines 9--10

! Dimension too large.
<argument> \dimexpr \ht \mdf@splitbox@one
+\dp \mdf@splitbox@one \relax
l.10 \end{mdframed}


What may be the problem here?

• TeX is happy to build boxes whose dimensions exceed \maxdimen, as long as you don't try to use those dimensions. The maximum dimension is a bit less than six meters; assuming a text height of 25cm, no more than 23/24 pages can fit. – egreg Sep 3 '13 at 10:48
• I see :) It would be nice if this restriction could be circumvented somehow? – Håkon Hægland Sep 3 '13 at 10:52
• Just saw @egreg's comment after I posted my answer:-) As I comment below you can actually just ignore it in this case, circumventing it would probably involve re-writing mdframed to use the output routine rather than \vsplit so that the content is collected on the main vertical list rather than in a box, but that might be tricky.... – David Carlisle Sep 3 '13 at 11:21

It's actually a tricky error to trap, if a box contains more content than \maxdimen that isn't itself an error and you can typeset or split or unbox its contents but any reference to \ht of the box , even to test it with \ifdim\ht\mybox>... results in an error.

\batchmode

• Thanks! This seems to work. I wonder, is there any drawbacks of using \batchmode ? ( In "TeX by topic" page 232, I find: "\batchmode TEX fixes errors itself and performs an emergency stop on serious errors such as missing input files, but no terminal output is generated." – Håkon Hægland Sep 3 '13 at 12:00
• @HåkonHægland well the drawback is that you don't get informed (on the terminal) of errors, but if you don't make errors that isn't a concern (you can just do it locally for mdframed and put it back with \errorstopmode) – David Carlisle Sep 3 '13 at 12:27
• @MarcoDaniel one solution would be to literally do as here, insert \batchmode before you do the tests, making sure that you roder them such that the automatic recovery always takes the "large" branch. It is a global setting but you can use the etex \interactionmode to find out what the setting was initially and restore it to that after the test. A more complete fix would be to accumulate the body in bits and once you have more than a page worth split it off and ship it out so you never get this big, but that is probably a much bigger change to the code? – David Carlisle Sep 3 '13 at 18:00