summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/endnotes-hy/endnotes-hy.sty
blob: 3ce809c2ea13ef5fc05cb0efad523c01f71f8945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
%%
%% This is file `endnotes-hy.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% endnotes-hy.dtx  (with options: `copyright,package')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% endnotes-hy.sty package,                              %%
%% Copyright (C) 2020                                    %%
%%   dpstory@uakron.edu  dpstory@acrotex.net             %%
%%                                                       %%
%% This program can redistributed and/or modified under  %%
%% the terms of the LaTeX Project Public License         %%
%% Distributed from CTAN archives in directory           %%
%% macros/latex/base/lppl.txt; either version 1.2 of the %%
%% License, or (at your option) any later version.       %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{endnotes-hy}
 [2020/04/08 v0.1 Enables hypertext links for endnotes]
\RequirePackage{endnotes}
\RequirePackage{etoolbox}
\newcommand\hyperref@nohy[2][]{#2}
\AtBeginDocument{\@ifundefined{hyperref}{\let\hyperref@en\hyperref@nohy
  \let\phantomendnote\relax}
  {\let\hyperref@en\hyperref}}
\def\phantomendnote{%
  \Hy@MakeCurrentHrefAuto{endnote}%
  \Hy@raisedlink
    {\hyper@anchorstart{endnote.\@theenmark}\hyper@anchorend}}
\def\endnoteautorefname{endnote}
\patchcmd{\theendnotes}{\enoteformat}
  {\phantomendnote\def\@currentHref{endnote.\@theenmark}%
   \enoteformat}{}{}
\newtoks\@entoks
\def\endnote{\let\@encurrlabelname\@empty
  \@ifstar{\let\@noMrk1\endnote@i}{\let\@noMrk0\endnote@i}}
\def\endnote@i{\@ifnextchar[%]
  {\@xendnote}
  {\stepcounter{endnote}%
   \protected@xdef\@theenmark{\theendnote}%
   \afterassignment\endnote@ii\@entoks}}
\def\endnote@ii{\@ifnextchar\label{\endnote@iii}{\endnote@iv}}
\def\endnote@iii\label#1{\def\@encurrlabelname{#1}\endnote@iv}
\def\endnote@iv{%
  \if\@noMrk0\relax
    \ifx\@encurrlabelname\@empty
      \@endnotemark
    \else
      \hyperref@en[\@encurrlabelname]{\@endnotemark}%
    \fi
  \fi
  \expandafter\@endnotetext\expandafter{\the\@entoks}}
\patchcmd{\@endnotetext}
  {\def\next{#1}}
  {\ifx\@encurrlabelname\@empty
    \def\next{#1}\else
    \edef\x{\noexpand\label{\@encurrlabelname}}%
    \expandafter\def\expandafter\next\expandafter{\x#1}\fi}{}{}
\patchcmd{\@xendnote}
  {\@endnotemark\@endnotetext}
  {\afterassignment\endnote@ii\@entoks}
  {}{}
\endinput
%%
%% End of file `endnotes-hy.sty'.