Skip to content

Commit 3d8ce9a

Browse files
committed
move latex-lab-code
1 parent 4a66bdc commit 3d8ce9a

File tree

2 files changed

+120
-15
lines changed

2 files changed

+120
-15
lines changed

ChangeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2026-02-04 Ulrike Fischer
2+
* hyperref.dtx: add \hyper@nopatch@natbib test for latex-lab-bib code
3+
14
Version 2026-01-29 v7.01p / v2.58
25

36
2026-01-10 Ulrike Fischer

hyperref.dtx

Lines changed: 117 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12027,18 +12027,23 @@
1202712027
\providecommand\protected@file@percent{}
1202812028
% \end{macrocode}
1202912029
%
12030+
% Change 2026-02-06: Add support for \cs{DocumentMetadata}. We externalize the command
12031+
% to allow booksmark to be set without explicit toc-entry.%
1203012032
% \begin{macrocode}
12031-
\@ifundefined{hyper@nopatch@toc}{%
12032-
\def\addcontentsline#1#2#3{% toc extension, type, tag
12033+
\def\Hy@addcontentsline@addbookmark#1#2#3%#1 toc type, #2 level, #3 content
12034+
{%
12035+
\ifHy@bookmarks
12036+
\ifx\@currentHref\@empty
12037+
\Hy@Warning{%
12038+
No destination for bookmark of \string\addcontentsline,%
12039+
\MessageBreak destination is added%
12040+
}%
12041+
\phantomsection
12042+
\fi
1203312043
\begingroup
12034-
\let\label\@gobble
12035-
\ifx\@currentHref\@empty
12036-
\Hy@Warning{%
12037-
No destination for bookmark of \string\addcontentsline,%
12038-
\MessageBreak destination is added%
12039-
}%
12040-
\phantomsection
12041-
\fi
12044+
\let\label\@gobble@om
12045+
\let\index\@gobble@som
12046+
\let\glossary\@gobble@om
1204212047
\expandafter\ifx\csname toclevel@#2\endcsname\relax
1204312048
\begingroup
1204412049
\def\Hy@tempa{#1}%
@@ -12074,13 +12079,31 @@
1207412079
}%
1207512080
\endgroup
1207612081
\fi
12077-
\addtocontents{#1}{%
12078-
\protect\contentsline{#2}{#3}{\thepage}{\@currentHref}\protected@file@percent
12079-
}%
12080-
\endgroup
12082+
\endgroup
12083+
\fi
1208112084
}
12082-
}{}
1208312085
% \end{macrocode}
12086+
% If \cs{DocumentMetadata} is not used, we must redefine \cs{addcontentsline} as in the
12087+
% latex-lab code to ensure that the target is written:
12088+
% \begin{macrocode}
12089+
\@ifundefined{hyper@nopatch@toc}{%
12090+
\def\addcontentsline#1#2#3{% #1=toc extension, #2= heading type, tag
12091+
\addtocontents{#1}{%
12092+
\protect\contentsline{#2}{#3}{\thepage}{\@currentHref}\protected@file@percent
12093+
}}}{}
12094+
% \end{macrocode}
12095+
%
12096+
% Then this addition works also if \cs{DocumentMetadata} is used.
12097+
% \begin{macrocode}
12098+
\AddToHookWithArguments{cmd/addcontentsline/before}[hyp]
12099+
{%
12100+
\Hy@addcontentsline@addbookmark
12101+
{#1}
12102+
{#2}
12103+
{#3}%
12104+
}
12105+
% \end{macrocode}
12106+
%
1208412107
% \begin{macro}{\contentsline}
1208512108
% The page number might be empty. In this case the link for the
1208612109
% page number is suppressed to avoid little link boxes.
@@ -12137,6 +12160,85 @@
1213712160
% \end{macrocode}
1213812161
% \end{macro}
1213912162
%
12163+
% If \cs{DocumentMetadata} is used we make use of the \cs{contentsline}-hooks to add links:
12164+
%
12165+
% \begin{macrocode}
12166+
\ExplSyntaxOn
12167+
\IfDocumentMetadataT
12168+
{
12169+
\AddToHookWithArguments{contentsline/text/before}[hyp]
12170+
{
12171+
\tl_if_blank:nF {#2}%text
12172+
{
12173+
\tl_if_blank:nF {#4}%destination
12174+
{
12175+
\int_case:nnF {\Hy@linktoc}
12176+
{
12177+
{0}{} %none
12178+
{1}{\hyper@linkstart{link}{#4}} %section
12179+
{2}{} %page
12180+
}
12181+
{\hyper@linkstart{link}{#4}} %all
12182+
}
12183+
}
12184+
}
12185+
\AddToHookWithArguments{contentsline/text/after}[hyp]
12186+
{
12187+
\tl_if_blank:nF {#2}
12188+
{
12189+
\tl_if_blank:nF {#4}
12190+
{
12191+
\int_case:nnF {\Hy@linktoc}
12192+
{
12193+
{0}{} %none
12194+
{1}{\hyper@linkend} %section
12195+
{2}{} %page
12196+
}
12197+
{\hyper@linkend} %all
12198+
} % none
12199+
}
12200+
}
12201+
12202+
\AddToHookWithArguments{contentsline/page/before}[hyp]
12203+
{
12204+
\tl_if_blank:nF {#3}
12205+
{
12206+
\tl_if_blank:nF {#4} %
12207+
{
12208+
\int_case:nnF {\Hy@linktoc}
12209+
{
12210+
{0}{} %none
12211+
{1}{} %section
12212+
{2}{\hyper@linkstart{link}{#4}} %page
12213+
}
12214+
{\hyper@linkstart{link}{#4}} %all
12215+
} % none
12216+
}
12217+
}
12218+
\AddToHookWithArguments{contentsline/page/after}[hyp]
12219+
{
12220+
\tl_if_blank:nF {#3}
12221+
{
12222+
\tl_if_blank:nF {#4}
12223+
{
12224+
\int_case:nnF {\Hy@linktoc}
12225+
{
12226+
{0}{} %none
12227+
{1}{} %section
12228+
{2}{\hyper@linkend} %page
12229+
}
12230+
{\hyper@linkend} %all
12231+
} % none
12232+
}
12233+
}
12234+
% \end{macrocode}
12235+
% Until the latex-lab file is cleaned up, we need to remove the hook code
12236+
% \begin{macrocode}
12237+
\AddToHook{package/hyperref/after}[latex-lab-testphase-toc]{}
12238+
\RemoveFromHook{package/hyperref/after}[latex-lab-testphase-toc]
12239+
}
12240+
\ExplSyntaxOff
12241+
% \end{macrocode}
1214012242
% \begin{macrocode}
1214112243
%</packageEnd>
1214212244
%<*check>

0 commit comments

Comments
 (0)