Debian Codegraph @

texmf-dist/source/latex/doipubmed/doipubmed.dtx

raw
1 %\iffalse
2 % doipubmed.dtx generated using makedtx version 0.94b (c) Nicola Talbot
3 % Command line args:
4 % -macrocode "doipubmed.perl"
5 % -setambles "doipubmed.perl=>\nopreamble\nopostamble"
6 % -comment "doipubmed.perl"
7 % -src "doipubmed.sty=>doipubmed.sty"
8 % -src "doipubmed.perl=>doipubmed.perl"
9 % -doc "manual.tex"
10 % -author "Nicola Talbot"
11 % -dir "source"
12 % doipubmed
13 % Created on 2007/8/20 16:15
14 %\fi
15 %\iffalse
16 %<*package>
17 %% \CharacterTable
18 %% {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
19 %% 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
20 %% Digits \0\1\2\3\4\5\6\7\8\9
21 %% Exclamation \! Double quote \" Hash (number) \#
22 %% Dollar \$ Percent \% Ampersand \&
23 %% Acute accent \' Left paren \( Right paren \)
24 %% Asterisk \* Plus \+ Comma \,
25 %% Minus \- Point \. Solidus \/
26 %% Colon \: Semicolon \; Less than \<
27 %% Equals \= Greater than \> Question mark \?
28 %% Commercial at \@ Left bracket \[ Backslash \\
29 %% Right bracket \] Circumflex \^ Underscore \_
30 %% Grave accent \` Left brace \{ Vertical bar \|
31 %% Right brace \} Tilde \~}
32 %</package>
33 %\fi
34 % \iffalse
35 % Doc-Source file to use with LaTeX2e
36 % Copyright (C) 2007 Nicola Talbot, all rights reserved.
37 % \fi
38 % \iffalse
39 %<*driver>
40 \documentclass{ltxdoc}
41
42 \usepackage{color}
43 \usepackage[colorlinks,
44 bookmarks,
45 bookmarksopen,
46 pdfauthor={Nicola L. C. Talbot},
47 pdftitle={Documentation for doipubmed.sty},
48 pdfkeywords={date,time,LaTeX}]{hyperref}
49 \usepackage{doipubmed}
50
51
52 \renewcommand{\usage}[1]{\textit{\hyperpage{#1}}}
53 \renewcommand{\main}[1]{\hyperpage{#1}}
54 \newcommand{\see}[2]{\emph{see} #1}
55 \makeatletter
56 \RecordChanges
57 \PageIndex
58 \definecolor{defbackground}{rgb}{1,1,0.75}
59 \newsavebox\defsbox
60 \newlength\defwidth
61
62 \newenvironment{definition}{%
63 \setlength{\fboxsep}{4pt}\setlength{\fboxrule}{1.25pt}%
64 \begin{lrbox}{\defsbox}%
65 \setlength\defwidth\linewidth
66 \addtolength\defwidth{-2\fboxrule}%
67 \addtolength\defwidth{-2\fboxsep}%
68 \begin{minipage}{\defwidth}\flushleft
69 }{%
70 \end{minipage}
71 \end{lrbox}%
72 \vskip10pt
73 \noindent
74 \fcolorbox{black}{defbackground}{\usebox\defsbox}%
75 \vskip10pt
76 }
77 \newcommand*{\sty}[1]{\textsf{#1}}
78
79
80 \CheckSum{148}
81
82 \begin{document}
83 \DocInput{doipubmed.dtx}
84 \end{document}
85 %</driver>
86 %\fi
87 %
88 %\title{Documentation for doipubmed.sty}
89 %\author{Nicola L. C. Talbot\\[10pt]
90 %School of Computing Sciences\\
91 %University of East Anglia\\
92 %Norwich. Norfolk\\
93 %NR4 7TJ. United Kingdom\\
94 %\url{http://theoval.cmp.uea.ac.uk/~nlct/}}
95 %\date{20th August 2007}
96 %\maketitle
97 %
98 % \section{Introduction}
99 % The commands defined in this package were primarily designed
100 % for use in bibliographies to make it easier to cite
101 % documents with digital object identifiers (DOI) or PubMed
102 % entries. If the command \cs{url} has been defined, the
103 % definition will remain, otherwise the \texttt{url} package
104 % will be loaded.
105 %
106 %\DescribeMacro{\doi}
107 %\begin{definition}
108 %\cs{doi}\marg{ref number}
109 %\end{definition}
110 %This displays doi: \meta{ref number} with a hyperlink to the
111 %corresponding web entry. For example:
112 %\begin{verbatim}
113 %\doi{10.1016/j.neunet.2004.07.002}
114 %\end{verbatim}
115 %produces:
116 %\doi{10.1016/j.neunet.2004.07.002}.
117 %
118 %As from version 1.01, this
119 %command also works with awkward characters, for example:
120 %\begin{verbatim}
121 %\doi{10.1002/1521-3951(200103)224:1<271::AID-PSSB271>3.0.CO;2-\#}
122 %\end{verbatim}
123 %produces:
124 %\doi{10.1002/1521-3951(200103)224:1<271::AID-PSSB271>3.0.CO;2-\#}.
125 %
126 %Alternatively, you can do:
127 %\begin{verbatim}
128 %\doi{10.1002/1521-3951(200103)224:1<271::AID-PSSB271>3.0.CO;2-\%23}
129 %\end{verbatim}
130 %which produces:
131 %\doi{10.1002/1521-3951(200103)224:1<271::AID-PSSB271>3.0.CO;2-\%23}.
132 %
133 %\DescribeMacro{\pubmed}
134 %\begin{definition}
135 %\cs{pubmed}\marg{ref number}
136 %\end{definition}
137 %This displays PubMed: \meta{ref number} with a hyperlink to the
138 %corresponding PubMed entry. For example:
139 %\begin{verbatim}
140 %\pubmed{15541948}
141 %\end{verbatim}
142 %produces:
143 %\pubmed{15541948}.
144 %
145 %\DescribeMacro{\citeurl}
146 %\begin{definition}
147 %\cs{citeurl}\marg{url}
148 %\end{definition}
149 %Displays the URL inside angle brackets. For example:
150 %\begin{verbatim}
151 %\citeurl{http://theoval.cmp.uea.ac.uk/~gcc/publications/}
152 %\end{verbatim}
153 %produces:
154 %\citeurl{http://theoval.cmp.uea.ac.uk/~gcc/publications/}.
155 %
156 %
157 %
158 %\StopEventually{}
159 %\section{The Code}
160 %\iffalse
161 % \begin{macrocode}
162 %<*doipubmed.sty>
163 % \end{macrocode}
164 %\fi
165 % Package initialisation and identification
166 % \begin{macrocode}
167 \NeedsTeXFormat{LaTeX2e}
168 \ProvidesPackage{doipubmed}[2007/08/20 1.01 (NLCT)]
169 % \end{macrocode}
170 % If \cs{url} has not been defined, load the \sty{url}
171 % package.
172 % \begin{macrocode}
173 \@ifundefined{url}{\RequirePackage{url}}{}
174 % \end{macrocode}
175 % If \cs{href} has been defined (e.g.\ if the \sty{hyperref}
176 % package has been loaded), then do nothing, otherwise if
177 % \cs{htmladdnormallink} has been defined (e.g.\ if the
178 % \sty{html} package has been loaded) then define
179 % \cs{href} in terms of \cs{htmladdnormallink}, otherwise define
180 % \cs{href} to simply print the second argument and the first
181 % is ignored (so there will be no hyperlink).
182 %\changes{1.01}{2007/8/19}{put \cs{href} check in \cs{AtBeginDocument}}
183 % \begin{macrocode}
184 \AtBeginDocument{%
185 \@ifundefined{href}{
186 \@ifundefined{htmladdnormallink}{%
187 \newcommand*{\href}[2]{#2}
188 }{%
189 \newcommand*{\href}[2]{\htmladdnormallink{#2}{#1}}%
190 }
191 }{}}
192 % \end{macrocode}
193 % Define some commands to allow the user to change the format
194 % of the text provided with the hyperlink.
195 %\begin{macro}{\doitext}
196 %\begin{definition}
197 %\cs{doitext}\marg{doi ref}
198 %\end{definition}
199 %This controls how to format the doi link text.
200 % \begin{macrocode}
201 \newcommand*{\doitext}[1]{doi: #1}
202 % \end{macrocode}
203 %\end{macro}
204 %\begin{macro}{\pubmedtext}
205 %\begin{definition}
206 %\cs{pubmedtext}\marg{pub med code}
207 %\end{definition}
208 % This controls how to format the PubMed link text.
209 % \begin{macrocode}
210 \newcommand*{\pubmedtext}[1]{PubMed: #1}
211 % \end{macrocode}
212 %\end{macro}
213 %
214 %\begin{macro}{\doi}
215 %\changes{1.01}{2007/8/19}{no works with awkward characters}
216 % \begin{macrocode}
217 \providecommand*{\doi}[1]{%
218 \def\@doi@code{}%
219 \@doi@linksubs#1\#\@@\@doi@code
220 \@onelevel@sanitize{\@doi@code}%
221 \def\@doi@text{}%
222 \@doi@textsubs#1\@nil\@@\@doi@text
223 \href{http://dx.doi.org/\@doi@code}{\doitext{\@doi@text}}}
224 % \end{macrocode}
225 %\end{macro}
226 %\begin{macro}{\@doi@linksubs}
227 % \begin{macrocode}
228 \newtoks\@doi@toks
229 \def\@doi@linksubs#1\##2\@@#3{%
230 \def\@doi@tmp{#2}%
231 \expandafter\@doi@toks\expandafter{#3}%
232 \toks@{#1}%
233 \edef#3{\the\@doi@toks\the\toks@}%
234 \ifx\@doi@tmp\@empty
235 \let\@doi@next=\@doi@noop
236 \else
237 \expandafter\@doi@toks\expandafter{#3}%
238 \edef#3{\the\@doi@toks\%23}%
239 \let\@doi@next=\@doi@linksubs
240 \fi
241 \@doi@next#2\@@#3\relax
242 }
243 % \end{macrocode}
244 %\end{macro}
245 %\begin{macro}{\@doi@noop}
246 % \begin{macrocode}
247 \def\@doi@noop#1\@@#2{}
248 % \end{macrocode}
249 %\end{macro}
250 %\begin{macro}{\@doi@textsubs}
251 % \begin{macrocode}
252 \def\@doi@textsubs#1#2\@@#3{%
253 \def\@doi@argi{#1}%
254 \def\@doi@argii{#2}%
255 \ifx\@doi@argi\@nnil
256 \let\@doi@next=\@doi@noop
257 \else
258 \ifx#1<\relax
259 \expandafter\@doi@toks\expandafter{#3}%
260 \edef#3{\the\@doi@toks\noexpand\textless}%
261 \else
262 \ifx#1>\relax
263 \expandafter\@doi@toks\expandafter{#3}%
264 \edef#3{\the\@doi@toks\noexpand\textgreater}%
265 \else
266 \expandafter\@doi@toks\expandafter{#3}%
267 \toks@{#1}%
268 \edef#3{\the\@doi@toks\the\toks@}%
269 \fi
270 \fi
271 \ifx\@doi@argii\@nnil
272 \let\@doi@next=\@doi@noop
273 \else
274 \let\@doi@next=\@doi@textsubs
275 \fi
276 \fi
277 \@doi@next#2\@@#3\relax
278 }
279 % \end{macrocode}
280 %\end{macro}
281 %
282 %\begin{macro}{\pubmed}
283 % \begin{macrocode}
284 \newcommand*{\pubmed}[1]{%
285 \href{http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=#1&dopt=Abstract}{%
286 \pubmedtext{#1}}}
287 % \end{macrocode}
288 %\end{macro}
289 %
290 %\begin{macro}{\citeurl}
291 % \begin{macrocode}
292 \newcommand*{\citeurl}[1]{\textless\url{#1}\textgreater}
293 % \end{macrocode}
294 %\end{macro}
295 %\iffalse
296 % \begin{macrocode}
297 %</doipubmed.sty>
298 % \end{macrocode}
299 %\fi
300 %\iffalse
301 % \begin{macrocode}
302 %<*doipubmed.perl>
303 % \end{macrocode}
304 %\fi
305 %\iffalse
306 % \begin{macrocode}
307 #!/usr/bin/perl
308
309 # File : doipub.perl
310 # Author : Nicola Talbot
311 # Date : 9th September 2005
312 # Last Modified : 20 Aug 2007
313 # Version : 1.01
314 #
315 # This is a LaTeX2HTML style implementing the doipubmed package, and
316 # is distributed as part of that package.
317 # Copyright 2007 Nicola L.C. Talbot
318 # This work may be distributed and/or modified under the
319 # conditions of the LaTeX Project Public License, either version 1.3
320 # of this license of (at your option) any later version.
321 # The latest version of this license is in
322 # http://www.latex-project.org/lppl.txt
323 # and version 1.3 or later is part of all distributions of LaTeX
324 # version 2005/12/01 or later.
325 #
326 # This work has the LPPL maintenance status `maintained'.
327 #
328 # The Current Maintainer of this work is Nicola Talbot.
329
330 sub do_cmd_doitext{
331 local($_) = @_;
332 local($doi);
333
334 s/$next_pair_pr_rx/$doi=$2;''/eo;
335 join('', "doi", $_);
336 }
337
338 sub do_cmd_pubmedtext{
339 local($_) = @_;
340 local($pubmed);
341
342 s/$next_pair_pr_rx/$pubmed=$2;''/eo;
343 join('', "PubMed", $_);
344 }
345
346 sub do_cmd_doi{
347 local($_) = @_;
348 local($doi,$doitext,$br_id);
349
350 s/$next_pair_pr_rx/$br_id=$1;$doi=$2;''/eo;
351
352 $doitext = &translate_commands("\\doitext$OP$br_id$CP$doi$OP$br_id$CP");
353
354 $doi=~s/#/${percent_mark}23/g;
355 join('',
356 &make_href("http://dx.doi.org/$doi", $doitext),
357 $_);
358 }
359
360 sub do_cmd_pubmed{
361 local($_) = @_;
362 local($pubmed,$pubmedtext,$br_id);
363
364 s/$next_pair_pr_rx/$br_id=$1;$pubmed=$2;''/eo;
365
366 $pubmedtext = &translate_commands("\\pubmedtext$OP$br_id$CP$pubmed$OP$br_id$CP");
367
368 join('',
369 &make_href("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids=$pubmed&dopt=Abstract",
370 $pubmedtext),
371 $_);
372 }
373
374 sub do_cmd_citeurl{
375 local($_) = @_;
376 local($url);
377
378 s/$next_pair_pr_rx/$url=$2;''/eo;
379
380 join('', '&lt;',
381 &make_href($url, $url), '&gt;',
382 $_);
383 }
384
385 1;
386 % \end{macrocode}
387 %\fi
388 %\iffalse
389 % \begin{macrocode}
390 %</doipubmed.perl>
391 % \end{macrocode}
392 %\fi
393 %\Finale
394 \endinput