
據我了解,要正確使用\@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
.)
有什麼辦法可以阻止寫入流嗎?