答案1
更多的事情将会失败\immediate\write
。
我建议获取以下“即时”版本\protected@write
:
\documentclass{article}
\usepackage{xpatch}
\makeatletter
% get a copy of `\protected@write
\let\protected@iwrite\protected@write
% patch the copy to add \immediate
\xpatchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
\makeatother
\newwrite\titlefile
\begin{document}
\author{A. Uthor}
\title{A title with \'accent \\ and new~line}
\immediate\openout\titlefile=\jobname.title
\makeatletter
\protected@iwrite\titlefile{\def\\{--}\def~{ }}{\@title}
\immediate\closeout\titlefile
\makeatother
\maketitle
\end{document}
看https://tex.stackexchange.com/a/110885/4427了解更多信息。
通过此设置,文件\jobname.title
将包含
A title with \'accent -- and new line