From 37778869d20a42439b123bb0c553953f716886b1 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 6 Oct 2019 03:01:15 +0000 Subject: CTAN sync 201910060301 --- macros/latex/contrib/fnpct/README | 6 +- macros/latex/contrib/fnpct/fnpct.sty | 800 ++++++++++++++++++-------------- macros/latex/contrib/fnpct/fnpct_en.pdf | Bin 572627 -> 573765 bytes macros/latex/contrib/fnpct/fnpct_en.tex | 108 +++-- 4 files changed, 515 insertions(+), 399 deletions(-) (limited to 'macros/latex/contrib/fnpct') diff --git a/macros/latex/contrib/fnpct/README b/macros/latex/contrib/fnpct/README index 0c82d70ad3..5a230d16e4 100644 --- a/macros/latex/contrib/fnpct/README +++ b/macros/latex/contrib/fnpct/README @@ -1,15 +1,15 @@ -------------------------------------------------------------------------- -the FNPCT package v0.4g +the FNPCT package v0.5 footnote kerning -2019/09/30 +2019/10/05 -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/fnpct/ E-Mail: contact@mychemistry.eu -------------------------------------------------------------------------- -Copyright 2012-2019 Clemens Niederberger +Copyright 2012--2019 Clemens Niederberger This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/macros/latex/contrib/fnpct/fnpct.sty b/macros/latex/contrib/fnpct/fnpct.sty index 909a9d88ce..bdd63448cd 100644 --- a/macros/latex/contrib/fnpct/fnpct.sty +++ b/macros/latex/contrib/fnpct/fnpct.sty @@ -8,7 +8,7 @@ % Web: https://bitbucket.org/cgnieder/fnpct/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012-2019 Clemens Niederberger +% Copyright 2012--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -28,220 +28,291 @@ % the package is inspired by the following question on TeX.SE: % http://tex.stackexchange.com/q/56094/5049 % -------------------------------------------------------------------------- -\RequirePackage { xparse , l3keys2e , scrlfile } -\ProvidesExplPackage - {fnpct} - {2019/09/30} - {0.4g} - {footnote kerning} - -% -------------------------------------------------------------------------- -% SETTING THINGS UP: -% this is plain's \nobreak: -\cs_new:Npn \fnpct_no_break: { \tex_penalty:D 10000 \scan_stop: } - -% messages: -\cs_new_protected:Npn \fnpct_dont_mess_around: +\RequirePackage {xparse,l3keys2e,scrlfile} +\ExplSyntaxOn + +\tl_const:Nn \c_fnpct_date_tl {2019/10/05} +\tl_const:Nn \c_fnpct_version_major_number_tl {0} +\tl_const:Nn \c_fnpct_version_minor_number_tl {5} +\tl_const:Nn \c_fnpct_version_subrelease_tl {} +\tl_const:Nx \c_fnpct_version_number_tl { - \iow_log:n { ................................................. } - \iow_log:n { . ~ fnpct~info: } - \iow_log:n { . } - \iow_log:n { . ~ All~right,~not~messing~around.~:( } - \iow_log:n { . ~ But~I'd~really~love~to~(http://www.youtube.com/watch?v=Bqz876VkwwY). } - \iow_log:n { ................................................. } + \c_fnpct_version_major_number_tl . + \c_fnpct_version_minor_number_tl } - -\msg_set:nnn { fnpct } { already-adapted } +\tl_const:Nx \c_fnpct_version_tl { - The~command~\token_to_str:N #1 \tl_use:N \c_space_tl has~already~been~ - adapted. \\ - I~will~do~nothing~instead. + \c_fnpct_version_number_tl + \c_fnpct_version_subrelease_tl } +\tl_const:Nn \c_fnpct_info_tl {footnote~ kerning} -\bool_new:N \l__fnpct_strict_bool +\ProvidesExplPackage + {fnpct} + {\c_fnpct_date_tl} + {\c_fnpct_version_tl} + {\c_fnpct_info_tl} -\cs_new_protected:Npn \fnpct_message:nx #1#2 - { - \bool_if:NTF \l__fnpct_strict_bool - { \msg_error:nnx { fnpct } { #1 } } - { \msg_warning:nnx { fnpct } { #1 } } - { #2 } - } +% -------------------------------------------------------------------------- +% this is plain's \nobreak: +\cs_new:Npn \fnpct_no_break: { \tex_penalty:D 10000 \scan_stop: } -% scratch variables: +% -------------------------------------------------------------------------- +% variables: \tl_new:N \l__fnpct_tmpa_tl \tl_new:N \l__fnpct_tmpb_tl + \dim_new:N \l__fnpct_tmpa_dim \dim_new:N \l__fnpct_tmpb_dim + \int_new:N \l__fnpct_tmpa_int -% rigid lengths: +\seq_new:N \l__fnpct_tmpa_seq +\seq_new:N \l__fnpct_tmpb_seq + \dim_new:N \l__fnpct_after_comma_dim -\dim_set:Nn \l__fnpct_after_comma_dim { -.06em } +\dim_set:Nn \l__fnpct_after_comma_dim {-.06em} \dim_new:N \l__fnpct_after_dot_dim -\dim_set:Nn \l__fnpct_after_dot_dim { -.06em } +\dim_set:Nn \l__fnpct_after_dot_dim {-.06em} \dim_new:N \l__fnpct_before_comma_dim -\dim_set:Nn \l__fnpct_before_comma_dim { -.16em } +\dim_set:Nn \l__fnpct_before_comma_dim {-.16em} \dim_new:N \l__fnpct_before_dot_dim -\dim_set:Nn \l__fnpct_before_dot_dim { -.16em } +\dim_set:Nn \l__fnpct_before_dot_dim {-.16em} \dim_new:N \l__fnpct_before_footnote_dim -\dim_set:Nn \l__fnpct_before_footnote_dim { .06em } +\dim_set:Nn \l__fnpct_before_footnote_dim {.06em} \dim_new:N \l__fnpct_normal_mark_width_dim -\dim_set:Nn \l__fnpct_normal_mark_width_dim { 1em } +\dim_set:Nn \l__fnpct_normal_mark_width_dim {1em} \dim_new:N \l__fnpct_normal_indent_dim -\dim_set:Nn \l__fnpct_normal_indent_dim { 1.5em } +\dim_set:Nn \l__fnpct_normal_indent_dim {1.5em} \dim_new:N \l__fnpct_normal_parindent_dim -\dim_set:Nn \l__fnpct_normal_parindent_dim { 1em } +\dim_set:Nn \l__fnpct_normal_parindent_dim {1em} \dim_new:N \l__fnpct_french_before_footnote_space_dim -\dim_set:Nn \l__fnpct_french_before_footnote_space_dim { .16667em } +\dim_set:Nn \l__fnpct_french_before_footnote_space_dim {.16667em} -% multiple footnote input and output variables: -\tl_new:N \l__fnpct_multiple_footnotes_delimiter_tl -\tl_set:Nn \l__fnpct_multiple_footnotes_delimiter_tl { ; } -\tl_new:N \l__fnpct_multiple_footnote_separator_tl -% check for KOMA-Script's \multfootsep: -\cs_if_exist:NTF \KOMAClassName - { \tl_set:Nn \l__fnpct_multiple_footnote_separator_tl { \multfootsep } } - { \tl_set:Nn \l__fnpct_multiple_footnote_separator_tl { , } } +\int_new:N \l__fnpct_multiple_notes_int -% basic booleans for punctuation order switch and multiple footnotes +\tl_new:N \l__fnpct_multiple_footnotes_delimiter_tl +\tl_set:Nn \l__fnpct_multiple_footnotes_delimiter_tl {;} +\tl_new:N \l__fnpct_multiple_footnote_separator_tl +\tl_new:N \l__fnpct_last_punct_mark_tl +\tl_new:N \l__fnpct_punctuation_marks_tl +\tl_set:Nn \l__fnpct_punctuation_marks_tl {.,} +\tl_new:N \l__fnpct_multiple_true_tl +\tl_new:N \l__fnpct_multiple_false_tl + +\bool_new:N \l__fnpct_strict_bool \bool_new:N \l__fnpct_punct_after_bool \bool_new:N \l__fnpct_dont_mess_around_bool \bool_new:N \l__fnpct_multiple_default_bool \bool_new:N \l__fnpct_multiple_footnotes_bool \bool_new:N \l__fnpct_reverse_switch_bool -\bool_new:N \l__fnpct_bigfoot_default_top_bool \bool_new:N \l__fnpct_normal_marks_bool \bool_new:N \l__fnpct_hyperref_bool - \bool_new:N \g__fnpct_after_punctuation_bool +\bool_new:N \g__fnpct_only_text_bool +\bool_new:N \l__fnpct_makepagenote_bool + +\seq_new:N \l__fnpct_multiple_footnotes_seq +\seq_new:N \l__fnpct_footnote_class_seq + +\prop_new:N \l__fnpct_punctuation_marks_after_prop +\prop_new:N \l__fnpct_punctuation_marks_before_prop +\prop_new:N \l__fnpct_sepfootnote_foot_classes_prop +\prop_new:N \l__fnpct_sepfootnote_end_classes_prop +\prop_new:N \l__fnpct_sepfootnote_symbol_classes_prop +\prop_new:N \g__fnpct_adapted_notes_prop +\prop_new:N \g__fnpct_inner_footnote_prop +\prop_new:N \g__fnpct_inner_footnote_hyperref_prop +\prop_new:N \l__fnpct_footnote_fixfoot_prop + +% -------------------------------------------------------------------------- +% variants: +\cs_generate_variant:Nn \str_remove_once:Nn {NV} +\cs_generate_variant:Nn \tl_remove_all:Nn {NV} +\cs_generate_variant:Nn \tl_put_right:Nn {NV} +\cs_generate_variant:Nn \seq_set_split:Nnn {NnV,NV} +\cs_generate_variant:Nn \prop_gput:Nnn {Nxn,Nxo} +\cs_generate_variant:Nn \prop_put:Nnn {Nnx} +\cs_generate_variant:Nn \prop_if_in:NnTF {Nx} + +% -------------------------------------------------------------------------- +% messages: +\cs_new_protected:Npn \fnpct_dont_mess_around: + { + \iow_log:n { ................................................. } + \iow_log:n { . ~ fnpct~info: } + \iow_log:n { . } + \iow_log:n { . ~ All~right,~not~messing~around.~:( } + \iow_log:n { . ~ But~I'd~really~love~to. } + \iow_log:n { . ~ (https://www.youtube.com/results?search_query=mess+around+ray+charles) } + \iow_log:n { ................................................. } + } + +\msg_new:nnn {fnpct} {already-adapted} + { + The~ command~ \token_to_str:N #1 \c_space_tl has~ already~ been~ + adapted. \\ + I~ will~ do~ nothing~ instead. + } + +\msg_new:nnn {fnpct} {pagenote} + { + If~ you~ use~ the~ `pagenote'~ package~ with~ `fnpct'~ please~ make~ sure~ + to~ use~ \token_to_str:N \makepagenote \c_space_tl after~ loading~ + `fnpct'! + } + +\msg_new:nnn {fnpct} {deprecated} + { + You've~ tried~ setting~ #1~ `#2'~ \msg_line_context: .~ However,~ + #1~ `#2'~ is~ deprecated.~ + \tl_if_blank:nF {#3} {Please~ use~ #1~ `#3'~ instead.~} + Refer~ to~ the~ manual~ for~ details. + } + +\cs_new_protected:Npn \fnpct_message:nx #1#2 + { + \bool_if:NTF \l__fnpct_strict_bool + { \msg_error:nnx {fnpct} {#1} } + { \msg_warning:nnx {fnpct} {#1} } + {#2} + } + +% -------------------------------------------------------------------------- +\prg_new_conditional:Npnn \fnpct_if_package_loaded:n #1 {p,T,F,TF} + { + \@ifpackageloaded {#1} + { \prg_return_true: } + { \prg_return_false: } + } -% default punctuation marks for switching: -\tl_new:N \l__fnpct_punctuation_marks_tl -\tl_set:Nn \l__fnpct_punctuation_marks_tl { ., } -\prop_new:N \l__fnpct_punctuation_marks_after_prop -\prop_new:N \l__fnpct_punctuation_marks_before_prop +% -------------------------------------------------------------------------- +% multiple footnote input and output variables: +% check for KOMA-Script's \multfootsep: +\cs_if_exist:NTF \KOMAClassName + { \tl_set:Nn \l__fnpct_multiple_footnote_separator_tl { \multfootsep } } + { \tl_set:Nn \l__fnpct_multiple_footnote_separator_tl {,} } +% -------------------------------------------------------------------------- % #1: before/after % #2: punctuation mark % #3: dimension \cs_new_protected:Npn \fnpct_set_punctuation_dim:nnn #1#2#3 { \prop_put:cnx { l__fnpct_punctuation_marks_#1_prop } - { #2 } - { \dim_eval:n { #3 } } + {#2} + { \dim_eval:n {#3} } } -\cs_generate_variant:Nn \fnpct_set_punctuation_dim:nnn { nV } +\cs_generate_variant:Nn \fnpct_set_punctuation_dim:nnn {nV} -\fnpct_set_punctuation_dim:nnn { after } { . } { \l__fnpct_after_dot_dim } -\fnpct_set_punctuation_dim:nnn { after } { , } { \l__fnpct_after_comma_dim } -\fnpct_set_punctuation_dim:nnn { before } { . } { \l__fnpct_before_dot_dim } -\fnpct_set_punctuation_dim:nnn { before } { , } { \l__fnpct_before_comma_dim } +\fnpct_set_punctuation_dim:nnn {after} {.} { \l__fnpct_after_dot_dim } +\fnpct_set_punctuation_dim:nnn {after} {,} { \l__fnpct_after_comma_dim } +\fnpct_set_punctuation_dim:nnn {before} {.} { \l__fnpct_before_dot_dim } +\fnpct_set_punctuation_dim:nnn {before} {,} { \l__fnpct_before_comma_dim } \cs_new_protected:Npn \fnpct_rm_punctuation:n #1 { - \tl_remove_all:Nn \l__fnpct_punctuation_marks_tl { #1 } - \prop_del:Nn \l__fnpct_punctuation_marks_after_prop { #1 } - \prop_del:Nn \l__fnpct_punctuation_marks_before_prop { #1 } + \tl_remove_all:Nn \l__fnpct_punctuation_marks_tl {#1} + \prop_del:Nn \l__fnpct_punctuation_marks_after_prop {#1} + \prop_del:Nn \l__fnpct_punctuation_marks_before_prop {#1} } -\tl_new:N \l__fnpct_last_punct_mark_tl - \cs_new_protected:Npn \fnpct_add_punctuation:n #1 { \__fnpct_add_punctuation:w #1 [ \q_no_value ] \q_no_value \q_stop } -\cs_generate_variant:Nn \fnpct_add_punctuation:n { V } +\cs_generate_variant:Nn \fnpct_add_punctuation:n {V} \cs_new_protected:Npn \__fnpct_add_punctuation:w #1[#2]#3 \q_stop { - \quark_if_no_value:nTF { #2 } + \quark_if_no_value:nTF {#2} { % there is no option at all - \tl_map_inline:nn { #1 } + \tl_map_inline:nn {#1} { - \tl_put_right:Nn \l__fnpct_punctuation_marks_tl { ##1 } - \fnpct_set_punctuation_dim:nnn { after } { ##1 } { 0pt } - \fnpct_set_punctuation_dim:nnn { before } { ##1 } { 0pt } - \tl_set:No \l__fnpct_last_punct_mark_tl { ##1 } + \tl_put_right:Nn \l__fnpct_punctuation_marks_tl {##1} + \fnpct_set_punctuation_dim:nnn {after} {##1} {0pt} + \fnpct_set_punctuation_dim:nnn {before} {##1} {0pt} + \tl_set:No \l__fnpct_last_punct_mark_tl {##1} } } { - \tl_if_blank:nTF { #1 } + \tl_if_blank:nTF {#1} { % #2 is a second option (= before space) - \fnpct_set_punctuation_dim:nVn { before } + \fnpct_set_punctuation_dim:nVn {before} \l__fnpct_last_punct_mark_tl - { #2 } + {#2} } { % #2 is a first option (= after space), #1 might be more than one token: - \tl_if_single_token:nTF { #1 } + \tl_if_single_token:nTF {#1} { - \tl_put_right:Nn \l__fnpct_punctuation_marks_tl { #1 } - \fnpct_set_punctuation_dim:nnn { after } { #1 } { #2 } - \fnpct_set_punctuation_dim:nnn { before } { #1 } { 0pt } - \tl_set:No \l__fnpct_last_punct_mark_tl { #1 } + \tl_put_right:Nn \l__fnpct_punctuation_marks_tl {#1} + \fnpct_set_punctuation_dim:nnn {after} {#1} {#2} + \fnpct_set_punctuation_dim:nnn {before} {#1} {0pt} + \tl_set:No \l__fnpct_last_punct_mark_tl {#1} } { \int_zero:N \l__fnpct_tmpa_int - \tl_map_inline:nn { #1 } + \tl_map_inline:nn {#1} { - \tl_put_right:Nn \l__fnpct_punctuation_marks_tl { ##1 } - \int_compare:nTF { \l__fnpct_tmpa_int < ( \tl_count:n { #1 } - 1 ) } + \tl_put_right:Nn \l__fnpct_punctuation_marks_tl {##1} + \int_compare:nTF { \l__fnpct_tmpa_int < ( \tl_count:n {#1} - 1 ) } { - \fnpct_set_punctuation_dim:nnn { after } { ##1 } { 0pt} - \fnpct_set_punctuation_dim:nnn { before } { ##1 } { 0pt } + \fnpct_set_punctuation_dim:nnn {after} {##1} {0pt} + \fnpct_set_punctuation_dim:nnn {before} {##1} {0pt} } { - \fnpct_set_punctuation_dim:nnn { after } { ##1 } { #2 } - \fnpct_set_punctuation_dim:nnn { before } { ##1 } { 0pt } + \fnpct_set_punctuation_dim:nnn {after} {##1} {#2} + \fnpct_set_punctuation_dim:nnn {before} {##1} {0pt} } - \tl_set:No \l__fnpct_last_punct_mark_tl { ##1 } + \tl_set:No \l__fnpct_last_punct_mark_tl {##1} \int_incr:N \l__fnpct_tmpa_int } } } } % is there more? - \tl_if_eq:nnF { #3 } { [\q_no_value]\q_no_value } + \tl_if_eq:nnF {#3} { [\q_no_value]\q_no_value } { - \quark_if_no_value:nF { #3 } + \quark_if_no_value:nF {#3} { - \tl_set:Nn \l__fnpct_tmpa_tl { #3 } + \tl_set:Nn \l__fnpct_tmpa_tl {#3} \tl_remove_all:Nn \l__fnpct_tmpa_tl { [\q_no_value]\q_no_value } \fnpct_add_punctuation:V \l__fnpct_tmpa_tl } } } +% -------------------------------------------------------------------------- % options: -\keys_define:nn { fnpct } +\keys_define:nn {fnpct} { + bigfoot-default-top .code:n = + \msg_warning:nnnn {fnpct} {deprecated} {option} {bigfoot-default-top} , strict .bool_set:N = \l__fnpct_strict_bool , - strict .default:n = true , after-comma-space .code:n = - \fnpct_set_punctuation_dim:nnn { after } { , } { #1 } , + \fnpct_set_punctuation_dim:nnn {after} {,} {#1} , after-dot-space .code:n = - \fnpct_set_punctuation_dim:nnn { after } { . } { #1 } , + \fnpct_set_punctuation_dim:nnn {after} {.} {#1} , before-comma-space .code:n = - \fnpct_set_punctuation_dim:nnn { before } { , } { #1 } , + \fnpct_set_punctuation_dim:nnn {before} {,} {#1} , before-dot-space .code:n = - \fnpct_set_punctuation_dim:nnn { before } { , } { #1 } , + \fnpct_set_punctuation_dim:nnn {before} {.} {#1} , after-punct-space .code:n = \prop_map_inline:Nn \l__fnpct_punctuation_marks_after_prop - { \fnpct_set_punctuation_dim:nnn { after } { ##1 } { #1 } } , + { \fnpct_set_punctuation_dim:nnn {after} {##1} {#1} } , before-punct-space .code:n = \prop_map_inline:Nn \l__fnpct_punctuation_marks_before_prop - { \fnpct_set_punctuation_dim:nnn { before } { ##1 } { #1 } } , + { \fnpct_set_punctuation_dim:nnn {before} {##1} {#1} } , before-footnote-space .dim_set:N = \l__fnpct_before_footnote_dim , french-before-footnote-space .dim_set:N = \l__fnpct_french_before_footnote_space_dim , punct-after .bool_set:N = \l__fnpct_punct_after_bool , - punct-after .default:n = true , dont-mess-around .code:n = \prop_map_inline:Nn \l__fnpct_punctuation_marks_after_prop - { \fnpct_set_punctuation_dim:nnn { after } { ##1 } { 0pt } } + { \fnpct_set_punctuation_dim:nnn {after} {##1} {0pt} } \prop_map_inline:Nn \l__fnpct_punctuation_marks_before_prop - { \fnpct_set_punctuation_dim:nnn { before } { ##1 } { 0pt } } + { \fnpct_set_punctuation_dim:nnn {before} {##1} {0pt} } \dim_zero:N \l__fnpct_before_footnote_dim \bool_set_true:N \l__fnpct_punct_after_bool \bool_set_true:N \l__fnpct_dont_mess_around_bool @@ -249,45 +320,41 @@ mult-fn-delim .tl_set:N = \l__fnpct_multiple_footnotes_delimiter_tl , mult-fn-sep .tl_set:N = \l__fnpct_multiple_footnote_separator_tl , multiple .bool_set:N = \l__fnpct_multiple_default_bool , - multiple .default:n = true , - bigfoot-default-top .bool_set:N = \l__fnpct_bigfoot_default_top_bool , - bigfoot-default-top .default:n = true , normal-marks .bool_set:N = \l__fnpct_normal_marks_bool , - normal-marks .default:n = true , normal-mark-width .dim_set:N = \l__fnpct_normal_mark_width_dim , normal-indent .dim_set:N = \l__fnpct_normal_indent_dim , normal-parindent .dim_set:N = \l__fnpct_normal_parindent_dim , verb-format .tl_set:N = \l__fnpct_verbatim_format_tl , - add-punct-marks .code:n = \fnpct_add_punctuation:n { #1 } , + add-punct-marks .code:n = \fnpct_add_punctuation:n {#1} , remove-punct-marks .code:n = - \tl_map_function:nN { #1 } \fnpct_rm_punctuation:n + \tl_map_function:nN {#1} \fnpct_rm_punctuation:n } -\ProcessKeysOptions { fnpct } +\ProcessKeysOptions {fnpct} % -------------------------------------------------------------------------- % MAIN INTERNAL FOOTNOTE FUNCTION: % write the notes: \cs_new:Npn \__fnpct_no_value_or_quark_no_value:nTF #1#2#3 { - \IfNoValueTF { #1 } { #2 } - { \quark_if_no_value:nTF { #1 } { #2 } { #3 } } + \IfNoValueTF {#1} {#2} + { \quark_if_no_value:nTF {#1} {#2} {#3} } } \cs_new:Npn \fnpct_write_note:Nnnn #1#2#3#4 { - \__fnpct_no_value_or_quark_no_value:nTF { #2 } - { #1 { #4 } } + \__fnpct_no_value_or_quark_no_value:nTF {#2} + { #1 {#4} } { - \__fnpct_no_value_or_quark_no_value:nTF { #3 } - { #1 [ #2 ] { #4 } } - { #1 [ #2 ] [ #3 ] { #4 } } + \__fnpct_no_value_or_quark_no_value:nTF {#3} + { #1 [#2] {#4} } + { #1 [#2] [#3] {#4} } } } % check for punctuation: \cs_new_protected:Npn \fnpct_check_punctuation:TF #1#2 - { \__fnpct_check_punctuation:nTF { 0 } { #1 } { #2 } } + { \__fnpct_check_punctuation:nTF {0} {#1} {#2} } \cs_new_protected:Npn \__fnpct_check_punctuation:nTF #1#2#3 { @@ -295,17 +362,17 @@ \l__fnpct_current_punct_mark_tl \l__fnpct_punctuation_marks_tl \exp_args:NV \peek_meaning_remove:NTF \l__fnpct_current_punct_mark_tl - { #2 } + {#2} { - \__fnpct_check_punctuation_aux:nnn { #1 } - { \__fnpct_check_punctuation:VTF \l__fnpct_tmpa_int { #2 } { #3 } } - { #3 } + \__fnpct_check_punctuation_aux:nnn {#1} + { \__fnpct_check_punctuation:VTF \l__fnpct_tmpa_int {#2} {#3} } + {#3} } } \cs_new_protected:Npn \__fnpct_check_punctuation_aux:nnn #1#2#3 { - \int_set:Nn \l__fnpct_tmpa_int { #1 } + \int_set:Nn \l__fnpct_tmpa_int {#1} \int_incr:N \l__fnpct_tmpa_int \tl_set:Nx \l__fnpct_tmpb_tl { \int_to_arabic:n { \l__fnpct_tmpa_int } } \tl_remove_all:NV \l__fnpct_punctuation_marks_tl @@ -313,25 +380,19 @@ \tl_put_right:NV \l__fnpct_punctuation_marks_tl \l__fnpct_current_punct_mark_tl \int_compare:nTF { \l__fnpct_tmpa_int < \tl_count:V \l__fnpct_punctuation_marks_tl } - { #2 } - { #3 } + {#2} + {#3} } -\cs_generate_variant:Nn \__fnpct_check_punctuation:nTF { V } -% \cs_generate_variant:Nn \peek_meaning_remove:NTF { V } -\cs_generate_variant:Nn \tl_remove_all:Nn { NV } -\cs_generate_variant:Nn \tl_put_right:Nn { NV } +\cs_generate_variant:Nn \__fnpct_check_punctuation:nTF {V} \cs_new_protected:Npn \__fnpct_get_head:NN #1#2 { \tl_set:Nx #1 { \tl_head:V #2 } } % check for multiple notes: -\tl_new:N \l__fnpct_multiple_true_tl -\tl_new:N \l__fnpct_multiple_false_tl - \cs_new_protected:Npn \fnpct_check_multiple:TF #1#2 { - \tl_set:Nn \l__fnpct_multiple_true_tl { #1 } - \tl_set:Nn \l__fnpct_multiple_false_tl { #2 } + \tl_set:Nn \l__fnpct_multiple_true_tl {#1} + \tl_set:Nn \l__fnpct_multiple_false_tl {#2} \bool_gset_false:N \g__fnpct_after_punctuation_bool \peek_after:Nw \__fnpct_check_multiple: } @@ -340,8 +401,9 @@ { \prop_map_inline:Nn \g__fnpct_adapted_notes_prop { - \prop_get:NnN \g__fnpct_adapted_notes_prop { ##1 } \l__fnpct_tmpb_tl - \exp_args:NV \token_if_eq_meaning:NNTF \l__fnpct_tmpb_tl \l_peek_token + \tl_set_rescan:Nnn \l__fnpct_tmpb_tl {} {##1} + \exp_args:NV + \token_if_eq_meaning:NNTF \l__fnpct_tmpb_tl \l_peek_token { \bool_set_true:N \l__fnpct_multiple_footnotes_bool \prop_map_break: @@ -353,10 +415,8 @@ { \tl_use:N \l__fnpct_multiple_false_tl } } -% \cs_generate_variant:Nn \token_if_eq_meaning:NNTF {V} - % check which mode is active: -\prg_new_conditional:Npnn \fnpct_punct_if_after: { T, TF } +\prg_new_conditional:Npnn \fnpct_punct_if_after: {T,TF} { \bool_if:nTF { @@ -426,7 +486,6 @@ \fnpct_check_multiple:TF { \bool_set_true:N \l__fnpct_multiple_footnotes_bool - % else insert space and then note \fnpct_no_break: \bool_if:NF \g__fnpct_after_punctuation_bool { \skip_horizontal:N \l__fnpct_before_footnote_dim } @@ -446,7 +505,6 @@ #1 \bool_set_false:N \l__fnpct_reverse_switch_bool } - % \bool_gset_false:N \g__fnpct_after_punctuation_bool } } @@ -462,12 +520,12 @@ % and then insert footnote \bool_if:NF \l__fnpct_dont_mess_around_bool { - \IfBooleanT { #5 } + \IfBooleanT {#5} { \bool_set_true:N \l__fnpct_reverse_switch_bool } } \fnpct_handle_punctuation:n { - \fnpct_write_note:Nnnn #1 { #2 } { #3 } { #4 } + \fnpct_write_note:Nnnn #1 {#2} {#3} {#4} \fnpct_write_inner:N #1 } } @@ -475,9 +533,6 @@ % -------------------------------------------------------------------------- % MULTIPLE FOOTNOTES -\seq_new:N \l__fnpct_multiple_footnotes_seq -\cs_generate_variant:Nn \seq_set_split:Nnn { NVn } - % #1: original note command % #2: star % #3: multiple notes separated by \l__fnpct_multiple_footnotes_delimiter_tl @@ -485,20 +540,19 @@ { \bool_if:NF \l__fnpct_dont_mess_around_bool { - \IfBooleanT { #2 } + \IfBooleanT {#2} { \bool_set_true:N \l__fnpct_reverse_switch_bool } } % split input: \seq_set_split:NVn \l__fnpct_multiple_footnotes_seq \l__fnpct_multiple_footnotes_delimiter_tl - { #3 } + {#3} \fnpct_handle_punctuation:n { \fnpct_write_notes:NN #1 \l__fnpct_multiple_footnotes_seq } } -\cs_generate_variant:Nn \fnpct_mult_note:Nnn { cnn } +\cs_generate_variant:Nn \fnpct_mult_note:Nnn {cnn} -\int_new:N \l__fnpct_multiple_notes_int % #1: original note command % #2: sequence variable holding the note arguments \cs_new_protected:Npn \fnpct_write_notes:NN #1#2 @@ -506,7 +560,7 @@ \int_zero:N \l__fnpct_multiple_notes_int \seq_map_inline:Nn #2 { - \__fnpct_read_note_with_option:w ##1 \q_stop { #1 } + \__fnpct_read_note_with_option:w ##1 \q_stop {#1} \int_incr:N \l__fnpct_multiple_notes_int } } @@ -518,7 +572,6 @@ % #3: second optional argument to original note command % #4: mandatory argument to original note command % #5: original note command -\bool_new:N \g__fnpct_only_text_bool \NewDocumentCommand \__fnpct_read_note_with_option:w { soo+u{\q_stop}m } { \bool_if:nT @@ -533,40 +586,36 @@ } } { - \IfBooleanTF { #1 } + \IfBooleanTF {#1} { \tex_unskip:D } { \textsuperscript { \l__fnpct_multiple_footnote_separator_tl } } } - \IfBooleanTF { #1 } + \IfBooleanTF {#1} { % TODO: maybe provide option to change \footnotetext? Or do it % automatically? \bool_gset_true:N \g__fnpct_only_text_bool - \IfNoValueTF { #2 } - { \footnotetext { #4 } } - { \footnotetext [ #2 ] { #4 } } + \IfNoValueTF {#2} + { \footnotetext {#4} } + { \footnotetext [#2] {#4} } } - { \fnpct_write_note:Nnnn #5 { #2 } { #3 } { #4 } } + { \fnpct_write_note:Nnnn #5 {#2} {#3} {#4} } \fnpct_write_inner:N #5 } % -------------------------------------------------------------------------- % NESTED FOOTNOTES: % 1 layer of nesting... -\prop_new:N \g__fnpct_inner_footnote_prop -\prop_new:N \g__fnpct_inner_footnote_hyperref_prop -\cs_generate_variant:Nn \prop_gput:Nnn { Nxn , Nxo } - % this shouldn't be a document command! But for the time being I'll stick to % this easy solution... -\NewDocumentCommand \fnpct_inner_footnote:w { o+m } +\NewDocumentCommand \fnpct_inner_footnote:w {o+m} { - \IfNoValueTF { #1 } + \IfNoValueTF {#1} { % TODO: maybe detect what type of note we're in and use the appropriate mark? % Or provide a user interface to choose the appropriate mark? \fnpct_orig_footnotemark:w - \prop_gput:Nxn \g__fnpct_inner_footnote_prop { \thefootnote } { #2 } + \prop_gput:Nxn \g__fnpct_inner_footnote_prop { \thefootnote } {#2} \bool_if:NT \l__fnpct_hyperref_bool { \prop_gput:Nxo \g__fnpct_inner_footnote_hyperref_prop @@ -574,28 +623,28 @@ } } { - \fnpct_orig_footnotemark:w [ #1 ] - \prop_gput:Nnn \g__fnpct_inner_footnote_prop { #1 } { #2 } + \fnpct_orig_footnotemark:w [#1] + \prop_gput:Nnn \g__fnpct_inner_footnote_prop {#1} {#2} \bool_if:NT \l__fnpct_hyperref_bool { \prop_gput:Nno \g__fnpct_inner_footnote_hyperref_prop - { #1 } { \Hy@footnote@currentHref } + {#1} { \Hy@footnote@currentHref } } } } -\cs_new:Npn \fnpct_write_inner:N #1 +\cs_new_protected:Npn \fnpct_write_inner:N #1 { \token_if_eq_meaning:NNF #1 \fnpct_inner_footnote:w { \prop_map_inline:Nn \g__fnpct_inner_footnote_prop { - \footnotetext [ ##1 ] + \footnotetext [##1] { \bool_if:NT \l__fnpct_hyperref_bool { \prop_get:NnN \g__fnpct_inner_footnote_hyperref_prop - { ##1 } \l__fnpct_tmpa_tl + {##1} \l__fnpct_tmpa_tl \Hy@raisedlink { \exp_args:NV \hyper@@anchor \l__fnpct_tmpa_tl } } @@ -659,11 +708,22 @@ } % -------------------------------------------------------------------------- -% LET'S MAKE IT EASIER TO ADAPT EXISTIUNG FUNCTIONS: -\prop_new:N \g__fnpct_adapted_notes_prop -\cs_generate_variant:Nn \prop_put:Nnn { Nxn } - +% LET'S MAKE IT EASIER TO ADAPT EXISTING FUNCTIONS: % COPY, RENEW AND CREATE MULT + +\prg_new_conditional:Npnn \fnpct_if_adapted:N #1 {p,T,F,TF} + { + \prop_if_in:NnTF \g__fnpct_adapted_notes_prop {#1} + { \prg_return_true: } + { \prg_return_false: } + } + +\cs_new_protected:Npn \fnpct_add_to_adapted:NN #1#2 + { + % \tl_show:n {1:~#1} \tl_show:n {2:~#2} + \prop_gput:Nnn \g__fnpct_adapted_notes_prop {#1} {#2} + } + % standard \footnote[]{} like commands % #1: old new name % #2: internal name of old definition @@ -672,184 +732,232 @@ % \footnote[]{} like: \cs_new_protected:Npn \fnpct_renew_and_mult:NNN #1#2#3 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \fnpct_create_mult_variant:NN #3 #2 - \bool_if:NTF \l__fnpct_multiple_default_bool - { \cs_set_eq:NN #1 #3 } + \fnpct_if_adapted:NF #1 { - \RenewDocumentCommand #1 { so+m } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { \q_no_value } { ##3 } { ##1 } } + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \fnpct_create_mult_variant:NN #3#2 + \bool_if:NTF \l__fnpct_multiple_default_bool + { \cs_set_eq:NN #1#3 } + { + \RenewDocumentCommand #1 {so+m} + { \fnpct_handle_note:Nnnnn #2 {##2} { \q_no_value } {##3} {##1} } + } } } -\cs_generate_variant:Nn \fnpct_renew_and_mult:NNN { ccc , NcN } +\cs_generate_variant:Nn \fnpct_renew_and_mult:NNN {ccc,NcN} % \footnote{} like: \cs_new_protected:Npn \fnpct_renew_and_mult_no_opt:NNN #1#2#3 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \fnpct_create_mult_variant:NN #3 #2 - \bool_if:NTF \l__fnpct_multiple_default_bool - { \cs_set_eq:NN #1 #3 } + \fnpct_if_adapted:NF #1 { - \RenewDocumentCommand #1 { s+m } + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \fnpct_create_mult_variant:NN #3#2 + \bool_if:NTF \l__fnpct_multiple_default_bool + { \cs_set_eq:NN #1#3 } { - \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } - { ##2 } { ##1 } + \RenewDocumentCommand #1 {s+m} + { + \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } + {##2} {##1} + } } } } -\cs_generate_variant:Nn \fnpct_renew_and_mult_no_opt:NNN { Nc, ccc } +\cs_generate_variant:Nn \fnpct_renew_and_mult_no_opt:NNN {Nc,ccc} % renew but don't create mult-variant: % \footnote[]{} like: \cs_new_protected:Npn \fnpct_renew:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \RenewDocumentCommand #1 { so+m } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { \q_no_value } { ##3 } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \RenewDocumentCommand #1 {so+m} + { \fnpct_handle_note:Nnnnn #2 {##2} { \q_no_value } {##3} {##1} } + } } -\cs_generate_variant:Nn \fnpct_renew:NN { cc ,Nc } +\cs_generate_variant:Nn \fnpct_renew:NN {cc,Nc} % new \cs_new_protected:Npn \fnpct_new:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \NewDocumentCommand #1 { so+m } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { \q_no_value } { ##3 } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \NewDocumentCommand #1 {so+m} + { \fnpct_handle_note:Nnnnn #2 {##2} { \q_no_value } {##3} {##1} } + } } -\cs_generate_variant:Nn \fnpct_new:NN { cc , Nc } +\cs_generate_variant:Nn \fnpct_new:NN {cc,Nc} % \note[][]{} like: \cs_new_protected:Npn \fnpct_renew_and_mult_opt:NNN #1#2#3 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \fnpct_create_mult_variant:NN #3 #2 - \bool_if:NTF \l__fnpct_multiple_default_bool - { \cs_set_eq:NN #1 #3 } + \fnpct_if_adapted:NF #1 { - \RenewDocumentCommand #1 { soo+m } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \fnpct_create_mult_variant:NN #3#2 + \bool_if:NTF \l__fnpct_multiple_default_bool + { \cs_set_eq:NN #1#3 } + { + \RenewDocumentCommand #1 {soo+m} + { \fnpct_handle_note:Nnnnn #2 {##2} {##3} {##4} {##1} } + } } } -\cs_generate_variant:Nn \fnpct_renew_and_mult_opt:NNN { ccc , NcN } +\cs_generate_variant:Nn \fnpct_renew_and_mult_opt:NNN {ccc,NcN} \cs_new_protected:Npn \fnpct_renew_opt:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \RenewDocumentCommand #1 { soo+m } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { ##3 } { ##4 } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \RenewDocumentCommand #1 {soo+m} + { \fnpct_handle_note:Nnnnn #2 {##2} {##3} {##4} {##1} } + } } -\cs_generate_variant:Nn \fnpct_renew_opt:NN { cc , Nc } +\cs_generate_variant:Nn \fnpct_renew_opt:NN {cc,Nc} % \note{} like \cs_new_protected:Npn \fnpct_renew_no_opt:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \RenewDocumentCommand #1 { s+m } - { \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } { ##2 } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \RenewDocumentCommand #1 {s+m} + { \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } {##2} {##1} } + } } -\cs_generate_variant:Nn \fnpct_renew_no_opt:NN { cc ,Nc } +\cs_generate_variant:Nn \fnpct_renew_no_opt:NN {cc,Nc} % \note like \cs_new_protected:Npn \fnpct_renew_no_arg:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \RenewDocumentCommand #1 { s } - { \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } { } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \RenewDocumentCommand #1 {s} + { \fnpct_handle_note:Nnnnn #2 { \q_no_value } { \q_no_value } { } {##1} } + } } -\cs_generate_variant:Nn \fnpct_renew_no_arg:NN { cc } +\cs_generate_variant:Nn \fnpct_renew_no_arg:NN {cc} % create mult-variant \cs_new_protected:Npn \fnpct_create_mult_variant:NN #1#2 { - \NewDocumentCommand #1 { s+m } - { \fnpct_mult_note:Nnn #2 { ##1 } { ##2 } } + \NewDocumentCommand #1 {s+m} + { \fnpct_mult_note:Nnn #2 {##1} {##2} } } % \footnotemark[] like commands: \cs_new_protected:Npn \fnpct_renew_mark:NN #1#2 { - \prop_gput:Nxn \g__fnpct_adapted_notes_prop { \cs_to_str:N #2 } { #1 } - \cs_new_eq:NN #2 #1 - \RenewDocumentCommand #1 { so } - { \fnpct_handle_note:Nnnnn #2 { ##2 } { \q_no_value } { } { ##1 } } + \fnpct_if_adapted:NF #1 + { + \fnpct_add_to_adapted:NN #1#2 + \cs_new_eq:NN #2#1 + \RenewDocumentCommand #1 {so} + { \fnpct_handle_note:Nnnnn #2 {##2} { \q_no_value } { } {##1} } + } } -\cs_generate_variant:Nn \fnpct_renew_mark:NN { cc , Nc } +\cs_generate_variant:Nn \fnpct_renew_mark:NN {cc,Nc} % user commands: -\NewDocumentCommand \AdaptNote { mm } +\NewDocumentCommand \AdaptNote {mm} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_and_mult:NcN #1 { fnpct_orig_ \cs_to_str:N #1 :w } #2 } } -\NewDocumentCommand \AdaptNoteNoMult { m } +\NewDocumentCommand \AdaptNoteNoMult {m} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew:Nc #1 { fnpct_orig_ \cs_to_str:N #1 :w } } } -\NewDocumentCommand \AdaptNoteOpt { mm } +\NewDocumentCommand \AdaptNoteOpt {mm} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_and_mult_opt:NcN #1 { fnpct_orig_ \cs_to_str:N #1 :w } #2 } } -\NewDocumentCommand \AdaptNoteOptNoMult { m } +\NewDocumentCommand \AdaptNoteOptNoMult {m} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_opt:Nc #1 { fnpct_orig_ \cs_to_str:N #1 :w } } } -\NewDocumentCommand \AdaptNoteNoOpt { mm } +\NewDocumentCommand \AdaptNoteNoOpt {mm} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_and_mult_no_opt:NcN #1 { fnpct_orig_ \cs_to_str:N #1 :w } #2 } } -\NewDocumentCommand \AdaptNoteNoOptNoMult { m } +\NewDocumentCommand \AdaptNoteNoOptNoMult {m} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1:w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_no_opt:Nc #1 { fnpct_orig_ \cs_to_str:N #1:w } } } -\NewDocumentCommand \AdaptNoteMark { m } +\NewDocumentCommand \AdaptNoteMark {m} { \cs_if_exist:cTF { fnpct_orig_ \cs_to_str:N #1 :w } - { \fnpct_message:nx { already-adapted } { #1 } } + { \fnpct_message:nx {already-adapted} {#1} } { \fnpct_renew_mark:Nc #1 { fnpct_orig_ \cs_to_str:N #1 :w } } } % -------------------------------------------------------------------------- % DO THE REDEFINING: % +% `bigfoot' loads `manyfoot' which saves its footnote classes in a 2e list: +\str_const:Nn \c__fnpct_footins_str {\footins} +\str_remove_once:Nn \c__fnpct_footins_str {~} +\cs_new_protected:Npn \__fnpct_grab_second:Nnw #1#2#3 \q_stop + { + \str_set:Nn \l__fnpct_tmpa_str {#3} + \str_remove_once:Nn \l__fnpct_tmpa_str {~} + \str_remove_once:NV \l__fnpct_tmpa_str \c__fnpct_footins_str + \seq_put_right:Nx #1 { \l__fnpct_tmpa_str } + } + +\cs_new_protected:Npn \__fnpct_get_fnclasses:NN #1#2 + { + \seq_set_split:NnV \l__fnpct_tmpa_seq {\@elt } #1 + \seq_pop_left:NN \l__fnpct_tmpa_seq \l__fnpct_tmpa_tl + \seq_map_inline:Nn \l__fnpct_tmpa_seq + { \__fnpct_grab_second:Nnw #2 ##1 \q_stop } + \seq_remove_duplicates:N #2 + } + % before we start make the testing more comfortable: -\cs_new:Npn \fnpct_treatment:nn #1#2 - { \@ifpackageloaded { #1 } { #2 } { } } -\cs_new:Npn \fnpct_special_treatment:nn #1#2 - { \@ifpackageloaded { #1 } { #2 } { \AfterPackage * { #1 } { #2 } } } +\cs_new_protected:Npn \fnpct_treatment:nn #1#2 + { \fnpct_if_package_loaded:nT {#1} {#2} } + +\cs_new_protected:Npn \fnpct_special_treatment:nn #1#2 + { \fnpct_if_package_loaded:nTF {#1} {#2} { \AfterPackage* {#1} {#2} } } % and now get going: \AtBeginDocument { - \@ifpackageloaded { hyperref } + \fnpct_if_package_loaded:nTF {hyperref} { \bool_set_true:N \l__fnpct_hyperref_bool } { \cs_if_exist:NF \AfterBeginDocument - { \cs_new:Npn \AfterBeginDocument #1 { #1 } } + { \cs_new:Npn \AfterBeginDocument #1 {#1} } } \AfterBeginDocument { @@ -859,48 +967,63 @@ { \AdaptNoteNoOptNoMult \footref } \fnpct_new:NN \innernote \fnpct_inner_footnote:w %% the `endnotes' package: - \fnpct_treatment:nn { endnotes } + \fnpct_treatment:nn {endnotes} { \AdaptNote \endnote \multendnote \AdaptNoteMark \endnotemark } %% the `enotez' package: - \fnpct_treatment:nn { enotez } + \fnpct_treatment:nn {enotez} { \AdaptNote \endnote \multendnote } %% the `snotez' package: - \fnpct_treatment:nn { snotez } + \fnpct_treatment:nn {snotez} { \AdaptNoteOpt \sidenote \multsidenote \AdaptNoteMark \sidenotemark } - %% the `sidenotes' package: - % \fnpct_treatment:nn { sidenotes } - % { - % \AdaptNoteOpt \sidenote \multsidenote - % \AdaptNoteMark \sidenotemark - % } %% the `parnotes' package: - \fnpct_treatment:nn { parnotes } + \fnpct_treatment:nn {parnotes} { \AdaptNote \parnote \multparnote } %% the `pagenote' package: - \fnpct_treatment:nn { pagenote } + \fnpct_treatment:nn {pagenote} { - \bool_if:NT \l__fnpct_makepagenote_bool + \bool_if:NTF \l__fnpct_makepagenote_bool { \AdaptNote \pagenote \multpagenote } + { \msg_warning:nn {fnpct} {pagenote} } } %% the `tablefootnote' package: - \fnpct_treatment:nn { tablefootnote } + \fnpct_treatment:nn {tablefootnote} { \AdaptNote \tablefootnote \multtablefootnote } - %% the `bigfoot' package: - \fnpct_treatment:nn { bigfoot } + %% the `manyfoot' package (also loaded by `bigfoot'): + \fnpct_treatment:nn {manyfoot} { - \prop_map_inline:Nn \l__fnpct_footnote_class_prop + \__fnpct_get_fnclasses:NN \MFL@list \l__fnpct_footnote_class_seq + \seq_map_inline:Nn \l__fnpct_footnote_class_seq { - \fnpct_renew_and_mult:ccc { footnote#2 } - { fnpct_orig_footnote#2:w } { multfootnote#2 } - \fnpct_renew_mark:cc { footnotemark#2 } { fnpct_orig_footnotemark#2:w } + \str_if_eq:nnTF {#1} {default} + { + \cs_if_exist:NT \footnotedefault + { + \fnpct_renew_and_mult:ccc {footnote#1} + {fnpct_orig_footnote#1:w} + {multfootnote#1} + \fnpct_renew_mark:cc {footnotemark#1} + {fnpct_orig_footnotemark#1:w} + } + } + { + \fnpct_renew_and_mult:ccc {footnote#1} + {fnpct_orig_footnote#1:w} + {multfootnote#1} + \fnpct_renew_mark:cc {footnotemark#1} + {fnpct_orig_footnotemark#1:w} + } } - \prop_if_in:NnT \l__fnpct_footnote_class_prop { default } + } + %% the `bigfoot' package: + \fnpct_special_treatment:nn {bigfoot} + { + \cs_if_exist:NT \footnotedefault { % re-set basics: \cs_set_eq:NN \footnote \footnotedefault @@ -909,119 +1032,91 @@ } } %% the `fixfoot' package: - \fnpct_treatment:nn { fixfoot } + \fnpct_treatment:nn {fixfoot} { \prop_map_inline:Nn \l__fnpct_footnote_fixfoot_prop - { \fnpct_renew_no_arg:cc { #2 } { fnpct_orig_fix_#2:w } } + { \fnpct_renew_no_arg:cc {#2} {fnpct_orig_fix_#2:w} } } %% the `sepfootnotes' package: - \fnpct_treatment:nn { sepfootnotes } + \fnpct_treatment:nn {sepfootnotes} { \prop_map_inline:Nn \l__fnpct_sepfootnote_foot_classes_prop { - \fnpct_renew_and_mult_no_opt:ccc { #2note } - { fnpct_orig_sep_#2:w } { #2multnote } - \fnpct_renew_and_mult_no_opt:ccc { #2quicknote } - { fnpct_orig_sep_#2_quick:w } { #2multquicknote } - \fnpct_renew_no_opt:cc { #2notemark } { fnpct_orig_sep_#2_mark:w } + \fnpct_renew_and_mult_no_opt:ccc {#2note} + {fnpct_orig_sep_#2:w} {#2multnote} + \fnpct_renew_and_mult_no_opt:ccc {#2quicknote} + {fnpct_orig_sep_#2_quick:w} {#2multquicknote} + \fnpct_renew_no_opt:cc {#2notemark} {fnpct_orig_sep_#2_mark:w} } \prop_map_inline:Nn \l__fnpct_sepfootnote_end_classes_prop { - \fnpct_renew_and_mult_no_opt:ccc { #2note } - { fnpct_orig_sep_#2:w } { #2multnote } - \fnpct_renew_no_opt:cc { #2notemark } { fnpct_orig_sep_#2_mark:w } + \fnpct_renew_and_mult_no_opt:ccc {#2note} + {fnpct_orig_sep_#2:w} {#2multnote} + \fnpct_renew_no_opt:cc {#2notemark} {fnpct_orig_sep_#2_mark:w} } } } } -% the `bigfoot' package neads special treatment: -\prop_new:N \l__fnpct_footnote_class_prop - -\fnpct_special_treatment:nn { bigfoot } - { - % hook into \DeclareNewFootnote so we can redefine all footnote - % classes defined be users - \cs_new_eq:NN \fnpct_new_footnote:w \DeclareNewFootnote - \RenewDocumentCommand \DeclareNewFootnote { omo } - { - \prop_put:Nnn \l__fnpct_footnote_class_prop { #2 } { #2 } - \IfNoValueTF { #1 } - { - \IfNoValueTF { #3 } - { \fnpct_new_footnote:w { #2 } } - { \fnpct_new_footnote:w { #2 } [ #3 ] } - } - { - \IfNoValueTF { #3 } - { \fnpct_new_footnote:w [ #1 ] { #2 } } - { \fnpct_new_footnote:w [ #1 ] { #2 } [ #3 ] } - } - } - \bool_if:NT \l__fnpct_bigfoot_default_top_bool - { \DeclareNewFootnote { default } } - } - -% as does the `fixfoot' package -\prop_new:N \l__fnpct_footnote_fixfoot_prop +% `bigfoot' package +% \fnpct_special_treatment:nn {fixfoot} +% { +% \bool_if:NT \l__fnpct_bigfoot_default_top_bool +% { \DeclareNewFootnote {default} } +% } -\fnpct_special_treatment:nn { fixfoot } +% `fixfoot' package +\fnpct_special_treatment:nn {fixfoot} { % hook into \DeclareFixedFootnote so we can redefine all footnote % classes defined be users \cs_new_eq:NN \fnpct_new_fixnote:w \DeclareFixedFootnote - \RenewDocumentCommand \DeclareFixedFootnote { smm } + \RenewDocumentCommand \DeclareFixedFootnote {smm} { - \prop_put:Nnx \l__fnpct_footnote_fixfoot_prop { #2 } + \prop_put:Nnx \l__fnpct_footnote_fixfoot_prop {#2} { \cs_to_str:N #2 } - \IfBooleanTF { #1 } - { \fnpct_new_fixnote:w * { #2 } { #3 } } - { \fnpct_new_fixnote:w { #2 } { #3 } } + \IfBooleanTF {#1} + { \fnpct_new_fixnote:w * {#2} {#3} } + { \fnpct_new_fixnote:w {#2} {#3} } } } -% and the `pagenote' package: -\bool_new:N \l__fnpct_makepagenote_bool - -\fnpct_special_treatment:nn { pagenote } +% `pagenote' package: +\fnpct_special_treatment:nn {pagenote} { \tl_put_left:Nn \makepagenote { \bool_set_true:N \l__fnpct_makepagenote_bool } } -% aaand... the `sepfootnotes' package: -\prop_new:N \l__fnpct_sepfootnote_foot_classes_prop -\prop_new:N \l__fnpct_sepfootnote_end_classes_prop -\prop_new:N \l__fnpct_sepfootnote_symbol_classes_prop - -\fnpct_special_treatment:nn { sepfootnotes } +% `sepfootnotes' package: +\fnpct_special_treatment:nn {sepfootnotes} { \cs_new_eq:NN \fnpct_orig_new_footnotes:w \newfootnotes \cs_new_eq:NN \fnpct_orig_new_endnotes:n \newendnotes \cs_new_eq:NN \fnpct_orig_new_symbolnotes:w \newsymbolfootnotes - \RenewDocumentCommand \newfootnotes { sm } + \RenewDocumentCommand \newfootnotes {sm} { - \prop_put:Nnn \l__fnpct_sepfootnote_foot_classes_prop { #2 } { #2 } - \IfBooleanTF { #1 } - { \fnpct_orig_new_footnotes:w * { #2 } } - { \fnpct_orig_new_footnotes:w { #2 } } + \prop_put:Nnn \l__fnpct_sepfootnote_foot_classes_prop {#2} {#2} + \IfBooleanTF {#1} + { \fnpct_orig_new_footnotes:w * {#2} } + { \fnpct_orig_new_footnotes:w {#2} } } - \RenewDocumentCommand \newendnotes { m } + \RenewDocumentCommand \newendnotes {m} { - \prop_put:Nnn \l__fnpct_sepfootnote_end_classes_prop { #1 } { #1 } - \fnpct_orig_new_endnotes:n { #1 } + \prop_put:Nnn \l__fnpct_sepfootnote_end_classes_prop {#1} {#1} + \fnpct_orig_new_endnotes:n {#1} } - \RenewDocumentCommand \newsymbolfootnotes { om } + \RenewDocumentCommand \newsymbolfootnotes {om} { - \prop_put:Nnn \l__fnpct_sepfootnote_symbol_classes_prop { #2 } { #2 } - \IfNoValueTF { #1 } - { \fnpct_orig_new_symbolnotes:w { #2 } } - { \fnpct_orig_new_symbolnotes:w [ #1 ] { #2 } } + \prop_put:Nnn \l__fnpct_sepfootnote_symbol_classes_prop {#2} {#2} + \IfNoValueTF {#1} + { \fnpct_orig_new_symbolnotes:w {#2} } + { \fnpct_orig_new_symbolnotes:w [#1] {#2} } } } % -------------------------------------------------------------------------- -\RequirePackage{translations}[2014/01/10] +\RequirePackage{translations} \AtBeginDocument{ \ifcurrentbaselanguage{French} { @@ -1040,8 +1135,8 @@ % -------------------------------------------------------------------------- % SETUP COMMAND: -\NewDocumentCommand \setfnpct { m } - { \keys_set:nn { fnpct } { #1 } } +\NewDocumentCommand \setfnpct {m} + { \keys_set:nn {fnpct} {#1} } \file_input_stop: @@ -1084,7 +1179,7 @@ 2012/08/27 v0.2f - switched to internal scratch variables 2012/11/14 v0.2g - adapt changes in `sidenotes' package 2013/01/18 v0.2h - bug fixed: \l__fnpct_multiple_footnote_separator_tl - should be { , } when `memoir' is loaded + should be {,} when `memoir' is loaded 2013/01/21 v0.2i - adapted to changes of sepfootnotes, bug fix in reading of multiple notes 2013/02/22 v0.2j - adaption of `enotez' \endnote command @@ -1114,6 +1209,9 @@ 2016/03/25 v0.4e - fix for issue #9 2019/02/17 v0.4f - fix for issues #13 and #19 2019/09/30 v0.4g - update for expl3 deprecations +2019/10/05 v0.5 - fix issue 18 + - remove option `bigfoot-default-top' + - support `manyfoot' package % -------------------------------------------------------------------------- % NOTES: diff --git a/macros/latex/contrib/fnpct/fnpct_en.pdf b/macros/latex/contrib/fnpct/fnpct_en.pdf index 4eb46d4e93..7ce6a35d4a 100644 Binary files a/macros/latex/contrib/fnpct/fnpct_en.pdf and b/macros/latex/contrib/fnpct/fnpct_en.pdf differ diff --git a/macros/latex/contrib/fnpct/fnpct_en.tex b/macros/latex/contrib/fnpct/fnpct_en.tex index 8eff9ac028..e84a68f15e 100644 --- a/macros/latex/contrib/fnpct/fnpct_en.tex +++ b/macros/latex/contrib/fnpct/fnpct_en.tex @@ -12,7 +12,7 @@ % Web: https://bitbucket.org/cgnieder/fnpct/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012-2019 Clemens Niederberger +% Copyright 2012--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -266,6 +266,13 @@ Package \pkg{babel}'s~\cite{pkg:babel} French settings redefine \cs*{@footnotemark}. \fnpct\ resets this redefinition but sets the \option{before-footnote-space} equal to a thin space (\code{.16667em}). +\subsection{Changes in v0.5}\label{ssec:news} + +\begin{itemize} + \item the option \option{bigfoot-default-top} has been removed + \item the \pkg{manyfoot} package is now supported +\end{itemize} + \section{Options}\label{sec:options} Most package options are listed below. They all can be set as a package option or with the \cs{setfnpct} command. Most of them are for adjusting the @@ -650,21 +657,19 @@ packages\footnote{If you find some package missing please let me know.}. Each of the following subsections is dedicated to one of these packages and if and how they work together with \fnpct. Fortunately most of them do quite well. -\subsection{bigfoot}\label{ssec:bigfoot} +\subsection{bigfoot and manyfoot}\label{ssec:bigfoot} The \pkg{bigfoot}~\cite{pkg:bigfoot} package extends the possibilities of the \pkg{manyfoot} package~\cite{pkg:manyfoot} (see section~\ref{ssec:manyfoot}). The main visible feature is to use different classes of footnotes which are typeset in different apparatus on the bottom of the page. -\fnpct\ is compatible with \pkg{bigfoot}. You need to be a bit cautious, -though. You need to \emph{declare footnotes with \cs*{DeclareNewFootnote} - \emph{after} loading \fnpct\ but in the document \emph{preamble}.} +\fnpct\ is compatible with \pkg{bigfoot}. -\emph{Also verbatim material won't work inside footnotes anymore}. But you -can of course use \lefloch's \pkg{cprotect}~\cite{pkg:cprotect} if you really -need verbatim material in footnotes \emph{and} want to use \fnpct. Since -\fnpct\ does not redefine any \cs{footnotetext} like command it will still -work inside one of them. +You need to be a bit cautious, though: \emph{verbatim material won't work + inside footnotes anymore}. You can of course use \lefloch's +\pkg{cprotect}~\cite{pkg:cprotect} if you really need verbatim material in +footnotes \emph{and} want to use \fnpct. Since \fnpct\ does not redefine any +\cs{footnotetext} like command it will still work inside one of them. For every footnote class defined with \cs*{DeclareNewFootnote} the commands \cs*{footnote\meta{class}} and \cs*{footnotemark\meta{class}} are redefined @@ -672,13 +677,6 @@ with the starred variant and a \cs*{multfootnote\meta{class}} is defined. The \option{multiple} option will turn all \cs*{footnote\meta{class}} commands into the corresponding \cs*{multfootnote\meta{class}}. -\fnpct\ has an additional package option which \emph{cannot} be set with -\cs{setfnpct} and only has any effects if \pkg{bigfoot} has been loaded: -\begin{options} - \keybool{bigfoot-default-top}\Default{false} - Sets the \code{default} footnote class as top layer. -\end{options} - Since this document cannot easily combine \emph{every} footnote package at the same time for demonstration purposes the following code is shown in figure~\ref{fig:bigfoot}: @@ -691,8 +689,9 @@ figure~\ref{fig:bigfoot}: bottom=1.5cm]{geometry} \usepackage{bigfoot} - \usepackage[bigfoot-default-top]{fnpct} + \usepackage{fnpct} \setfnpct{multiple} + \DeclareNewFootnote{default} \DeclareNewFootnote[para]{B}[alph] \begin{document} @@ -795,7 +794,7 @@ figure~\ref{fig:fixfoot}: \end{document} \end{example} -\subsection{footmisc}\label{ssec:manyfoot} +\subsection{footmisc}\label{ssec:footmisc} The \pkg{footmisc} package~\cite{pkg:footmisc} provides a range of options to customize footnotes, for example output them as margin notes or count footnotes per page. @@ -803,34 +802,24 @@ footnotes per page. Testing showed no incompatibilities with \pkg{footmisc}. The only thing is that you won't have to (and shouldn't) use its \option{multiple} option. -\subsection{footnote} +\subsection{footnote}\label{ssec:footnote} Unfortunately \fnpct\ is not compatible with the \pkg{footnote} package~\cite{pkg:footnote}. Or more precisely it is not compatible if the command pair \cs*{savenotes}/\cs*{spewnotes} is invoked. This disables \pkg{footnote}'s environments as well as its environment escaping mechanism through \cs{makesavenoteenv}. -\subsection{manyfoot} -The \pkg{manyfoot} package~\cite{pkg:manyfoot} is not and will not directly be -supported. It is loaded by \pkg{bigfoot} (see section~\ref{ssec:bigfoot}), anyway. -And since the latter states in its documentation -\begin{cnltxquote}[David Kastrup~\textup{\cite{pkg:bigfoot}}] - Purpose of this package is to provide a one-stop solution to almost all - problems related to footnotes. You can use it as a drop-in replacement of - the `\pkg{manyfoot}' package, but without many of its shortcomings, and - quite a few features of its own. -\end{cnltxquote} -you should probably prefer it anyway. - -If it is \emph{really} wanted by users I might change my opinion, though \ldots +\subsection{manyfoot}\label{ssec:manyfoot} +The package \pkg{manyfoot}~\cite{pkg:manyfoot} is supported. See +section~\ref{ssec:bigfoot} for more details. -\subsection{pagenote} +\subsection{pagenote}\label{ssec:pagenote} The package \pkg{pagenote}~\cite{pkg:pagenote} is supported and its \cs*{pagenote} command is treated the same way as all other note commands: it got an optional \sarg\ argument and an additional \cs*{multpagenote} is defined. -\subsection{parnotes} +\subsection{parnotes}\label{ssec:parnotes} The function of the package \pkg{parnotes}~\cite{pkg:parnotes} is similar to the \pkg{endnotes} package. basically it allows to output the footnote text after a paragraph, either by using a special environment or by invoking @@ -861,7 +850,7 @@ Again the \option{multiple} option turns all \cs*{parnote}s into \end{minipage} \end{example} -\subsection{sepfootnotes} +\subsection{sepfootnotes}\label{ssec:sepfootnotes} \fnpct\ supports the \pkg{sepfootnotes} package~\cite{pkg:sepfootnotes}. Each note type you have created with with one of the commands \begin{description} @@ -889,28 +878,57 @@ loading \fnpct. \end{minipage} \end{example} -% \subsection{sidenotes} -% The package \pkg{sidenotes}~\cite{pkg:sidenotes} is supported and its commands -% \cs*{sidenote} and \cs*{sidenotemark} are treated the same way as footnotes: -% they got an optional \sarg\ argument and the additional \cs*{multsidenote} is -% created. The option \option{multiple} turns all note commands into their -% mult-variant. +\subsection{sidenotes}\label{ssec:sidenotes} +The package \pkg{sidenotes}~\cite{pkg:sidenotes} is \emph{not} supported. +For the time being users can use the following code\footnote{Since the code + depends on the implementation of \pkg{sidenotes} this may break with each + update of \pkg{sidenotes}.;Thanks to Marijn van Vliet for + providing it!}: +\begin{sourcecode} + \ExplSyntaxOn + \makeatletter + \NewDocumentCommand \origsidenotemark {o} + { + \@sidenotes@multichecker + \IfNoValueOrEmptyTF {#1} + { \@sidenotes@thesidenotemark { \thesidenote } } + { \@sidenotes@thesidenotemark {#1} } + \@sidenotes@multimarker + } + + \NewDocumentCommand \origsidenote {oo+m} + { + \origsidenotemark [#1] + \sidenotetext [#1] [#2] {#3} + \@sidenotes@multimarker + } + + \fnpct_create_mult_variant:NN \multsidenote \origsidenote + + \RenewDocumentCommand \sidenote {soo+m} + { \fnpct_handle_note:Nnnnn \origsidenote {#2} {#3} {#4} {#1} } + + \RenewDocumentCommand \sidenotemark {so} + { \fnpct_handle_note:Nnnnn \origsidenotemark {#2} { \q_no_value } { } {#1} } + \makeatother + \ExplSyntaxOff +\end{sourcecode} -\subsection{snotez} +\subsection{snotez}\label{ssec:snotez} The package \pkg{snotez}~\cite{pkg:snotez} is supported and its commands \cs*{sidenote} and \cs*{sidenotemark} are treated the same way as footnotes: they got an optional \sarg\ argument and the additional \cs*{multsidenote} is created. The option \option{multiple} turns all note commands into their mult-variant. -\subsection{tablefootnote} +\subsection{tablefootnote}\label{ssec:tablefootnote} The package \pkg{tablefootnote}~\cite{pkg:tablefootnote} is supported and its \cs*{tablefootnote} command is treated the same way as all other note commands: it got an optional \sarg\ argument and an additional \cs*{multtablefootnote} is defined. The option \option{multiple} turns all note commands into their mult-variant. -\subsection{yafoot} +\subsection{yafoot}\label{ssec:yafoot} Currently no issues are known when using \fnpct\ with one or all of the packages of the \bnd{yafoot}~\cite{bnd:yafoot} bundle. Just for reference: these packages are \pkg*{pfnote}, \pkg*{fnpos} and \pkg*{dblfnote}. -- cgit v1.2.3