I have three .tex files that get compiled fine using polyglassia & xelatex packages. When I combine these three tex files in one tex file, it exceeds the memory due to a lot of special fonts used in them. So I ended up compiling them separately. As a result, I have three PDF outputs that contain hyperlinked pages to their TOC, and hyperlinked sections in TOC. So, there are three PDF's, thus three Table of Contents for each PDF.

How do I combine these PDF's preserving hyperlinks as well as having one TOC file [preferably in a single multi-column page]?

  • Have you tried increasing the memory for the runs of the files? – Martin Schröder May 16 '12 at 21:09
  • No I haven't. There were some instructions how to do for Mac/TeXLive, but not for MikTeX on Windows. – Nina May 16 '12 at 21:46

I suppose you are getting TeX capacity exceeded error. To overcome that you can increase the memory allocated as suggested by @Martin:


  1. Open a DOS command prompt window (execute ‘cmd.exe’ via ‘Start’ → ‘Run’).
  2. At the DOS prompt, enter initexmf --edit-config-file=latex
  3. Type main_memory=10000000 into the editor window that opens, save the file and quit the editor.
  4. To rebuild the format, enter initexmf --dump=latex at the DOS prompt
  5. Repeat steps 2–4 with config files pdflatex and xelatex

For the sake of completeness, I add these particulars for Texlive also.

For TEX Live:

  1. Find the configuration file ‘texmf.cnf’ by means of kpsewhich texmf.cnf at the shell prompt in a terminal.
  2. As Root, open the file in your favourite text editor, scroll to the main_memory entry and change it to the value given above; save and quit.
  3. Rebuild the formats by fmtutil-sys --byfmt latex and fmtutil-sys --byfmt pdflatex and fmtutil-sys --byfmt xelatex
  • Hi. I did exactly how you told here. However, the capacity has decreased from 247 pages [inputs] to 228 pages. Any idea why? – Nina May 17 '12 at 13:50
  • From here I am not in a position to guess any thing as I don't have any information on your files. Sorry. Generally this will increase the memory allocation. – user11232 May 17 '12 at 13:54
  • I tried to use main_memory=500000000 instead of main_memory=10000000, cmd couldn't proceed with initexmf --dump=latex command. Then I saved and continued with main_memory=500000000 anyway. This time Texworks gave me an error regarding the memory problem. – Nina May 17 '12 at 15:23

Consider merging the pdf files after you've generated them from LaTeX with pdftk (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) or some other pdf manipulation tool.

If it can't get the TOC right you might be able to hack a TOC (perhaps with \includeonly) and merge it too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.