From 3e1f377a9dc3bece7acd2dddb7237065504db65c Mon Sep 17 00:00:00 2001 From: Brian Bi Date: Thu, 9 Nov 2023 16:00:22 -1000 Subject: [PATCH] [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 --- source/macros.tex | 4 +++- source/styles.tex | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/macros.tex b/source/macros.tex index fd5293136d..f8c3e2b720 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -64,6 +64,7 @@ %% Cross-references. %%-------------------------------------------------- \newcommand{\addxref}[1]{% + \hypertarget{#1}{}% \glossary[xrefindex]{\indexescape{#1}}{(\ref{\indexescape{#1}})}% } @@ -92,6 +93,7 @@ % defines a first-level section whose name is "Scope" and whose short % tag is intro.scope. The square brackets are mandatory. \def\Sec#1[#2]#3{% +\addxref{#2}% \ifcase#1\let\s=\chapter\let\l=\clauselabel \or\let\s=\section\let\l=\label \or\let\s=\subsection\let\l=\label @@ -99,7 +101,7 @@ \or\let\s=\paragraph\let\l=\label \or\let\s=\subparagraph\let\l=\label \fi% -\s[#3]{#3\hfill[#2]}\l{#2}\addxref{#2}% +\s[#3]{#3\hfill[#2]}\l{#2}% } % A convenience feature (mostly for the convenience of the Project diff --git a/source/styles.tex b/source/styles.tex index d77f983b38..9258953c1c 100644 --- a/source/styles.tex +++ b/source/styles.tex @@ -87,8 +87,8 @@ %%-------------------------------------------------- % set heading style for annexes \newcommand{\Annex}[3]{\chapter[#2]{(#3)\protect\\#2\hfill[#1]}\relax\annexlabel{#1}} -\newcommand{\infannex}[2]{\Annex{#1}{#2}{informative}\addxref{#1}} -\newcommand{\normannex}[2]{\Annex{#1}{#2}{normative}\addxref{#1}} +\newcommand{\infannex}[2]{\addxref{#1}\Annex{#1}{#2}{informative}} +\newcommand{\normannex}[2]{\addxref{#1}\Annex{#1}{#2}{normative}} %%-------------------------------------------------- %% set footnote style