# Excessive Input causes problems in XeLaTeX

I am using `polyglossia` and `xelatex` for my Arabic document.

I have about 600 pages wrapped in `001.tex` `002.tex` ... and a unique TTF font assigned for each page.

When I use all these external tex files as

``````\input{001.tex}
\input{002.tex}
\input{003.tex}
..
``````

On Texmaker it gives some metric errors if input files exceed 200. On Kile it gives some metric errors if input files exceed 250. I divided whole document into three tex files containing 200 input files, but compiles fine, but doesn't solve my issue. I need all 600 pages in one single tex file. Errors mentioned above are mostly related to font metrics. Because the text are pretty complex I can't produce a minimal example to share here:

Any idea what causes this and a way around it?

Edit:

At the beginning it was giving plain errors, and compilation was not going through. Now, it proceeds with it but ignores any input files after 247th one. Here is the log message at the end:

``````Here is how much of TeX's memory you used:
22602 strings out of 429293
409326 string characters out of 3169431
428278 words of memory out of 3000000
23413 multiletter control sequences out of 15000+200000
7648 words of font info for 515 fonts, out of 3000000 for 9000
669 hyphenation exceptions out of 8191
44i,5n,64p,1902b,319s stack positions out of 5000i,500n,10000p,200000b,50000s
Output written on c1.pdf (247 pages).
``````

@Boris, then I lose RTL oriented and hyperlinked TOC & hyperlinked page numbers to TOC.

-
you mention texmaker and kile but they are both editors/IDE sitting over TeX. Are you hitting limitations in those systems or in the underlying TeX? What happens if you just use xelatex on the command line? If you get an error from that what is the error message exactly? –  David Carlisle May 14 '12 at 18:58
XeTeX has to load into memory all the metric information for the 600 fonts. Your log file should have, near the end a line such as `4553 words of font info for 17 fonts, out of 3000000 for 9000` which will tell you if you have hit a memory limit (you certainly will). AFAIK, the `9000` limit is hard coded (the maximum number of fonts), while the 3000000 can be brought up to 147483647. –  egreg May 14 '12 at 19:56
Then how do I solve it? –  Nina May 14 '12 at 20:17
egreg, how do I increase that limit? –  Nina May 14 '12 at 21:18
Could you post the exact error message you get? –  Khaled Hosny May 15 '12 at 1:17

Since you have one font per page, you can do the following. Split your document into smaller parts (just big enough for XeTeX to process them). You may want to adjust page numbering with `\setcounter{page}{...}`. Then use a separate tool like pdftk to merge your documents.