[texhax] how to copy a file within eTeX?
D. R. Evans
doc.evans at gmail.com
Tue Apr 6 00:58:16 CEST 2010
I need to process a single ToC file multiple times within the course of
compiling a single TeX file. However, since I'm also regenerating the ToC,
I can't simply put the usual \readtoc at the points where I want the ToC
processing to occur.
My guess at a reasonable solution:
Actually, I had two approaches:
1. Read the contents of the ToC file into a single variable, then execute
the variable as if it were a macro at each to the points where I want a ToC.
2. Copy the \jobname.toc file to \jobname.mytoc, and then execute a
slightly modified version of \readtocfile (modified to read from
\jobname.mytoc) at the places where I want the ToC.
I can't get either of these to work, not because they are intrinsically
wrong (although they may be) but simply because I can't figure out how to
implement either of them. I've spent the last hour poring over the TeXbook
and "TeX for the Impatient" and trying things, but not really getting very
In particular I thought that #2 would be essentially trivial (by --
horribly -- reading and writing a line at a time), but I don't see how to
tell when I've reached the end of the source file. The discussions of \read
and descriptions of file I/O don't seem to explain that anywhere.
Any help much appreciated (as always).
PS I *almost* considered simply copying the file in the shell before I run
TeX but that seemed defeatist.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 260 bytes
Desc: OpenPGP digital signature
More information about the texhax