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

  • Did you had a look at this answer? – Clément Jan 27 '16 at 19:58
  • 1
    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. – John Kormylo Jan 27 '16 at 20:47
  • 5
    You may try adding \usepackage{morewrites} – egreg Jan 27 '16 at 22:33

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
| improve this answer | |
  • 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 Jan 29 '16 at 7:12
  • @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 Jan 29 '16 at 16:24
  • I did not realise that you condensed the information manually. Thanks! – Dirk Jan 31 '16 at 9:59
  • 3
    @Dirk: Not manually. I used grep ;-) – user31729 Jan 31 '16 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 Feb 5 '16 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

| improve this answer | |

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.