Skip to content

Commit 1548672

Browse files
committed
[macros] Add \termref
1 parent 17f46b6 commit 1548672

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.
@@ -389,6 +398,14 @@
389398
%% Inline non-parenthesized figure reference (override memoir's \fref)
390399
\renewcommand{\fref}[1]{\hyperref[fig:#1]{\figurerefname \nolinebreak[3] \ref*{fig:#1}}}
391400

401+
%% Inline reference to a defined term
402+
\newcommand{\termrefx}[2]{\hyperref[term.#2]{#1}\iref{term.#2}}
403+
\newcommand{\termref}[1]{\begingroup%
404+
\StrSubstitute{#1}{ }{.}[\temp]%
405+
\titleref{term.\temp}\iref{term.\temp}%
406+
\endgroup%
407+
}
408+
392409
%% NTBS, etc.
393410
\verbtocs{\StrTextsmaller}|\textsmaller[1]{|
394411
\verbtocs{\StrTextsc}|\textsc{|

0 commit comments

Comments
 (0)