Skip to content

Commit 079fbab

Browse files
committed
[macros] Add \termref
1 parent 5b54814 commit 079fbab

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

source/macros.tex

+19-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,15 @@
239239
\newcommand{\defnlibxname}[1]{\indexlibrary{\idxxname{#1}}\xname{#1}}
240240

241241
% term.* labels
242-
\newcommand{\termlabel}[1]{\label{term.#1}}
242+
\makeatletter
243+
% define a label such that \titleref yields the name of the term
244+
\newcommand{\termlabel}[2]{\@bsphack\begingroup%
245+
\protected@edef\@currentlabel{\protect\M@TitleReference
246+
{\@currentlabel}{#1}}%
247+
\MNR@label{term.#2}%
248+
\endgroup \@esphack}%
249+
\makeatother
250+
243251
% convert space-separated phrase to dot-separated label name
244252
\newcommand{\newtermlabelx}[1]{%
245253
{% remove all formatting instructions
@@ -251,8 +259,9 @@
251259
\let\oldconcept\oldconceptname%
252260
\renewcommand{\ntbs}{ntbs}%
253261
\renewcommand{\ntmbs}{ntmbs}%
262+
\edef\title{#1}%
254263
\StrSubstitute{#1}{ }{.}[\temp]%
255-
\termlabel{\temp}%
264+
\termlabel{\title}{\temp}%
256265
}}
257266

258267
% Non-compound defined term.
@@ -378,6 +387,14 @@
378387
%% Inline non-parenthesized figure reference (override memoir's \fref)
379388
\renewcommand{\fref}[1]{\hyperref[fig:#1]{\figurerefname \nolinebreak[3] \ref*{fig:#1}}}
380389

390+
%% Inline reference to a defined term
391+
\newcommand{\termrefx}[2]{\hyperref[term.#2]{#1}\iref{term.#2}}
392+
\newcommand{\termref}[1]{\begingroup%
393+
\StrSubstitute{#1}{ }{.}[\temp]%
394+
\titleref{term.\temp}\iref{term.\temp}%
395+
\endgroup%
396+
}
397+
381398
%% NTBS, etc.
382399
\verbtocs{\StrTextsmaller}|\textsmaller[1]{|
383400
\verbtocs{\StrTextsc}|\textsc{|

0 commit comments

Comments
 (0)