Skip to content

Commit

Permalink
[macros, styles] Add \hypertarget to headings (#6516)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
t3nsor authored Nov 10, 2023
1 parent ce5ef1b commit 3e1f377
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion source/macros.tex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
%% Cross-references.
%%--------------------------------------------------
\newcommand{\addxref}[1]{%
\hypertarget{#1}{}%
\glossary[xrefindex]{\indexescape{#1}}{(\ref{\indexescape{#1}})}%
}

Expand Down Expand Up @@ -92,14 +93,15 @@
% 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
\or\let\s=\subsubsection\let\l=\label
\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
Expand Down
4 changes: 2 additions & 2 deletions source/styles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3e1f377

Please sign in to comment.