# How to increase the TeX open file limit?

I noticed that TeX has a open file limit, while using some additional bibliographies with multibib, using hyperref, backrefs and so on (basically only 5 additional newcites were possible in that document before hitting the limit).

I worked around that with migrating from multibib to biblatex, which I've discovered then and which seems like a good solution to other bibliography related challenges as well.

Anyways, I found this 2007 open file limit discussion and I wondered if the situation changed with current TeX Live distributions. And if yes, how to increase the open file limit in LaTeX now.

-

## 4 Answers

I've never experimented with changing it, but texmf.cnf has (near the end)

max_in_open = 15        % simultaneous input files and error insertions,


which you could paste into the local texmf.cnf and adjust. (On my system, the appropriate file to make changes to is /usr/local/texlive/2010/texmf.cnf.)

I guess you would have to rebuild your formats after doing this before the changes take effect. You might have issues with hard-coded limits in LaTeX that assume a maximum of 15 io streams; it's too late for me to check right now :)

-
@LaTeX allocation routines check for maximum number of files so you will definitely need to overwrite those counter limits as well. –  Yiannis Lazarides Nov 28 '10 at 18:48
Also, you'd probably run into trouble with the \write18 weirdness. –  Bruno Le Floch Oct 14 '12 at 9:58
• LaTeX 3 (i.e., the expl3 package) has a "bitmap allocator" that only allocates streams if they are opened
• With LuaTeX you can use the standard Lua libraries, giving you an essentially unlimited number of open files
-
See also the rvwrite package (ctan.org/pkg/rvwrite). As far as I know, none of these solutions will help with existing code unless it is rewritten to take advantage of the facilities. (For example, in expl3 we recommend storing material in a token list if possible, and only writing to file when required. The expl3 implementation will re-allocate streams when they are closed, but this still requires that no-one tries to open more than 16 in one go.) –  Joseph Wright Nov 28 '10 at 16:31
@Joseph From the looks of things, newfile is more similar in spirit than the expl3 approach than rvwrite. (My reading of the rvwrite docs implies that it uses a single file to write to for everything, and then splits it up later. I could be wrong.) –  Will Robertson Nov 29 '10 at 4:39

In the KOMA-Script-bundle, Markus Kohm’s replacement for the standard LaTeX-classes and much more, he includes a package called scrwfile. The package is designed to provide a way around the limited number of file handles in LaTeX.

If you do not read German, the author has started the work on improving the English manual. He describes scrwfile on pages 258ff. You will find KOMA-Script at CTAN and BerliOS.

-
anonymous edit converted to a comment: Additionally: Download the last package of the KOMA-bundle: developer.berlios.de/project/showfiles.php?group_id=4307 Extract the archive and search for the scrwfile.sty, as well as include the package as an individual package of your tex-project, e.g.: \usepackage{./YourIndividualPackageFolder/scrwfile} For me, it worked without any great adoptions of my origin text file - also worked with multibib package; –  Martin Scharrer Mar 26 '12 at 14:21
This one corrected my problem, where morewrites fails with utf-8 files and rvwrite does nothing. –  Bjonnh Oct 13 '12 at 18:30
@Bjonnh I just saw that comment of yours. Could you send me an example of a file where morewrites fails? (BL@gmail.com, where B -> blf and L -> latex) –  Bruno Le Floch Oct 14 '12 at 9:56

The morewrites package (see CTAN) aims to be a drop-in solution for the case of output files (i.e., just load the package early enough in your document). It works by redefining some primitives.

Doing this for input streams is significantly harder, as emulating a primitive conditional is impossible, hence \ifeof would give incorrect results. On the other hand, I have never yet seen a case of exceeding the input stream limit.

-