summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/doi/doi.sty
blob: 5e686c47e64248f8ff522434f5bacb464215856c (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{doi}[2005/03/24 handle doi numbers]
%% original code written by Heiko Oberdiek and published on comp.text.tex
%% Packaged as a style file by Maarten Sneep, with some minor 
%% changes suggested by Bruno Voisin to accomodate the Apple 
%% pdf framework
%%
%% This code is placed under the LPPL

%% We need hyperref, but you probably want to load hyperref 
%% beforehand, or set some options later on.
\RequirePackage{hyperref}

\newcommand*{\doi}{% 
  \begingroup 
  \lccode`\~=`\#\relax 
  \lowercase{\def~{\#}}
  \lccode`\~=`\<\relax 
  \lowercase{\def~{\textless}}
  \lccode`\~=`\>\relax 
  \lowercase{\def~{\textgreater}}
  \lccode`\~=0\relax 
  \catcode`\#=\active 
  \catcode`\<=\active 
  \catcode`\>=\active 
  \@doi
}% 

\def\@doi#1{% 
  \let\#\relax 
  \let\textless\relax 
  \let\textgreater\relax 
  \edef\x{\toks0={{#1}}}% 
  \x
  \edef\#{\@percentchar23}%
  \edef\textless{\@percentchar3C}% instead of {\string<} for Apple
  \edef\textgreater{\@percentchar3E}% instead of {\sting>} for Apple
  \edef\x{\toks1={\noexpand\href{http://dx.doi.org/#1}}}% 
  \x
  \edef\x{\endgroup\the\toks1 \the\toks0}
  \x
}