summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/usebib/usebib.sty
blob: 096a7be44f3b5c9c5e9bb5d5d2525eca5be6c956 (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
%%
%% This is file `usebib.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% usebib.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2012 by Enrico Gregorio
%% <Enrico dot Gregorio at univr dot it>
%% -------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any
%% later version. The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions
%% of LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Enrico Gregorio.
%% 
%% This work consists of the files
%%   usebib.dtx
%%   usebib.ins
%% and the derived file usebib.sty.
%% 
\NeedsTeXFormat{LaTeX2e}[2008/04/05]
\ProvidesPackage{usebib}
    [2012/03/17 v1.0 Reusing bib files]
\@ifundefined{eTeXversion}
  {\PackageError{usebib}{LaTeX engine too old, aborting}
   {Please upgrade your TeX system}\@@end}{}
\RequirePackage{url}
\RequirePackage{keyval}
\define@key{usebib}{currenttype}{\def\@tempa{#1}}
\define@key{usebib}{currententry}{\def\reuse@current{#1}}
\def\define@reuse@key#1{%
  \define@key{usebib}{#1}{\lowercase{\global\@namedef{reuse@\reuse@current @#1}}{##1}}}
\define@reuse@key{title}
\define@reuse@key{isbn}
\define@reuse@key{url}
\define@reuse@key{year}
\define@reuse@key{note}
\def\reuse@find#1#{%
  \lowercase{\setkeys{usebib}{currenttype=#1}}%
  \ifcsname reuse@type@\@tempa\endcsname
    \expandafter\@gobble
  \else
    \begingroup\@makeother\%\makeatother
    \expandafter\reuse@extract
  \fi}
\def\reuse@extract#1{\setkeys{usebib}{currententry=#1}\endgroup}
\let\reuse@type@preamble\@empty
\let\reuse@type@string\@empty
\def\newbibignore#1{\expandafter\let\csname reuse@type@#1\endcsname\@empty}
\def\reuse@error#1#2{%
  \PackageError{usebib}
    {Undefined key `#1' or empty value for `#2'}
    {The key you used is wrong or the value to `#2' has not been set}}
\newcommand\newbibfield[1]{\define@reuse@key{#1}}
\def\usebibentry#1#2{\@ifundefined{reuse@#1@#2}
  {\reuse@error{#1}{#2}}
  {\@nameuse{reuse@#1@#2}}}
\newcommand{\usebibentryurl}[2][|]{\@ifundefined{reuse@#2@url}
  {\reuse@error{#2}{url}}
  {\reuse@usebibentryurl{#1}{#2}}}
\@ifpackageloaded{hyperref}{\@tempswatrue}{\@tempswafalse}
\if@tempswa
  \def\reuse@usebibentryurl#1#2{%
    \scantokens{\url{\csname reuse@#2@url\endcsname}\endinput}}
\else
  \def\reuse@usebibentryurl#1#2{%
    \toks@=\expandafter\expandafter\expandafter
      {\csname reuse@#2@url\endcsname}%
    \scantokens\expandafter{%
      \expandafter\url\expandafter#1\the\toks@#1\endinput}}
\fi
\newcommand{\bibinput}[1]{%
  \begingroup
  \catcode`\^^M=10
  \let\KV@err=\@gobble
  \let\KV@errx=\@gobble
  \let\XKV@err=\@gobble
  \begingroup\lccode`\~=`\@
    \lowercase{\endgroup\let~}\reuse@find
  \catcode`\@=\active \input{#1.bib}\endgroup}
\endinput
%%
%% End of file `usebib.sty'.