# [XeTeX] xdvipdfmx says "** ERROR ** Capacity exceeded"

Daniel Rubin daniel at dimedis.de
Fri Feb 19 09:22:26 CET 2010

Jonathan Kew wrote:
> On 18 Feb 2010, at 18:50, Daniel Rubin wrote:
>
>> Dear xetex list,
>>
>> I've got a problem with xdvipdfmx trying to build a PDF from an xdvi
>> file compiled with xelatex.
>>
>> The logfile is empty except for this:
>>
>> <FONTMAP:cm-dvipdfm-fix.map><FONTMAP:dvipdfm.map><FONTMAP:cid-x.map>
>> ** WARNING ** DVI need stack depth of 291,
>> ** WARNING ** but DVI_STACK_DEPTH_MAX is 256.
>> ** ERROR ** Capacity exceeded.
>>
>> I have no clue as to what's causing this.  It happens with about 1 out
>> of 1000 source files I'm creating.  I'd be glad to get some help to
>> pinpoint this.
>
> Offhand (i.e, without going to check code....) I think this is related to nesting lots (and lots and lots) of boxes inside each other in the TeX document.
>
> For example, if you keep adding things to a box using code such as
>
>   \def\appendtohbox#1#2{\setbox#1{\box#1 #2}}
>   \setbox0=\hbox{}
>   \appendtohbox0{\box1}
>   \appendtohbox0{\box2}
>   \appendtohbox0{\box3}
>   \appendtohbox0{\box4}
>
> because you want to accumulate boxes 1-4 into a single hbox, you've actually been nesting. If you instead define
>
>   \def\appendtohbox#1#2{\setbox#1{\unhbox#1 #2}}
>
> then the nesting is avoided, you have a single-level list instead.
>
> (Of course, I don't imagine you've written code like that, it's just a simplified example to give the idea. But whatever process is creating your source may be doing something equivalent at a more complex level, if it's constructing complex layouts out of lots of pieces.)
>
> HTH,
>
> JK

Hi JK,

that definitely is a helpful observation.  I *do* have a lot of nested
boxes (although, as I hardly use low-level TeX-commands, these are
mostly parboxes) to structure the layout.

Luckily, there's a finite maximum to the depth of the nesting and the
number of boxes I'll ever put into another.

That makes me confident that simply increasing the stack depth limit
would indeed solve my problem once and for all.

So I'll give the compilers a run.

have fun
----Daniel

--
Daniel Rubin              drubin at dimedis.de
dimedis GmbH              www.dimedis.de
Dillenburger Strasse 83   0221/921260-44 (-59,Fax)
51105 Koeln               Software Entwicklung
HRB Köln 51787            Geschäftsführer: Dipl.-Ing. W. Halling