latex3 / latex3/hyperref

hyperref redefinition of `\contentsline` adds one level of braces if `linktoc=page`

Open
#65 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
205
Forks
41
PR merge metrics
No merged PRs in 30d

Description

In the definition of \contentsline, there is the following

8636 \def\Hy@temp{#3}%
8637 \ifx\Hy@temp\ltx@empty
8638 \csname l@#1\endcsname{#2}{#3}%
8639 \else
8640 \csname l@#1\endcsname{{#2}}{%
8641 \hyper@linkstart{link}{\Hy@tocdestname}{#3}\hyper@linkend
8642 }%
8643 \fi

This is triggered by linktoc=page option.

The issue (if there is one) is the {{#2}} at code line 8640. This is the only location in \contentsline definition where #2 ends up wrapped this way.

This makes it harder to see if #2 starts with \numberline or variants (depending on document class). In fact this causes a bug in etoc (a bug which was there since initial release of etoc), which does not detect the \numberline and leaves it in \etocname, thus it delayed expansion (which depends on then current setting of \@tempdima) causes varying effect. This surfaced in an issue in yathesis.

Is there any reason for the added braces?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at hyperref's \contentsline definition around code lines 8636–8642 and reproduce the behavior with linktoc=page, checking how the added braces affect #2 and \numberline. Compare the result with etoc's handling and determine whether the braces are required; done means the behavior is corrected or the reason is documented with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, tex
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.