<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% !TeX root = ../easyfloats.tex

% Copyright © 2020 E. Zöllner
% Alternatively to the terms of the LPPL, at your choice,
% you can redistribute and/or modify this file under the
% terms of the Do What The Fuck You Want To Public License, Version 2,
% as published by Sam Hocevar. See http://www.wtfpl.net/about/.

% Adds an abstraction layer above hyperref's \href and \hyperref commands.
% Links are defined with:
%     \newurllink{&lt;name&gt;}{&lt;url&gt;}
%     \newlabellink{&lt;name&gt;}{&lt;label&gt;}
% A text is turned into a link with
%     \link[&lt;name&gt;]{&lt;text&gt;}
% Like in markdown the name of the link is optional.
% If it is omitted &lt;text&gt; is used instead.
% This has the advantage that all links can be declared in one place
% and URLs don't need to be repeated.
% Changing an external link to an internal link is easy.

\makeatletter
\newcommand{\link@csname}[1]{link@cs@#1}

\newcommand\newurllink{%
	\begingroup
	\let\do=\@makeother
	\dospecials
	\catcode`{=1
	\catcode`}=2
	\newurllink@do
}
\newcommand\newurllink@do[2]{% #1: name, #2: url
	\endgroup
	\expandafter \newcommand \csname\link@csname{#1}\endcsname{\href{#2}}%
}

\newcommand\newlabellink[2]{% #1: name, #2: label
	\expandafter \newcommand \csname\link@csname{#1}\endcsname{\hyperref[#2]}%
}

\newcommand\link{% [#1: name], #2: displayed text
	\@ifnextchar [
		{\link@do}
		{\@dblarg\link@do}%
}
\def\link@do[#1]#2{%
	\ifcsname\link@csname{#1}\endcsname
		\csname\link@csname{#1}\endcsname{#2}%
	\else
		\PackageError{link}{link name `#1' undefined}{}%
	\fi
}
\makeatother
</pre></body></html>