summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/notes2bib
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-01-09 07:01:49 +0000
committerNorbert Preining <preining@logic.at>2008-01-09 07:01:49 +0000
commit7495028ed468cd4decdf0ce2c49619881e1254af (patch)
tree02806bd0959e65660f04f89c72972a2215ffbbf8 /Master/texmf-dist/tex/latex/notes2bib
parent48fc0899d97add1af7cf379220706d679888a7f1 (diff)
notes2bib update from ctan 08-01-09
git-svn-id: svn://tug.org/texlive/trunk@6150 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/notes2bib')
-rw-r--r--Master/texmf-dist/tex/latex/notes2bib/jawltxdoc.sty55
-rw-r--r--Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty751
2 files changed, 468 insertions, 338 deletions
diff --git a/Master/texmf-dist/tex/latex/notes2bib/jawltxdoc.sty b/Master/texmf-dist/tex/latex/notes2bib/jawltxdoc.sty
index f568592299f..4b82f48aec4 100644
--- a/Master/texmf-dist/tex/latex/notes2bib/jawltxdoc.sty
+++ b/Master/texmf-dist/tex/latex/notes2bib/jawltxdoc.sty
@@ -13,16 +13,13 @@
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%%
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{jawltxdoc}
- [2007/10/23 v1.0 Formatting for .dtx files (JAW)]
\usepackage[T1]{fontenc}
\usepackage[english,UKenglish]{babel}
\usepackage[scaled=0.95]{helvet}
\usepackage[version=3]{mhchem}
\usepackage[final]{microtype}
\usepackage[osf]{mathpazo}
-\usepackage{booktabs,array,url,graphicx,courier,unitsdef}
+\usepackage{booktabs,array,url,graphicx,courier,xspace}
\usepackage{upgreek,ifpdf,listings}
\ifpdf
\usepackage{embedfile}
@@ -32,14 +29,15 @@
desc={LaTeX docstrip source archive for package `\jobname'}%
]{\jobname.dtx}
\fi
-\usepackage{\jobname}
+\IfFileExists{\jobname.sty}
+ {\usepackage{\jobname}}{}
\usepackage[numbered]{hypdoc}
\newlength\LaTeXwidth
\newlength\LaTeXoutdent
\newlength\LaTeXgap
\setlength\LaTeXgap{1em}
\setlength\LaTeXoutdent{-0.15\textwidth}
-\def\typesetexampleandcode{%
+\newcommand*{\typesetexampleandcode}{%
\begin{list}{}{%
\setlength\itemindent{0pt}
\setlength\leftmargin\LaTeXoutdent
@@ -56,7 +54,7 @@
\end{minipage}%
\end{list}
}
-\def\typesetcodeandexample{%
+\newcommand*{\typesetcodeandexample}{%
\begin{list}{}{%
\setlength\itemindent{0pt}
\setlength\leftmargin{0pt}
@@ -69,7 +67,7 @@
\lst@sampleInput
\end{list}
}
-\def\typesetfloatexample{%
+\newcommand*{\typesetfloatexample}{%
\begin{list}{}{%
\setlength\itemindent{0pt}
\setlength\leftmargin{0pt}
@@ -82,7 +80,7 @@
\end{minipage}%
\end{list}
}
-\def\typesetcodeonly{%
+\newcommand*{\typesetcodeonly}{%
\begin{list}{}{%
\setlength\itemindent{0pt}
\setlength\leftmargin{0pt}
@@ -101,22 +99,19 @@
\let\typesetexample#1
\global\let\lst@intname\@empty
\setbox\lst@samplebox=\hbox\bgroup
- \setkeys{lst}{language=[LaTeX]{TeX},tabsize=4,gobble=2,%
+ \setkeys{lst}{language=[LaTeX]{TeX},tabsize=4,gobble=3,%
breakindent=0pt,basicstyle=\small\ttfamily,basewidth=0.51em,%
keywordstyle=\color{blue},%
- morekeywords={bibnote,citenote,bibnotetext,bibnotemark,%
- thebibnote,bibnotename,includegraphics,schemeref,%
- floatcontentsleft,floatcontentsright,floatcontentscentre,%
- schemerefmarker,compound,schemerefformat,color,%
- startchemical,stopchemical,chemical,setupchemical,bottext,%
- listofschemes}}
+ morekeywords={% notes2bib
+ niibsetup,bibnote,bibnotetext,bibnotemark,thebibnote,%
+ flushnotestack,citenote,printbibnotes}}
\lst@BeginAlsoWriteFile{\LaTeXexamplefile}
}{%
\lst@EndWriteFile\egroup
\setlength\LaTeXwidth{\wd\lst@samplebox}
\typesetexample%
}
-\def\lst@sampleInput{%
+\newcommand*{\lst@sampleInput}{%
\MakePercentComment\catcode`\^^M=10\relax
\small%
{\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
@@ -124,7 +119,31 @@
\leavevmode \input{\LaTeXexamplefile}}%
\MakePercentIgnore%
}
-\hyphenation{PDF-LaTeX}
+\newcommand*{\pkg}[1]{\textsf{#1}}
+\newcommand*{\currpkg}{\pkg{\jobname}\xspace}
+\newcommand*{\opt}[1]{\texttt{#1}}
+\newcommand*{\ext}[1]{\texttt{.#1}}
+\newcommand*{\latin}[1]{\emph{#1}}
+\newcommand*{\etc}{%
+ \@ifnextchar.
+ {\latin{etc}}
+ {\latin{etc.}}
+ \xspace}
+\newcommand*{\eg}{%
+ \@ifnextchar.
+ {\latin{e.g}}
+ {\latin{e.g.}}
+ \xspace}
+\newcommand*{\ie}{%
+ \@ifnextchar.
+ {\latin{i.e}}
+ {\latin{i.e.}}
+ \xspace}
+\newcommand*{\AMS}{{\protect\usefont{OMS}{cmsy}{m}{n}%
+ A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
+\providecommand*{\eTeX}{\ensuremath{\varepsilon}-\TeX}
+\newcommand*{\XeTeX}
+ {X\kern-.125em\lower.5ex\hbox{\reflectbox{E}}\kern-.1667em\TeX}
\endinput
%%
%% End of file `jawltxdoc.sty'.
diff --git a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
index e19a1ef31a5..d132e311795 100644
--- a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
+++ b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
@@ -15,346 +15,457 @@
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{notes2bib}
- [2007/10/31 v1.2a Integrating notes into the bibliography]
-\@ifundefined{eTeXversion}
- {\PackageError{notes2bib}
- {Not running under e-TeX}
- {This package requires e-TeX. Try compiling the document
- with\MessageBreak `elatex' instead of `latex'. When using
- pdfTeX, try `pdfelatex'\MessageBreak instead of `pdflatex'}%
- \endinput}
- {}
-\RequirePackage{etoolbox}
-\newif\ifniib@fn\niib@fnfalse
-\DeclareOption{footnotes}{%
- \niib@fntrue
- \AtBeginDocument{%
- \let\footnote\bibnote%
- \PackageInfo{notes2bib}%
- {Converting footnotes to bibnotes}%
-}}
-\DeclareOption{endnotes}{%
- \AtBeginDocument{%
- \let\endnote\bibnote%
- \let\endnotemark\bibnotemark%
- \let\endnotetext\bibnotetext%
- \@ifpackageloaded{endnotes}%
- {\let\theendnotes\printbibnotes}{}%
- \PackageInfo{notes2bib}%
- {Converting endnotes to bibnotes}%
-}}
-\newif\ifniib@tail\niib@tailfalse
-\newif\ifniib@head\niib@headfalse
-\DeclareOption{tail}{\niib@tailtrue}
-\DeclareOption{head}{\niib@headtrue}
-\ProcessOptions\relax
-\ifniib@fn
- \let\niib@fnmark\footnotemark
- \let\niib@fntext\footnotetext
- \let\niib@thanks\thanks
- \patchcmd{\thanks}{\footnotemark}{\niib@fnmark}{%
- \patchcmd{\thanks}{\footnotetext}{\niib@fntext}{%
- \AtBeginDocument{%
- \let\footnotemark\bibnotemark
- \let\footnotetext\bibnotetext
- }%
- \PackageInfo{notes2bib}%
- {Modifying \protect\thanks\space macro}%
- }{%
- \let\thanks\niib@thanks%
- \PackageWarning{notes2bib}%
- {Could not patch \protect\thanks}}%
- }{%
- \let\thanks\niib@thanks%
- \PackageWarning{notes2bib}%
- {Could not patch \protect\thanks}}%
-\fi
-\ifniib@head
- \ifniib@tail
- \PackageWarning{notes2bib}
- {You've given both ``head'' and ``tail'' as
- options\MessageBreak I'm ignoring both!\MessageBreak
- bibnotes will be interspersed with other citations}
- \niib@headfalse\niib@tailfalse
- \else
- \PackageInfo{notes2bib}%
- {bibnotes will head other citations}
- \fi
-\else
+ [2008/01/08 v1.3 Integrating notes into the bibliography]
+\begingroup
+ \@ifundefined{eTeXversion}
+ {\PackageError{notes2bib}
+ {Not running under e-TeX}
+ {This package requires e-TeX. Try compiling the document
+ with\MessageBreak `elatex' instead of `latex'. When using
+ pdfTeX, try `pdfelatex'\MessageBreak instead of `pdflatex'}
+ \endgroup\endinput}
+ {\endgroup}
+\RequirePackage{xkeyval,etoolbox}
+\newcommand*{\niib@tempa}{}
+\newcommand*{\niib@tempb}{}
+\newif\ifniib@debug
+\newif\ifniib@logmin
+\newif\ifniib@lognone
+\newcommand*{\niib@log@err}[2]{%
+ \ifniib@lognone\else
+ \ifniib@logmin
+ \PackageWarning{notes2bib}{#1}%
+ \else
+ \PackageError{notes2bib}{#1}{#2}%
+ \fi
+ \fi}
+\newcommand*{\niib@log@warn}[1]{%
+ \ifniib@lognone\else
+ \ifniib@logmin\else
+ \PackageWarning{notes2bib}{#1}%
+ \fi
+ \fi}
+\newcommand*{\niib@log@inf}[1]{%
+ \ifniib@lognone\else
+ \ifniib@logmin\else
+ \PackageInfo{notes2bib}{#1}%
+ \fi
+ \fi}
+\newcommand*{\niib@log@debug}[1]{%
+ \ifniib@lognone\else
+ \ifniib@debug
+ \PackageInfo{notes2bib}{#1}%
+ \fi
+ \fi}
+\newcommand*{\niib@opt@boolkey}[2][]{%
+ \define@boolkey[niib]{opt}[niib@]{#2}[true]
+ {#1\niib@log@debug{Option #2 set to ##1}}}
+\newcommand*{\niib@opt@choicekey}[5][]{%
+ \define@choicekey*+[niib]{opt}{#2}[\niib@tempa]{#3}[#1]
+ {#4\niib@log@debug{Option #2 set to ##1}}
+ {#5\niib@log@debug{Option #2 set to ##1}}}
+\newcommand*{\niib@opt@cmdkeys}[1]{%
+ \define@cmdkeys[niib]{opt}[niib@]{#1}}
+\newcommand*{\niibsetup}[1]{%
+ \iffalse{\fi\ifnum0=`}\fi
+ \setkeys[niib]{opt}{#1}%
+ \ifnum0=`{\fi\iffalse}\fi}
+\niib@opt@choicekey[normal]{log}{debug,verbose,normal,errors,none}
+ {\niib@debugfalse
+ \niib@logminfalse
+ \niib@lognonefalse
+ \renewcommand*{\niib@tempb}{none}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@lognonetrue
+ \fi
+ \renewcommand*{\niib@tempb}{minimal}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@logmintrue
+ \fi
+ \renewcommand*{\niib@tempb}{debug}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@debugtrue
+ \fi
+ \renewcommand*{\niib@tempb}{verbose}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@debugtrue
+ \fi}
+ {\niib@log@warn{Unrecognised value `#1' for option log}}
+\niib@opt@boolkey{debug}
+\niib@opt@boolkey[\niib@swapfoot]{footnotes}
+\niib@opt@boolkey[\niib@swapend]{endnotes}
+\newif\ifniib@tail
+\newif\ifniib@head
+\niib@opt@choicekey[none]{sort}{none,head,tail}
+ {\niib@headfalse
+ \niib@tailfalse
+ \renewcommand*{\niib@tempb}{head}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@headtrue
+ \fi
+ \renewcommand*{\niib@tempb}{tail}%
+ \ifx\niib@tempa\niib@tempb
+ \niib@tailtrue
+ \fi}
+ {\niib@log@warn{Unrecognised value `#1' for option sort}}
+\niib@opt@boolkey[%
+ \ifniib@head
+ \ifniib@tail
+ \niib@tailfalse
+ \niib@log@inf{Option head cancels existing\MessageBreak
+ tail or sort=tail option}
+ \fi
+ \fi]{head}
+\niib@opt@boolkey[%
\ifniib@tail
- \PackageInfo{notes2bib}%
- {bibnotes will tail other citations}
- \else
- \PackageInfo{notes2bib}%
- {bibnotes will be interspersed with other citations}
- \fi
-\fi
+ \ifniib@head
+ \niib@headfalse
+ \niib@log@inf{Option tail cancels existing\MessageBreak
+ head or sort=head option}
+ \fi
+ \fi]{tail}
+\niib@opt@cmdkeys{%
+ cite,
+ name,
+ prefix,
+ record,
+ field,
+ presorthead,
+ presortnone,
+ presorttail,
+ keyhead,
+ keynone,
+ keytail}
+\niibsetup{%
+ cite=cite,
+ name=Bibnote,
+ prefix=niib-,
+ record=Misc,
+ field=note,
+ presorthead=ml,
+ presortnone=mm,
+ presorttail=mn,
+ keyhead=aaa,
+ keynone={},
+ keytail=zzz}
\AtBeginDocument{%
- \ifniib@head
- \let\delaycite\niib@delaycite
- \delaycite{cite}%
- \@ifpackageloaded{natbib}{%
- \delaycite{citet}%
- \delaycite{citep}%
- \delaycite{citenum}%
- \delaycite{citealt}%
- \delaycite{citealp}%
- \delaycite{citetext}%
- \delaycite{citeauthor}%
- \delaycite{citeyear}%
- \delaycite{citeyearpar}%
- \delaycite{Citet}%
- \delaycite{Citep}%
- \delaycite{Citealt}%
- \delaycite{Citealp}%
- \delaycite{Citeauthor}%
- }{}%
- \@ifpackageloaded{biblatex}{%
- \delaycite{Cite}%
- \delaycite{parencite}%
- \delaycite{Parencite}%
- \delaycite{footcite}%
- \delaycite{Footcite}%
- \delaycite{textcite}%
- \delaycite{Textcite}%
- \@ifundefined{autocite}{}%
- {\delaycite{autocite}}%
- \@ifundefined{supercite}{}%
- {\delaycite{supercite}}%
- }{}%
- \fi%
-}
-\newcommand*\bibnotename{Bibnote}
+ \let\niib@org@footnote\footnote
+ \let\niib@org@footnotemark\footnotemark
+ \let\niib@org@footnotetext\footnotetext
+ \let\niib@org@thanks\thanks
+ \@ifpackageloaded{endnotes}
+ {\let\niib@org@endnote\endnote
+ \let\niib@org@endnotemark\endnotemark
+ \let\niib@org@endnotetext\endnotetext
+ \let\niib@org@theendnotes\theendnotes}}
+\AtBeginDocument{%
+ \let\niib@thanks\thanks
+ \let\niib@footnotetext\footnotetext
+ \let\niib@footnotemark\footnotemark
+ \patchcmd{\niib@thanks}{\footnotetext}{\niib@org@footnotetext}
+ {\patchcmd{\niib@thanks}{\footnotemark}
+ {\niib@org@footnotemark}
+ {\let\thanks\niib@thanks
+ \let\niib@footnotetext\bibnotetext
+ \let\niib@footnotemark\bibnotemark
+ \niib@log@debug{Successfully patched \noexpand\thanks}}
+ {\niib@log@warn{Failed to patch \noexpand\thanks\MessageBreak
+ \noexpand\footnotemark\space and
+ \noexpand\footnotetext\MessageBreak are unmodified}%
+ \niib@log@debug{Could not substitute
+ \noexpand\footnotemark\MessageBreak in \noexpand\thanks}}}
+ {\niib@log@warn{Failed to patch \noexpand\thanks\MessageBreak
+ \noexpand\footnotemark\space and
+ \noexpand\footnotetext\MessageBreak are unmodified}%
+ \niib@log@debug{Could not substitute
+ \noexpand\footnotetext\MessageBreak in \noexpand\thanks}}}
+\newcommand*{\niib@swapfoot}{}
+\AtBeginDocument{%
+ \renewcommand*{\niib@swapfoot}{%
+ \ifniib@footnotes
+ \let\footnote\bibnote
+ \let\footnotemark\niib@footnotemark
+ \let\footnotetext\niib@footnotetext
+ \niib@log@debug{Converting footnotes to bibnotes}%
+ \else
+ \let\footnote\niib@org@footnote
+ \let\footnotemark\niib@org@footnotemark
+ \let\footnotetext\niib@org@footnotetext
+ \niib@log@debug{Using kernel definition of footnotes}%
+ \fi}
+ \niib@swapfoot}
+\newcommand*{\niib@swapend}{}
+\AtBeginDocument{%
+ \@ifpackageloaded{endnotes}
+ {\renewcommand*{\niib@swapend}{%
+ \ifniib@endnotes
+ \let\endnote\bibnote
+ \let\endnotemark\bibnotemark
+ \let\endnotetext\bibnotetext
+ \let\theendnotes\printbibnotes
+ \niib@log@debug{Converting endnotes to bibnotes}%
+ \else
+ \let\endnote\niib@org@endnote
+ \let\endnotemark\niib@org@endnotemark
+ \let\endnotetext\niib@org@endnotetext
+ \let\theendnotes\niib@org@theendnotes
+ \niib@log@debug{Using endnotes package to handle endnotes}%
+ \fi}
+ \niib@swapend}
+ {\ifniib@endnotes
+ \let\endnote\bibnote
+ \let\endnotemark\bibnotemark
+ \let\endnotetext\bibnotetext
+ \let\theendnotes\printbibnotes
+ \niib@log@debug{Converting endnotes to bibnotes}%
+ \fi
+ \renewcommand*{\niib@swapend}{%
+ \ifniib@endnotes
+ \let\endnote\bibnote
+ \let\endnotemark\bibnotemark
+ \let\endnotetext\bibnotetext
+ \let\theendnotes\printbibnotes
+ \niib@log@debug{Converting endnotes to bibnotes}%
+ \else
+ \niib@log@inf{endnotes package not loaded\MessageBreak
+ endnotes=false ignored}%
+ \fi}}}
\newcounter{bibnote}
-\renewcommand*{\thebibnote}{\bibnotename\the\value{bibnote}}
-\newcommand*\niibprefix{niib-}
-\newcommand*\niibrecord{Misc}
-\newcommand*\niibfield{note}
-\newcommand*\niibpresorthead{ml}
-\newcommand*\niibpresortnone{mm}
-\newcommand*\niibpresorttail{mn}
-\newcommand*\niibkeyhead{aaa}
-\newcommand*\niibkeynone{}
-\newcommand*\niibkeytail{zzz}
-\newcommand*\niibcite{\cite}
-\newrobustcmd*{\bibnote}{%
+\renewcommand*{\thebibnote}{\niib@name\the\value{bibnote}}
+\DeclareRobustCommand*{\bibnote}{%
\stepcounter{bibnote}%
- \@ifnextchar[%
- {\niib@bibnote}%
- {\niib@bibnote[\thebibnote]}%
-}
-\newrobustcmd*{\bibnotemark}{%
+ \@ifnextchar[%]
+ {\niib@bibnote}
+ {\niib@bibnote[\thebibnote]}}
+\DeclareRobustCommand*{\bibnotemark}{%
\stepcounter{bibnote}%
- \@ifnextchar[%
- {\niib@mark}%
- {\niib@mark[\thebibnote]}%
-}
-\newrobustcmd*{\bibnotetext}[1][\thebibnote]{%
- \niib@text{#1}%
-}
-\@ifpackageloaded{biblatex}{%
- \let\printbibnotes\printbibliography%
-}{%
- \newrobustcmd*{\printbibnotes}{\niib@bib%
- {\niibprefix\jobname}}%
-}%
-\newrobustcmd*{\flushcitestack}{%
- \ifx\niib@stack\relax\else%
- \expandafter\nocite\expandafter{\niib@stack}%
- \global\let\niib@stack\relax%
- \fi%
-}
-\newrobustcmd*{\delaycite}[1]{%
- \PackageWarning{notes2bib}{%
- \@nameuse{delaycite}can only be used in the document
- body\MessageBreak Not modifying citation macro \@nameuse{#1}}
-}
-\ifniib@tail
- \newrobustcmd*\citenote{%
- \niib@cnfalse%
- \niibcite%
- }%
-\else
- \newrobustcmd*\citenote{\niibcite}%
-\fi
+ \@ifnextchar[%]
+ {\niib@mark}
+ {\niib@mark[\thebibnote]}}
+\DeclareRobustCommand*{\bibnotetext}[1][\thebibnote]{%
+ \niib@text{#1}}
\@ifpackageloaded{biblatex}
- {\def\niib@keyname{keysort}}
- {\def\niib@keyname{key}}
-\ifniib@head
- \def\niib@presort{\niibpresorthead}
- \def\niib@key{\niibkeyhead}
-\else
- \ifniib@tail
- \def\niib@presort{\niibpresorttail}
- \def\niib@key{\niibkeytail}
+ {\let\printbibnotes\printbibliography}
+ {\DeclareRobustCommand*{\printbibnotes}
+ {\niib@org@bib{\niib@prefix\jobname}}}
+\DeclareRobustCommand*{\flushnotestack}{%
+ \ifx\@empty\niib@stack\@empty
+ \niib@log@debug{Citation stack empty: nothing for\MessageBreak
+ \noexpand\flushnotestack to do}%
+ \else%
+ \niib@log@debug{Flushing note citations to aux file}%
+ \expandafter\nocite\expandafter{\niib@stack}%
+ \gdef\niib@stack{}%
+ \fi}
+\DeclareRobustCommand*{\citenote}[1]{\niib@mark[#1]}
+\AtBeginDocument{%
+ \@ifpackageloaded{biblatex}
+ {\niib@log@debug{Using field `keysort' for sorting key}%
+ \newcommand*\niib@keyname{keysort}}
+ {\niib@log@debug{Using field `key' for sorting key}%
+ \newcommand*\niib@keyname{key}}}
+\newcommand*{\niib@presort}{%
+ \ifniib@head
+ \niib@presorthead%
\else
- \def\niib@presort{\niibpresortnone}
- \def\niib@key{\niibkeynone}
- \fi
-\fi
+ \ifniib@tail
+ \niib@presorttail%
+ \else
+ \niib@presortnone%
+ \fi
+ \fi}
+\newcommand*{\niib@key}{%
+ \ifniib@head
+ \niib@keyhead%
+ \else
+ \ifniib@tail
+ \niib@keytail%
+ \else
+ \niib@keynone%
+ \fi
+ \fi}
\edef\niib@msg{%
This is an auxiliary file used by the `notes2bib' package.^^J%
This file may safely be deleted. It will be recreated as
required.^^J}
-\let\niib@stack\relax
-\newif\ifniib@cn\niib@cnfalse%
-\newif\ifniib@citing\niib@citingfalse%
-\newif\ifniib@filesw\niib@fileswfalse%
-\newif\ifniib@orig@filesw
-\if@filesw
- \niib@orig@fileswtrue%
-\else
- \niib@orig@fileswfalse%
-\fi
-\def\niib@head@filesw{%
- \let\@fileswtrue\niib@orig@fileswtrue%
- \let\@fileswfalse\niib@orig@fileswfalse%
- \def\if@filesw{%
- \ifniib@orig@filesw
- \niib@fileswtrue%
- \else
- \niib@fileswfalse%
- \fi
- \ifniib@citing
- \ifniib@cn\else
- \niib@fileswfalse%
- \fi
- \fi
- \global\niib@cnfalse%
- \global\niib@citingfalse%
- \ifniib@filesw%
- }
-}
-\ifniib@head
- \niib@head@filesw%
-\fi
-\def\niib@tail@filesw{%
- \let\@fileswtrue\niib@orig@fileswtrue%
- \let\@fileswfalse\niib@orig@fileswfalse%
- \def\if@filesw{%
- \ifniib@orig@filesw
- \niib@fileswtrue%
+\newcommand*{\niib@stack}{}
+\newcommand*{\niib@addtostack}[1]{%
+ \niib@log@debug{Adding citation #1 to stack}%
+ \edef\niib@tempa{#1}%
+ \ifx\@empty\niib@stack\@empty
+ \xdef\niib@stack{\niib@tempa}%
+ \else
+ \xdef\niib@stack{\niib@stack,\niib@tempa}%
+ \fi}
+\long\def\niib@bibnote[#1]#2{%
+ \niib@text{#1}{#2}%
+ \niib@mark[#1]}
+\newcommand*{\niib@headlist}{}
+\def\niib@mark[#1]{%
+ \ifniib@head
+ \edef\niib@tempa{#1}%
+ \ifx\@empty\niib@headlist\@empty
+ \xdef\niib@headlist{\niib@tempa}%
\else
- \niib@fileswfalse%
- \fi
- \ifniib@cn
- \niib@fileswfalse%
+ \xdef\niib@headlist{\niib@headlist,\niib@tempa}%
\fi
- \global\niib@cnfalse%
- \ifniib@filesw%
- }
-}
-\ifniib@tail
- \niib@tail@filesw%
-\fi
-\newrobustcmd*\niib@delaycite[1]{%
- \@ifundefined{#1}{%
- \PackageWarning{notes2bib}
- {Citation macro \@nameuse{#1}undefined\MessageBreak
- \protect\delaycite\space cannot operate on this macro}
- }{%
- \@ifundefined{niib@orig@#1}{%
- \expandafter\expandafter\expandafter\let\expandafter%
- \csname niib@orig@#1\expandafter\endcsname\csname #1\endcsname%
- \expandafter\renewcommand\csname #1\endcsname{%
- \niib@citingtrue%
- \@ifnextchar[%]
- {\@nameuse{niib@optarg@#1}}
- {\@nameuse{niib@noarg@#1}}
- }
- \expandafter\def\csname niib@optarg@#1\endcsname[##1]{%
- \@ifnextchar[%]
- {\@nameuse{niib@twoopt@#1}[##1]}
- {\@nameuse{niib@oneopt@#1}[##1]}
- }
- \expandafter\def\csname niib@oneopt@#1\endcsname[##1]##2{%
- \niib@stackup{##2}%
- \@nameuse{niib@orig@#1}[##1]{##2}%
- }
- \expandafter\def\csname niib@twoopt@#1\endcsname[##1][##2]##3{%
- \niib@stackup{##3}%
- \@nameuse{niib@orig@#1}[##1][##2]{##3}%
- }
- \expandafter\def\csname niib@noarg@#1\endcsname##1{%
- \niib@stackup{##1}%
- \@nameuse{niib@orig@#1}{##1}%
- }
- }{%
- \PackageInfo{notes2bib}%
- {Already delayed \@nameuse{#1}}%
- }
- }
-}
-\def\niib@stackup#1{%
- \ifniib@cn\else
- \edef\niib@temp{#1}%
- \ifx\niib@stack\relax%
- \xdef\niib@stack{\niib@temp}%
- \else
- \xdef\niib@stack{\niib@stack,\niib@temp}%
+ \if@filesw
+ \niib@log@debug{Adding citation #1 to list for next run}%
+ \immediate\write\@auxout{\string\niibheadcite{#1}}%
\fi
\fi
-}
-\long\def\niib@bibnote[#1]#2{%
- \niib@text{#1}{#2}%
- \niib@cite{#1}%
-}
-\def\niib@mark[#1]{\niib@cite{#1}}
-\ifniib@head%
- \def\niib@cite#1{%
- \niib@cntrue%
- \niibcite{#1}%
- }%
-\else%
- \ifniib@tail%
- \def\niib@cite#1{%
- \ifx\niib@stack\relax%
- \xdef\niib@stack{#1}%
- \else%
- \xdef\niib@stack{\niib@stack,#1}%
- \fi%
- \niib@cntrue%
- \niibcite{#1}%
- }%
- \else%
- \def\niib@cite#1{\niibcite{#1}}%
- \fi%
-\fi%
-\long\def\niib@text#1#2{%
+ \ifniib@tail
+ \expandafter\niib@tailcite%
+ \else
+ \expandafter\niib@normcite%
+ \fi
+ {#1}}
+\newif\ifniib@filesw
+\AtBeginDocument{%
+ \@ifpackageloaded{biblatex}
+ {\newcommand{\niib@tailcite}[1]{%
+ \niib@addtostack{#1}%
+ \AtNextCite{\@fileswfalse}%
+ \niib@normcite{#1}}}
+ {\newcommand{\niib@tailcite}[1]{%
+ \niib@addtostack{#1}%
+ \let\ifniib@filesw\if@filesw
+ \@fileswfalse
+ \let\niib@auxhook\niib@restorefilesw
+ \niib@tcite{#1}}}}
+\newcommand*{\niib@restorefilesw}{%
+ \let\if@filesw\ifniib@filesw
+ \let\niib@auxhook\relax}
+\AtBeginDocument{%
+ \@ifpackageloaded{cite}
+ {\newcommand*{\niib@tcite}[1]{\niib@normcite{#1}}}
+ {\newcommand*{\niib@tcite}[1]{%
+ \niib@normcite{#1}%
+ \niib@restorefilesw}}}
+\newcommand*{\niib@normcite}{\@nameuse{\niib@cite}}
+\newcommand{\niib@text}[2]{%
\@ifundefined{niib@out}{%
- \if@filesw%
+ \if@filesw
\newwrite\niib@out%
- \gdef\niib@stream{\niibprefix\jobname.bib}%
- \immediate\openout\niib@out\niib@stream\relax%
+ \gdef\niib@stream{\niib@prefix\jobname.bib}%
+ \niib@log@debug{Creating BibTeX database file \MessageBreak
+ \niib@stream\space to contain bibnotes}%
+ \immediate\openout\niib@out\niib@stream\relax
\immediate\write\niib@out{\niib@msg}%
- \fi}%
- {}%
- \if@filesw%
+ \fi}{}%
+ \if@filesw
+ \niib@log@debug{Writing bibnote #1 contents
+ \MessageBreak---\MessageBreak#2\MessageBreak---\MessageBreak
+ to BibTeX database}%
\immediate\write\niib@out{%
- @\niibrecord\string{#1,^^J%
- presort = \string{\niib@presort\string},^^J%
- \niib@keyname\space= \string{\niib@key#1\string},^^J%
- \niibfield\space= \string{\unexpanded{#2}\string}^^J%
- \string}^^J}%
- \fi%
-}
-\@ifpackageloaded{biblatex}{%
- \expandafter\bib@gadd\expandafter\blx@bibfiles\expandafter%
- {,\niibprefix\jobname}%
- }{%
- \let\niib@bib\bibliography%
- \renewcommand{\bibliography}[1]{%
- \ifnum\the\value{bibnote} > \z@%
- \niib@bib{\niibprefix\jobname,#1}%
- \else%
- \niib@bib{#1}%
- \fi}}%
-%%
+ @\niib@record\string{#1,^^J%
+ presort = \string{\niib@presort\string},^^J%
+ \niib@keyname\space= \string{\niib@key#1\string},^^J%
+ \niib@field\space= \string{\unexpanded{#2}\string}^^J%
+ \string}^^J}%
+ \fi}
+\newcommand*{\niib@headcitelist}{}
+\g@addto@macro{\document}{\niib@dochook}
+\newcommand*{\niibheadcite}[1]{%
+ \edef\niib@tempa{#1}%
+ \ifx\@empty\niib@headcitelist\@empty
+ \xdef\niib@headcitelist{\niib@tempa}%
+ \else
+ \xdef\niib@headcitelist{\niib@headcitelist,\niib@tempa}%
+ \fi
+ \if@filesw
+ \niib@log@debug{Adding citation #1 to start of .aux file}%
+ \fi
+ \g@addto@macro{\niib@dochook}{\nocite{#1}}}
+\newcommand*{\niib@dochook}{%
+ \@ifundefined{@restore@auxhandle}
+ {\newcommand*{\@restore@auxhandle}{\niib@auxhook}}
+ {\ifx\relax\@restore@auxhandle\relax
+ \newcommand*{\@restore@auxhandle}{\niib@auxhook}%
+ \else
+ \g@addto@macro{\@restore@auxhandle}{\niib@auxhook}%
+ \fi}}
+\newcommand*{\niib@auxhook}{}
+\let\niib@auxhook\relax
+\AtEndPreamble{%
+ \@ifpackageloaded{biblatex}%
+ {\expandafter\gappto\expandafter\blx@bibfiles\expandafter%
+ {,\niib@prefix\jobname}
+ \niib@log@debug{Added bibnotes database to biblatex file list}}%
+ {\let\niib@org@bib\bibliography
+ \renewcommand{\bibliography}[1]{%
+ \ifnum\the\value{bibnote} > \z@
+ \niib@org@bib{\niib@prefix\jobname,#1}%
+ \else
+ \niib@org@bib{#1}%
+ \fi}
+ \niib@log@debug{Added bibnote database to
+ \noexpand\bibliography}}}
+\newif\ifniib@rerun
+\newcommand*{\niib@checkrerun}{%
+ \niib@rerunfalse
+ \ifx\@empty\niib@headlist\@empty
+ \ifx\@empty\niib@headcitelist\@empty
+ \niib@log@debug{No `head' notes detected}%
+ \else
+ \niib@reruntrue
+ \niib@log@debug{No `head' notes found this run\MessageBreak
+ but .aux files contained the `head' requests:\MessageBreak
+ \niib@headcitelist}%
+ \fi
+ \else
+ \ifx\@empty\niib@headcitelist\@empty
+ \niib@reruntrue
+ \niib@log@debug{No `head' requests in .aux file\MessageBreak
+ but `head' notes in this run:\MessageBreak
+ \niib@headlist}%
+ \else
+ \niib@checklists%
+ \fi
+ \fi
+ \ifniib@rerun
+ \niib@log@warn{Rerun LaTeX to get correct `head' notes}%
+ \niib@log@warn{Please (re)run BibTeX on the file(s):
+ \MessageBreak\jobname.aux
+ \MessageBreak and rerun LaTeX afterwards.}%
+ \ifniib@lognone\else
+ \typeout{%
+ REQ:3:latex:REQ^^J%
+ REQ:2:bibtex:REQ^^J%
+ REQ:1:latex:REQ}%
+ \fi
+ \fi}
+\newcommand*{\niib@checklists}{%
+ \@for\niib@tempa:=\niib@headlist\do{%
+ \niib@reruntrue
+ \@for\niib@tempb:=\niib@headcitelist\do{%
+ \ifx\niib@tempa\niib@tempb
+ \niib@rerunfalse
+ \fi}
+ \ifniib@rerun
+ \niib@log@debug{Note \niib@tempa is a `head' note
+ \MessageBreak but request not in .aux file}%
+ \fi}
+ \ifniib@rerun\else
+ \@for\niib@tempa:=\niib@headcitelist\do{%
+ \niib@reruntrue
+ \@for\niib@tempb:=\niib@headlist\do{%
+ \ifx\niib@tempa\niib@tempb
+ \niib@rerunfalse
+ \fi}
+ \ifniib@rerun
+ \niib@log@debug{Note \niib@tempa is set to `head' in
+ .aux\MessageBreak file but is not a `head' note}%
+ \fi}
+ \fi}
\AtEndDocument{%
- \flushcitestack%
- \@ifundefined{niib@out}{}%
- {\immediate\closeout\niib@out}%
-}
+ \flushnotestack%
+ \niib@checkrerun%
+ \@ifundefined{niib@out}{}
+ {\immediate\closeout\niib@out%
+ \niib@log@debug{Closed BibTeX database file\MessageBreak
+ \niib@stream}}}
+\ProcessOptionsX[niib]<opt>
\endinput
%%
%% End of file `notes2bib.sty'.