4

I've already searched a lot about it and I'm aware of both questions "No room for a new \read" with writing a journal and No room for a new \read/\write. Still, I couldn't find a solution to my problem since I'm using the SVG package to include .svg files. The package morewrites helped stopping "No room for a new \write" error messages while e-Tex extensions didn't help with \read (also mentioned here). The include command is entered as follows:

\includesvg[clean,pdf]{SVG_File}

The clean option remove the temporary files produced when extracting pdf from svg.

It turned out that the extraction and the cleaning option are producing the problem (removing them turned off the error messages!).

Having a quick look at the SVG implementation, it appears that calling these options invokes more \immediate\write18 commands. I'm not sure if this command was producing the reading error, but if so, I cannot see how a writing command would request a reading one!

Any hints?

  • 2
    looking at the source of the package it does a \newread on every \includesvg that's just wrong:-) – David Carlisle Nov 2 '14 at 13:09
  • @DavidCarlisle You did well to find that: the code is horribly laid out! – Joseph Wright Nov 2 '14 at 13:24
  • @JosephWright well I assumed that was the problem and searched for it, so only looked at a couple of lines:-) – David Carlisle Nov 2 '14 at 13:30
7

As David Carlisle points out, the error is in the fact that \includesvg calls \newread\SVG@in@file at every call (and also does \newwrite\SVG@out@file.

This is a big error, because LaTeX doesn't free an allocated output/input stream after usage.

You can fix the bad behavior by patching \@includesvg:

\documentclass{article}
\usepackage{svg}
\usepackage{etoolbox}

\makeatletter
\newread\SVG@in@file
\newwrite\SVG@out@file
\patchcmd{\@includesvg}{\newread\SVG@in@file}{}{}{}
\patchcmd{\@includesvg}{\newwrite\SVG@out@file}{}{}{}
\makeatother

...<the rest of the document>...

This allocates the streams once and for all, removing the bad code from the macro.

You should point out this bug to the package maintainer.

  • That worked! Still, I cannot figure out why removing the options also made the error disappear. – Mhd Mayya Nov 3 '14 at 11:09
  • 1
    @MhdMayya The \read stream is allocated only when the clean option is present. So overflowing the number of \read stream doesn't happen. Loading morewrite helps alleviating the symptoms, but it doesn't cure the disease. – egreg Nov 3 '14 at 12:37

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.