In my special package combination I get the error No room for new \write. \tablecontents and Bad number (16). \tablecontents. The following MWE throws this error in pdflatex and lualatex with TeX Live 2015. As you can see, I add the own content register loi. I can delete nearly every package separately and the error directly vanishes.

Does anyone have an idea what is wrong with this package combination?

% load packages
\usepackage{adjustbox, amsmath, blindtext, datatool, fancybox, fixme, graphicx, marginnote, pgfplots}
% load package for code code highlighting

% define Open Issue and corresponding List of Open Issues
    \phantomsection% comment out if hyperref is noy used
            \ifcsname c@chapter\endcsname%
        }{#1: #2}%
    \textbf{Open Issue -- #1:} #2}%
% define counter
\ifcsname c@chapter\endcsname%
\newcommand*{\listopenissuesname}{List of Open Issues}
    \ifcsname chapter\endcsname%

\fxsetup{status = draft}


% include open issues
% include list of corrections
% include indicies
\tableofcontents                            % Inhaltsverzeichnis einbinden

  • 1
    Did you had a look at this answer?
    – Clément
    Commented Jan 27, 2016 at 19:58
  • 2
    According to Knuth, there are only 16 IO channels, which are normally allocated using \newread and \newwrite. I don't believe they reuse closed channels automatically. Commented Jan 27, 2016 at 20:47
  • 7
    You may try adding \usepackage{morewrites}
    – egreg
    Commented Jan 27, 2016 at 22:33

2 Answers 2


The solution is to use \usepackage{morewrites} since basically any of the packages already loaded there grabs at least one (write) file handle, but the number of file handles is restricted to 16 registers only, unless morewrites is loaded, which extends the number of registers.

The question is: Are some of the packages really needed?

Here is a short excerpt of the \jobname.log file

\@dtl@write=\write3   % package datatool
\Verbatim@Outfile=\write4  % fancyvrb
\w@pgf@writea=\write5  % pgf
\blx@bcfout=\write6   % biblatex
\FV@OutFile=\write7   % fancyvrb again
\@xs@message=\write8  % xstring
\minted@code=\write9  % minted
\glswrite=\write10    % glossaries
\glo@main@file=\write11  % glossaries again
\noroom@idxfile=\write12  % imakeidx
\@outlinefile=\write13    % hyperref?
\tf@loi=\write14          % code itself with \addcontentsline{loi}
\tf@lox=\write15          % fixme package
! No room for a new \write.
\tf@toc=\write16  % Failure here
  • 1
    Thanks for your explanation! You are right, I do not need all packages every time and will reduce them. However, I wanted to understand the problem. How do you get the file jobname.log?
    – Dirk
    Commented Jan 29, 2016 at 7:12
  • 1
    @Dirk: Any TeX compilation run produces a .log file. If your file is called foo.tex, the jobname is foo and the log file is foo.log then. The information I presented in this answer is of course condensed, i.e. I took only the relevant lines with \write...
    – user31729
    Commented Jan 29, 2016 at 16:24
  • I did not realise that you condensed the information manually. Thanks!
    – Dirk
    Commented Jan 31, 2016 at 9:59
  • 3
    @Dirk: Not manually. I used grep ;-)
    – user31729
    Commented Jan 31, 2016 at 10:46
  • I just realised, that you marked lox with my code. Where do I have the line \addcontentsline{lox} in my code?
    – Dirk
    Commented Feb 5, 2016 at 14:29

LaTeX has a limit of 16 open files, and many packages open them.

There are 3 proposed solutions for this error that I could find:

  • Use LuaLaTeX, and the limit will be the limit in the operating systems (never tried)
  • Use the packages morewrites (used it for a while but later hit in a bug)
  • Use the package scrwfile from KOMA-Script (My current choice)

morewrites and scrwfile have different approaches to solve this problem, but both change the LaTeX kernel somehow. Deep Magic.

See debug No room for a new \write problem

  • Some packages are not compatible with LuaLaTeX, but it looks to be the better solution overall.
    – Xexeo
    Commented Apr 29, 2021 at 22:56

You must log in to answer this question.

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