# [tex-eplain] \tocentry with `depth' argument,

Dorai Sitaram dorai at ccs.neu.edu
Wed May 3 23:36:56 CEST 2006

```>
>     Is there a reason why the arguments of
>
> There is no reason.  I just wrote it that way because it seemed "logical".
>
>     I would have thought #1 and #2 are better in each other's places.  That
>     way, if a user were to allow for catcode changes in the title,
>
> I must be being dense, but I don't see how the argument ordering would
> make allowing for catcode changes easier?

Scenario 1.  \tocentry is called with section number, then text for section
title, with possible catcode changes.

When you're reading the .toc file, and thus evaluating the \tocentry
command, you can pick up the first argument but simply let the subsequent
argument print itself.

Scenario 2.  \tocentry is called with text for section title (again with
possible catcode changes), then the section number.

When reading the .toc file, you need to get at the section number first.
So you pick up the section title after setting catcodes to 11, then pick up
the section number, print the section number, and then you can't just write
the title argument you picked up... because it has the wrong catcodes.  You
have to write it back to a temp file, and then input the file.

Dorai

> Anyway, I don't think we can change the behavior now.  Any existing
> document that uses the toc stuff would break.
>
> What we could do, if Oleg doesn't think it's too onerous to implement,
> is provide a switch that changes the behavior of \writenumberedtocentry,
> or a second command, e.g., \writenumberedtocentryb, with the arguments
> in the order you want ...
>
> thanks,
> k
>
>

```