diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-01 23:35:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-01 23:35:46 +0000 |
commit | 763d037a12b5dd4d6bc9dcf92c049a55839b6ffd (patch) | |
tree | c0b19388a241a6e8118438bacbee60a7ab4ac3e8 /Master/texmf-dist/tex/latex | |
parent | 563bcfa06168849da809214cc1af73c6e6c5f36a (diff) |
enotez (1may13)
git-svn-id: svn://tug.org/texlive/trunk@30200 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/enotez/enotez.sty | 243 |
1 files changed, 175 insertions, 68 deletions
diff --git a/Master/texmf-dist/tex/latex/enotez/enotez.sty b/Master/texmf-dist/tex/latex/enotez/enotez.sty index 07a6666c1fa..f3bcac7068e 100644 --- a/Master/texmf-dist/tex/latex/enotez/enotez.sty +++ b/Master/texmf-dist/tex/latex/enotez/enotez.sty @@ -31,11 +31,25 @@ \RequirePackage{ expl3 , xparse , l3keys2e , xtemplate , etoolbox , xpatch , scrlfile } \ProvidesExplPackage {enotez} - {2013/04/06} - {0.6} + {2013/05/01} + {0.7} {Endnotes for LaTeX2e} % -------------------------------------------------------------------------- +% check expl3 version: +\@ifpackagelater { expl3 } { 2012/11/21 } + { } + { + \PackageError { enotez } { Support~package~expl3~too~old } + { + You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~ + 'l3packages'.\MessageBreak + Loading~enotez~will~abort! + } + \tex_endinput:D + } + +% -------------------------------------------------------------------------- % messages \msg_new:nnnn { enotez } { captions } { Endnotes~might~not~work~in~captions. } @@ -45,6 +59,24 @@ will~work~then. } + +\msg_new:nnnn { enotez } { deprecated } + { The~#1~`#2'~is~deprecated.~Use~`#3'~instead~\msg_line_context:. } + { + The~#1~`#2'~you~used~\msg_line_context: \c_space_tl is~deprecated~and~has~ + been~replaced~by~`#3'.~Since~I~will~not~guarantee~that~#1~will~be~kept~ + forever~I~encourage~you~to~switch. + } + +\cs_new:Npn \enotez_option_deprecated:nn #1#2 + { \msg_warning:nnnnn { enotez } { deprecated } { option } { #1 } { #2 } } + +\cs_new:Npn \acro_command_deprecated:NN #1#2 + { + \msg_warning:nnnnn { enotez } { deprecated } { command } + { \token_to_str:N #1 } { \token_to_str:N #2 } + } + % -------------------------------------------------------------------------- % variables: \bool_new:N \l__enotez_print_note_bool @@ -52,6 +84,7 @@ \bool_new:N \l__enotez_totoc_bool \bool_new:N \l__enotez_hyperref_bool \bool_new:N \l__enotez_hyperfootnotes_bool +\bool_new:N \l__enotez_hyperbackref_bool \bool_new:N \l__enotez_split_bool \bool_new:N \l__enotez_caption_patched_bool \bool_new:N \l__enotez_koma_patched_bool @@ -81,6 +114,8 @@ \tl_new:N \g__enotez_list_every_preamble_tl \tl_new:N \g__enotez_list_next_postamble_tl \tl_new:N \g__enotez_list_every_postamble_tl +\tl_new:N \g__enotez_split_list_preamble_tl +\tl_new:N \g__enotez_split_list_postamble_tl \tl_new:N \l__enotez_footnotes_tl \skip_new:N \l__enotez_list_preamble_skip @@ -109,6 +144,7 @@ \keys_define:nn { enotez } { + backref .bool_set:N = \l__enotez_hyperbackref_bool , footnotes .bool_set:N = \l__enotez_footnotes_tl , list-name .tl_set:N = \l__enotez_list_name_tl , reset .bool_set:N = \l__enotez_reset_bool , @@ -117,10 +153,8 @@ \cs_set_eq:Nc \enotez_counter_format:n { int_to_ \l_keys_choice_tl :n } , counter-format .generate_choices:n = { arabic , alph , Alph , roman , Roman } , - mark-format .code:n = - \cs_set:Npn \enmarkstyle { #1 } , - mark-cs .code:n = - \cs_set:Npn \enotezwritemark { #1 } , + mark-format .code:n = \cs_set:Npn \enmarkstyle { #1 } , + mark-cs .code:n = \cs_set:Npn \enotezwritemark { #1 } , totoc .choice_code:n = \tl_if_eq:VnTF \l_keys_choice_tl { false } { \bool_set_false:N \l__enotez_totoc_bool } @@ -128,16 +162,20 @@ \bool_set_true:N \l__enotez_totoc_bool \tl_set_eq:NN \l__enotez_totoc_tl \l_keys_choice_tl } , - totoc .generate_choices:n = - { section , chapter , false } , + totoc .generate_choices:n = { section , chapter , false } , + list-heading .code:n = + \cs_set:Npn \enotezlistheading ##1 { #1 } , split .choice_code:n = \tl_if_eq:VnTF \l_keys_choice_tl { false } { \bool_set_false:N \l__enotez_split_bool } { \bool_set_true:N \l__enotez_split_bool } \tl_set_eq:NN \l__enotez_split_tl \l_keys_choice_tl , - split .generate_choices:n = - { section , chapter , false } , - split-sectioning .tl_set:N = \l__enotez_splitted_list_sectioning_tl , + split .generate_choices:n = { section , chapter , false } , + split-sectioning .code:n = + \enotez_option_deprecated:nn { split-sectioning } { split-heading } + \l__enotez_splitted_list_sectioning_tl , + split-heading .code:n = + \cs_set:Npn \enotezsplitlistheading ##1 { #1 } , split-title .tl_set:N = \l__enotez_splitted_title_tl , list-style .tl_set:N = \l__enotez_list_instance_tl , list-preamble-skip .skip_set:N = \l__enotez_list_preamble_skip , @@ -153,7 +191,14 @@ \cs_new:Npn \enotez_write_mark:nn #1#2 { \bool_if:NTF \l__enotez_hyperfootnotes_bool - { \enotezwritemark { \hyperlink { enz.#1 } { \enmarkstyle #2 } } } + { + \enotezwritemark { \hyperlink { enz.#1 } { \enmarkstyle #2 } } + \bool_if:NT \l__enotez_hyperbackref_bool + { + \box_move_up:nn { 1em } + { \hbox:n { \hypertarget { enz.#1.backref } { } } } + } + } { \enotezwritemark { \enmarkstyle #2 } } } @@ -362,11 +407,18 @@ % -------------------------------------------------------------------------- % the list of notes +\cs_if_exist:cTF { chapter } + { \cs_new:Npn \enotezlistheading { \chapter* } } + { \cs_new:Npn \enotezlistheading { \section* } } + +\cs_new:Npn \enotezsplitlistheading + { \use:c { \l__enotez_splitted_list_sectioning_tl } } + \DeclareObjectType { enotez-list } { 1 } \DeclareTemplateInterface { enotez-list } { paragraph } { 1 } { - heading : function 1 = \section*{#1} , + heading : function 1 = \enotezlistheading{#1} , format : tokenlist = \footnotesize , number : function 1 = \enmark{#1} , number-format : tokenlist = \normalfont , @@ -390,8 +442,6 @@ } \enotez_list_heading:n { \l__enotez_list_name_tl } \enotez_list_preamble: - \group_begin: - \tl_use:N \l__enotez_list_format_tl \int_zero:N \l__enotez_tmpa_int \int_do_while:nn { \l__enotez_tmpa_int <= \g__enotez_list_printed_int } { @@ -406,24 +456,16 @@ \bool_if:NT \l__enotez_print_note_bool { \par\noindent + \group_begin: + \tl_use:N \l__enotez_list_format_tl \llap { \enotez_list_number:n - { - \bool_if:NT \l__enotez_hyperfootnotes_bool - { - \box_move_up:nn { 1em } - { \hbox:n { \hypertarget { enz.##1 } { } } } - } - \tl_use:N \l__enotez_list_number_format_tl - \tl_if_eq:nxTF { a } - { \prop_get:Nn \g__enotez_endnote_man_prop { ##1 } } - { \enotez_counter_format:V \l__enotez_endnote_mark_tl } - { \tl_use:N \l__enotez_endnote_mark_tl } - } + { \enotez_write_list_number:n { ##1 } } \tl_use:N \c_space_tl } \tl_use:N \l__enotez_endnote_text_tl + \group_end: } } \par @@ -432,13 +474,12 @@ } \int_incr:N \l__enotez_tmpa_int } - \group_end: \enotez_list_postamble: } \DeclareTemplateInterface { enotez-list } { list } { 1 } { - heading : function 1 = \section*{#1} , + heading : function 1 = \enotezlistheading{#1} , format : tokenlist = \footnotesize , number : function 1 = \enmark{#1} , number-format : tokenlist = \normalfont , @@ -462,8 +503,6 @@ } \enotez_list_heading:n { \l__enotez_list_name_tl } \enotez_list_preamble: - \group_begin: - \tl_use:N \l__enotez_list_format_tl \int_zero:N \l__enotez_tmpa_int \int_do_while:nn { \l__enotez_tmpa_int <= \g__enotez_list_printed_int } { @@ -477,7 +516,9 @@ \tl_if_blank:VF \l__enotez_tmpc_tl { \enotez_get_split_title:n { ##1 } - \begin{\l__enotez_list_type_tl} + \group_begin: + \tl_use:N \l__enotez_list_format_tl + \begin{\l__enotez_list_type_tl} } \tl_if_eq:xxT { \int_use:N \l__enotez_tmpa_int } @@ -489,27 +530,16 @@ \item [ \enotez_list_number:n - { - \bool_if:NT \l__enotez_hyperfootnotes_bool - { - \box_move_up:nn { 1em } - { \hbox:n { \hypertarget { enz.##1 } { } } } - } - \tl_use:N \l__enotez_list_number_format_tl - \tl_if_eq:nxTF { a } - { \prop_get:Nn \g__enotez_endnote_man_prop { ##1 } } - { \enotez_counter_format:V \l__enotez_endnote_mark_tl } - { \tl_use:N \l__enotez_endnote_mark_tl } - } + { \enotez_write_list_number:n { ##1 } } ] \tl_use:N \l__enotez_endnote_text_tl } } - \tl_if_blank:VF \l__enotez_tmpc_tl { \end{\l__enotez_list_type_tl} } + \tl_if_blank:VF \l__enotez_tmpc_tl + { \end{\l__enotez_list_type_tl} \group_end: } } \int_incr:N \l__enotez_tmpa_int } - \group_end: \enotez_list_postamble: } @@ -518,25 +548,38 @@ \DeclareInstance { enotez-list } { description } { list } { } \DeclareInstance { enotez-list } { itemize } { list } { list-type = itemize } -% the titles in between the splits: -\cs_new_protected:Npn \enotez_read_splitted_title:nn #1#2 +% -------------------------------------------------------------------------- +% write the mark in the lists: +\cs_new_protected:Npn \enotez_write_list_number:n #1 { - \group_begin: - \tl_set:Nn \l__enotez_tmpa_tl { #1 } - \tl_replace_all:Nnx \l__enotez_tmpa_tl { <name> } - { \l__enotez_actual_sectioning_tl } - \tl_replace_all:Nnx \l__enotez_tmpa_tl { <ref> } - { \prop_get:Nn \g__enotez_endnote_sect_prop { #2 } } - \tl_gset_eq:NN \l__enotez_tmpb_tl \l__enotez_tmpa_tl - \group_end: + \bool_if:NT \l__enotez_hyperfootnotes_bool + { \box_move_up:nn { 1em } { \hbox:n { \hypertarget { enz.#1 } { } } } } + \tl_use:N \l__enotez_list_number_format_tl + \tl_if_eq:nxTF { a } + { \prop_get:Nn \g__enotez_endnote_man_prop { #1 } } + { + \bool_if:nTF + { \l__enotez_hyperfootnotes_bool && \l__enotez_hyperbackref_bool } + { + \exp_args:Nnx + \hyperlink { enz.#1.backref } + { \enotez_counter_format:V \l__enotez_endnote_mark_tl } + } + { \enotez_counter_format:V \l__enotez_endnote_mark_tl } + } + { + \bool_if:nTF + { \l__enotez_hyperfootnotes_bool && \l__enotez_hyperbackref_bool } + { + \exp_args:Nnx + \hyperlink { enz.#1.backref } + { \tl_use:N \l__enotez_endnote_mark_tl } + } + { \tl_use:N \l__enotez_endnote_mark_tl } + } } -\cs_generate_variant:Nn \enotez_read_splitted_title:nn { V , x } -\cs_generate_variant:Nn \tl_replace_all:Nnn { Nnx } - -\cs_new_protected:Npn \enotez_first_upper:n #1 - { \tl_to_uppercase:n { \tl_head:n { #1 } } \tl_tail:n { #1 } } -\cs_generate_variant:Nn \enotez_first_upper:n { V } +% -------------------------------------------------------------------------- % determine which note's next: \cs_new_protected:Npn \enotez_get_note:nn #1#2 { @@ -567,6 +610,26 @@ } } +% -------------------------------------------------------------------------- +% the titles in between the splits: +\cs_new_protected:Npn \enotez_read_splitted_title:nn #1#2 + { + \group_begin: + \tl_set:Nn \l__enotez_tmpa_tl { #1 } + \tl_replace_all:Nnx \l__enotez_tmpa_tl { <name> } + { \l__enotez_actual_sectioning_tl } + \tl_replace_all:Nnx \l__enotez_tmpa_tl { <ref> } + { \prop_get:Nn \g__enotez_endnote_sect_prop { #2 } } + \tl_gset_eq:NN \l__enotez_tmpb_tl \l__enotez_tmpa_tl + \group_end: + } +\cs_generate_variant:Nn \enotez_read_splitted_title:nn { V , x } +\cs_generate_variant:Nn \tl_replace_all:Nnn { Nnx } + +\cs_new_protected:Npn \enotez_first_upper:n #1 + { \tl_to_uppercase:n { \tl_head:n { #1 } } \tl_tail:n { #1 } } +\cs_generate_variant:Nn \enotez_first_upper:n { V } + \cs_new_protected:Npn \enotez_get_split_title:n #1 { \prop_get:NnN \g__enotez_endnote_split_prop { #1 } \l__enotez_tmpa_tl @@ -580,19 +643,23 @@ \enotez_read_splitted_title:xn { \l__enotez_splitted_title_tl } { #1 } + \cs_set_eq:NN \EnotezCurrentSplitTitle \l__enotez_tmpb_tl + \enotez_split_list_preamble: \tl_if_blank:VTF \l__enotez_splitted_list_sectioning_tl { \tl_if_eq:VnTF \l__enotez_split_tl { section } { \subsection* } { \section* } } - { \use:c { \l__enotez_splitted_list_sectioning_tl } } - { \exp_not:V \l__enotez_tmpb_tl } + { \enotezsplitlistheading } + { \exp_not:V \EnotezCurrentSplitTitle }% this is the argument to the sectioning command + \enotez_split_list_postamble: } } \prop_get:NnN \g__enotez_endnote_split_prop { #1 } \l__enotez_tmpb_tl } +% -------------------------------------------------------------------------- % the marks in the list: \cs_new:Npn \enmark #1 { #1 . } @@ -600,6 +667,7 @@ \cs_new:Npn \enmarkstyle { } \cs_new_eq:NN \enotezwritemark \textsuperscript +% -------------------------------------------------------------------------- % internal printendnotes: \cs_new_protected:Npn \enotez_print_endnotes:nn #1#2 { @@ -675,19 +743,53 @@ \cs_new_protected:Npn \enotez_set_every_postamble:n #1 { \tl_gset:Nn \g__enotez_list_every_postamble_tl { #1 } } -\NewDocumentCommand \AtNextEndnotesList { m } +\NewDocumentCommand \AtNextEndnotesList { +m } { \enotez_set_next_preamble:n { #1 } } -\NewDocumentCommand \AtEveryEndnotesList { m } +\NewDocumentCommand \AtEveryEndnotesList { +m } { \enotez_set_every_preamble:n { #1 } } -\NewDocumentCommand \AfterNextEndnotesList { m } +\NewDocumentCommand \AfterNextEndnotesList { +m } { \enotez_set_next_postamble:n { #1 } } -\NewDocumentCommand \AfterEveryEndnotesList { m } +\NewDocumentCommand \AfterEveryEndnotesList { +m } { \enotez_set_every_postamble:n { #1 } } % -------------------------------------------------------------------------- +% preamble and postamble to the sub-headings in a splitted list: +\cs_new_protected:Npn \enotez_split_list_preamble: + { + \tl_if_empty:NF \g__enotez_split_list_preamble_tl + { + \par + \tl_use:N \g__enotez_split_list_preamble_tl + } + } + +\cs_new_protected:Npn \enotez_split_list_postamble: + { + \tl_if_empty:NF \g__enotez_split_list_postamble_tl + { + \tl_use:N \g__enotez_split_list_postamble_tl + \par + } + } + +\cs_new_protected:Npn \enotez_set_every_split_preamble:n #1 + { \tl_gset:Nn \g__enotez_split_list_preamble_tl { #1 } } + +\cs_new_protected:Npn \enotez_set_every_split_postamble:n #1 + { \tl_gset:Nn \g__enotez_split_list_postamble_tl { #1 } } + +\NewDocumentCommand \AtEveryListSplit { +m } + { \enotez_set_every_split_preamble:n { #1 } } + +\NewDocumentCommand \AfterEveryListSplit { +m } + { \enotez_set_every_split_postamble:n { #1 } } + +\cs_new:Npn \EnotezCurrentSplitTitle {} + +% -------------------------------------------------------------------------- % process the options: \ProcessKeysOptions { enotez } @@ -809,6 +911,11 @@ 2013/03/18 v0.5a - adapt to deprecated expl3 commands 2013/04/06 v0.6 - \endnote sets \@currentlabel so endnotes can be referenced with \label{} and \ref{} +2013/05/01 v0.7 - new option `backref' adds links from the notes in the list + back to the notes in the text (needs `hyperref' loaded) + - new: \AtEveryListSplit, \AfterEveryListSplit, + \EnotezCurrentSplitTitle + - new option: `list-heading' % -------------------------------------------------------------------------- % TODO: |