# [tex-eplain] Many TOC's in one document, help.

Oleg Katsitadze geolsoft at mail.ru
Sun Sep 25 10:32:36 CEST 2005

```On Fri, Sep 23, 2005 at 02:43:12PM -0400, Arctic Fidelity wrote:
> The only problem with this is that the \writetocentry's are still
> going to the main TOC file, rather than to the special one

The problem is that \writetocentry's open the .toc file only
at the first call.  Even if \tocfilebasename has changed
after the .toc file has been opened (e.g., at the start of
the appendix), the new file is not opened, all the entries
still go to the old file.

I believe the trick with changing \tocfilebasename was
intended only for _reading_ TOCs with different base names,
not writing them.  (Karl, should the manual state this
explicitly?)

I think \definecontentsfile is more appropriate here.
Another solution might be fooling Eplain by saying
\@tocfileopenedfalse at the beginning of your appendix.  So
at the first \writetocentry within your appendix, Eplain
will again open the .toc file, now with the new
\tocfilebasename.  But before doing it, don't forget to
close the previous .toc file
(\immediate\closeout\tocfilebasename.toc), otherwise you
might overflow the open files limit, when there is a lot of
appendices.

I did not test the second solution, but I hope this will
help.

--
Best regards,