summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/t2/citehack.sty
blob: 4e44dc54170a032730e7b25ee81d284a904d0843 (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
% This is the file citehack.sty of the T2 package.
%
% Allow inputenc-generated characters as references in \cite and \bibitem.
% Also in \label and \ref.

\ProvidesPackage{citehack}

\let\org@IeC\IeC
\def\tmp@IeC#1{\string\IeC\space{\string#1 }}

% This is a modified \@bibitem command;
% we added \let\protect\noexpand, like in \@lbibitem,
% because the item may include, e.g., \IeC {...}
% or some other protected commands.
\def\@bibitem#1{\item\if@filesw {\let\protect\noexpand\immediate\write\@auxout
       {\string\bibcite{#1}{\the\value{\@listctr}}}}\fi\ignorespaces}
%\def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw
%      {\let\protect\noexpand\let\IeC\tmp@IeC
%       \immediate
%       \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
%\def\@bibitem#1{\item\if@filesw \let\IeC\tmp@IeC\immediate\write\@auxout
%       {\string\bibcite{#1}{\the\value{\@listctr}}}\let\IeC\org@IeC\fi\ignorespaces}

\def\@citex[#1]#2{\let\IeC\tmp@IeC\edef\CH@temp{#2}\let\IeC\org@IeC
  \let\@citea\@empty
  \@cite{\@for\@citeb:=\CH@temp\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}

\def\nocite#1{\@bsphack
  \let\IeC\tmp@IeC\edef\CH@temp{#1}\let\IeC\org@IeC
  \@for\@citeb:=\CH@temp\do{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
    \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
    \@ifundefined{b@\@citeb}{\G@refundefinedtrue
        \@latex@warning{Citation `\@citeb' undefined}}{}}%
  \@esphack}

\def\@newl@bel#1#2#3{\let\IeC\tmp@IeC
  \@ifundefined{#1@#2}%
    \relax
    {\gdef \@multiplelabels {%
       \@latex@warning@no@line{There were multiply-defined labels}}%
     \@latex@warning@no@line{Label `#2' multiply defined}}%
  \global\@namedef{#1@#2}{#3}\let\IeC\org@IeC}

% This is a modified \@testdef command taken from Babel:
\def\@testdef #1#2#3{%
  \let\IeC\tmp@IeC
  \expandafter\let\expandafter\bbl@tempa\csname #1@#2\endcsname
  \def\bbl@tempb{#3}%
  \ifx\bbl@tempa\relax\else
  \edef\bbl@tempa{\expandafter\strip@prefix\meaning\bbl@tempa}\fi
  \edef\bbl@tempb{\expandafter\strip@prefix\meaning\bbl@tempb}%
  \ifx \bbl@tempa \bbl@tempb
  \else \@tempswatrue \fi\let\IeC\org@IeC}

% \ref, \pageref and \label support:
\DeclareRobustCommand\ref[1]{\let\IeC\tmp@IeC
  \expandafter\let\expandafter\CH@temp\csname r@#1\endcsname
  \let\IeC\org@IeC\@setref\CH@temp\@firstoftwo{#1}}
\DeclareRobustCommand\pageref[1]{\let\IeC\tmp@IeC
  \expandafter\let\expandafter\CH@temp\csname r@#1\endcsname
  \let\IeC\org@IeC\@setref\CH@temp\@secondoftwo{#1}}
\def\label#1{\let\IeC\tmp@IeC
  \@bsphack\protected@write\@auxout{}{\string\newlabel{#1}{{\@currentlabel}{\thepage}}}\@esphack
  \let\IeC\org@IeC}

% varioref package support:
\def\vref@pagenum#1#2{\let\IeC\tmp@IeC
  \@ifundefined{r@#2}{\@namedef{r@#2}{{??}{??}}}{}%
  \edef#1{\expandafter\expandafter\expandafter
                \@cdr\csname r@#2\endcsname
                \@nil}%
  \let\IeC\org@IeC}
\def\vrefpagenum#1#2{\let\IeC\tmp@IeC
  \@ifundefined{r@#2}%
    {\G@refundefinedtrue
     \@latex@warning{Reference `#2' on page \thepage \space
             undefined}}{}%
  \let\IeC\org@IeC
  \vref@pagenum{#1}{#2}}