summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-04-03 21:15:59 +0000
committerKarl Berry <karl@freefriends.org>2010-04-03 21:15:59 +0000
commitd0303a8ab6faea3619305ff94bc8e3aa2f497813 (patch)
tree65fcc108352aa20767d9d345fe9c9b4f8f8984bf /Master/texmf-dist/tex/latex
parenta589cb25f922e7ce0e9390d80e689b9f7571feac (diff)
notes2bib update
git-svn-id: svn://tug.org/texlive/trunk@17665 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty123
1 files changed, 58 insertions, 65 deletions
diff --git a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
index ef36e7af63c..e6da38ee40a 100644
--- a/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
+++ b/Master/texmf-dist/tex/latex/notes2bib/notes2bib.sty
@@ -15,11 +15,12 @@
%%
\RequirePackage{xparse}
\ProvidesExplPackage
- {notes2bib} {2010/01/11} {2.0b}
+ {notes2bib} {2010/03/30} {2.0c}
{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.
+\tl_new:N \c_niib_file_message_tl
+\tl_set: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:
@@ -36,6 +37,7 @@
\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 \g_niib_notes_tl
\tl_new:N \l_niib_sortkey_field_tl
\int_new:N \g_niib_total_notes_int
\cs_new_nopar:Npn \niib_cite:w { }
@@ -98,11 +100,11 @@
sort-key-before = aaa ,
use-sort-key = true
}
-\cs_set_nopar:Npn \niib_options_redefine: {
+\AtBeginDocument {
\keys_define:nn { notes2bib }
{
cite-function .code:n =
- { \cs_set_eq:NN \niib_cite:w ##1 } ,
+ { \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 =
@@ -117,7 +119,6 @@
}
\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 = { } ,
@@ -153,44 +154,35 @@
\cs_new_nopar:Npn \niib_filesw: { }
\cs_new:Npn \niib_mark_note:n #1 { }
\cs_generate_variant:Nn \niib_mark_note:n { x }
-\cs_new:Npn \niib_mark_note_after:n #1 {
+\cs_new_protected:Npn \niib_mark_note_after:n #1 {
\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:Npn \niib_mark_note_after_aux:n #1 { }
-\cs_new:Npn \niib_mark_note_before:n #1 {
+\cs_new_protected:Npn \niib_mark_note_before:n #1 {
\int_gincr:N \g_niib_total_notes_int
\clist_gput_right:Nx \g_niib_before_clist {#1}
\niib_cite:w {#1}
}
-\cs_new:Npn \niib_mark_note_mixed:n #1 {
+\cs_new_protected:Npn \niib_mark_note_mixed:n #1 {
\int_gincr:N \g_niib_total_notes_int
\niib_cite:w {#1}
}
-\cs_new_nopar:Npn \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:Npn \niib_write_field:nn #1#2 {
- \iow_space: \iow_space: #1 \iow_space: = \iow_space: {#2} ,
+ \c_space_tl \c_space_tl #1 \c_space_tl = \c_space_tl {#2} ,
\iow_newline:
}
\cs_generate_variant:Nn \niib_write_field:nn { V }
-\cs_new_nopar:Npn \niib_write_note:nn {
+\cs_new_protected_nopar:Npn \niib_write_note:nn {
\if@filesw
\exp_after:wN \niib_write_note_aux:nn
\else:
\exp_after:wN \use_none:nn
\fi:
}
-\cs_new:Npn \niib_write_note_aux:nn #1#2 {
- \niib_stream_check:
- \iow_now:Nx \g_niib_file_stream
+\cs_new_protected:Npn \niib_write_note_aux:nn #1#2 {
+ \tl_gput_right:Nx \g_niib_notes_tl
{
@ \l_niib_record_type_tl
{
@@ -204,15 +196,17 @@
\niib_write_field:nn { keywords } { \l_niib_keyword_tl }
\niib_write_field:nn { presort } { \l_niib_presort_tl }
}
+ \iow_newline:
+ \iow_newline:
}
}
\cs_generate_variant:Nn \niib_write_note:nn { x }
-\cs_new_nopar:Npn \niib_record_notes: {
+\cs_new_protected_nopar:Npn \niib_record_notes: {
\if@filesw
\exp_after:wN \niib_flush_notes_aux:
\fi
}
-\cs_new_nopar:Npn \niib_flush_notes_aux: {
+\cs_new_protected_nopar:Npn \niib_flush_notes_aux: {
\clist_if_empty:NF \g_niib_before_clist
{
\iow_now:Nx \@auxout
@@ -229,50 +223,43 @@
\clist_gclear:N \g_niib_after_clist
}
}
-\cs_new_nopar:Npn \niib_to_bibnote:n #1 {
+\cs_new_protected_nopar:Npn \niib_to_bibnote:n #1 {
\cs_set_eq:cN {#1} \bibnote
\cs_set_eq:cN { #1 mark } \bibnotemark
\cs_set_eq:cN { #1 text } \bibnotetext
}
-\cs_new_nopar:Npn \niib_from_bibnote:n #1 {
+\cs_new_protected_nopar:Npn \niib_from_bibnote:n #1 {
\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:Npn \niib_save_endnote: {
+\AtBeginDocument {
\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:Npn \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:Npn \niib_create_print_notes: {
\@ifpackageloaded { biblatex }
{
- \cs_new_nopar:Npn \niib_print_notes:
+ \cs_new_protected_nopar:Npn \niib_print_notes:
{
- \cs_set_nopar:Npx \niib_create_print_notes_aux:
+ \cs_set_nopar:Npx \niib_create_print_notes:
{
\printbibliography
[ keyword = \exp_not:V \l_niib_keyword_tl ]
}
- \niib_create_print_notes_aux:
+ \niib_create_print_notes:
}
}
{
- \cs_new_nopar:Npn \niib_print_notes:
+ \cs_new_protected_nopar:Npn \niib_print_notes:
{ \exp_args:NV \niib_bibliography:n \g_niib_filename_tl }
}
}
-\cs_new_nopar:Npn \niib_create_print_notes_aux: { }
-\AtBeginDocument { \niib_create_print_notes: }
+\cs_new_nopar:Npn \niib_create_print_notes: { }
\cs_new_nopar:Npn \niib_attach_bibliography: {
\@ifpackageloaded { biblatex }
{ \exp_args:NV \bibliography \g_niib_filename_tl }
@@ -295,43 +282,40 @@
}
}
}
-\@ifpackageloaded { biblatex } {
- \exp_args:NV \bibliography \g_niib_filename_tl
- \cs_gundefine:N \niib_attach_bibliography:
-}{
- \AtBeginDocument { \niib_attach_bibliography: }
-}
-\cs_new_nopar:Npn \niib_set_sortkey_name: {
+\@ifpackageloaded { biblatex }
+ {
+ \exp_args:NV \bibliography \g_niib_filename_tl
+ \cs_gundefine:N \niib_attach_bibliography:
+ }
+ { \AtBeginDocument { \niib_attach_bibliography: } }
+\AtBeginDocument {
\@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:Npn \niib_set_mark_note_after: {
+\AtBeginDocument {
\@ifpackageloaded { biblatex }
{
- \cs_set:Npn \niib_mark_note_after_aux:n ##1
+ \cs_set:Npn \niib_mark_note_after_aux:n #1
{
\AtNextCite { \@fileswfalse }
- \niib_cite:w {##1}
+ \niib_cite:w {#1}
}
}
{
- \cs_set:Npn \niib_mark_note_after_aux:n ##1
+ \cs_set:Npn \niib_mark_note_after_aux:n #1
{
\cs_set_eq:NN \niib_filesw: \if@filesw
\@fileswfalse
- \niib_cite:w {##1}
+ \niib_cite:w {#1}
\cs_set_eq:NN \if@filesw \niib_filesw:
}
}
}
-\AtBeginDocument { \niib_set_mark_note_after: }
-\cs_new_nopar:Npn \niib_check_cite: {
+\AtBeginDocument {
\@ifpackageloaded { cite }
{
- \cs_set:Npn \niib_mark_note_after_aux:n ##1
+ \cs_set:Npn \niib_mark_note_after_aux:n #1
{
\cs_set_eq:NN \niib_filesw: \if@filesw
\@fileswfalse
@@ -340,7 +324,7 @@
\cs_set_eq:NN \if@filesw \niib_filesw:
\cs_set_nopar:Npn \niib_aux_hook: { }
}
- \niib_cite:w {##1}
+ \niib_cite:w {#1}
}
\cs_new_nopar:Npn \niib_aux_hook: { }
\tl_gput_right:Nn \g_niib_document_hook_tl
@@ -352,7 +336,6 @@
}
{ }
}
-\AtBeginDocument { \niib_check_cite: }
\NewDocumentCommand \bibnote { o +m } {
\IfNoValueTF {#1}
{
@@ -361,7 +344,7 @@
}
{ \niib_bibnote:nn {#1} {#2} }
}
-\cs_new:Npn \niib_bibnote:nn #1#2 {
+\cs_new_protected:Npn \niib_bibnote:nn #1#2 {
\niib_write_note:nn {#1} {#2}
\niib_mark_note:n {#1}
}
@@ -406,7 +389,7 @@
\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:Npn \niib_check_rerun: {
+\AtEndDocument {
\clist_if_eq:NNTF \g_niib_all_before_clist
\g_niib_previous_before_clist
{
@@ -416,23 +399,33 @@
}
{ \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:Npn \niib_write_total_notes: {
+\AtEndDocument {
+ \if@filesw
+ \exp_after:wN \niib_write_note_file:
+ \fi:
+}
+\cs_new_protected_nopar:Npn \niib_write_note_file: {
+ \tl_if_empty:NF \g_niib_notes_tl {
+ \iow_open:Nn \g_niib_file_stream { \g_niib_filename_tl .bib }
+ \iow_now:Nx \g_niib_file_stream { \c_niib_file_message_tl }
+ \iow_now:Nx \g_niib_file_stream
+ { \exp_not:V \g_niib_notes_tl }
+ \iow_close:N \g_niib_file_stream
+ }
+}
+\AtEndDocument {
\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