TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've already searched a lot about it and there seems to be no possible way of increasing the number of files (La)TeX can open. This for example, gives an explanation about the error message. I've also seen some solutions for this problem, but all were specifically for graphics instead of files.

So basically, I want to open several files, currently in total possibly more than 16 (which is the current limit), and together with some packages that also use some slots. There should be at least 2 possible solutions for me:

  1. Increase the amount of files that can be opened at the same time. This however is an inefficient way of doing things.
  2. Closing and removing the file completely out of the register. I noticed that using the command \closein or \closeout does not free up space in the register. Opening a new one will still fill the next slot instead of overwriting the closed ones. For me, a max of 2 files are open at once. (I use the package datatool though, that possibly uses at least one slot too)

If anyone has an idea how to implement one of these solutions?

EDIT: Also, the first source mentioned something about e-TeX, Omega and LuaTeX. What are those and how do they help? I tried searching for them too, but I don't seem to understand if they are extensions of TeX or whole new languages. Someone also mentioned something about ConTeXt which seems to be an editor instead of language, according to Google, for Java and C++ etc.

share|improve this question
Try the morewrites package. – Ulrike Fischer Jul 23 '12 at 12:02
You should be able to open and close more than 16 files. You say "the next slot" which makes me think you are using \newwrite multiple times, that allocates the next register so can only be done 16 times (in classic tex), but you can open and close files multiple files using the same write stream. – David Carlisle Jul 23 '12 at 12:03
If you need two files at the same time, just allocate two streams and reuse them. When a stream has been closed, the symbolic name can be assigned to another file. – egreg Jul 23 '12 at 12:04
Aha! That I didn't know.. Thanks a lot! :D – Didii Jul 23 '12 at 12:10

The following shows 50 files being written from plain TeX:


\advance\count0 by 1
\immediate\write\foo{this is \the\count0}


$ tex write50
This is TeX, Version 3.1415926 (TeX Live 2012)
(./write50.tex )
No pages of output.
Transcript written on write50.log.

davidc@malta /c/tmp
$ ls file-*
file-1.tex   file-18.tex  file-26.tex  file-34.tex  file-42.tex  file-50.tex
file-10.tex  file-19.tex  file-27.tex  file-35.tex  file-43.tex  file-6.tex
file-11.tex  file-2.tex   file-28.tex  file-36.tex  file-44.tex  file-7.tex
file-12.tex  file-20.tex  file-29.tex  file-37.tex  file-45.tex  file-8.tex
file-13.tex  file-21.tex  file-3.tex   file-38.tex  file-46.tex  file-9.tex
file-14.tex  file-22.tex  file-30.tex  file-39.tex  file-47.tex
file-15.tex  file-23.tex  file-31.tex  file-4.tex   file-48.tex
file-16.tex  file-24.tex  file-32.tex  file-40.tex  file-49.tex
file-17.tex  file-25.tex  file-33.tex  file-41.tex  file-5.tex

davidc@malta /c/tmp
$ cat file-1.tex
this is 1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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