On Mon, Jan 06, 2025 at 06:27:58AM +0000, Werner LEMBERG wrote:
> 
> > I'm inclined not to do it for the title page, but do it for the
> > contents.
> 
> Sounds good, thanks.

It is quite straightforward to always add an outline entry for the table of
contents at the beginning of the outline.  However, it is possible for
@contents to occur at the end of the document.  Then the entry should be
at the end of the outline.  (The table of contents in the middle of
a document does not work.)

However, the order of entries in the outline is defined by the .toc
file that is read by the @contents command.  So if the position of the
@contents command is to be kept, then @contents should write to the
.toc file.

This is not possible, as you cannot read from and write to the same
file at the same time.  For example, if @contents is at the start of the
file, writing to the .toc file in @contents would wipe out the .toc file
from the last run.

We would need some other way of detecting if @contents is being used
at the very end of the document.  I tried doing it with special-case
code to check if a @node had been seen yet, but this does not
account for the case of @shortcontents at the start of the file,
and @contents at the end, if an outline entry is to be generated
for @shortcontents as well (we cannot write to the .toc file in
@shortcontents either).  So it is quite tricky to handle all possible
cases correctly.


Reply via email to