summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/doipubmed/doipubmed.dtx
blob: cf2c4e7570009b9e1376fce025bd31eb9fd8e034 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
%\iffalse
%<*package>
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2005 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
\documentclass{ltxdoc}

\usepackage[colorlinks,
            bookmarks,
            bookmarksopen,
            pdfauthor={N.L.C. Talbot},
            pdftitle={Documentation for doipubmed.sty},
            pdfkeywords={date,time,LaTeX}]{hyperref}



\begin{document}
\DocInput{doipubmed.dtx}
\end{document}
%</driver>
%\fi
%
%\def\filedate{9 September 2005}
%\def\fileversion{1.0}
%\def\filename{doipubmed.dtx}
%\def\docdate{9 September 2005}
%\title{Documentation for doipubmed.sty}
%\author{Nicola Talbot}
%\date{\docdate}
%\maketitle
% \section{Introduction}
% The commands defined in this package were primarily designed
% for use in bibliographies to make it easier to cite
% documents with digital object identifiers (DOI) or PubMed 
% entries. If the command \verb|\url| has been defined, the
% definition will remain, otherwise the \texttt{url} package
% will be loaded.
%
% Example:
%\begin{verbatim}
%@article{Cawley2002e,
%   author    = "Cawley, Gavin C. and Talbot, Nicola L. C.",
%   title     = "Fast leave-one-out cross-validation of sparse least-squares
%                support vector machines",
%   journal   = "Neural Networks",
%   volume    = 17,
%   number    = 10,
%   pages     = "1467--1475",
%   month     = DEC,
%   year      = 2004,
%   note      = "(\doi{10.1016/j.neunet.2004.07.002},
%                 \pubmed{15541948}). Also available from
%                  \citeurl{http://theoval.cmp.uea.ac.uk/~gcc/publications}"
%}
%\end{verbatim}
%
% \section{doipubmed.sty code}
% Package initialisation and identification
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{doipubmed}[2005/09/09 (NLCT)]
%    \end{macrocode}
% If |\url| has not been defined, load the \texttt{url}
% package.
%    \begin{macrocode}
\@ifundefined{url}{\RequirePackage{url}}{}
%    \end{macrocode}
% If |\href| has been defined (e.g.\ if the \texttt{hyperref}
% package has been loaded), then do nothing, otherwise if
% |\htmladdnormallink| has been defined (e.g.\ if the 
% \texttt{html} package has been loaded) then define
% |\href| in terms of |\htmladdnormallink|, otherwise define
% |\href| to simply print the second argument and the first
% is ignored (so there will be no hyperlink).
%    \begin{macrocode}
\@ifundefined{href}{
\@ifundefined{htmladdnormallink}{
\newcommand{\href}[2]{#2}
}{%
\newcommand{\href}[2]{\htmladdnormallink{#2}{#1}}
}
}{}
%    \end{macrocode}
% Define some commands to allow the user to change the format
% of the text provided with the hyperlink. The argument will 
% be the argument as passed to |\doi| or |\pubmed|:
%    \begin{macrocode}
\newcommand{\doitext}[1]{doi: #1}
\newcommand{\pubmedtext}[1]{PubMed: #1}
%    \end{macrocode}
%\DescribeMacro{\doi}Define |\doi|. Syntax:
%|\doi{|\meta{code}|}|. 
% For example, |\doi{10.1109/ICPR.2004.1334245}| 
% will produce \href{http://dx.doi.org/10.1109/ICPR.2004.1334245}{doi: 10.1109/ICPR.2004.1334245}.
%    \begin{macrocode}
\newcommand{\doi}[1]{\href{http://dx.doi.org/#1}{\doitext{#1}}}
%    \end{macrocode}
%\DescribeMacro{\pubmed}Define |\pubmed|. Syntax:
%|\pubmed{|\meta{code}|}|.
%For example, |\pubmed{15541948}| will produce 
% \href{http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=15541948&dopt=Abstract}{PubMed: 15541948}.
%    \begin{macrocode}
\newcommand{\pubmed}[1]{%
\href{http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=#1&dopt=Abstract}{%
\pubmedtext{#1}}}
%    \end{macrocode}
%\DescribeMacro{\citeurl}Define |\citeurl| to place address
% between \textless\ and \textgreater.
%    \begin{macrocode}
\newcommand{\citeurl}[1]{\textless\url{#1}\textgreater}
%</package>
%    \end{macrocode}
% \section{doipubmed.perl code}
% This is the code for the \LaTeX2HTML style file. The text
% produced by the |\doi| and |\pubmed| commands don't include
% the code (but this can be changed by redefining |\doitext|
% and |\pubmedtext|)
%    \begin{macrocode}
%<*perl>
#!/usr/bin/perl

# File        : doipub.perl
# Author      : Nicola Talbot
# Date        : 9th September 2005
# Description : LaTeX2HTML style file implementing doipubmed package 

sub do_cmd_doitext{
   local($_) = @_;
   local($doi);

   s/$next_pair_pr_rx/$doi=$2;''/eo;
   join('', "doi", $_);
}

sub do_cmd_pubmedtext{
   local($_) = @_;
   local($pubmed);

   s/$next_pair_pr_rx/$pubmed=$2;''/eo;
   join('', "PubMed", $_);
}

sub do_cmd_doi{
   local($_) = @_;
   local($doi,$doitext,$br_id);

   s/$next_pair_pr_rx/$br_id=$1;$doi=$2;''/eo;

   $doitext = &do_cmd_doitext("$OP$br_id$CP$doi$OP$br_id$CP");

   join('', 
        &make_href("http://dx.doi.org/$doi", $doitext), 
        $_);
}

sub do_cmd_pubmed{
   local($_) = @_;
   local($pubmed,$pubmedtext,$br_id);

   s/$next_pair_pr_rx/$br_id=$1;$pubmed=$2;''/eo;

   $pubmedtext = &do_cmd_pubmedtext("$OP$br_id$CP$pubmed$OP$br_id$CP");

   join('', 
        &make_href("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=$pubmed&dopt=Abstract", 
                   $pubmedtext), 
        $_);
}

sub do_cmd_citeurl{
   local($_) = @_;
   local($url);

   s/$next_pair_pr_rx/$url=$2;''/eo;

   join('', '&lt;',
        &make_href($url, $url), '&gt;',
        $_);
}

1;
%</perl>
%    \end{macrocode}