如何使用 \@writefile 而不阻塞寫入流?

如何使用 \@writefile 而不阻塞寫入流?

據我了解,要正確使用\@writefile必須阻止寫入流,如下所示:

\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}

(這實際上創建了一個文件.foo,其中一行包含Bar.)

有什麼辦法可以阻止寫入流嗎?

相關內容