diff options
author | Karl Berry <karl@freefriends.org> | 2006-09-24 13:23:54 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-09-24 13:23:54 +0000 |
commit | d393aa3001718dd4cacb67ac2bcd6f2785ce95f4 (patch) | |
tree | 19288d9ad7003b6136696e5a987214a80c4a78cb /Master/texmf-dist/tex/latex/opcit | |
parent | 71d296be7666265566a487ddf94aba000de79603 (diff) |
opcit update (22sep06)
git-svn-id: svn://tug.org/texlive/trunk@2186 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/opcit')
-rw-r--r-- | Master/texmf-dist/tex/latex/opcit/opcit.sty | 236 |
1 files changed, 181 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/opcit/opcit.sty b/Master/texmf-dist/tex/latex/opcit/opcit.sty index 37ec7c119ea..3812ed4069d 100644 --- a/Master/texmf-dist/tex/latex/opcit/opcit.sty +++ b/Master/texmf-dist/tex/latex/opcit/opcit.sty @@ -7,93 +7,219 @@ %% opcit.dtx (with options: `package') %% Part of the `opcit' project: bibliographical references as footnotes. %% -%% Copyright 2002 Federico Garcia +%% Copyright 2006 Federico Garcia %% \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{opcit}[2002/12/25 Footnote references (Federico Garcia)] +\ProvidesPackage{opcit}[2006/09/20 Footnote references (Federico Garcia) Version 2] \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 +\newif\ifhyper@opcit +\newif\if@omitting +\newif\if@idem +\newif\ifcheck@idem +\newif\ifcheck@@idem +\newif\if@opcit +\newif\ifcustom@bst +\newcount\@lastcite \newlength{\sameauthorsrule}\setlength{\sameauthorsrule}{23pt} \newtoks\opcit@redefs +\newtoks\opcit@defs +\newcommand*{\last@cited}{)OpcitFirst(} +\newcommand*{\opcittext}{\textit{op.\,cit.}} +\newcommand*{\idemtext}{\textit{Idem}} +\newcommand*{\sameauthors}{\rule{\sameauthorsrule}{.4pt}} +\newcommand*\opcitwarning[1]{\PackageWarning{noopcit option is called for, + but `#1' has no hereafter.}} +\newcommand*\opcit@noreferror[1]{\PackageError{key `#1' has not been cited.} + {\string\bibref can be used only after the first citation of a work. + (You might also have mistyped the key.) Go on, but there won't be a + cross reference here.}\textbf{??}} +\let\@quoteornot\relax +\DeclareOption{hyperref}{\hyper@opcittrue} +\DeclareOption{nohyperref}{\hyper@opcitfalse} +\DeclareOption{omitting}{\@omittingtrue} +\DeclareOption{noomitting}{\@omittingfalse} +\DeclareOption{noidem}{\@idemfalse} +\DeclareOption{idem}{\@idemtrue} +\DeclareOption{checkidem}{\check@idemtrue} +\DeclareOption{nocheckidem}{\check@idemfalse} +\DeclareOption{opcit}{\@opcittrue} +\DeclareOption{noopcit}{\@opcitfalse} +\DeclareOption{nocustombst}{\newcommand\opcit@bst{\bibliographystyle{opcit}}} +\DeclareOption{custombst}{\let\opcit@bst\relax} +\@ifpackageloaded{hyperref} + {\ExecuteOptions{omitting,checkidem,nocustombst,idem,opcit,hyperref}} + {\ExecuteOptions{omitting,checkidem,nocustombst,idem,opcit}} +\ProcessOptions +\ifhyper@opcit\RequirePackage{hyperref}\fi +\opcit@bst \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}} +\let\opcitstart\relax +\newBibCommand{\opcitend}{\relax}{\ifnum\spacefactor=\sfcode`?\else\unskip.\fi} +\newBibCommand{\bibpunctuation}{,\xspace}{% + \ifnum\spacefactor=\sfcode`?\else\unskip.\fi\xspace} \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} + \global\expandafter\edef\csname\@curr@bibitem @hereafter\endcsname{% + \ifhyper@opcit + \noexpand\hyperlink{\@curr@bibitem @key}{#1}\else#1\fi}}{\relax} +\newBibCommand{\bibcase[1]}{\lowercase{#1}}{\uppercase{#1}} +\newBibCommand\QuoteOrNot{\gdef\@quoteornot{''\global\let\@quoteornot\relax}}{\relax} +\if@omitting + \newBibCommand{\toomit[2][omitted]}{% + \@nameuse{omit@#1}\@gobble{#2}}{#2}% + \newcommand\with[1]{% + \global\expandafter\let\csname omit@#1\endcsname\@gobble + \edef\@reomit{\@reomit,#1}} + \newcommand\@reomit{omitted}% +\else + \newcommand\toomit[2][omitted]{#2} + \let\with\@gobble +\fi \bgroup + \renewcommand{\newBibCommand}[3]{% + \newcommand#1{#2}% + \global\opcit@defs\expandafter{\the\opcit@defs + \newBibCommand{#1}{#2}{#3}}} \renewenvironment{thebibliography}[1]{\relax}{\relax} - \def\bibitem#1#2\opcitstart #3\bibpunctuation \newblock#4\opcitend{% + \def\toomit{\noexpand\toomit}% + \def\QuoteOrNot{\noexpand\QuoteOrNot}% + \long\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}% + \global\expandafter\edef\csname #1@first\endcsname{% + \noexpand\opcit@noreferror{#1}}% + \global\@namedef{#1@star}{% + \global\expandafter\edef\csname #1@first\endcsname{\thefootnote}% + \ifhyper@opcit\hypertarget{#1@key}{}\fi + #4}% + \global\def\hereafter{\@nameuse{#1@hereafter}}% + \global\expandafter\def\csname @#1\endcsname{% + \@nameuse{#1@author}, \@nameuse{#1@star}}% + \bibhereafter{\if@opcit\noexpand\opcittext\else\opcitwarning{#1}\fi}% #2} \InputIfFileExists{\jobname.bbl}{\global\opcit@bbltrue}% {\global\opcit@bblfalse\PackageWarningNoLine{opcit}{% - No information found about bibliographical references.}} + No \jobname.bbl file. There will be no footnote references}} \egroup +\the\opcit@defs \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}} + \renewcommand{\cite}{\@ifstar{\opcit@cite@star}{\opcit@cite}}% \fi +\newcommand*\resetcites{% + \bgroup + \renewcommand{\newBibCommand}[3]{% + \newcommand##1{##2}% + \global\opcit@defs\expandafter{\the\opcit@defs + \newBibCommand{##1}{##2}{##3}}} + \renewenvironment{thebibliography}[1]{\relax}{\relax} + \def\toomit{\noexpand\toomit}% + \def\QuoteOrNot{\noexpand\QuoteOrNot}% + \long\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\edef\csname ##1@first\endcsname{% + \noexpand\opcit@noreferror{##1}}% + \global\@namedef{##1@star}{% + \global\expandafter\edef\csname ##1@first\endcsname{\thefootnote}% + \ifhyper@opcit\hypertarget{##1@key}{}\fi + ##4}% + \global\def\hereafter{\@nameuse{##1@hereafter}}% + \global\expandafter\def\csname @##1\endcsname{% + \@nameuse{##1@author}, \@nameuse{##1@star}}% + \bibhereafter{\if@opcit\noexpand\opcittext\else\opcitwarning{##1}\fi}% + ##2} + \let\newcommand\renewcommand + \InputIfFileExists{\jobname.bbl}{\global\opcit@bbltrue}% + {\global\opcit@bblfalse\PackageWarningNoLine{opcit}{% + No \jobname.bbl file. There will be no footnote references}} + \egroup} +\newcommand{\opcit@cite}[2][\@empty]{\nocite{#2}% + \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue + \else\opcit@footnotefalse\expandafter\footnote\fi + {\@nameuse{@#2}% + \check@for@period{\@nameuse{@#2}}% + \finalize@cite{#1}{#2}}} +\newcommand{\opcit@cite@star}[2][\@empty]{\nocite{#2}% + \ifnum\interlinepenalty=\interfootnotelinepenalty\opcit@footnotetrue + \else\opcit@footnotefalse\expandafter\footnote\fi + {\@nameuse{#2@star}% + \check@for@period{\@nameuse{#2@star}}% + \finalize@cite{#1}{#2}}} +\newcommand\finalize@cite[2]{% + \global\@lastcite=\c@footnote\relax + \ifx\@empty#1\else + \ifcheck@@idem + \check@for@period{\idemtext}% + \def\this@opt{#1}% + \ifx\last@opt\this@opt\else + \check@for@period{#1},\@quoteornot\ #1% + \fi + \else\check@for@period{#1},\@quoteornot\ #1% + \fi + \fi + \ifopcit@footnote\peri@dtrue\fi + \ifperi@d\else.\@quoteornot\fi + \global\def\last@opt{#1}% + \check@@idemfalse + \if@omitting + \@for\@tempcsa :=\@reomit \do + {\global\expandafter\let\csname omit@\@tempcsa\endcsname\relax}% + \global\def\@reomit{omitted}% + \fi + \renew@cites{#2}% + } \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}}}% + \recover@last% \global\def\last@cited{#1}% - \global\@namedef{#1}{{\em\idemtext}}% - \global\@namedef{#1star}{{\em\@nameuse{#1@hereafter}}}% - \global\def\hereafter{\@nameuse{#1@hereafter}}} + \cited{#1}% + \ifopcit@footnote\else\if@idem + \global\@namedef{@#1}{\@idem{@#1}}% + \global\@namedef{#1@star}{\@idem{@#1}}% + \fi\fi + \global\def\hereafter{\textit{\@nameuse{#1@hereafter}}}}% +\newcommand*\cited[1]{\@for\@tempcsa :=#1 \do{% + \global\@namedef{@#1}{\@nameuse{#1@authors},~\@nameuse{#1@hereafter}}% + \global\@namedef{#1@star}{\@nameuse{#1@hereafter}}}}% +\newcommand\recover@last{% + \global\expandafter\edef\csname @\last@cited\endcsname{% + \noexpand\@nameuse{\last@cited @authors},% + ~{\noexpand\@nameuse{\last@cited @hereafter}}}% + \global\expandafter\edef\csname\last@cited @star\endcsname{% + {\noexpand\@nameuse{\last@cited @hereafter}}}% + } +\newcommand\@idem[1]{\advance\@lastcite1\relax + \ifnum\@lastcite=\c@footnote + \idemtext\ifcheck@idem\check@@idemtrue\fi + \else + \check@@idemfalse\recover@last\@nameuse{#1}% + \fi} \def\check@for@period#1{{\normalsfcodes\setbox0\hbox{#1% - \ifnum\spacefactor=\sfcode`.\global\peri@dtrue\else% + \ifnum\spacefactor=\sfcode`.\global\peri@dtrue\else \global\peri@dfalse\fi}}} +\ifhyper@opcit + \newcommand*\bibref[1]{\hyperlink{#1@key}{\@nameuse{#1@first}}} +\else + \newcommand*\bibref[1]{\@nameuse{#1@first}} +\fi +\newcommand\nobibliography[1]{\if@filesw + \immediate\write\@auxout{\string\bibdata{#1}}\fi + \if@omitting\PackageWarningNoLine{opcit}{No final references list, + there might be information within \string\toomit\space commands that will be lost}\fi} \let\opcit@bibliography\bibliography -\renewcommand{\bibliography}{\the\opcit@redefs\opcit@bibliography} +\renewcommand{\bibliography}{% + \renewcommand\newBibCommand[3]{\relax}% + \the\opcit@redefs\opcit@bibliography} \newcommand{\thebib@renew}{} -\@ifclassloaded{article}{% +\@ifundefined{chapter}{% \renewcommand{\thebib@renew}{\section*{\refname}\@mkboth{\refname}{\refname}}}{% \renewcommand{\thebib@renew}{\chapter*{\bibname}\@mkboth{\bibname}{\bibname}}}% \renewenvironment{thebibliography}[1] |