[texhax] how to copy a file within eTeX?

D. R. Evans doc.evans at gmail.com
Tue Apr 6 00:58:16 CEST 2010


My problem:

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
far :-(

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).

  Doc

PS I *almost* considered simply copying the file in the shell before I run
TeX but that seemed defeatist.

-- 
Web:  http://www.sff.net/people/N7DR

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://tug.org/pipermail/texhax/attachments/20100405/e44e9678/attachment.bin>


More information about the texhax mailing list