summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/notes2bib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-09-29 00:06:35 +0000
committerKarl Berry <karl@freefriends.org>2009-09-29 00:06:35 +0000
commit65e993b3adaf9d89a85926bb68e1b62df91769fb (patch)
treea170bf3cebda605bd425a43da81c6a1268ca435a /Master/texmf-dist/tex/latex/notes2bib
parent90f79e4b239311b4bfef31778404320880ca3aaf (diff)
notes2bib 2 (28sep09)
git-svn-id: svn://tug.org/texlive/trunk@15542 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/notes2bib')
-rw-r--r--Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty979
-rw-r--r--Master/texmf-dist/tex/latex/notes2bib/xnotes2bib.sty435
2 files changed, 449 insertions, 965 deletions
diff --git a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
index b65120709d2..730da978946 100644
--- a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
+++ b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
@@ -5,539 +5,458 @@
%% The original source files were:
%%
%% notes2bib.dtx (with options: `package')
-%% ----------------------------------------------------------------
-%% note2bib --- Integrating notes into the bibliography
-%% Maintained by Joseph Wright
-%% E-mail: joseph.wright@morningstar2.co.uk
-%% Released under the LaTeX Project Public License v1.3 or later
-%% See http://www.latex-project.org/lppl.txt
-%% ----------------------------------------------------------------
+%% ---------------------------------------------------------------
+%% notes2bib --- Integrating notes into the bibliography
+%% Maintained by Joseph Wright
+%% E-mail: joseph.wright@morningstar2.co.uk
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%% ---------------------------------------------------------------
%%
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{notes2bib}
- [2008/10/31 v1.6a Integrating notes into the bibliography]
-\RequirePackage{xkeyval}[2005/05/07]
-\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}{\setkeys[niib]{opt}}
-\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
- \ifniib@head
- \niib@headfalse
- \niib@log@inf{Option tail cancels existing\MessageBreak
- head or sort=head option}
- \fi
- \fi]{tail}
-\niib@opt@boolkey{writekey}
-\niib@opt@cmdkeys{%
- cite,
- name,
- prefix,
- record,
- field,
- presorthead,
- presortnone,
- presorttail,
- keyhead,
- keynone,
- keytail,
- keyword}
-\niibsetup{
- cite=cite,
- name=Bibnote,
- prefix=niib-,
- record=Misc,
- field=note,
- presorthead=ml,
- presortnone=mm,
- presorttail=mn,
- keyhead=aaa,
- keynone={},
- keytail=zzz,
- keyword=bibnote,
- writekey=true}
-\niib@opt@boolkey{etex}
-\begingroup
- \@ifundefined{eTeXversion}
- {}
- {\global\niib@etextrue}
-\endgroup
-\let\niib@org@footnote\footnote
-\let\niib@org@footnotemark\footnotemark
-\let\niib@org@footnotetext\footnotetext
-\AtBeginDocument{
- \@ifpackageloaded{endnotes}
- {\let\niib@org@endnote\endnote
- \let\niib@org@endnotemark\endnotemark
- \let\niib@org@endnotetext\endnotetext
- \let\niib@org@theendnotes\theendnotes}{}}
-\@ifundefined{thanks}{}
- {\renewcommand*{\thanks}[1]{%
- \niib@org@footnotemark
- \protected@xdef\@thanks{\@thanks
- \protect\niib@org@footnotetext[\the\c@footnote]{#1}}}}
-\newcommand*{\niib@swapfoot}{%
- \ifniib@footnotes
- \let\footnote\bibnote
- \let\footnotemark\bibnotetext
- \let\footnotetext\bibnotemark
- \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}
-\AtBeginDocument{\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}}}
-\ProcessOptionsX[niib]<opt>
-\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
-\newcounter{bibnote}
-\renewcommand*{\thebibnote}{\niib@name\the\value{bibnote}}
-\DeclareRobustCommand*{\bibnote}{%
- \stepcounter{bibnote}%
- \@ifnextchar[%]
- {\niib@bibnote}
- {\niib@bibnote[\thebibnote]}}
-\DeclareRobustCommand*{\bibnotemark}{%
- \stepcounter{bibnote}%
- \@ifnextchar[%]
- {\niib@mark}
- {\niib@mark[\thebibnote]}}
-\DeclareRobustCommand*{\bibnotetext}[1][\thebibnote]{%
- \let\niib@next\niib@gobble
- \niib@text{#1}}
-\AtBeginDocument{
- \@ifpackageloaded{biblatex}
- {\let\printbibnotes\printbibliography}
- {\DeclareRobustCommand*{\printbibnotes}
- {\niib@org@bib{\niib@prefix\jobname}}}}
-\DeclareRobustCommand*{\flushnotestack}{%
- \let\niib@taillist\niib@stack
- \ifniib@rerun\else
- \niib@checkrerun{tail}%
- \fi
- \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}%
- \if@filesw
- \immediate\write\@auxout{%
- \string\niibtailcite{\niib@stack}}%
- \fi
- \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
- \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}
-\newcommand*{\niib@stack}{}
-\newcommand*{\niib@addtostack}[1]{%
- \niib@log@debug{Adding citation #1\MessageBreak to `tail'
- 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{%
- \let\niib@next\niib@mark
- \niib@text{#1}{#2}}
-\newcommand*{\niib@headlist}{}
-\def\niib@mark[#1]{%
- \ifniib@head
- \edef\niib@tempa{#1}%
- \ifx\@empty\niib@headlist\@empty
- \xdef\niib@headlist{\niib@tempa}%
- \else
- \xdef\niib@headlist{\niib@headlist,\niib@tempa}%
- \fi
- \if@filesw
- \niib@log@debug{Adding citation #1 to list for next run}%
- \immediate\write\@auxout{\string\niibheadcite{#1}}%
- \fi
- \fi
- \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@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}
- {}%
+\RequirePackage{xparse}
+\ProvidesExplPackage
+ {notes2bib} {2009/09/28} {2.0}
+ {Integrating notes into the bibliography}
+\RequirePackage{l3keys2e}
+\tl_new:Nn \c_niib_file_message_tl {
+ This~is~an~auxiliary~file~used~by~the~`notes2bib'~package.
+ \iow_newline:
+ This~file~may~safely~be~deleted.
+ \iow_newline:
+ It~will~be~recreated~as~required.
+ \iow_newline:
+}
+\clist_new:N \g_niib_after_clist
+\clist_new:N \g_niib_before_clist
+\clist_new:N \g_niib_all_after_clist
+\clist_new:N \g_niib_all_before_clist
+\int_new:N \g_niib_note_int
+\tl_new:N \l_niib_presort_tl
+\tl_new:N \l_niib_sortkey_tl
+\clist_new:N \g_niib_previous_after_clist
+\clist_new:N \g_niib_previous_before_clist
+\int_new:N \g_niib_previous_notes_int
+\tl_new:N \l_niib_sortkey_field_tl
+\int_new:N \g_niib_total_notes_int
+\cs_new_nopar:Nn \niib_cite:w { }
+\keys_define:nn { notes2bib } {
+ cite-function .code:n = {
+ \AtBeginDocument { \cs_set_eq:NN \niib_cite:w #1 }
+ } ,
+ file-name .tl_gset_x:N = \g_niib_filename_tl ,
+ convert-endnotes .choice: ,
+ convert-endnotes / false .code:n = {
+ \AtBeginDocument { \niib_from_bibnote:n { endnote } }
+ },
+ convert-endnotes / true .code:n = {
+ \AtBeginDocument { \niib_to_bibnote:n { endnote } }
+ },
+ convert-footnotes .choice: ,
+ convert-footnotes / false .code:n = {
+ \AtBeginDocument { \niib_from_bibnote:n { footnote } }
+ },
+ convert-footnotes / true .code:n = {
+ \AtBeginDocument { \niib_to_bibnote:n { footnote } }
+ },
+ keyword-entry .tl_set:N = \l_niib_keyword_tl ,
+ note-field .tl_set:N = \l_niib_note_field_tl ,
+ note-name .tl_set:N = \l_niib_note_name_tl ,
+ placement .choice: ,
+ placement / after .code:n = {
+ \cs_set_eq:NN \niib_mark_note:n \niib_mark_note_after:n
+ \tl_set_eq:NN \l_niib_presort_tl \l_niib_presort_after_tl
+ \tl_set_eq:NN \l_niib_sortkey_tl \l_niib_sortkey_after_tl
+ } ,
+ placement / before .code:n = {
+ \cs_set_eq:NN \niib_mark_note:n \niib_mark_note_before:n
+ \tl_set_eq:NN \l_niib_presort_tl \l_niib_presort_before_tl
+ \tl_set_eq:NN \l_niib_sortkey_tl \l_niib_sortkey_before_tl
+ },
+ placement / mixed .code:n = {
+ \cs_set_eq:NN \niib_mark_note:n \niib_mark_note_mixed:n
+ \tl_set_eq:NN \l_niib_presort_tl \l_niib_presort_mixed_tl
+ \tl_set_eq:NN \l_niib_sortkey_tl \l_niib_sortkey_mixed_tl
+ },
+ presort-after .tl_set:N = \l_niib_presort_after_tl ,
+ presort-before .tl_set:N = \l_niib_presort_before_tl ,
+ presort-mixed .tl_set:N = \l_niib_presort_mixed_tl ,
+ record-type .tl_set:N = \l_niib_record_type_tl ,
+ sort-key-after .tl_set:N = \l_niib_sortkey_before_tl ,
+ sort-key-before .tl_set:N = \l_niib_sortkey_after_tl ,
+ sort-key-mixed .tl_set:N = \l_niib_sortkey_mixed_tl ,
+ use-sort-key .bool_set:N = \l_niib_write_sortkey_bool,
+}
+\keys_set:nn { notes2bib } {
+ cite-function = \cite ,
+ file-name = notes2bib-\jobname ,
+ keyword-entry = note ,
+ note-field = note ,
+ note-name = Note ,
+ presort-after = mn ,
+ presort-before = ml ,
+ presort-mixed = mm ,
+ record-type = misc ,
+ sort-key-after = zzz ,
+ sort-key-before = aaa ,
+ use-sort-key = true
+}
+\cs_set_nopar:Nn \niib_options_redefine: {
+ \keys_define:nn { notes2bib } {
+ cite-function .code:n = {
+ \cs_set_eq:NN \niib_cite:w ##1
+ } ,
+ file-name .code:n = {
+ \msg_info:nnn { notes2bib } { preamble-only } { file-name }
+ } ,
+ convert-endnotes / false .code:n = {
+ \niib_from_bibnote:n { endnote }
+ },
+ convert-endnotes / true .code:n = {
+ \niib_to_bibnote:n { endnote }
+ },
+ convert-footnotes / false .code:n = {
+ \niib_from_bibnote:n { footnote }
+ },
+ convert-footnotes / true .code:n = {
+ \niib_to_bibnote:n { footnote }
+ },
+ }
+}
+\msg_new:nnn { notes2bib } { preamble-only } {%
+ The option `#1' can only be used in the preamble.%
+}
+\AtBeginDocument { \niib_options_redefine: }
+\keys_define:nn { notes2bib } {
+ cite .meta:x = { cite-function = \exp_not:c {#1} } ,
+ debug .code:n = { } ,
+ endnotes .meta:n = { convert-footnotes = #1 } ,
+ etex .code:n = { } ,
+ field .meta:n = { note-field = #1 } ,
+ footnotes .meta:n = { convert-footnotes = #1 } ,
+ head .meta:n = { placement = before } ,
+ keyhead .meta:n = { sort-key-before = #1 } ,
+ keytail .meta:n = { sort-key-after = #1 } ,
+ keynone .meta:n = { sort-key-mixed = #1 } ,
+ keyword .meta:n = { keyword-entry = #1 } ,
+ log .meta:n = { } ,
+ name .meta:n = { note-name = #1 } ,
+ prefix .meta:n = { file-name = #1 \jobname } ,
+ presorthead .meta:n = { presort-before = #1 } ,
+ presorttail .meta:n = { presort-after = #1 } ,
+ presortnone .meta:n = { presort-mixed = #1 } ,
+ record .meta:n = { record-type = #1 } ,
+ sort .choice: ,
+ sort / head .meta:n = { placement = before } ,
+ sort / none .meta:n = { placement = after } ,
+ sort / tail .meta:n = { placement = mixed } ,
+ tail .meta:n = { placement = after } ,
+ writekey .meta:n = { use-sort-key = #1 }
+}
+\cs_new_nopar:Nn \niib_note_name: {
+ \tl_use:N \l_niib_note_name_tl
+ \intexpr_compare:nT { \g_niib_previous_notes_int > \c_nine } {
+ \intexpr_compare:nT { \g_niib_note_int < \c_ten } {
+ 0
+ }
+ }
+ \int_to_arabic:n { \g_niib_note_int }
+}
+\cs_new_nopar:Nn \niib_filesw: { }
+\cs_new:Nn \niib_mark_note:n { }
+\cs_generate_variant:Nn \niib_mark_note:n { x }
+\cs_new:Nn \niib_mark_note_after:n {
+ \int_gincr:N \g_niib_total_notes_int
+ \clist_gput_right:Nx \g_niib_after_clist {#1}
+ \niib_mark_note_after_aux:n {#1}
+}
+\cs_new:Nn \niib_mark_note_after_aux:n { }
+\cs_new:Nn \niib_mark_note_before:n {
+ \int_gincr:N \g_niib_total_notes_int
+ \clist_gput_right:Nx \g_niib_before_clist {#1}
+ \niib_cite:w {#1}
+}
+\cs_new:Nn \niib_mark_note_mixed:n {
+ \int_gincr:N \g_niib_total_notes_int
+ \niib_cite:w {#1}
+}
+\cs_new_nopar:Nn \niib_stream_check: {
+ \cs_if_free:NT \g_niib_file_stream {
+ \iow_new:N \g_niib_file_stream
+ \iow_open:Nn \g_niib_file_stream { \g_niib_filename_tl .bib }
+ \iow_now:Nx \g_niib_file_stream { \c_niib_file_message_tl }
+ }
+}
+\cs_new:Nn \niib_write_field:nn {
+ \iow_space: \iow_space: #1 \iow_space: = \iow_space: {#2} ,
+ \iow_newline:
+}
+\cs_generate_variant:Nn \niib_write_field:nn { V }
+\cs_new_nopar:Npn \niib_write_note:nn {
\if@filesw
- \expandafter\niib@write
- \else
- \expandafter\niib@tidy
- \fi}
-\newcommand*{\niib@tidy}[2]{%
- \@esphack
- \niib@next[#1]}
-\ifniib@etex
- \newcommand*{\niib@write}[2]{%
- \niib@log@debug{Writing bibnote #1 contents
- \MessageBreak---\MessageBreak#2\MessageBreak
- ---\MessageBreak to BibTeX database}%
- \immediate\write\niib@out{%
- @\niib@record\string{#1,^^J%
- presort = \string{\niib@presort\string},^^J%
- \ifniib@writekey
- \niib@keyname\space= \string{\niib@key#1\string},^^J%
- \fi
- keywords = \string{\niib@keyword\string},^^J%
- \niib@field\space= \string{\unexpanded{#2}\string}^^J%
- \string}^^J}%
- \@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]{%
- \edef\niib@tempa{#1}%
- \ifx\@empty\niib@headcitelist\@empty
- \xdef\niib@headcitelist{\niib@tempa}%
- \else
- \xdef\niib@headcitelist{\niib@headcitelist,\niib@tempa}%
- \fi
+ \exp_after:wN \niib_write_note_aux:nn
+ \fi:
+}
+\cs_new:Nn \niib_write_note_aux:nn {
+ \niib_stream_check:
+ \iow_now:Nx \g_niib_file_stream {
+ @ \l_niib_record_type_tl {
+ #1 , \iow_newline:
+ \niib_write_field:Vn \l_niib_note_field_tl { \exp_not:n {#2} }
+ \bool_if:NT \l_niib_write_sortkey_bool {
+ \niib_write_field:Vn \l_niib_sortkey_field_tl
+ { \l_niib_sortkey_tl #1 }
+ }
+ \niib_write_field:nn { keywords } { \l_niib_keyword_tl }
+ \niib_write_field:nn { presort } { \l_niib_presort_tl }
+ }
+ }
+}
+\cs_generate_variant:Nn \niib_write_note:nn { x }
+\cs_new_nopar:Nn \niib_record_notes: {
\if@filesw
- \niib@log@debug{Adding citation #1 to start of .aux file}%
- \fi
- \g@addto@macro{\niib@dochook}{\nocite{#1}}}
-\newcommand*{\niib@tailcitelist}{}
-\newcommand*{\niibtailcite}[1]{%
- \edef\niib@tempa{#1}%
- \ifx\@empty\niib@tailcitelist\@empty
- \xdef\niib@tailcitelist{\niib@tempa}%
- \else
- \xdef\niib@tailcitelist{\niib@tailcitelist,\niib@tempa}%
- \fi}
-\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
-\AtBeginDocument{
- \@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}[1]{%
- \niib@rerunfalse
- \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}%
- \fi
- \else
- \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}%
- \else
- \niib@checklists{#1}%
- \fi
+ \exp_after:wN \niib_flush_notes_aux:
\fi
- \ifniib@rerun
- \niib@log@warn{Rerun LaTeX to get correct \MessageBreak
- `#1' 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}[1]{%
- \expandafter\edef\expandafter\niib@list\expandafter
- {\csname niib@#1list\endcsname}%
- \expandafter\edef\expandafter\niib@citelist\expandafter
- {\csname niib@#1citelist\endcsname}%
- \@for\niib@tempa:=\niib@list\do{%
- \niib@reruntrue
- \@for\niib@tempb:=\niib@citelist\do{%
- \ifx\niib@tempa\niib@tempb
- \niib@rerunfalse
- \fi}
- \ifniib@rerun
- \niib@log@debug{Note \niib@tempa\space is a `#1' note
- \MessageBreak but request not in .aux file}%
- \fi}
- \ifniib@rerun\else
- \@for\niib@tempa:=\niib@citelist\do{%
- \niib@reruntrue
- \@for\niib@tempb:=\niib@list\do{%
- \ifx\niib@tempa\niib@tempb
- \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}%
- \fi}
- \fi}
-\AtEndDocument{%
- \niib@rerunfalse
- \niib@checkrerun{head}%
- \flushnotestack
- \@ifundefined{niib@out}{}
- {\immediate\closeout\niib@out
- \niib@log@debug{Closed BibTeX database file\MessageBreak
- \niib@stream}}}
-\endinput
+}
+\cs_new_nopar:Nn \niib_flush_notes_aux: {
+ \clist_if_empty:NF \g_niib_before_clist {
+ \iow_now:Nx \@auxout {
+ \NotesBeforeCitations { \exp_not:V \g_niib_before_clist }
+ }
+ \clist_gput_right:NV \g_niib_all_before_clist \g_niib_before_clist
+ \clist_gclear:N \g_niib_before_clist
+ }
+ \clist_if_empty:NF \g_niib_after_clist {
+ \iow_now:Nx \@auxout {
+ \NotesAfterCitations { \exp_not:V \g_niib_after_clist }
+ }
+ \exp_args:NV \nocite \g_niib_after_clist
+ \clist_gput_right:NV \g_niib_all_after_clist \g_niib_after_clist
+ \clist_gclear:N \g_niib_after_clist
+ }
+}
+\cs_new_nopar:Nn \niib_to_bibnote:n {
+ \cs_set_eq:cN {#1} \bibnote
+ \cs_set_eq:cN { #1 mark } \bibnotemark
+ \cs_set_eq:cN { #1 text } \bibnotetext
+}
+\cs_new_nopar:Nn \niib_from_bibnote:n {
+ \cs_set_eq:cc {#1} { niib_ #1 :w }
+ \cs_set_eq:cc { #1 mark } { niib_ #1 mark:w }
+ \cs_set_eq:cc { #1 text } { niib_ #1 text:w }
+}
+\cs_new_nopar:Nn \niib_save_endnote: {
+ \cs_set_eq:NN \niib_endnote:w \endnote
+ \cs_set_eq:NN \niib_endnotemark:w \endnotemark
+ \cs_set_eq:NN \niib_endnotetext:w \endnotetext
+}
+\cs_new_nopar:Nn \niib_save_footnote: {
+ \cs_set_eq:NN \niib_footnote:w \footnote
+ \cs_set_eq:NN \niib_footnotemark:w \footnotemark
+ \cs_set_eq:NN \niib_footnotetext:w \footnotetext
+}
+\AtBeginDocument {
+ \niib_save_endnote:
+ \niib_save_footnote:
+}
+\cs_new_nopar:Nn \niib_create_print_notes: {
+ \@ifpackageloaded { biblatex } {
+ \cs_new_nopar:Nn \niib_print_notes: {
+ \cs_set:Nx \niib_create_print_notes_aux: {
+ \printbibliography [ keyword = \exp_not:V \l_niib_keyword_tl ]
+ }
+ \niib_create_print_notes_aux:
+ }
+ }{
+ \cs_new_nopar:Nn \niib_print_notes: {
+ \exp_args:NV \niib_bibliography:n \g_niib_filename_tl
+ }
+ }
+}
+\cs_new:Nn \niib_create_print_notes_aux: { }
+\AtBeginDocument { \niib_create_print_notes: }
+\cs_new_nopar:Nn \niib_attach_bibliography: {
+ \@ifpackageloaded { biblatex } {
+ \exp_args:NV \bibliography \g_niib_filename_tl
+ }{
+ \cs_new_eq:NN \niib_bibliography:n \bibliography
+ \RenewDocumentCommand \bibliography { m } {
+ \intexpr_compare:nTF { \g_niib_total_notes_int = \c_zero } {
+ \niib_bibliography:n {##1}
+ }{
+ \cs_set_nopar:Nx \niib_attach_bibliography: {
+ \exp_not:N \niib_bibliography:n {
+ \exp_not:n {##1} , \exp_not:V \g_niib_filename_tl
+ }
+ }
+ \niib_attach_bibliography:
+ }
+ }
+ }
+}
+\@ifpackageloaded { biblatex } {
+ \exp_args:NV \bibliography \g_niib_filename_tl
+ \cs_gundefine:N \niib_attach_bibliography:
+}{
+ \AtBeginDocument { \niib_attach_bibliography: }
+}
+\cs_new_nopar:Nn \niib_set_sortkey_name: {
+ \@ifpackageloaded { biblatex } {
+ \tl_set:Nn \l_niib_sortkey_field_tl { sortkey }
+ }{
+ \tl_set:Nn \l_niib_sortkey_field_tl { key }
+ }
+ \cs_gundefine:N \niib_set_sortkey_name:
+}
+\AtBeginDocument { \niib_set_sortkey_name: }
+\cs_new_nopar:Nn \niib_set_mark_note_after: {
+ \@ifpackageloaded { biblatex } {
+ \cs_set:Nn \niib_mark_note_after_aux:n {
+ \AtNextCite { \@fileswfalse }
+ \niib_cite:w {##1}
+ }
+ }{
+ \cs_set:Nn \niib_mark_note_after_aux:n {
+ \cs_set_eq:NN \niib_filesw: \if@filesw
+ \@fileswfalse
+ \niib_cite:w {##1}
+ \cs_set_eq:NN \if@filesw \niib_filesw:
+ }
+ }
+}
+\AtBeginDocument { \niib_set_mark_note_after: }
+\cs_new_nopar:Nn \niib_check_cite: {
+ \@ifpackageloaded { cite } {
+ \cs_set:Nn \niib_mark_note_after_aux:n {
+ \cs_set_eq:NN \niib_filesw: \if@filesw
+ \@fileswfalse
+ \cs_set_nopar:Nn \niib_aux_hook: {
+ \cs_set_eq:NN \if@filesw \niib_filesw:
+ \cs_set_nopar:Nn \niib_aux_hook: { }
+ }
+ \niib_cite:w {##1}
+ }
+ \cs_new_nopar:Nn \niib_aux_hook: { }
+ \tl_gput_right:Nn \g_niib_document_hook_tl {
+ \cs_if_exist:NF \@restore@auxhandle {
+ \tl_new:N \@restore@auxhandle
+ }
+ \tl_put_right:Nn \@restore@auxhandle { \niib_aux_hook: }
+ }
+ } { }
+}
+\AtBeginDocument { \niib_check_cite: }
+\NewDocumentCommand \bibnote { o +m } {
+ \IfNoValueTF {#1} {
+ \int_gincr:N \g_niib_note_int
+ \niib_bibnote:xn { \niib_note_name: } {#2}
+ }{
+ \niib_bibnote:nn {#1} {#2}
+ }
+}
+\cs_new:Nn \niib_bibnote:nn {
+ \niib_write_note:nn {#1} {#2}
+ \niib_mark_note:n {#1}
+}
+\cs_generate_variant:Nn \niib_bibnote:nn { x }
+\NewDocumentCommand \bibnotemark { o } {
+ \IfNoValueTF {#1} {
+ \int_gincr:N \g_niib_note_int
+ \niib_mark_note:x { \niib_note_name: }
+ }{
+ \niib_mark_note:n {#1}
+ }
+}
+\NewDocumentCommand \bibnotetext { o +m } {
+ \IfNoValueTF {#1} {
+ \niib_write_note:xn { \niib_note_name: } {#2}
+ }{
+ \niib_write_note:nn {#1} {#2}
+ }
+}
+\NewDocumentCommand \recordnotes { } {
+ \niib_record_notes:
+}
+\NewDocumentCommand \bibnotesetup { m } {
+ \keys_set:nn { notes2bib } {#1}
+}
+\NewDocumentCommand \printbibnotes { } {
+ \niib_print_notes:
+}
+\NewDocumentCommand \citenote { m } {
+ \niib_mark_note:n {#1}
+}
+\cs_new_eq:NN \flushnotestack \recordnotes
+\cs_new_eq:NN \niibsetup \bibnotesetup
+\NewDocumentCommand \NotesAfterCitations { m } {
+ \clist_gput_right:Nn \g_niib_previous_after_clist {#1}
+}
+\NewDocumentCommand \NotesBeforeCitations { m } {
+ \clist_gput_right:Nn \g_niib_previous_after_clist {#1}
+ \tl_gput_right:Nn \g_niib_document_hook_tl {
+ \nocite {#1}
+ }
+}
+\NewDocumentCommand \TotalNotes { m } {
+ \int_gset:Nn \g_niib_previous_notes_int {#1}
+}
+\tl_gput_right:Nn \document { \g_niib_document_hook_tl }
+\tl_new:N \g_niib_document_hook_tl
+\AtEndDocument { \niib_record_notes: }
+\cs_new_nopar:Nn \niib_check_rerun: {
+ \clist_if_eq:NNTF \g_niib_all_before_clist
+ \g_niib_previous_before_clist {
+ \clist_if_eq:NNF \g_niib_all_after_clist
+ \g_niib_previous_after_clist {
+ \msg_info:nn { notes2bib } { rerun }
+ }
+ }{
+ \msg_info:nn { notes2bib } { rerun }
+ }
+}
+\AtEndDocument {
+ \niib_check_rerun:
+}
+\msg_new:nnn { notes2bib } { rerun } {%
+ To get notes in the correct order, please run:\\%
+ 1) LaTeX \\%
+ 2) BibTeX \\%
+ 3) LaTeX
+}
+\cs_new_nopar:Nn \niib_write_total_notes: {
+ \intexpr_compare:nT { \g_niib_note_int > \c_zero } {
+ \iow_now:Nx \@auxout {
+ \TotalNotes { \int_to_arabic:n { \g_niib_note_int } }
+ }
+ }
+}
+\AtEndDocument { \niib_write_total_notes: }
+\cs_set:Npn \thanks #1 {
+ \niib_footnotemark:w
+ \protected@xdef \@thanks {
+ \@thanks
+ \protect \niib_footnotetext:w [ \the \c@footnote ] {#1}
+ }
+}
+\keys_set:nn { notes2bib } { placement = mixed }
+\ProcessKeysOptions { notes2bib }
+%%
+%% Copyright (C) 2007-2009 by
+%% Joseph Wright <joseph.wright@morningstar2.co.uk>
+%%
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version. The latest
+%% version of this license is in the file:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status) by
+%% Joseph Wright.
+%%
+%% This work consists of the file notes2bib.dtx
+%% and the derived files notes2bib.ins,
+%% notes2bib.pdf and
+%% notes2bib.sty.
+%%
%%
%% End of file `notes2bib.sty'.
diff --git a/Master/texmf-dist/tex/latex/notes2bib/xnotes2bib.sty b/Master/texmf-dist/tex/latex/notes2bib/xnotes2bib.sty
deleted file mode 100644
index 5fd25767f80..00000000000
--- a/Master/texmf-dist/tex/latex/notes2bib/xnotes2bib.sty
+++ /dev/null
@@ -1,435 +0,0 @@
-%%
-%% This is file `xnotes2bib.sty',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% xnotes2bib.dtx (with options: `package')
-%% ---------------------------------------------------------------
-%% The notes2bib bundle --- Integrating notes into the
-%% bibliography
-%% Maintained by Joseph Wright
-%% E-mail: joseph.wright@morningstar2.co.uk
-%% Released under the LaTeX Project Public License v1.3c or later
-%% See http://www.latex-project.org/lppl.txt
-%% ---------------------------------------------------------------
-%%
-\RequirePackage{l3names}
-\GetIdInfo$Id: xnotes2bib.dtx 6 2008-10-31 21:00:00Z joseph $
- {Integrating notes into the bibliography (expl3 version)}
-\ProvidesExplPackage
- {\filename}{\filedate}{\fileversion}{\filedescription}
-\RequirePackage {expl3,keys3,xparse}
-\err_file_new:Nn \c_niib_err_tlp {xnotes2bib.err}
-\tlp_new:Nn \l_niib_err_option_tlp {option}
-\err_interrupt_new:NNNnnn \c_niib_err_tlp \l_niib_err_option_tlp 0
- {All~package~control~should~be~given~using~the~\token_to_str:N~
- \niibsetup~\text_put_sp:~macro}
- {\err_help_return_or_X:}
- {}
-\err_file_close:N \c_niib_err_tlp
-\DeclareOption* {
- \err_interrupt:NNw \c_niib_err_tlp \l_niib_err_option_tlp
-}
-\ProcessOptions \scan_stop:
-\int_new:N \g_niib_note_int
-\def_new:Npn \niib_thenote: {
- \l_niib_name_tlp
- \num_compare:nNnT {\g_niib_totalnotes_int} > {\c_nine} {
- \num_compare:nNnF {\g_niib_note_int} > {\c_nine} {
- 0
- }
- }
- \int_to_arabic:n \g_niib_note_int
-}
-\bool_new:N \l_niib_after_cite_bool
-\bool_new:N \l_niib_before_cite_bool
-\let_new:NN \niib_convert_endnotes: \scan_stop:
-\let_new:NN \niib_convert_footnotes: \scan_stop:
-\keys_manage_quick:n {
- niib/.cd:,
- cite/.store~in~tlp:N = \niib_cite:n,
- debug/.choice:,
- debug/.default:n = true,
- debug/true/.code:n = {
- \def:Npn \niib_debug:n ##1 {
- \err_info:nn {##1} {(xnotes2bib) \text_put_four_sp:}
- }
- },
- debug/false/.code:n = {
- \let:NN \niib_debug:n \use_none:n
- },
- convert~endnotes/.choices:nn = {true,false} {
- \let:Nc \niib_convert_endnotes:
- {niib_convert_endnotes_ \l_keys_current_choice_tlp}
- },
- convert~endnotes/.default:n = true,
- convert~footnotes/.choices:nn = {true,false} {
- \let:Nc \niib_convert_footnotes:
- {niib_convert_footnotes_ \l_keys_current_choice_tlp}
- },
- convert~footnotes/.default:n = true,
- /keys/current~module:n = niib,
- field/.store~in~tlp:c = field,
- key~after/.store~in~tlp:c = key_after,
- key~before/.store~in~tlp:c = key_before,
- key~mixed/.store~in~tlp:c = key_mixed,
- keyword/.store~in~tlp:c = keyword,
- name/.store~in~tlp:c = name,
- placement/.choice: = \l_niib_placement_tlp,
- placement/.default:n = mixed,
- placement/after/.code:n = {
- \bool_set_true:N \l_niib_after_cite_bool
- \bool_set_false:N \l_niib_before_cite_bool
- },
- placement/before/.code:n = {
- \bool_set_false:N \l_niib_after_cite_bool
- \bool_set_true:N \l_niib_before_cite_bool
- },
- placement/mixed/.code:n = {
- \bool_set_false:N \l_niib_after_cite_bool
- \bool_set_false:N \l_niib_before_cite_bool
- },
- /keys/current~module:n = niib,
- prefix/.store~in~tlp:c = prefix,
- presort~after/.store~in~tlp:c = presort_after,
- presort~before/.store~in~tlp:c = presort_before,
- presort~mixed/.store~in~tlp:c = presort_mixed,
- record/.store~in~tlp:c = record,
- write~key~field/.boolean:c = write_key
-}
-\keys_manage_quick:n{
- /niib/.cd:,
- cite = \cite,
- debug = false,
- field = note,
- key~after = zzz,
- key~before = aaa,
- key~mixed = {},
- name = Bibnote,
- placement = mixed,
- prefix = niib-,
- presort~after = mn,
- presort~before = ml,
- presort~mixed = mm,
- record = Misc,
- write~key~field = true}
-\NewDocumentCommand {\bibnote} {o>{P}m} {
- \IfNoValueTF {#1} {
- \int_gincr:N \g_niib_note_int
- \bibnotetext {#2}
- \bibnotemark [\niib_thenote:]
- }{
- \bibnotetext [#1] {#2}
- \bibnotemark [#1]
- }
-}
-\NewDocumentCommand {\bibnotemark} {o} {
- \IfNoValueTF {#1} {
- \int_gincr:N \g_niib_note_int
- \niib_notemark:n {\niib_thenote:}
- }{
- \niib_notemark:n {#1}
- }
-}
-\NewDocumentCommand {\bibnotetext} {O{\niib_thenote:}>{P}m} {
- \if@filesw
- \cs_if_free:NT \g_niib_out_stream {
- \iow_new:N \g_niib_out_stream
- \iow_open:Nn \g_niib_out_stream
- {\l_niib_prefix_tlp \c_job_name_tlp.bib}
- \iow_expanded:Nn \g_niib_out_stream
- {This~is~an~auxiliary~file~used~by~the~`xnotes2bib'~package.^^J
- This~file~may~safely~be~deleted.^^J It~will~be~recreated~as~
- required.^^J}
- }
- \niib_debug:n {
- Writing~text:\MessageBreak #2\MessageBreak to~database~for~note~
- `#1'
- }
- \iow_expanded:Nn \g_niib_out_stream {
- @\l_niib_record_tlp{
- #1,^^J
- \text_put_sp: \text_put_sp: \l_niib_field_tlp \text_put_sp:
- =~{\exp_not:n{#2}},^^J
- \bool_if:NT \l_niib_write_key_bool {
- \text_put_sp: \text_put_sp: \l_niib_keyname_tlp \text_put_sp:
- =~{\niib_key:#1},^^J
- }
- \text_put_sp: \text_put_sp: keywords~
- =~{\l_niib_keyword_tlp},^^J
- \text_put_sp: \text_put_sp: presort~
- =~{\niib_presort:},^^J
- }^^J
- }
- \fi
-}
-\NewDocumentCommand {\flushnotestack} {} {
- \clist_if_empty:NF \g_niib_before_cite_clist {
- \if@filesw
- \iow_expanded:Nn \@auxout {
- \token_to_str:N \niibbeforecite {
- \g_niib_before_cite_clist
- }
- }
- \fi
- }
- \clist_if_empty:NF \g_niib_after_cite_clist {
- \nocite { \g_niib_after_cite_clist}
- \if@filesw
- \iow_expanded:Nn \@auxout {
- \token_to_str:N \niibaftercite {\g_niib_after_cite_clist}
- }
- \fi
- }
- \clist_gclear:N \g_niib_after_cite_clist
-}
-\NewDocumentCommand {\niibsetup} {m} {\keys_manage:n {/niib/.cd:,#1}}
-\clist_new:N \g_niib_before_cite_old_clist
-\clist_new:N \g_niib_after_cite_old_clist
-\tlp_new:N \g_niib_document_tlp
-\tlp_gput_right:Nn \document {\g_niib_document_tlp}
-\NewDocumentCommand {\niibbeforecite} {m} {
- \clist_gput_right:Nn \g_niib_before_cite_old_clist {#1}
- \tlp_gput_right:Nn \g_niib_document_tlp {\nocite{#1}}
-}
-\NewDocumentCommand {\niibaftercite} {m} {
- \clist_gput_right:Nn \g_niib_after_cite_old_clist {#1}
-}
-\int_new:N \g_niib_totalnotes_int
-\NewDocumentCommand {\niibtotalnotes} {m} {
- \int_gset:Nn \g_niib_totalnotes_int {#1}
-}
-\def_new:Npn \niib_notemark:n #1 {
- \niib_debug:n {Creating~citation~for~note~`#1'}
- \bool_if:NT \l_niib_before_cite_bool {
- \niib_debug:n {Note~`#1'~before~real~citations}
- \clist_gput_right:Nx \g_niib_before_cite_clist {#1}
- }
- \bool_if:NTF \l_niib_after_cite_bool {
- \niib_debug:n {Note~`#1'~after~real~citations}
- \clist_gput_right:Nx \g_niib_after_cite_clist {#1}
- \niib_after_cite:n {#1}
- }{
- \niib_cite:n {#1}
- }
-}
-\clist_new:N \g_niib_before_cite_clist
-\clist_new:N \g_niib_after_cite_clist
-\def_new:Npn \niib_key: {
- \bool_if:NTF \l_niib_before_cite_bool {
- \tlp_use:N \l_niib_key_before_tlp
- }{
- \bool_if:NTF \l_niib_after_cite_bool {
- \tlp_use:N \l_niib_key_after_tlp
- }{
- \tlp_use:N \l_niib_key_mixed_tlp
- }
- }
-}
-\def_new:Npn \niib_presort: {
- \bool_if:NTF \l_niib_before_cite_bool {
- \tlp_use:N \l_niib_presort_before_tlp
- }{
- \bool_if:NTF \l_niib_after_cite_bool {
- \tlp_use:N \l_niib_presort_after_tlp
- }{
- \tlp_use:N \l_niib_presort_mixed_tlp
- }
- }
-}
-\def_new:Npn \niib_convert_endnotes_false: {
- \niib_debug:n {Restoring~normal~endnotes}
- \let:NN \endnote \niib_saved_endnote:
- \let:NN \endnotemark \niib_saved_endnotemark:
- \let:NN \endnotetext \niib_saved_endnotetext:
-}
-\def_new:Npn \niib_convert_endnotes_true: {
- \niib_debug:n {Converting~endnotes~to~bibnotes}
- \let:NN \endnote \bibnote
- \let:NN \endnotemark \bibnotemark
- \let:NN \endnotetext \bibnotetext
-}
-\def_new:Npn \niib_convert_footnotes_false: {
- \niib_debug:n {Restoring~normal~footnotes}
- \let:NN \footnote \niib_saved_footnote:
- \let:NN \footnotemark \niib_saved_footnotemark:
- \let:NN \footnotetext \niib_saved_footnotetext:
-}
-\def_new:Npn \niib_convert_footnotes_true: {
- \niib_debug:n {Converting~footnotes~to~bibnotes}
- \let:NN \footnote \bibnote
- \let:NN \footnotemark \bibnotemark
- \let:NN \footnotetext \bibnotetext
-}
-\def:Npn \thanks #1 {
- \niib_saved_footnotemark:
- \protected@xdef \@thanks {
- \@thanks
- \protect \niib_saved_footnotetext: [\the\c@footnote] {#1}
- }
-}
-\tlp_new:N \l_niib_keyname_tlp
-\AtBeginDocument{
- \err_info:nn {
- (xnotes2bib) \text_put_sp: Beginning~\token_to_str:N
- \AtBeginDocument \text_put_sp: tasks
- } {}
- \@ifpackageloaded {biblatex} {
- \tlp_set:Nn \l_niib_keyname_tlp {keysort}
- \gappto \blx@bibfiles {,\niib_prefix\c_job_name_tlp}
- \let_new:NN \printbibnotes \printbibliography
- \def_new:Npn \niib_after_cite:n #1 {
- \AtNextCite {\@fileswfalse}
- \niib_cite:n {#1}
- }
- }{
- \tlp_gset:Nn \l_niib_keyname_tlp {key}
- \let_new:NN \niib_biliography:n \bibliography
- \def:Npn \bibliography #1 {
- \int_compare:nNnTF {\g_niib_note_int} = {\c_zero} {
- \niib_biliography:n {#1}
- }{
- \niib_biliography:n {
- #1, \l_niib_prefix_tlp \c_job_name_tlp
- }
- }
- }
- \NewDocumentCommand {\printbibnotes} {} {
- \niib_biliography:n {\l_niib_prefix_tlp\c_job_name_tlp}
- }
- \newif \ifniib@filesw
- \@ifpackageloaded {cite}{
- \def_new:Npn \niib_after_cite:n #1 {
- \let:NN \ifniib@filesw \if@filesw
- \@fileswfalse
- \def:Npn \niib_auxhandle: {
- \let:NN \if@filesw \ifniib@filesw
- \let:NN \niib_auxhandle: \scan_stop:
- }
- \niib_cite:n {#1}
- }
- \tlp_gput_right:Nn \g_niib_document_tlp {
- \cs_if_exist:NTF \@restore@auxhandle{
- \tlp_put_right:Nn \@restore@auxhandle {\niib_auxhandle:}
- }{
- \def_new:Npn \@restore@auxhandle {\niib_auxhandle:}
- }
- }
- \let_new:NN \niib_auxhandle: \scan_stop:
- }{
- \def_new:Npn \niib_after_cite:n #1 {
- \let:NN \ifniib@filesw \if@filesw
- \@fileswfalse
- \niib_cite:n {#1}
- \let:NN \if@filesw \ifniib@filesw
- }
- }
- }
- \let_new:NN \niib_saved_footnote: \footnote
- \let_new:NN \niib_saved_footnotemark: \footnotemark
- \let_new:NN \niib_saved_footnotetext: \footnotetext
- \let_new:NN \niib_saved_endnote: \endnote
- \let_new:NN \niib_saved_endnotemark: \endnotemark
- \let_new:NN \niib_saved_endnotetext: \endnotetext
- \niib_convert_endnotes:
- \niib_convert_footnotes:
- \keys_manage_quick:n {
- /niib/.cd:,
- convert~endnotes/true/.code:n = {\niib_convert_endnotes_true:},
- convert~endnotes/false/.code:n = {\niib_convert_endnotes_false:},
- convert~footnotes/true/.code:n = {\niib_convert_footnotes_true:},
- convert~footnotes/false/.code:n = {\niib_convert_footnotes_false:},
- }
- \err_info:nn {
- (xnotes2bib) \text_put_sp: Finished~\token_to_str:N
- \AtBeginDocument \text_put_sp: tasks
- } {}
-}
-\def_new:Npn \niib_rerun_check:n #1 {
- \clist_if_empty:cTF {g_niib_old#1cite_clist}{
- \clist_if_empty:cF {g_niib_#1cite_clist}{
- \niib_rerun_log:
- }
- }{
- \clist_if_empty:cTF {g_niib_#1cite_clist}{
- \niib_rerun_log:
- }{
- \bool_set_false:N \l_tmpa_bool
- \def:Npn \niib_rerun_test:n ##1 {
- \clist_if_in:cnTF {g_niib_old#1cite_clist} {##1} {
- \bool_set_true:N \l_tmpa_bool
- \clist_map_break:w
- }{
- }
- }
- \clist_map_function:cN {g_niib_#1cite_clist}
- \niib_rerun_test:n
- \def:Npn \niib_rerun_test:n ##1 {
- \clist_if_in:cnTF {g_niib_#1cite_clist} {##1} {
- \bool_set_true:N \l_tmpa_bool
- \clist_map_break:w
- }{
- }
- }
- \clist_map_function:cN {g_niib_old#1cite_clist}
- \niib_rerun_test:n
- \bool_if:NF \l_tmpa_bool {
- \niib_rerun_log:
- }
- }
- }
-}
-\let_new:NN \niib_rerun_test:n \use_none_i:n
-\def_new:Npn \niib_rerun_log: {
- \err_info:nn {
- (xnotes2bib) \text_put_sp: To~get~notes~in~the~correct~order,~
- please \err_newline: rerun~LaTeX,~(re)run~BibTeX~on~the~file~
- \c_job_name_tlp.aux \err_newline: and~rerun~LaTeX~again~afterwards
- } {(xnotes2bib) \text_put_sp:}
- \io_put_log:x {
- REQ:3:latex:REQ \iow_newline:
- REQ:2:bibtex:REQ \iow_newline:
- REQ:1:latex:REQ \iow_newline:
- }
- \let \niib_rerun_log: \scan_stop:
-}
-\AtEndDocument{
- \niib_rerun_check:n {before}
- \niib_rerun_check:n {after}
- \flushnotestack
- \iow_expanded:Nn \@auxout {
- \token_to_str:N \niibtotalnotes {\int_to_arabic:n \g_niib_note_int}
- }
- \num_compare:nNnF {\g_niib_totalnotes_int} = {\g_niib_note_int} {
- \niib_rerun_log:
- }
- \cs_if_free:NF \g_niib_out_stream {
- \iow_close:N \g_niib_out_stream
- }
-}
-%%
-%% Copyright (C) 2007-2008 by
-%% Joseph Wright <joseph.wright@morningstar2.co.uk>
-%%
-%% It may be distributed and/or modified under the conditions of
-%% the LaTeX Project Public License (LPPL), either version 1.3c of
-%% this license or (at your option) any later version. The latest
-%% version of this license is in the file:
-%%
-%% http://www.latex-project.org/lppl.txt
-%%
-%% This work is "maintained" (as per LPPL maintenance status) by
-%% Joseph Wright.
-%%
-%% This work consists of the file notes2bib.dtx
-%% xnotes2bib.dtx
-%% and the derived files notes2bib.pdf,
-%% notes2bib.sty,
-%% notes2bib.ins,
-%% xnotes2bib.pdf,
-%% xnotes2bib.sty and
-%% xnotes2bib.ins.
-%%
-%%
-%% End of file `xnotes2bib.sty'.