Skip to content

Commit

Permalink
use hooks with args for addcontentsline
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrike Fischer authored and josephwright committed Jun 7, 2023
1 parent 545fd4d commit f019f02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
9 changes: 4 additions & 5 deletions required/latex-lab/latex-lab-toc-hyperref-changes.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,12 @@
} % none
}
}
\AddToHook{cmd/addcontentsline/before}[hyp]
\AddToHookWithArguments{cmd/addcontentsline/before}[hyp]
{%
\ExpandArgs{ooo}
\Hy@addcontentsline@addbookmark
{\addcontentsline@arg@one}
{\addcontentsline@arg@two}
{\addcontentsline@arg@three}%
{#1}
{#2}
{#3}%
}
}
\ExplSyntaxOff
Expand Down
11 changes: 4 additions & 7 deletions required/latex-lab/latex-lab-toc-kernel-changes.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,12 @@
% \cs{addcontentsline} should always write the unique counter representation
% \cs{@currentHref} so that we can create the |/Ref| key. At the same time
% we need a hook, so that hyperref can add its bookmarks code. The generic hook
% would be ok, but we need the arguments, so we store them first.
% is ok. We only declare it and add until the merge.
%
% \begin{macrocode}
\NewHook{cmd/addcontentsline/before}
\def\addcontentsline#1#2#3{% toc extension, type, tag
\def\addcontentsline@arg@one{#1}% name??
\def\addcontentsline@arg@two{#2}%
\def\addcontentsline@arg@three{#3}%
\UseHook{cmd/addcontentsline/before}%
\NewHookWithArguments{cmd/addcontentsline/before}{3}
\def\addcontentsline#1#2#3{% #1=toc extension, #2= heading type, tag
\UseHookWithArguments{cmd/addcontentsline/before}{3}{#1}{#2}{#3}%
\addtocontents{#1}{%
\protect\contentsline{#2}{#3}{\thepage}{\@currentHref}\protected@file@percent
}}
Expand Down

0 comments on commit f019f02

Please sign in to comment.