如何修改环境和命令才能通过 \write 命令将内容写入文件中?

如何修改环境和命令才能通过 \write 命令将内容写入文件中?

我想在编译时"generate/convert".tex文件转换为 xml 格式LaTeX。我不想修改 tex 文件,我想在编译时通过基于 DTD 的命令生成xml文件。我只能通过命令和环境构建文档类。是否可以通过命令生成文件?到目前为止,我尝试了以下代码:\writeLaTeXxml\write

\documentclass{book}
\usepackage{amsmath}

\newwrite\xmlwrite
\immediate\openout\xmlwrite \jobname.xml

\renewenvironment{quote}{\immediate\write\xmlwrite{<bq id="">}%
                         \par\addvspace{6pt}
                         \leftskip24pt\rightskip24pt\noindent
                        }
                        {\immediate\write\xmlwrite{</sample>}%
                        \par\addvspace{6pt}\ignorespacesafterend}
\everypar{\immediate\write\xmlwrite{<p>}}

\begin{document}

We note that we cannot fully eliminate a possibility, however small, that
the results of our alternative tests are falsely rejecting the true hypothesis that
splitting activity responds to investor preferences.

\begin{quote}
Given that the spurious regression bias may result in finding empirical
support for the catering hypothesis even if firms do not actually respond to
catering incentives, we revisit the results using five alternative techniques that
reduce the bias concerns.
\end{quote}
We note that we cannot fully eliminate a possibility, however small, that
the results of our alternative tests are falsely rejecting the true hypothesis that
splitting activity responds to investor preferences.

\immediate\closeout\xmlwrite
\end{document} 

相关内容