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

Thu Feb 18 23:24:32 CET 2010

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