diff options
author | Karl Berry <karl@freefriends.org> | 2021-12-20 21:30:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-12-20 21:30:15 +0000 |
commit | 10c0448f0a37bb0c9aad482c365e8410c572af51 (patch) | |
tree | 279a6d2d8bf46fb68f8f37179ccbc514fd4c6fcb /Master/texmf-dist/source | |
parent | 2bf0542d3eca03870bf292349c0eca5469d69ae6 (diff) |
knowledge (20dec21)
git-svn-id: svn://tug.org/texlive/trunk@61356 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx | 574 |
1 files changed, 435 insertions, 139 deletions
diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx index 8c5c6aeb43c..3b9b18e8a2c 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx @@ -23,7 +23,7 @@ % % \iffalse %<head>\usepackage{expl3} -%<head>\ProvidesExplPackage{knowledge}{2021/03/31}{1.25}{} +%<head>\ProvidesExplPackage{knowledge}{2021/12/20}{1.26}{} %<*driver> \def\knowledgecode{active} \input{knowledge.tex} @@ -58,6 +58,7 @@ % \changes{1.23}{2020/04/25}{minor change} % % \changes{1.24}{2020/09/22}{silent option} % % \changes{1.25}{2021/03/31}{bug correction} % +% \changes{1.26}{2021/12/20}{enhanced math+other functionalities+extra options} % % \GetFileInfo{knowledge.sty} % % \DoNotIndex{} % @@ -77,8 +78,8 @@ This directory contains the package name: knowledge license: LaTeX Project Public License version 1.2 or above - version: v1.25 - date: 2021/03/31 + version: v1.26 + date: 2021/12/20 author: Thomas Colcombet mail: thomas.colcombet@irif.fr web: https://www.irif.fr/~colcombe/knowledge_en.html @@ -198,7 +199,7 @@ This directory contains the package \cs_new:Nn\knowledge_info:n {\msg_info:nnn{knowledge}{knowledge~info}{#1}} \cs_new:Nn\knowledge_warning:n{ - \msg_warning:nnn{knowledge}{knowledge~warning}{#1} + \msg_warning:nnn{knowledge}{knowledge~warning}{#1} } \cs_new:Nn\knowledge_error:n {\msg_error:nnn{knowledge}{knowledge~error}{#1}} @@ -221,25 +222,25 @@ This directory contains the package % % \begin{macrocode} \cs_new:Npn\knowledge_warning:nn{ - \bool_if:NTF\knowledge_warningsilent_bool - \use_none:nn - \msg_warning:nn + \bool_if:NTF\knowledge_warningsilent_bool + \use_none:nn + \msg_warning:nn } \cs_new:Npn\knowledge_warning:nnn{ - \bool_if:NTF\knowledge_warningsilent_bool - \use_none:nnn - \msg_warning:nnn + \bool_if:NTF\knowledge_warningsilent_bool + \use_none:nnn + \msg_warning:nnn } \cs_new:Npn\knowledge_warning:nnnn{ - \bool_if:NTF\knowledge_warningsilent_bool - \use_none:nnnn - \msg_warning:nnnn + \bool_if:NTF\knowledge_warningsilent_bool + \use_none:nnnn + \msg_warning:nnnn } \cs_generate_variant:Nn\knowledge_warning:nnnn{nnxx} \cs_new:Npn\knowledge_warning:nnnnn{ - \bool_if:NTF\knowledge_warningsilent_bool - \use_none:nnnnn - \msg_warning:nnnnn + \bool_if:NTF\knowledge_warningsilent_bool + \use_none:nnnnn + \msg_warning:nnnnn } \cs_generate_variant:Nn\knowledge_warning:nnnnn{nnxxx} % \end{macrocode} @@ -539,10 +540,70 @@ This directory contains the package % % % \begin{macrocode} +\tl_new:N\knowledge_option_anchor_point_color_tl +\tl_set:Nn\knowledge_option_anchor_point_color_tl{red} +\KnowledgeConfigureTrigger{anchor~point~color} + {\tl_set:Nn\knowledge_option_anchor_point_color_tl{#1}} +\KnowledgeConfigureTrigger{AP~color} + {\tl_set:Nn\knowledge_option_anchor_point_color_tl{#1}} +\tl_new:N\knowledge_option_anchor_point_shift_tl +\tl_set:Nn\knowledge_option_anchor_point_shift_tl{(0,0)} +\KnowledgeConfigureTrigger{anchor~point~shift} + {\tl_set:Nn\knowledge_option_anchor_point_shift_tl{(#1)}} +\KnowledgeConfigureTrigger{AP~shift} + {\tl_set:Nn\knowledge_option_anchor_point_shift_tl{(#1)}} + +\cs_new:Nn\knowledge_anchor_point_corner:n{\line(0,-1){#1}\line(1,0){#1}} +\cs_new:Nn\knowledge_anchor_point_cross:n{ + \put(0,0){\line(0,-1){#1}}\put(0,0){\line(0,1){#1}}\put(0,0){\line(-1,0){#1}}\put(0,0){\line(1,0){#1}}} +\tl_new:N\knowledge_option_anchor_point_shape_tl +\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_corner:n{0.2}} + +\tl_const:Nn\knowledge_APshape_name_corner_tl{corner} +\tl_const:Nn\knowledge_APshape_name_tinycorner_tl{tiny~corner} +\tl_const:Nn\knowledge_APshape_name_smallcorner_tl{small~corner} +\tl_const:Nn\knowledge_APshape_name_largecorner_tl{large~corner} +\tl_const:Nn\knowledge_APshape_name_cross_tl{cross} +\tl_const:Nn\knowledge_APshape_name_tinycross_tl{tiny~cross} +\tl_const:Nn\knowledge_APshape_name_smallcross_tl{small~cross} +\tl_const:Nn\knowledge_APshape_name_largecross_tl{large~cross} + +\KnowledgeConfigureTrigger{AP~shape} + {\knowledge_set_anchor_point_shape:n{#1}} +\KnowledgeConfigureTrigger{anchor~point~shape} + {\knowledge_set_anchor_point_shape:n{#1}} +\cs_new:Nn \knowledge_set_anchor_point_shape:n{ + \tl_set:Nn\l_tmpa_tl{#1} + \tl_case:NnTF\l_tmpa_tl{ + \knowledge_APshape_name_corner_t + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_corner:n{0.5}}} + \knowledge_APshape_name_tinycorner_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_corner:n{0.1}}} + \knowledge_APshape_name_smallcorner_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_corner:n{0.2}}} + \knowledge_APshape_name_largecorner_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_corner:n{0.8}}} + \knowledge_APshape_name_cross_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_cross:n{0.5}}} + \knowledge_APshape_name_tinycross_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_cross:n{0.1}}} + \knowledge_APshape_name_smallcross_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_cross:n{0.2}}} + \knowledge_APshape_name_largecross_tl + {\tl_set:Nn\knowledge_option_anchor_point_shape_tl{\knowledge_anchor_point_cross:n{0.8}}} + }{}{ + \tl_set:Nn\knowledge_option_anchor_point_shape_tl{#1} + } + } +% \end{macrocode} +% +% +% \begin{macrocode} \KnowledgeConfigureTrigger{ fix~hyperref~twocolumn } {\knowledgeFixHyperrefTwocolumn} \KnowledgeConfigureTrigger{ notion } {\KnowledgeConfigureNotion{notion} + \knowledge_directives_require_aci_package:nn{notion}{hyperref} \knowledgesetvariant\kl{suggestion=notion} \knowledgesetvariant\intro{suggestion=notion} \knowledgesetvariant\phantomintro{suggestion=notion} @@ -583,6 +644,7 @@ This directory contains the package \knowledge_option_aci_test_loaded:n{hyperref} \knowledge_option_aci_test_loaded:n{xcolor} \knowledge_option_aci_test_loaded:n{makeidx} +\knowledge_option_aci_test_loaded:n{cleveref} % \end{macrocode} %\begin{quote}\tt %\csintro{\knowledge_option_aci_define:n}\{package name\} @@ -627,6 +689,7 @@ This directory contains the package \knowledge_option_aci_define:n{hyperref} \knowledge_option_aci_define:n{xcolor} \knowledge_option_aci_define:n{makeidx} +\knowledge_option_aci_define:n{cleveref} % \end{macrocode} % % \subsubsection{Executing the package options} @@ -698,6 +761,7 @@ This directory contains the package \knowledge_option_aci_autoload:nnn{ hyperref }{}{} \knowledge_option_aci_autoload:nn{ xcolor }{} \knowledge_option_aci_autoload:nn{ makeidx }{} +\knowledge_option_aci_autoload:nn{ cleveref }{} % \end{macrocode} % % @@ -2424,7 +2488,7 @@ This directory contains the package \keys_if_exist:nnTF{ knowledge~directives }{ #2 } {\IfBooleanTF{#1} {\knowledgedirective:nnn{#2}{#3}{#4}} - {\msg_error:nnn{ knowledge }{ knowledgedirective~redifinition }{#2}}} + {\msg_error:nnn{ knowledge }{ knowledgedirective~redefinition }{#2}}} {\knowledgedirective:nnn{#2}{#3}{#4}} \kl_hide_end: } @@ -2432,10 +2496,10 @@ This directory contains the package \cs_set:cn {knowledgedirective_#1:n} {\keys_set:nn{ knowledge~directives }{#3}} - \keys_define:nn{ knowledge~directives } + \keys_define:nn{ knowledge~directives } {#1 .code:n = {\use:c{knowledgedirective_#1:n}{##1}}} - \IfNoValueF{#2} - {\keys_define:nn{ knowledge~directives }{#2 .default:n = {#2}}} + \IfNoValueF{#2} + {\keys_define:nn{ knowledge~directives }{#1 .default:n = {#2}}} } % \end{macrocode} % @@ -2521,7 +2585,7 @@ This directory contains the package {\use:c{knowledge_kl_\tl_to_str:V\knowledge_kl_modifiers_tl _init_tl}} {\knowledge_error:x {Unknown~variant~modifier~sequence~`\exp_not:V\knowledge_kl_modifiers_tl'.}} - % + % \knowledge_kl_modifiers_reset: % \knowledge_kl_use_styles:x{\knowledge_kl_default_style_tl} @@ -2694,7 +2758,8 @@ This directory contains the package % When the \kl{knowledge} is found, it is eventually executed using % \begin{code} % \csintro{\knowledge_kl_exec:nnn}\{namespace\}\{instance\}\{key\} -% \end{code} The argument is a control sequence pointing to the \kl{knowledge}. It is first executed +% \end{code} +% The argument is a control sequence pointing to the \kl{knowledge}. It is first executed % in order to set the variables. % Then, the token of the \kl{knowledge} is stored in the variable \cs{\knowledge_kl_resourcetoken_tl}. % Then, if a \kl{style} is given, it is executed. The next step is to update the \kl{knowledge} @@ -2771,8 +2836,6 @@ This directory contains the package % % % -% -% % \subsubsection{Error handling} % % @@ -2946,12 +3009,6 @@ This directory contains the package {}} % \end{macrocode} % -% \begin{macrocode} -% \end{macrocode} -% -% \begin{macrocode} -% \end{macrocode} -% % \subsubsection{Implementation of \cs{\knowledgenewvariant}} % % \begin{macrocode} @@ -3004,6 +3061,8 @@ This directory contains the package \exp_not:c{knowledge_kl_\cs_to_str:N#1_unknown_style_cont_tl} \exp_not:n{\tl_set_eq:NN\knowledge_kl_styledirectives_tl} \exp_not:c{knowledge_kl_\cs_to_str:N#1 _styledirectives_tl} + \exp_not:n{\tl_set_eq:NN\knowledge_kl_display_process_tl} + \exp_not:c{knowledge_kl_\cs_to_str:N#1 _display_process_tl} \exp_not:c{knowledge_kl_\cs_to_str:N#1 _autoknowledge_tl} } % @@ -3037,6 +3096,9 @@ This directory contains the package namespace .code:n = {\tl_set:cn{knowledge_kl_\knowledge_variant_key_tl _namespace_tl}{#1}}, % + display~code .code:n = + {\tl_set:cn{knowledge_kl_\knowledge_variant_key_tl _display_process_tl}{#1}}, + % unknown~warning .choices:nn = {true,false} {\bool_set_text:cn{knowledge_kl_\knowledge_variant_key_tl _unknownwarning_bool}{#1}}, % @@ -3327,7 +3389,9 @@ This directory contains the package % % % -% +% \csintro{\knowledge_kl_display_generic:n} applies a code to the current displaycode, which is surrounded by braces. +% \csintro{\knowledge_kl_display_generic_cond:Nn} does the same thing under condition +% of a boolean (see code of \cs{\knowledge_kl_default_compute_code:}). % \begin{macrocode} \cs_new:Nn\knowledge_kl_display_generic:n {\tl_gset:Nx\knowledge_display_code_tl @@ -3340,8 +3404,17 @@ This directory contains the package \cs_generate_variant:Nn\knowledge_kl_display_generic:n{x} \cs_generate_variant:Nn\knowledge_kl_display_generic_cond:Nn{Nx} % \end{macrocode} +% \AP \csintro{\knowledge_kl_compute_code:} tests whether a special display process is given, or otherwise +% defaults to the standard one. % \begin{macrocode} \cs_new:Nn\knowledge_kl_compute_code:{ + \tl_if_exist_ne:NTF\knowledge_kl_display_process_tl + \knowledge_kl_display_process_tl + \knowledge_kl_default_compute_code: +} +% \end{macrocode} +% \begin{macrocode} +\cs_new:Nn\knowledge_kl_default_compute_code:{ \tl_if_exist_ne:NTF\knowledge_kl_forcedtext_tl {\tl_gset_eq:NN\knowledge_display_code_tl\knowledge_kl_forcedtext_tl} {\tl_gset_eq:NN\knowledge_display_code_tl\knowledge_kl_text_tl} @@ -3363,6 +3436,9 @@ This directory contains the package % \bool_if:NT\knowledge_xcolor_active_bool \knowledge_kl_compute_code_xcolor: + % + \knowledge_kl_compute_code_hyperreftarget: + % \bool_if:NT\knowledge_hyperref_active_bool \knowledge_kl_compute_code_hyperref: % @@ -3394,20 +3470,22 @@ This directory contains the package \bool_if:NT\kl_invisible_bool {\tl_gclear:N\knowledge_display_code_tl} } +% \end{macrocode} +% \begin{macrocode} \cs_new:Nn\knowledge_kl_compute_code_xcolor:{ \tl_if_empty:NF\knowledge_kl_color_tl {\knowledge_kl_display_generic:x{\exp_not:N\textcolor{\knowledge_kl_color_tl}}} \tl_if_empty:NF\knowledge_kl_colorbox_tl {\knowledge_kl_display_generic:x{\exp_not:N\colorbox{\knowledge_kl_colorbox_tl}}} } +% \end{macrocode} +% \begin{macrocode} \cs_new:Nn\knowledge_kl_compute_code_hyperref:{ \tl_if_exist_ne:NT\knowledge_kl_ref_tl {\knowledge_kl_display_generic:x {\exp_not:N\kl_hyperlink_silentref:nn {\exp_not:V\knowledge_kl_ref_tl}}} % - \knowledge_kl_compute_code_hyperreftarget: - % \bool_if:NT\kl_autoreflink_bool {\tl_if_exist_ne:NT\knowledge_kl_autoref_tl {\knowledge_kl_display_generic:x @@ -3420,6 +3498,8 @@ This directory contains the package {\exp_not:N\kl_hyperlink_url:nn {\exp_not:V\knowledge_kl_url_tl}}} } +% \end{macrocode} +% \begin{macrocode} \cs_new:Nn\knowledge_kl_compute_code_hyperreftarget:{ \bool_if:NT\kl_autoreftarget_bool {\tl_if_exist_ne:NT\knowledge_kl_autoref_tl @@ -3435,25 +3515,10 @@ This directory contains the package {\exp_not:N\KAuxAutorefTarget \exp_not:o\knowledge_kl_resourcearguments_tl}} } -\cs_new:Nn\knowledge_kl_compute_code_makeidx:{ - \tl_if_exist_ne:NTF\knowledge_kl_index_tl - {\exp_args:Nx\index - {\tl_if_exist_ne:NTF\knowledge_kl_index_parent_key_tl - {\exp_not:V\knowledge_kl_index_parent_key_tl!}{} - \tl_if_exist_ne:NTF\knowledge_kl_index_key_tl - {\exp_not:V\knowledge_kl_index_key_tl@}{} - \expandafter\tl_to_str:n\expandafter{\knowledge_kl_index_tl} - \tl_if_exist_ne:NTF\knowledge_kl_index_number_style_tl - {|\exp_not:V\knowledge_kl_index_number_style_tl}{} - }}{} -} - -%\cs_new:Nn\knowledge_kl_default_display_code_fbox:n -% {\bool_if:NTF\kl_fbox_bool{\exp_not:N\fbox{#1}}{#1}} % \end{macrocode} % \begin{macrocode} \cs_new:Npn\kl_up:n{\mode_if_math:TF\use:n\textup} -\cs_new:Npn\kl_md:n{\mode_if_math:TF\mathmd\textmd} +\cs_new:Npn\kl_md:n{\mode_if_math:TF\use:n\textmd} \cs_new:Npn\kl_sc:n{\mode_if_math:TF\mathsc\textsc} \cs_new:Npn\kl_it:n{\mode_if_math:TF\mathit\textit} \cs_new:Npn\mathscerror#1{\knowledge_error:n{`smallcaps'~only~allowed~in~math~mode.}} @@ -3498,6 +3563,32 @@ This directory contains the package } % \end{macrocode} % +% +% \subsection{Displaying labels} +% Code for \cs{\kref}, \cs{\kpageref}, \cs{\kcref} and \cs{\kCref}. +% +% \csintro{\knowledgedisplayref} is to be used when defining a variant. It takes a macro, and creates the display code +% which applies it to the label reference of the knowledge. See code of \cs{\kref}, \cs{\kcref}, \dots +% \begin{macrocode} +\cs_new:Nn\knowledge_labelref_display_process:n{ + \tl_if_exist_ne:NTF\knowledge_kl_ref_tl + {\tl_gset:Nx\knowledge_display_code_tl + {\exp_not:n{#1} + {\exp_not:V\knowledge_kl_ref_tl}} + }{ + \bool_if:NTF\kl_autoreflink_bool + {\tl_if_exist_ne:NT\knowledge_kl_autoref_tl + {\tl_gset:Nx\knowledge_display_code_tl + {\exp_not:n{#1} + {\exp_not:V\knowledge_kl_autoref_tl}} + } + }{ \tl_gset:Nn\knowledge_display_code_tl{???} + } + } +} +\cs_set_eq:NN\knowledgedisplayref\knowledge_labelref_display_process:n +% \end{macrocode} +% % \subsubsection{Other commands} % % \paragraph{\cs{\AP} and \cs{\itemAP}} @@ -3555,16 +3646,16 @@ This directory contains the package \smash{\llap{\knowledge_AP_mark:\kern0.3em}} \vss}} \cs_new:Nn\knowledge_AP_mark:{% - \setlength\unitlength{1em} - \begin{picture}(0,0) - \put(0,1.2){ - \bool_if:NT\knowledge_hyperref_active_bool - {\put(-0.05,-1.04){\phantomsection}} - \bool_if:NT\knowledge_configuration_visibleAP_bool + \setlength\unitlength{1em} + \begin{picture}(0,0) + \put(0,1.1){\expandafter\put\knowledge_option_anchor_point_shift_tl{ + \bool_if:NT\knowledge_hyperref_active_bool + {\put(-0.05,-1.18){\phantomsection}} + \bool_if:NT\knowledge_configuration_visibleAP_bool {\bool_if:NTF\knowledge_xcolor_active_bool - {\textcolor{red}}{\use:n} - {\line(0,-1){0.5}\line(1,0){0.5}}}} - \end{picture}{}} + {\textcolor{\knowledge_option_anchor_point_color_tl}}{\use:n} + {\knowledge_option_anchor_point_shape_tl}}}} + \end{picture}{}} \cs_new:Nn\knowledge_itemAP:{ \hbox_overlap_left:n {\knowledge_AP_mark:\hspace{1em}} @@ -3653,91 +3744,180 @@ This directory contains the package % \subsection{Mathematics} % -% \subsubsection{Capturing subscripts, superscripts and primes} -% We know provide the core code for parsing subscripts, superscripts and primes. -% -% The central command is \csintro{\klparse_absorb_modifiers:}. -% This command parses all the subscripts and so on occurring after, -% and then launches \csintro{\klparse_absorb_modifiers_exec:} -% (that is supposed to have been set with the proper code). -% At the end, the token lists \csintro{\klparse_primes_tl}, \csintro{\klparse_subscript_tl} -% and \csintro{\klparse_supscript_tl} -% contain the texts that have been collected during the parsing. -% If a subscript or a superscript is not present, then the corresponding token list -% is set equal to be \cs{\klparse_novalue_tl}. This is not the case for primes: -% if there are no primes, then the token list \cs{\klparse_primes_tl} is simply empty. -% Parsing subscripts, superscripts and primes can be deactivated or activated by setting appropriately the -% macros \cs{\klparse_if_load_primes:TF} -% \cs{\klparse_if_load_subscript:TF} and \cs{\klparse_if_load_supscript:TF}. -% \begin{macrocode} -\cs_new:Nn\klparse_absorb_modifiers: - {\tl_set_eq:NN\klparse_primes_tl\c_empty_tl - \bool_if:NTF\klparse_load_primes_bool - \klparse_absorb_modifiers_pses: - \klparse_absorb_modifiers_ses: - } +% \begin{macrocode} +\knowledgenewvariant\rekl{ + namespace= default, + default~style= {autoref~link}, + unknown~style= kl~unknown, + unknown~style~cont= kl~unknown~cont, + style~directive= style +} +\knowledgevariantmodifier{\intro*\rekl}{\reintro} +\knowledgevariantmodifier{\rekl*\intro}{\reintro} +\knowledgevariantmodifier{\reintro*\rekl}{\reintro} +\knowledgevariantmodifier{\rekl*\reintro}{\reintro} +\knowledgevariantmodifier{\rekl*\kl}{\rekl} +\knowledgevariantmodifier{\kl*\rekl}{\rekl} +\knowledgevariantmodifier{\rekl*\rekl}{\rekl} +\knowledgevariantmodifier{\phantomintro*\rekl}{\phantomkl} +\knowledgevariantmodifier{\rekl*\phantomintro}{\phantomkl} +\knowledgevariantmodifier{\phantomintro*\kl}{\phantomintro} +\knowledgevariantmodifier{\phantomkl*\kl}{\phantomkl} -\cs_new:Nn\klparse_absorb_modifiers_pses: - {\klparse_ifnextchar:NTF' - {\tl_put_right:Nn\klparse_primes_tl' - \use_i:nn\klparse_absorb_modifiers_pses:} - \klparse_absorb_modifiers_ses: - } +\knowledgedirective{automatic~in~command}{notion} +% \end{macrocode} +% \begin{macrocode} -\cs_new:Nn\klparse_absorb_modifiers_ses: - {\bool_if:NTF\klparse_load_subscript_bool - {\klparse_absorb_subscript:Nn\klparse_subscript_tl\klparse_absorb_modifiers_es:} - {\tl_set_eq:NN\klparse_subscript_tl\klparse_novalue_tl - \klparse_absorb_modifiers_es:} - } +\tl_gset:Nn\knowledge_inner_modifer_re_tl{\rekl*} -\cs_new:Nn\klparse_absorb_modifiers_es: - {\bool_if:NTF\klparse_load_supscript_bool - {\tl_if_empty:NTF\klparse_primes_tl - {\klparse_absorb_supscript:Nn\klparse_supscript_tl - \klparse_absorb_modifiers_ts:} - {\tl_set_eq:NN\klparse_supscript_tl\klparse_novalue_tl - \klparse_absorb_modifiers_exec:}} - {\tl_set_eq:NN\klparse_supscript_tl\klparse_novalue_tl - \klparse_absorb_modifiers_exec:} - } +\int_new:N\knowledge_inner_modifier_count_int +\cs_new:Nn\knowledge_inner_command: + {knowledge_cmdkl \int_to_arabic:n\knowledge_inner_modifier_count_int :n} -\cs_new:Nn\klparse_absorb_modifiers_ts: - {\bool_if:NTF\klparse_load_subscript_bool{ - \klparse_if_novalue:NTF\klparse_subscript_tl - {\klparse_absorb_subscript:Nn\klparse_subscript_tl\klparse_absorb_modifiers_exec:} - \klparse_absorb_modifiers_exec:} - {\klparse_absorb_modifiers_exec:} - } -% \end{macrocode} -% -% The macros \csintro{\klparse_absorb_subscript:Nn} and \csintro{\klparse_absorb_supscript:Nn}. -% These are weirdly defined because the catcode of underscore is changed. -% \begin{macrocode} -\ExplSyntaxOff -\def\absorbsupscriptNn{\absorbopt ^} -\def\absorbsubscriptNn{\absorbopt _} -\ExplSyntaxOn -\cs_set_eq:NN\klparse_absorb_supscript:Nn\absorbsupscriptNn -\cs_set_eq:NN\klparse_absorb_subscript:Nn\absorbsubscriptNn + +\NewDocumentCommand\withkl{mm}{ + \int_gincr:N\knowledge_inner_modifier_count_int + \group_begin: + \group_end: + \cs_gset:cpx + {\knowledge_inner_command:} + {\exp_not:N\cs_gset:Npn + \exp_not:c{\knowledge_inner_command:} + {\knowledge_inner_modifer_re_tl\knowledge_kl_modifiers_tl\exp_not:n{#1}} + \knowledge_kl_modifiers_tl\exp_not:n{#1}} + \knowledge_kl_modifiers_reset: + #2{}{} + \int_gdecr:N\knowledge_inner_modifier_count_int +} -\cs_new:Npn\absorbopt#1#2#3 - {\klparse_ifnextchar:NTF #1 - {\klparse_absorbopt_ii:NnNn #2 {#3}} - {\tl_set_eq:NN #2 \klparse_novalue_tl #3}} +\cs_new:Nn\knowledge_error_unexpected_cmdkl:{ + \knowledge_error:n{\cmdkl~is~only~allowed~inside~\withkl~or~in~macros~defined~using~\knowledgenewcommand-like~commands} +} +\newrobustcmd\cmdkl[1]{ + \int_compare:nNnTF\knowledge_inner_modifier_count_int=0 + \knowledge_error_unexpected_cmdkl: + \use:c{\knowledge_inner_command:}{#1} +} -\cs_new:Nn\klparse_absorbopt_ii:NnNn - {\tl_set:Nn #1 {#4} #2 } +% 1: command to extend, 2:, 3,4,5,6: the newcommand arguments (token sequence, optional star, first optional parameter, second optional parameter, and body of the definition). +\NewDocumentCommand\knowledge_knowledgified_newcommand:NNwn{mmsoom}{ + \use:x{ + \exp_not:n{#1{#2}} + \IfBooleanTF {#3} {*} {} + \IfNoValueF{#4}{\exp_not:n{[{#4}]}} + \IfNoValueF{#5}{\exp_not:n{[{#5}]}} } + {\withkl{\kl[{#2}]}{#6}} + \knowledge{#2}{automatic~in~command} +} +\NewDocumentCommand\knowledge_knowledgified_NewDocumentCommand:NNnn{mmmm}{ + #1#2{#3}{\withkl{\kl[{#2}]}{#4}} + \knowledge{#2}{cmdkl} +} +\NewDocumentCommand\KnowledgifyNewcommand{m}{ + \cs_if_exist:NTF#1{ + \exp_args:Nc\NewDocumentCommand{knowledge\cs_to_str:N#1}{} + {\knowledge_knowledgified_newcommand:NNwn#1} + }{ + %\tl_show:n{Unknown~#1~in~\KnowledgifyNewcommand} + \use:x{\exp_not:N\NewDocumentCommand + \exp_not:c{knowledge\cs_to_str:N#1} + {} + {\exp_not:N\knowledge_error:n{ + The~command~\exp_not:N#1~should~be~defined~for~\exp_not:c + {knowledge\cs_to_str:N#1}~to~be~usable.}} + } + } +} +\NewDocumentCommand\KnowledgifyNewDocumentCommand{m}{ + \cs_if_exist:NTF#1{ + \exp_args:Nc\NewDocumentCommand{Knowledge\cs_to_str:N#1}{} + {\knowledge_knowledgified_NewDocumentCommand:NNnn#1} + }{ + %\tl_show:n{Unknown~#1~in~\KnowledgifyNewDocumentCommand} + \use:x{\exp_not:N\NewDocumentCommand + \exp_not:c{knowledge\cs_to_str:N#1} + {} + {\exp_not:N\knowledge_error:n{ + The~command~\exp_not:N#1~should~be~defined~for~\exp_not:c + {Knowledge\cs_to_str:N#1}~to~be~usable.}} + } + } +} % \end{macrocode} -% -% \begin{macrocode} -\cs_set_eq:NN\klparse_if_load_subscript:TF\use_i:nn -\cs_set_eq:NN\klparse_if_load_supscript:TF\use_i:nn -\cs_set_eq:NN\klparse_if_load_primes:TF\use_i:nn +% Commands from LaTeX. +% \begin{macrocode} +\KnowledgifyNewcommand\newcommand +\KnowledgifyNewcommand\renewcommand +\KnowledgifyNewcommand\newrobustcmd +% \end{macrocode} +% Commands from "xparse@@package". +% \begin{macrocode} +\KnowledgifyNewDocumentCommand\NewDocumentCommand +\KnowledgifyNewDocumentCommand\RenewDocumentCommand +\KnowledgifyNewDocumentCommand\ProvideDocumentCommand +\KnowledgifyNewDocumentCommand\DeclareDocumentCommand +% \end{macrocode} +% Commands from "mathcommand@@package" ( +% \csintro\knowledgedeclarecommand, +% \csintro\knowledgenewmathcommand, +% \csintro\knowledgenewtextcommand, +% \csintro\knowledgerenewmathcommand, +% \csintro\knowledgerenewtextcommand, +% \csintro\knowledgedeclaremathcommand, +% \csintro\knowledgedeclaretextcommand, +% \csintro\KnowledgeNewDocumentMathCommand, +% \csintro\KnowledgeNewDocumentTextCommand, +% \csintro\KnowledgeRenewDocumentMathCommand, +% \csintro\KnowledgeRenewDocumentTextCommand, +% \csintro\KnowledgeProvideDocumentMathCommand, +% \csintro\KnowledgeProvideDocumentTextCommand, +% \csintro\KnowledgeDeclareDocumentMathCommand, +% \csintro\KnowledgeDeclareDocumentTextCommand, +% \csintro\knowledgenewcommandPIE, +% \csintro\knowledgerenewcommandPIE, +% \csintro\knowledgedeclarecommandPIE, +% \csintro\knowledgenewmathcommandPIE, +% \csintro\knowledgerenewmathcommandPIE, +% \csintro\knowledgedeclaremathcommandPIE, +% \csintro\KnowledgeNewDocumentCommandPIE, +% \csintro\KnowledgeRenewDocumentCommandPIE, +% \csintro\KnowledgeDeclareDocumentCommandPIE, +% \csintro\KnowledgeProvideDocumentCommandPIE, +% \csintro\KnowledgeNewDocumentMathCommandPIE, +% \csintro\KnowledgeRenewDocumentMathCommandPIE, +% \csintro\KnowledgeDeclareDocumentMathCommandPIE, and +% \csintro\KnowledgeProvideDocumentMathCommandPIE). +% \begin{macrocode} +\KnowledgifyNewcommand\declarecommand +\KnowledgifyNewcommand\newmathcommand +\KnowledgifyNewcommand\newtextcommand +\KnowledgifyNewcommand\renewmathcommand +\KnowledgifyNewcommand\renewtextcommand +\KnowledgifyNewcommand\declaremathcommand +\KnowledgifyNewcommand\declaretextcommand +\KnowledgifyNewDocumentCommand\NewDocumentMathCommand +\KnowledgifyNewDocumentCommand\NewDocumentTextCommand +\KnowledgifyNewDocumentCommand\RenewDocumentMathCommand +\KnowledgifyNewDocumentCommand\RenewDocumentTextCommand +\KnowledgifyNewDocumentCommand\ProvideDocumentMathCommand +\KnowledgifyNewDocumentCommand\ProvideDocumentTextCommand +\KnowledgifyNewDocumentCommand\DeclareDocumentMathCommand +\KnowledgifyNewDocumentCommand\DeclareDocumentTextCommand +\KnowledgifyNewcommand\newcommandPIE +\KnowledgifyNewcommand\renewcommandPIE +\KnowledgifyNewcommand\declarecommandPIE +\KnowledgifyNewcommand\newmathcommandPIE +\KnowledgifyNewcommand\renewmathcommandPIE +\KnowledgifyNewcommand\declaremathcommandPIE +\KnowledgifyNewDocumentCommand\NewDocumentCommandPIE +\KnowledgifyNewDocumentCommand\RenewDocumentCommandPIE +\KnowledgifyNewDocumentCommand\DeclareDocumentCommandPIE +\KnowledgifyNewDocumentCommand\ProvideDocumentCommandPIE +\KnowledgifyNewDocumentCommand\NewDocumentMathCommandPIE +\KnowledgifyNewDocumentCommand\RenewDocumentMathCommandPIE +\KnowledgifyNewDocumentCommand\DeclareDocumentMathCommandPIE +\KnowledgifyNewDocumentCommand\ProvideDocumentMathCommandPIE % \end{macrocode} -% -% -% % \subsection{Subpackages} % % \subsubsection{Generalities} @@ -3791,9 +3971,8 @@ This directory contains the package % \begin{macrocode} \NewKnowledgeParamTl*{url} \NewKnowledgeParamTl*{ref} - \knowledge_directives_require_aci_package:nn - {url,ref,autoref}{hyperref} + {url}{hyperref} % \end{macrocode} % The commands \cs{\intro}, \cs{\kl} and \cs{\reintro} are made silent when % creating the pdf names of sections (for avoiding warnings of the "hyperref@@package"). @@ -3826,6 +4005,24 @@ This directory contains the package % \expandafter\tl_to_str:n\expandafter{\knowledge_kl_index_tl} % }}}} %} +% \end{macrocode} +% \begin{macrocode} +\cs_new:Nn\knowledge_kl_compute_code_makeidx:{ + \bool_if:NF\knowledge_kl_noindex_bool{ + \tl_if_exist_ne:NTF\knowledge_kl_index_tl + {\exp_args:Nx\index + {\tl_if_exist_ne:NTF\knowledge_kl_index_parent_key_tl + {\exp_not:V\knowledge_kl_index_parent_key_tl!}{} + \tl_if_exist_ne:NTF\knowledge_kl_index_key_tl + {\exp_not:V\knowledge_kl_index_key_tl@}{} + \expandafter\tl_to_str:n\expandafter{\knowledge_kl_index_tl} + \tl_if_exist_ne:NTF\knowledge_kl_index_number_style_tl + {|\exp_not:V\knowledge_kl_index_number_style_tl}{} + }}{} + } +} +% \end{macrocode} +% \begin{macrocode} \def\knowledgeIntroIndexStyle#1{\textbf{#1}} \NewKnowledgeParamTl{index} \keys_define:nn { knowledge~directives } @@ -3839,6 +4036,90 @@ This directory contains the package \NewKnowledgeParamTl*[\knowledge_kl_index_number_style_tl]{index~style} \NewKnowledgeParamTl*[\knowledge_kl_index_parent_key_tl]{index~parent~key} \NewKnowledgeParamTl*[\knowledge_kl_index_key_tl]{index~key} +\NewKnowledgeParamBool*{no~index}\knowledge_kl_noindex_bool +% \end{macrocode} +% +% \subsubsection{The \kl{cleveref option}} +% +% \begin{macrocode} +\bool_if:NTF\knowledge_cleveref_active_bool{ + \knowledgenewvariant\kcref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\cref} + } + \knowledgenewvariant\kCref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\Cref} + } + \knowledgenewvariant\kcpageref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\cpageref} + } + \knowledgenewvariant\kCpageref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\Cpageref} + } + \knowledgenewvariant\knamecref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\namecref} + } + \knowledgenewvariant\knameCref{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\nameCref} + } + \knowledgenewvariant\knamecrefs{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\namecrefs} + } + \knowledgenewvariant\knameCrefs{ + namespace=default, + unknown~style={kl~unknown,ref~unknown}, + unknown~style~cont={kl~unknown~cont,ref~unknown}, + default~style=autoref~link, + display~code={\knowledgedisplayref\nameCrefs} + } + \knowledgevariantmodifier{\kcref*\kl}{\kcref} + \knowledgevariantmodifier{\kCref*\kl}{\kCref} + \knowledgevariantmodifier{\kcpageref*\kl}{\kcpageref} + \knowledgevariantmodifier{\kCpageref*\kl}{\kCpageref} + \knowledgevariantmodifier{\knamecref*\kl}{\knamecref} + \knowledgevariantmodifier{\knameCref*\kl}{\knameCref} + \knowledgevariantmodifier{\knamecrefs*\kl}{\knamecrefs} + \knowledgevariantmodifier{\knameCrefs*\kl}{\knameCrefs} +}{ + \cs_new:Nn\knowledge_cleveref_error:N{ + \newcommand#1{\knowledge_error:n{Use~package~'cleveref'~for~command~#1.}} + } + \knowledge_cleveref_error:N\kcref + \knowledge_cleveref_error:N\kCref + \knowledge_cleveref_error:N\kcpageref + \knowledge_cleveref_error:N\kCpageref + \knowledge_cleveref_error:N\knamecref + \knowledge_cleveref_error:N\knameCref + \knowledge_cleveref_error:N\knamecrefs + \knowledge_cleveref_error:N\knameCrefs +} % \end{macrocode} % % \subsection{Fixes} @@ -3989,8 +4270,23 @@ This directory contains the package unknown style cont=intro unknown cont, style directive=intro style } - - +\knowledgestyle{ref unknown}{text=??} +\knowledgenewvariant\kref{ + namespace=default, + unknown style={kl unknown,ref unknown}, + unknown style cont={kl unknown cont,ref unknown}, + default style=autoref link, + display code={\knowledgedisplayref\ref} +} +\knowledgenewvariant\kpageref{ + namespace=default, + unknown style={kl unknown,ref unknown}, + unknown style cont={kl unknown cont,ref unknown}, + default style=autoref link, + display code={\knowledgedisplayref\pageref} +} +\knowledgevariantmodifier{\kref*\kl}{\kref} +\knowledgevariantmodifier{\kpageref*\kl}{\kpageref} \knowledgevariantmodifier{\intro*\kl}{\intro} \knowledgevariantmodifier{\reintro*\kl}{\reintro} |