23

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 4

13

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 :)

2
  • 4
    @LaTeX allocation routines check for maximum number of files so you will definitely need to overwrite those counter limits as well.
    – yannisl
    Commented Nov 28, 2010 at 18:48
  • Also, you'd probably run into trouble with the \write18 weirdness. Commented Oct 14, 2012 at 9:58
12
  • 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
2
  • 2
    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
    Commented Nov 28, 2010 at 16:31
  • 1
    @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.) Commented Nov 29, 2010 at 4:39
10

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.

8

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.

3
  • 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; Commented Mar 26, 2012 at 14:21
  • This one corrected my problem, where morewrites fails with utf-8 files and rvwrite does nothing.
    – Bjonnh
    Commented Oct 13, 2012 at 18:30
  • @Bjonnh I just saw that comment of yours. Could you send me an example of a file where morewrites fails? ([email protected], where B -> blf and L -> latex) Commented Oct 14, 2012 at 9:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .