summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/oberdiek/refcount.sty
blob: d9c147d3a72bdccf204098dd4a4386b382fc4b1d (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
%%
%% This is file `refcount.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% refcount.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 1998, 2000, 2006, 2008 by
%%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%% 
%% 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. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and 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".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file refcount.dtx
%% and the derived files
%%    refcount.sty, refcount.pdf, refcount.ins, refcount.drv.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{refcount}
  [2008/08/11 v3.1 Data extraction from references (HO)]%

\def\setrefcountdefault#1{%
  \def\rc@default{#1}%
}
\setrefcountdefault{0}

\def\rc@cartwo#1#2#3\@nil{#2}

\long\def\rc@refused#1{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \protect\G@refundefinedtrue
    \@latex@warning{%
      Reference `#1' on page \thepage\space undefined%
    }%
  \fi
}

\newcommand*{\refused}[1]{%
  \begingroup
    \csname @safe@activestrue\endcsname
    \rc@refused{#1}{}%
  \endgroup
}

\def\rc@set#1#2#3#4{%
  \begingroup
    \csname @safe@activestrue\endcsname
    \rc@refused{#4}%
    \expandafter\rc@@set\csname r@#4\endcsname{#1}{#2}{#3}%
  \endgroup
}
\def\rc@@set#1#2#3#4{%
  \ifx#1\relax
    #2{#4}{\rc@default}%
  \else
    #2{#4}{%
      \expandafter#3#1\rc@default\rc@default\@nil
    }%
  \fi
}


\newcommand*{\setcounterref}{\rc@set\setcounter\@car}
\newcommand*{\addtocounterref}{\rc@set\addtocounter\@car}
\newcommand*{\setcounterpageref}{\rc@set\setcounter\rc@cartwo}
\newcommand*{\addtocounterpageref}{\rc@set\addtocounter\rc@cartwo}

\newcommand*{\getrefnumber}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \rc@default
  \else
    \expandafter\expandafter\expandafter\@car
    \csname r@#1\endcsname\@nil
  \fi
}
\newcommand*{\getpagerefnumber}[1]{%
  \expandafter\ifx\csname r@#1\endcsname\relax
    \rc@default
  \else
    \expandafter\expandafter\expandafter\rc@cartwo
    \csname r@#1\endcsname\rc@default\rc@default\@nil
  \fi
}
\newcommand*{\getrefbykeydefault}[2]{%
  \expandafter\rc@getrefbykeydefault
    \csname r@#1\expandafter\endcsname
    \csname rc@extract@#2\endcsname
}
\def\rc@getrefbykeydefault#1#2#3{%
  \ifx#1\relax
    % reference is undefined
    #3%
  \else
    \ifx#2\relax
      % extract method is missing
      #3%
    \else
      \expandafter\rc@generic#1{#3}{#3}{#3}{#3}{#3}\@nil#2{#3}%
    \fi
  \fi
}
\def\rc@generic#1#2\@nil#3#4{%
  #3{#1\TR@TitleReference\@empty{#4}\@nil}{#1}#2\@nil
}
\def\rc@extract@{%
  \expandafter\@car\@gobble
}
\def\rc@extract@page{%
  \expandafter\@car\@gobbletwo
}
\def\rc@extract@name{%
  \expandafter\@car\@gobblefour\@empty
}
\def\rc@extract@anchor{%
  \expandafter\@car\@gobblefour
}
\def\rc@extract@url{%
  \expandafter\expandafter\expandafter\@car\expandafter
      \@gobble\@gobblefour
}
\def\rc@extract@title#1#2\@nil{%
  \rc@@extract@title#1%
}
\def\rc@@extract@title#1\TR@TitleReference#2#3#4\@nil{#3}
\endinput
%%
%% End of file `refcount.sty'.