Changes

Jump to navigation Jump to search
756 bytes added ,  14:18, 8 June 2020
m
no edit summary
Basically, to embed text in your document (tex input file) which is written to an external document when you process it, you can use buffers:
 
<texcode>
\startbuffer[x]
x
\stopbuffer
 
\savebuffer[x][temp.log]
</texcode>
 
The second argument is optional and when omitted the buffer will be saved as <code>jobname-<buffername>.tmp</code>.
 
 
----
Written in 2010
 
LaTeX provides a <code>filecontent</code> environment to embed text in your document
which is written to a an external document when your you process it. The filename is given with
the argument for the environment.
You could define a an environment for the same effect with the buffer mechanism, the codefor such a an environment is:
<texcode>
\unprotect
 
\definemessageconstant {filecontents}
 
\startinterface all
\setinterfacemessage{filecontents}{title}{filecontents}
\setinterfacemessage{filecontents}{1} {Overwriting file --}
\setinterfacemessage{filecontents}{2} {Writing file --}
\stopinterface
\def\startfilecontents
\def\dostartfilecontents[#1]%
{\doiffileexistselse{#1} {\showmessage\m!filecontents{1}{#1}} {\showmessage\m!filecontents{2}{#1}}% \beforesplitstring#1\at.\to\filename
\aftersplitstring #1\at.\to\extension
\let\f!temporaryextension\extension
\stopfilecontents
</texcode>
 
[[Category:Tools]]

Navigation menu