1

From what I understand, to properly use \@writefile one has to block a write stream, like this:

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\makeatletter
\newwrite\tf@foo
\openout\tf@foo=\jobname.foo
\newcommand\foo[1]{%
    Writing ``#1'' to \texttt{\jobname.foo}!%
    \protected@write\@auxout{}{\string\@writefile{foo}{#1}}%
    }
\makeatother

\foo{Bar}

\end{document}

(This really creates a file .foo with one line containing Bar.)

Is there any way around blocking the write stream?

  • Do you mean that it should not be written immediately? – user31729 Mar 24 '16 at 7:47
  • Well, it need not be. I'm slightly worried about occupying resources, that's all – yo' Mar 24 '16 at 8:00
  • not sure what you mean by block here, also you don't have to write indirectly via the aux file, unless you want to do that??? – David Carlisle Mar 24 '16 at 8:01
  • Well, you have 16 write resources, if I understand things correctly. Maybe I'm mistaken by something, but I hoped to be able to write to file without the file being open during the whole document... This should save some of them, no? Also, I would be more convenient in case of errors, but that's a side effect for now. – yo' Mar 24 '16 at 8:03
  • @yo': The \@writefile command is basically used only by \addtocontents to defer things to the various ToC - related files (i.e. .toc, .lof etc.) I don't get the question actually. – user31729 Mar 24 '16 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.