summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/opcit/opcit.sty
blob: 37ec7c119ea21100ef4f898311c2308107754afe (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
%%
%% This is file `opcit.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% opcit.dtx  (with options: `package')
%% Part of the `opcit' project: bibliographical references as footnotes.
%% 
%% Copyright 2002 Federico Garcia
%% 
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{opcit}[2002/12/25 Footnote references (Federico Garcia)]
\RequirePackage{xspace}
\newcommand{\opcit@bst}{opcit}
\DeclareOption*{\PackageInfo{opcit}{%
    `\CurrentOption' used as bibliography style}%
    \let\opcit@bst\CurrentOption}
\ProcessOptions
\newif\ifopcit@bbl\opcit@bblfalse
\newif\ifopcit@footnote\opcit@footnotefalse
\newif\ifperi@d\peri@dfalse
\newlength{\sameauthorsrule}\setlength{\sameauthorsrule}{23pt}
\newtoks\opcit@redefs
\newcommand{\newBibCommand}[3]{%
    \newcommand#1{#2}%
    \opcit@redefs\expandafter{\the\opcit@redefs%
        \renewcommand#1{#3}}}
\newcommand{\opcitstart}{\relax}
\newBibCommand{\opcitend}{\relax}{\ifnum\spacefactor=\sfcode`?\else.\fi}
\newBibCommand{\bibparenthesis[1]}{ (#1)}{. \newblock #1}
\newBibCommand{\bibIn}{in}{In}
\newBibCommand{\bibpunctuation}{%
    \ifnum\spacefactor=\sfcode`.\else,\fi\xspace}{%
    \ifnum\spacefactor=\sfcode`?\else.\fi\xspace}
\newcommand{\sameauthors}{\rule{\sameauthorsrule}{.4pt}}
\newBibCommand{\biblastnames[1]}{%
    \global\@namedef{\@curr@bibitem @authors}{#1}}{\relax}
\newBibCommand{\bibhereafter[1]}{%
    \global\@namedef{\@curr@bibitem @hereafter}{#1}}{\relax}
\newcommand{\last@cited}{)OpcitFirst(}
\newcommand{\opcittext}{Op.~Cit.}
\newcommand{\idemtext}{Idem}
\bibliographystyle{\opcit@bst}
\bgroup
    \renewenvironment{thebibliography}[1]{\relax}{\relax}
    \def\bibitem#1#2\opcitstart #3\bibpunctuation \newblock#4\opcitend{%
        \ifx#3\sameauthors\else\def\@lastauthors{#3}\fi
        \global\expandafter\edef\csname#1@author\endcsname{\@lastauthors}%
        \global\def\@curr@bibitem{#1}%
        \global\expandafter\def\csname#1\endcsname{\@nameuse{#1@author}, #4}%
        \global\@namedef{#1@star}{#4}%
        \bibhereafter{\opcittext}%
        #2}
    \InputIfFileExists{\jobname.bbl}{\global\opcit@bbltrue}%
        {\global\opcit@bblfalse\PackageWarningNoLine{opcit}{%
            No information found about bibliographical references.}}
\egroup
\ifopcit@bbl
\renewcommand{\cite}{\@ifstar{\opcit@cite@star}{\opcit@cite}}%
\newcommand{\opcit@cite}[2][.]{\nocite{#2}%
    \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue%
        \else\opcit@footnotefalse\expandafter\footnote\fi%
    {\@nameuse{#2}\ifx#1.\check@for@period{\@nameuse{#2}}%
        \else\check@for@period{#1}%
        {, #1}\fi%
        \ifopcit@footnote\peri@dtrue\fi%
        \ifperi@d\else.\fi}%
    \renew@cites{#2}}
\newcommand{\opcit@cite@star}[2][.]{\nocite{#2}%
    \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue%
        \else\opcit@footnotefalse\expandafter\footnote\fi%
    {\@nameuse{#2star}\ifx#1.\check@for@period{\@nameuse{#2}}%
        \else\check@for@period{#1}%
        {, #1}\fi%
        \ifopcit@footnote\peri@dtrue\fi%
        \ifperi@d\else.\fi}%
    \renew@cites{#2}}
\fi
\newcommand{\renew@cites}[1]{%
    \global\expandafter\edef\csname\last@cited\endcsname{%
        \@nameuse{\last@cited @authors},%
        ~{\noexpand\em\@nameuse{\last@cited @hereafter}}}%
    \global\expandafter\edef\csname\last@cited star\endcsname{%
        {\noexpand\em\@nameuse{\last@cited @hereafter}}}%
    \global\def\last@cited{#1}%
    \global\@namedef{#1}{{\em\idemtext}}%
    \global\@namedef{#1star}{{\em\@nameuse{#1@hereafter}}}%
    \global\def\hereafter{\@nameuse{#1@hereafter}}}
\def\check@for@period#1{{\normalsfcodes\setbox0\hbox{#1%
    \ifnum\spacefactor=\sfcode`.\global\peri@dtrue\else%
    \global\peri@dfalse\fi}}}
\let\opcit@bibliography\bibliography
\renewcommand{\bibliography}{\the\opcit@redefs\opcit@bibliography}
\newcommand{\thebib@renew}{}
\@ifclassloaded{article}{%
    \renewcommand{\thebib@renew}{\section*{\refname}\@mkboth{\refname}{\refname}}}{%
    \renewcommand{\thebib@renew}{\chapter*{\bibname}\@mkboth{\bibname}{\bibname}}}%
\renewenvironment{thebibliography}[1]
     {\thebib@renew%
      \the\opcit@redefs%
      \list{}%
           {\setlength\labelwidth{\z@}%
            \leftmargin\bibindent
            \itemindent -\bibindent
            \parsep \z@
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
\endinput
%%
%% End of file `opcit.sty'.