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

\cs_new_eq:NN \Repeat \prg_replicate:nn

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?

  • 1
    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, 2013 at 10:48
  • I see :) It would be nice if this restriction could be circumvented somehow? Sep 3, 2013 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.... Sep 3, 2013 at 11:21

1 Answer 1


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.

If you add


You get the document that you wanted....

  • 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." Sep 3, 2013 at 12:00
  • 1
    @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) Sep 3, 2013 at 12:27
  • Interesting. Do you know a solution. Sep 3, 2013 at 17:03
  • @MarcoDaniel My solution was to ping you in chat to come here and fix it:-) Sep 3, 2013 at 17:03
  • 1
    @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? Sep 3, 2013 at 18:00

You must log in to answer this question.

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