![如何使用 \@writefile 而不阻塞寫入流?](https://rvso.com/image/330723/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20%5C%40writefile%20%E8%80%8C%E4%B8%8D%E9%98%BB%E5%A1%9E%E5%AF%AB%E5%85%A5%E6%B5%81%EF%BC%9F.png)
據我了解,要正確使用\@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
.)
有什麼辦法可以阻止寫入流嗎?