Skip to content

Commit 3e1f377

Browse files
authored
[macros, styles] Add \hypertarget to headings (#6516)
This allows forming URLs with a stable label as a fragment and have PDF viewers jump to the corresponding (sub)clause. For example: std.pdf#basic.life
1 parent ce5ef1b commit 3e1f377

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

source/macros.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
%% Cross-references.
6565
%%--------------------------------------------------
6666
\newcommand{\addxref}[1]{%
67+
\hypertarget{#1}{}%
6768
\glossary[xrefindex]{\indexescape{#1}}{(\ref{\indexescape{#1}})}%
6869
}
6970

@@ -92,14 +93,15 @@
9293
% defines a first-level section whose name is "Scope" and whose short
9394
% tag is intro.scope. The square brackets are mandatory.
9495
\def\Sec#1[#2]#3{%
96+
\addxref{#2}%
9597
\ifcase#1\let\s=\chapter\let\l=\clauselabel
9698
\or\let\s=\section\let\l=\label
9799
\or\let\s=\subsection\let\l=\label
98100
\or\let\s=\subsubsection\let\l=\label
99101
\or\let\s=\paragraph\let\l=\label
100102
\or\let\s=\subparagraph\let\l=\label
101103
\fi%
102-
\s[#3]{#3\hfill[#2]}\l{#2}\addxref{#2}%
104+
\s[#3]{#3\hfill[#2]}\l{#2}%
103105
}
104106

105107
% A convenience feature (mostly for the convenience of the Project

source/styles.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@
8787
%%--------------------------------------------------
8888
% set heading style for annexes
8989
\newcommand{\Annex}[3]{\chapter[#2]{(#3)\protect\\#2\hfill[#1]}\relax\annexlabel{#1}}
90-
\newcommand{\infannex}[2]{\Annex{#1}{#2}{informative}\addxref{#1}}
91-
\newcommand{\normannex}[2]{\Annex{#1}{#2}{normative}\addxref{#1}}
90+
\newcommand{\infannex}[2]{\addxref{#1}\Annex{#1}{#2}{informative}}
91+
\newcommand{\normannex}[2]{\addxref{#1}\Annex{#1}{#2}{normative}}
9292

9393
%%--------------------------------------------------
9494
%% set footnote style

0 commit comments

Comments
 (0)