From 507fd2d5ca1378ad57eb17175dfe67a6ba794962 Mon Sep 17 00:00:00 2001 From: Manuel Pégourié-Gonnard Date: Sun, 22 Jun 2008 10:38:33 +0000 Subject: notes2bib v1.4 2008/06/21 git-svn-id: svn://tug.org/texlive/trunk@8923 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/notes2bib/notes2bib.sty | 216 +++++++++++++-------- 1 file changed, 132 insertions(+), 84 deletions(-) (limited to 'Master/texmf-dist/tex/latex/notes2bib') diff --git a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty index 793d3bd29d4..c24a2950549 100644 --- a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty +++ b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty @@ -14,27 +14,12 @@ %% ---------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} +\def\niib@id$#1: #2.#3 #4 #5-#6-#7 #8 #9${% + #5/#6/#7\space v1.4\space} \ProvidesPackage{notes2bib} - [2008/02/26 v1.3c 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} -\@ifpackagelater{xkeyval}{2005/05/07} - {} - {\PackageError{notes2bib} - {xkeyval >= 2.5 required} - {notes2bib requires the `xkeyval' package, version 2.5 or - later.\MessageBreak The version loaded is: - `\@nameuse{ver@etoolbox.sty}'.\MessageBreak - This is a fatal error; the package will abort.}% - \endinput} + [\niib@id$Id: notes2bib.dtx 11 2008-06-21 16:00:05Z joseph $ + Integrating notes into the bibliography] +\RequirePackage{xkeyval}[2005/05/07] \newcommand*{\niib@tempa}{} \newcommand*{\niib@tempb}{} \newif\ifniib@debug @@ -75,11 +60,9 @@ {#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} +\newcommand*{\niibsetup}{\setkeys[niib]{opt}} +\niib@opt@choicekey[normal]{log} + {debug,verbose,normal,errors,none} {\niib@debugfalse \niib@logminfalse \niib@lognonefalse @@ -145,7 +128,7 @@ keyhead, keynone, keytail} -\niibsetup{% +\niibsetup{ cite=cite, name=Bibnote, prefix=niib-, @@ -157,10 +140,31 @@ keyhead=aaa, keynone={}, keytail=zzz} +\niib@opt@boolkey{etex} +\begingroup + \@ifundefined{eTeXversion} + {} + {\global\niib@etextrue} +\endgroup +\ProcessOptionsX[niib] +\AtEndOfPackage{ + \define@key[niib]{opt}{etex} + {\niib@log@warn{Option `etex' only available + \MessageBreak when loading notes2bib}}} +\begingroup + \@ifundefined{eTeXversion} + {\ifniib@etex + \niib@log@warn{e-TeX unavailable}% + \global\niib@etexfalse + \fi} + {\ifniib@etex\else + \niib@log@inf{Use of e-TeX disabled}% + \fi} +\endgroup \let\niib@org@footnote\footnote \let\niib@org@footnotemark\footnotemark \let\niib@org@footnotetext\footnotetext -\AtBeginDocument{% +\AtBeginDocument{ \@ifpackageloaded{endnotes} {\let\niib@org@endnote\endnote \let\niib@org@endnotemark\endnotemark @@ -185,7 +189,7 @@ \fi} \AtBeginDocument{\niib@swapfoot} \newcommand*{\niib@swapend}{} -\AtBeginDocument{% +\AtBeginDocument{ \@ifpackageloaded{endnotes} {\renewcommand*{\niib@swapend}{% \ifniib@endnotes @@ -199,7 +203,8 @@ \let\endnotemark\niib@org@endnotemark \let\endnotetext\niib@org@endnotetext \let\theendnotes\niib@org@theendnotes - \niib@log@debug{Using endnotes package to handle endnotes}% + \niib@log@debug{Using endnotes package to handle + endnotes}% \fi} \niib@swapend} {\ifniib@endnotes @@ -233,8 +238,9 @@ {\niib@mark} {\niib@mark[\thebibnote]}} \DeclareRobustCommand*{\bibnotetext}[1][\thebibnote]{% + \let\niib@next\niib@gobble \niib@text{#1}} -\AtBeginDocument{% +\AtBeginDocument{ \@ifpackageloaded{biblatex} {\let\printbibnotes\printbibliography} {\DeclareRobustCommand*{\printbibnotes} @@ -245,50 +251,52 @@ \niib@checkrerun{tail}% \fi \ifx\@empty\niib@stack\@empty - \niib@log@debug{Citation stack empty: nothing for\MessageBreak - \noexpand\flushnotestack to do}% + \niib@log@debug{Citation stack empty: nothing for + \MessageBreak\noexpand\flushnotestack to do}% \else% \niib@log@debug{Flushing note citations to aux file}% \if@filesw - \immediate\write\@auxout{\string\niibtailcite{\niib@stack}}% + \immediate\write\@auxout{% + \string\niibtailcite{\niib@stack}}% \fi \expandafter\nocite\expandafter{\niib@stack}% \gdef\niib@stack{}% \fi} \DeclareRobustCommand*{\citenote}[1]{\niib@mark[#1]} -\AtBeginDocument{% +\AtBeginDocument{ \@ifpackageloaded{biblatex} {\niib@log@debug{Using field `keysort' for sorting key}% - \newcommand*\niib@keyname{keysort}} + \newcommand*{\niib@keyname}{keysort}} {\niib@log@debug{Using field `key' for sorting key}% - \newcommand*\niib@keyname{key}}} + \newcommand*{\niib@keyname}{key}}} \newcommand*{\niib@presort}{% \ifniib@head - \niib@presorthead% + \niib@presorthead \else \ifniib@tail - \niib@presorttail% + \niib@presorttail \else - \niib@presortnone% + \niib@presortnone \fi \fi} \newcommand*{\niib@key}{% \ifniib@head - \niib@keyhead% + \niib@keyhead \else \ifniib@tail - \niib@keytail% + \niib@keytail \else - \niib@keynone% + \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} + This is an auxiliary file used by the `notes2bib' + package.^^J This file may safely be deleted. It + will be recreated as required.^^J} \newcommand*{\niib@stack}{} \newcommand*{\niib@addtostack}[1]{% - \niib@log@debug{Adding citation #1\MessageBreak to `tail' stack}% + \niib@log@debug{Adding citation #1\MessageBreak to `tail' + stack}% \edef\niib@tempa{#1}% \ifx\@empty\niib@stack\@empty \xdef\niib@stack{\niib@tempa}% @@ -296,8 +304,8 @@ \xdef\niib@stack{\niib@stack,\niib@tempa}% \fi} \long\def\niib@bibnote[#1]#2{% - \niib@text{#1}{#2}% - \niib@mark[#1]} + \let\niib@next\niib@mark + \niib@text{#1}{#2}} \newcommand*{\niib@headlist}{} \def\niib@mark[#1]{% \ifniib@head @@ -319,7 +327,7 @@ \fi {#1}} \newif\ifniib@filesw -\AtBeginDocument{% +\AtBeginDocument{ \@ifpackageloaded{biblatex} {\newcommand{\niib@tailcite}[1]{% \niib@addtostack{#1}% @@ -341,27 +349,67 @@ \niib@normcite{#1}% \niib@restorefilesw}}} \newcommand*{\niib@normcite}{\@nameuse{\niib@cite}} -\newcommand{\niib@text}[2]{% - \@ifundefined{niib@out}{% - \if@filesw - \newwrite\niib@out% - \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}{}% +\newcommand*{\niib@next}{} +\def\niib@gobble[#1]{} +\let\niib@next\niib@gobble +\newcommand*{\niib@text}{% + \@bsphack + \@ifundefined{niib@out} + {\if@filesw + \newwrite\niib@out + \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 + \expandafter\niib@write + \fi} +\ifniib@etex + \newcommand*{\niib@write}[2]{% \niib@log@debug{Writing bibnote #1 contents - \MessageBreak---\MessageBreak#2\MessageBreak---\MessageBreak - to BibTeX database}% + \MessageBreak---\MessageBreak#2\MessageBreak + ---\MessageBreak to BibTeX database}% \immediate\write\niib@out{% @\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} + \@esphack + \niib@next[#1]} +\else + \newcommand*{\niib@write}[1]{% + \begingroup + \let\do\@makeother + \dospecials + \catcode`\{=1\relax + \catcode`\}=2\relax + \niib@write@{#1}} +\fi +\newcommand\niib@write@[1]{% + \long\def\niib@tempa##1{% + \def\niib@tempa{##1}% + \@onelevel@sanitize\niib@tempa\expandafter\endgroup + \expandafter\def\expandafter\niib@tempa\expandafter{% + \niib@tempa}% + \niib@write@@{#1}}% + \catcode`\^^M=10\relax + \niib@tempa} +\newcommand*\niib@write@@[1]{% + \niib@log@debug{Writing bibnote #1 contents + \MessageBreak---\MessageBreak\niib@tempa\MessageBreak + ---\MessageBreak to BibTeX database}% + \immediate\write\niib@out{% + @\niib@record\string{#1,^^J% + presort = \string{\niib@presort\string},^^J% + \niib@keyname\space= \string{\niib@key#1\string},^^J% + \niib@field\space= \string{\niib@tempa\string}^^J% + \string}^^J}% + \@esphack + \niib@next[#1]} \newcommand*{\niib@headcitelist}{} \g@addto@macro{\document}{\niib@dochook} \newcommand*{\niibheadcite}[1]{% @@ -393,11 +441,12 @@ \fi}} \newcommand*{\niib@auxhook}{} \let\niib@auxhook\relax -\AtBeginDocument{% - \@ifpackageloaded{biblatex}% - {\expandafter\gappto\expandafter\blx@bibfiles\expandafter% +\AtBeginDocument{ + \@ifpackageloaded{biblatex} + {\expandafter\gappto\expandafter\blx@bibfiles\expandafter {,\niib@prefix\jobname} - \niib@log@debug{Added bibnotes database to biblatex file list}}% + \niib@log@debug{Added bibnotes database to biblatex file + list}}% {\let\niib@org@bib\bibliography \renewcommand*{\bibliography}[1]{% \ifnum\the\value{bibnote} > \z@ @@ -410,24 +459,24 @@ \newif\ifniib@rerun \newcommand*{\niib@checkrerun}[1]{% \niib@rerunfalse - \expandafter\ifx\expandafter\@empty\csname niib@#1list\endcsname% - \@empty - \expandafter\ifx\expandafter\@empty\csname niib@#1citelist% - \endcsname\@empty + \expandafter\ifx\expandafter\@empty + \csname niib@#1list\endcsname\@empty + \expandafter\ifx\expandafter\@empty + \csname niib@#1citelist\endcsname\@empty \niib@log@debug{No `#1' notes detected}% \else \niib@reruntrue \niib@log@debug{No `#1' notes found this run\MessageBreak - but .aux files contained the `#1' requests:\MessageBreak - \csname niib@#1citelist\endcsname}% + but .aux files contained the `#1' requests: + \MessageBreak\csname niib@#1citelist\endcsname}% \fi \else - \expandafter\ifx\expandafter\@empty\csname niib@#1citelist% - \endcsname\@empty + \expandafter\ifx\expandafter\@empty + \csname niib@#1citelist\endcsname\@empty \niib@reruntrue - \niib@log@debug{No `#1' requests in .aux file\MessageBreak - but `#1' notes in this run:\MessageBreak - \csname niib@#1list\endcsname}% + \niib@log@debug{No `#1' requests in .aux file + \MessageBreak but `#1' notes in this run: + \MessageBreak\csname niib@#1list\endcsname}% \else \niib@checklists{#1}% \fi @@ -446,9 +495,9 @@ \fi \fi} \newcommand*{\niib@checklists}[1]{% - \expandafter\edef\expandafter\niib@list\expandafter% + \expandafter\edef\expandafter\niib@list\expandafter {\csname niib@#1list\endcsname}% - \expandafter\edef\expandafter\niib@citelist\expandafter% + \expandafter\edef\expandafter\niib@citelist\expandafter {\csname niib@#1citelist\endcsname}% \@for\niib@tempa:=\niib@list\do{% \niib@reruntrue @@ -468,19 +517,18 @@ \niib@rerunfalse \fi} \ifniib@rerun - \niib@log@debug{Note \niib@tempa\space is set to `#1' in - .aux\MessageBreak file but is not a `#1' note}% + \niib@log@debug{Note \niib@tempa\space is set to `#1' + in .aux\MessageBreak file but is not a `#1' note}% \fi} \fi} \AtEndDocument{% \niib@rerunfalse \niib@checkrerun{head}% - \flushnotestack% + \flushnotestack \@ifundefined{niib@out}{} - {\immediate\closeout\niib@out% + {\immediate\closeout\niib@out \niib@log@debug{Closed BibTeX database file\MessageBreak \niib@stream}}} -\ProcessOptionsX[niib] \endinput %% %% End of file `notes2bib.sty'. -- cgit v1.2.3