From 7e9227dfbf310d133bca2331f978d17b65320433 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 17 May 2018 20:25:25 +0000 Subject: knowledge (17may18) git-svn-id: svn://tug.org/texlive/trunk@47739 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/knowledge/README.md | 4 +- .../texmf-dist/doc/latex/knowledge/knowledge.pdf | Bin 673977 -> 677639 bytes .../texmf-dist/doc/latex/knowledge/knowledge.tex | 75 +++++++++++++----- .../source/latex/knowledge/knowledge-code.dtx | 88 +++++++++++---------- .../source/latex/knowledge/knowledge-utils.dtx | 55 ++++++++++--- .../texmf-dist/tex/latex/knowledge/knowledge.sty | 70 ++++++++++------ 6 files changed, 194 insertions(+), 98 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/knowledge/README.md b/Master/texmf-dist/doc/latex/knowledge/README.md index e78dd4ff02d..c05535030e0 100644 --- a/Master/texmf-dist/doc/latex/knowledge/README.md +++ b/Master/texmf-dist/doc/latex/knowledge/README.md @@ -3,8 +3,8 @@ This directory contains the package name: knowledge license: LaTeX Project Public License version 1.2 or above - version: v1.10 - date: 2018/02/17 + version: v1.11 + date: 2018/05/17 author: Thomas Colcombet mail: thomas.colcombet@irif.fr web: https://www.irif.fr/~colcombe/knowledge_en.html diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf index d3b3246c9fc..8c5970a16ad 100644 Binary files a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf and b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf differ diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex index d104052f6bc..72f8bb013b7 100644 --- a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex +++ b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex @@ -33,6 +33,7 @@ \renewrobustcmd\bibitem\oldbibitem +\expandafter\let\expandafter\item\csname switch item\endcsname \ifcodeTF{ \NewDocumentCommand\textmenu{m}{#1} @@ -389,6 +390,7 @@ \knowledge{import}{kenvironment} \knowledge{theorem}{environment} \knowledge{tikzcd}{environment,ref=section:tikzcd} + \knowledge{thebibliography}{environment,ref=section:thebibliography} \knowledge{document}{environment} \end{scope} @@ -630,8 +632,8 @@ This is essentially a list for personal referencing of what has to be done. \item[2017-01-15] Added the \kl[\knowledge directives]{directive} \kl{synonym}. \item[2017-01-15] Added the \texttt{noknowledge package} for minimizing the effects of not having "knowledge@@package" activated. \item[2017-01-17] Changed the way options are handled, decoupling the package options (options of \cs{\usepackage}) from the configuration options (see \cs{\knowledgeconfigure}). -\item[2017-01-17] Proper treatment of `final` option and \kl[composition mode]{composition} options. -\item[2017-01-17] Added \robustdisplaycs{IfKnowledgeFinalMode}\texttt{[TF]} commands for the user. +\item[2017-01-17] Proper treatment of `final' option and \kl[composition mode]{composition} options. +\item[2017-01-17] Added \cs{\IfKnowledgeFinalMode}\texttt{[TF]} commands for the user. \item[2017-01-17] Added the option \kl{fix hyperref twocolumn} as a shorthand for calling \cs{\knowledgeFixHyperrefTwocolumn} (thanks to Daniela Petrisan and Luca Reggio). \item[2017-01-18] Added the configuration option \kl(option){notion} that offers a basic configuration compatible with \kl(package){xcolor} or not, and \texttt{final} and \kl{composition} modes. \item[2017-01-19] Added \cs{\phantomintro} and an explanation on how to deal with \kl{align*}. @@ -660,34 +662,33 @@ This is essentially a list for personal referencing of what has to be done. \item[2017-06-08] The file \texttt{knowledge-example.sty} as been improved. \item[2017-06-09] First release of version 1.0 on "CTAN". \item[2017-06-10] Corrected the "quotation notation" to make it expandable for avoiding problems in table of contents (the @ was not working). -\item[2017-06-11] Corrected a bug linked to changes of expl3 on recent distributions (pointed by Murray Eisenberg) -\item[2017-06-11] Release of v1.01 +\item[2017-06-11] Corrected a bug linked to changes of expl3 on recent distributions (pointed by Murray Eisenberg). Release of v1.01 on CTAN. \item[2017-06-27] Overloaded labels now perform an expansion of the argument (this was causing problems with biblatex). -\item[2017-06-28] Options \texttt{log-declarations} of "xparse@@package" package removed (causing clash wit other packages, as pointed by Juliusz Chroboczek). -\item[2017-06-28] Release of v1.02. +\item[2017-06-28] Options \texttt{log-declarations} of "xparse@@package" package removed (causing clash with other packages, as pointed by Juliusz Chroboczek). Release of v1.02 on CTAN. \item[2017-06-30] added the field \texttt{\robustdisplay{labelizable_bool}} to areas. Coded missing features of scoping. Now the "scope=" directive works with as parameter an enclosing "area", or a label. \item [2017-06-30] Added in the source a Regression subdirectory containing files to be tested (so far only one: regression-scope.tex) \item [2017-07-01] Corrected a conflict between the "scope@@option" and "makeidx@@option" option. \item [2017-07-03] Scoping becomes operational. \item [2017-07-04] The documentation for "notion@@style" and "intro notion@@style" are added (thanks to Fabian Reiter). -\item [2017-07-09] The boolean \cs{environment_bool} has been added to "areas" in order to not always trigger the scope from an environment. Now the environment "document@@env" has this Boolean set to false, and it resolves a bug with the package "standalone@@package" noticed by Fabian Reiter. +\item [2017-07-09] Added boolean \cs{environment_bool} field to "areas",in order to resolve an incompatibility with the package "standalone@@package" noticed by Fabian Reiter. \item [2017-07-20] "Scoping" becomes fully operational, with the parenthesis notation of \cs{\kl} and \cs{\intro}. The use of scope has been recoded. Now scope links reuse implicitly the key as a link. Documentation updated. \item[2017-07-26] File and line numbers added in the "kaux file". Added the option "diagnose line=" to deactivate it. -\item[2017-07-26] Corrections to the documentation. -\item[2017-07-27] Version 1.03. +\item[2017-07-26] Corrections to the documentation. Version 1.03 on CTAN. \item[2017-07-28] Corrected a bug of scoping in the context of synonyms. Added ctan for producing the ctan zip file. \item[2017-08-06] Now passes the compliance test \texttt{check-declarations} of "expl3@@package" (thanks to Marc Zeitoun) \item[2017-09-12] The "hidelinks" option of "hyperref@@package" is now always activated. -\item[2017-09-25] Ancient version of "xparse@@package" does not have \cs{\NewExpandableDocumentCommand}. Corrected. -\item[2017-09-26] Version 1.05 on "CTAN". -\item[2017-10-10] Bug in the implementation of \cs{\knowledgenewvariant} (that was invisible for older versions of "expl3@@package"). Found and corrected (thanks to Marc Zeitoun). -\item[2017-10-10] Version 1.06 on "CTAN". +\item[2017-09-25] Ancient version of "xparse@@package" does not have \cs{\NewExpandableDocumentCommand}. Corrected. Version 1.05 on "CTAN". +\item[2017-10-10] Bug in the implementation of \cs{\knowledgenewvariant} (that was invisible for older versions of "expl3@@package"). Found and corrected (thanks to Marc Zeitoun). Version 1.06 on "CTAN". \item[2017-10-15] Diagnose extended (suggested by Fabian Reiter). Minor corrections. Version 1.07 on "CTAN". \item[2017-10-17] Added "cyclic color" and "cyclic colors=@@option". Reorganization of the structure of the code for producing a better "CTAN" archive. Version 1.08 on "CTAN". \item[2018-01-31] Added the "strict" configuration option. \item[2018-02-05] Added the "smallcaps" formatting directive. -\item[2018-02-17] Corrected incompatibility with latest version of "expl3@@package". +\item[2018-02-17] Corrected incompatibility with latest version of "expl3@@package". Version 1.10 on "CTAN". +\item[2018-02-21] Bug correction concerning the activation of scopes. +\item[2018-02-21] Documentation improvement for "Emacs" (thanks to Michaël Cadilhac). +\item[2018-02-24] Documentation improvement for the environment "thebibliography@@env". +\item[2018-05-17] Correction to be compatible with the lastest version of "expl3@@package" (thanks to Leo Stefanesco). \end{compactdesc} \normalsize %\restoregeometry @@ -960,7 +961,12 @@ Now, using code like \end{code} \noindent will properly be linked to the definition of a semigroup and a monoid. +% +%\subsection{Managing an index} +%Though it is not its primary goal, without using its hyperlinking capabilities, the "knowledge@@package" offers convenient features for easily managing data for the construction of an index. +%For instance, let us imagine that one wants to write a book +% \subsection{Mathematics} \label{subsection:mathematics scenario} @@ -2298,24 +2304,44 @@ A workaround is to use the \texttt{breaklinks} option of \kl(package){hyperref} \subsection{Problems with scope} -\subsubsection{Problems in combination with \cs{\bibitem}} - -The "scope option" of the package triggers some analysis of the code, and restrains the structure of the code (in particular, this is because "scopes" have to be nested, and thus some not so well nested part of "LaTeX" yields error). In particular, the "scope option" does not allow to have a \cs{\section} command inside a list. However, this is what does \cs{\bibitem}. +\subsubsection{Problems in combination with \cs{\bibitem} and "thebibliography@@env"} +\section{} +The "scope option" of the package triggers some analysis of the code, and restrains the structure of the code (in particular, this is because "scopes" have to be nested, and thus some not so well nested part of \LaTeX{} yields error). In particular, the "scope option" does not allow to have a \cs{\section} command inside a list. +However, this is what does the environment "thebibliography@@env", yielding a scoping error. + +A simple hack to treat this situation: +\begin{code}[6cm] +\cs\let\cs\section\cs\SUPERsection\\ +\cs\begin\{"thebibliography@@env"\}\\ +\cs\bibitem\dots\\ +{}[...]\\ +\cs\end\{"thebibliography@@env"\}\\ +\cs\let\cs\section\cs\NEWsection +\end{code} +The result is to revert to the original version of the macro \smallcode{\cs\section}, which does not make any structural test, and then reactivate the modified version of the command. -Here is a hack to treat this situation: +Another solution is to reconfigure the environment "thebibliography@@env" using in the preamble: +\begin{code} +\cs\ScopeConfigure\{"thebibliography@@env"\}\par +\hspace{3cm}\{push code=\cs\let\cs\section\cs\SUPERsection,\par +\hspace{3cm}~pop code=\cs\let\cs\section\cs\NEWsection\} +\end{code} -\subsection{Editor} +\subsection{Editors} \newenvironment{pquote}{\begin{quote}}{\end{quote}} \knowledgeconfigure{protect quotation=pquote} \subsubsection{"Emacs" editor and \kl[quotation notation]{quotes}} -The "AucTex" mode in "Emacs" binds the quote symbol to other characters. This is not convenient when using the "knowledge@@package" package. +The "AucTex" mode in "Emacs" binds the quote symbol to other characters, cycling +through \verb|``|, \quotesymbol, and \quotesymbol\quotesymbol. This is not +convenient when using the "knowledge@@package" package. This behavior can be deactivated temporarily using: \begin{pquote} -\texttt{M-x local-unset-key $\backslash$\quotesymbol.} +%\texttt{M-x local-unset-key $\backslash$\quotesymbol.} +\texttt{M-x local-unset-key RET \quotesymbol{} RET} \end{pquote}\noindent or definitively using: \begin{pquote} @@ -2325,6 +2351,13 @@ or definitively using: % source: Sylvain Perifel, and: %(source : https://stackoverflow.com/questions/24835536/insert-regular-double-quotes-in-latex-mode-with-auctex) +Alternatively, this can be changed so as to cycle through \quotesymbol, +\verb|``|, and \quotesymbol\quotesymbol, which is slightly more convenient than +the default. This is achieved by customizing \texttt{TeX-quote-after-quote}: +\begin{pquote} + \texttt{M-x customize-set-variable RET TeX-quote-after-quote RET y} +\end{pquote} + \subsection{Others} If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr}. diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx index b05e9b8cdf8..1828e3d2aa6 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 %\usepackage{expl3} -%\ProvidesExplPackage{knowledge}{2018/02/17}{1.10}{} +%\ProvidesExplPackage{knowledge}{2018/05/17}{1.11}{} %<*driver> \def\knowledgecode{active} \input{knowledge.tex} @@ -42,7 +42,8 @@ % \changes{1.07}{2017/10/15}{minor improvements} % % \changes{1.08}{2017/10/17}{minor changes and reorganization of the files} % % \changes{1.09}{2017/10/31}{minor changes} % -% \changes{1.10}{2018/17/02}{bug fixes} % +% \changes{1.10}{2018/02/17}{bug fixes} % +% \changes{1.11}{2018/05/17}{bug fixes} % % \GetFileInfo{knowledge.sty} % % \DoNotIndex{} % @@ -62,8 +63,8 @@ This directory contains the package name: knowledge license: LaTeX Project Public License version 1.2 or above - version: v1.10 - date: 2018/02/17 + version: v1.11 + date: 2018/05/17 author: Thomas Colcombet mail: thomas.colcombet@irif.fr web: https://www.irif.fr/~colcombe/knowledge_en.html @@ -244,6 +245,7 @@ Content of the file knowledge-sources.zip: {Some~knowledge~is~used~but~not~introduced.~See~the~'.diagnose'~file~for~more~information.} % \end{macrocode} % +% % \subsection{Option and packages} % % @@ -1050,6 +1052,7 @@ Content of the file knowledge-sources.zip: % \end{macrocode} % \begin{macrocode} \cs_new:Nn\scope_internal_push:n { + \ScopeActivate \tl_gset:Nn\scope_top_area_tl{#1} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].nesting_int} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].count_int} @@ -1301,15 +1304,15 @@ Content of the file knowledge-sources.zip: % like knowledge. % \begin{macrocode} \NewDocumentCommand\ScopeActivate{}{ - \scope_internal_push:n{base} \cs_gset_eq:NN\ScopeActivate\relax + \scope_internal_push:n{base} } \AtBeginDocument{\ScopeActivate} % \end{macrocode} % % \begin{macrocode} \AtBeginDocument{\ScopeHackEnvironments} -%\AtEndDocument{\scope_area_pop:n{document}} +\AtEndDocument{\scope_area_pop:n{document}} % \end{macrocode} % % \begin{macrocode} @@ -1335,7 +1338,7 @@ Content of the file knowledge-sources.zip: {body}{knowledge=none} % \newenvironment{scope} - {\mode_if_preamble:TF{\scope_area_push:n{scope}}{}} + {\mode_if_preamble:TF{\ScopeActivate\scope_area_push:n{scope}}{}} {\mode_if_preamble:TF{\scope_area_pop:n{scope}}{}} \knowledgeconfigureenvironment{scope}{} % \end{macrocode} @@ -2069,11 +2072,12 @@ Content of the file knowledge-sources.zip: % % % The \cs{\kl}, and its internal version \cs{\klTKS} are the central ones in the package. Indeed, all commands such as \cs{\intro}, \cs{\phantomintro}, \cs{\reintro} or the \kl{"...@...@..."} notation eventually end to a call to these functions. -% -% Essentially, \cs{\kl} parses its parameters, and then call its internal version \cs{\knowledge_klTKS:nnn} +%\AP Essentially, \cs{\kl} parses its parameters, and then call its internal version \cs{\knowledge_klTKS:nnn} % with proper parameters: Text, Knowledge, Scope (the scope can be empty): +% +% \AP The macro \csintro{\knowledge_kl:w} is the part of \cs{\kl}-like commands that parses the arguments, and then calls \cs{\knowledge_klTKS:nnn} with proper arguments. % \begin{macrocode} -\NewDocumentCommand\__kl:w{d() o d() m}{ +\NewDocumentCommand\knowledge_kl:w{d() o d() m}{ \IfNoValueTF{#1} {\IfNoValueTF{#3} {\IfNoValueTF{#2} @@ -2088,11 +2092,13 @@ Content of the file knowledge-sources.zip: } % \end{macrocode} % -% The following macro, \cs{\knowledge_klTKS:nnn} is the internal version of \cs{\kl}. it takes explicitely the text to be displayed, +% \AP The following macro, \csintro{\knowledge_klTKS:nnn} is an internal version of \cs{\kl}-like commands. it takes explicitely the text to be displayed, % followed by the \kl{knowledge name} to be used, and a \kl{label} pointing to the \kl[instance]{instance of scope} -% in which the \kl{knowledge name} has to searched. This \kl{label} can be empty, and in this case, this means that +% in which the \kl{knowledge name} has to be searched for. This \kl{label} can be empty, and in this case, this means that % the stack of instances that are visible in the context of the call of the command should be inspected for searching for -% the knowledge. There exists a version \cs{\klTKS} which can be used, and does not require the \kl(package){expl3} syntax. +% the knowledge. +% \AP The macro \csintro{\klTKS} is a version of \cs{\knowledge_klTKS:nnn} +% that can be used without the "expl3@@package" syntax. % \begin{macrocode} \tl_clear_new:N\knowledge_kl_text_tl \tl_clear_new:N\knowledge_kl_base_key_tl @@ -2148,10 +2154,10 @@ Content of the file knowledge-sources.zip: % and then launches the search. % % -% The core of the \cs{\kl} command is \csintro{\knowledge_kl_find:}. +%\AP The core of the \cs{\kl} command is \csintro{\knowledge_kl_find:}. % It uses the variables \cs{\knowledge_kl_recursion_int} for checking non-recursion. % It searches for the entry \cs{\knowledge_kl_key_tl}, either in searching in the \kl{stack of visible scope instances}, -% or following \cs{\knowledge_kl_linkscope_tl} if the label exist. +% or following \cs{\knowledge_kl_linkscope_tl} if the label exists. % It first works on whether a scope label is given or not: % \begin{macrocode} \cs_set:Nn\knowledge_kl_find:{ @@ -2505,7 +2511,7 @@ Content of the file knowledge-sources.zip: % \NewDocumentCommand#1{s} {\knowledge_kl_modifiers_add:N#1 - \IfBooleanF{##1}{\__kl:w}} + \IfBooleanF{##1}{\knowledge_kl:w}} % \tl_new_eq:cN {knowledge_kl_\cs_to_str:N#1_namespace_tl} @@ -2614,25 +2620,25 @@ Content of the file knowledge-sources.zip: % When defining a new use of \texttt{knowledge}, many macros have to be taken into account. % Some have to be defined explicitly. Some other have default behaviours. % \begin{asparaitem} -% \item \csintro{\knowledge_kl_display_preprocess_tl} is the code to be used first before displaying. It does nothing for \cs{\kl}, but is set to \cs{\knowledge_kl_target_preprocess_tl} for \cs{\intro}, which performs the \cs{\label} command fir the introduction. -% \item \csintro{\knowledge_kl_display_process_tl} is the code to be executed for displaying the \kl{knowledge}. This is not defined by default. -% \item \csintro{\knowledge_kl_error_unknown:} The fallback code to execute when the \kl{knowledge} is unknown. +% \itemAP \csintro{\knowledge_kl_display_preprocess_tl} is the code to be used first before displaying. It does nothing for \cs{\kl}, but is set to \cs{\knowledge_kl_target_preprocess_tl} for \cs{\intro}, which performs the \cs{\label} command fir the introduction. +% \itemAP \csintro{\knowledge_kl_display_process_tl} is the code to be executed for displaying the \kl{knowledge}. This is not defined by default. +% \itemAP \csintro{\knowledge_kl_error_unknown:} The fallback code to execute when the \kl{knowledge} is unknown. % By default, it displays a warning and put the name in orange. -% \item \csintro{\knowledge_kl_update:N} is a code to be executed to update the knowledge. By default, it increments the ktuple counter `\cs{countuse_int}'. -% \item \csintro{\knowledge_kl_namespace_tl} is the \kl{namespace} in which the \kl{knowledge} is to be searched. Not defined by default. -% \item \csintro{\knowledge_kl_linkscope_tl} is a label that points to an instance of a \kl{scope}. It can be empty, and in this case, this means that the search proceeds in the \kl{stack of visible scope instances}. By default it is empty. -% \item \csintro{\knowledge_kl_max_recursion_int} is the maximum number of recursion allowed when searching for a \kl{knowledge}. It is by default 40. +% \itemAP \csintro{\knowledge_kl_update:N} is a code to be executed to update the knowledge. By default, it increments the ktuple counter `\cs{countuse_int}'. +% \itemAP \csintro{\knowledge_kl_namespace_tl} is the \kl{namespace} in which the \kl{knowledge} is to be searched. Not defined by default. +% \itemAP \csintro{\knowledge_kl_linkscope_tl} is a label that points to an instance of a \kl{scope}. It can be empty, and in this case, this means that the search proceeds in the \kl{stack of visible scope instances}. By default it is empty. +% \itemAP \csintro{\knowledge_kl_max_recursion_int} is the maximum number of recursion allowed when searching for a \kl{knowledge}. It is by default 40. % \end{asparaitem} % % The codes can uses internally the following variables, that are accessible for the user when defining new \cs\kl-like commands: % \begin{asparaitem} -% \item \csintro{\knowledge_kl_command_tl} the command that has triggered the search -% \item \csintro{\knowledge_kl_base_key_tl} contains the name of the knowledge for which the search has started, -% \item \csintro{\knowledge_kl_text_tl} contains the text to be displayed, -% \item \csintro{\knowledge_kl_key_tl} contains the name of the knowledge searched at a particular moment, -% \item \csintro{\knowledge_kl_recursion_int} counts the number of indirection in the current, starting from \cs{\knowledge_kl_max_recursion_int}, and going down, -% \item \csintro{\knowledge_kl_link_tl} contains the link to be followed. -% \item \cs{\knowledge_kl_resourcetoken_tl} contains a single token, which is the location of the knowledge. +% \itemAP \csintro{\knowledge_kl_command_tl} the command that has triggered the search +% \itemAP \csintro{\knowledge_kl_base_key_tl} contains the name of the knowledge for which the search has started, +% \itemAP \csintro{\knowledge_kl_text_tl} contains the text to be displayed, +% \itemAP \csintro{\knowledge_kl_key_tl} contains the name of the knowledge searched at a particular moment, +% \itemAP \csintro{\knowledge_kl_recursion_int} counts the number of indirection in the current, starting from \cs{\knowledge_kl_max_recursion_int}, and going down, +% \itemAP \csintro{\knowledge_kl_link_tl} contains the link to be followed. +% \itemAP \cs{\knowledge_kl_resourcetoken_tl} contains a single token, which is the location of the knowledge. % \end{asparaitem} % % \begin{macrocode} @@ -2960,11 +2966,11 @@ Content of the file knowledge-sources.zip: {\int_compare:nNnTF\l_tmpa_int=1 {} {\int_to_alph:n\l_tmpa_int}} \exp_args:Nx\label{\exp_not:V\knowledge_kl_autoref_tl\l_tmpa_tl}} - \expandafter\ktuple_countintro_gincr:N - \knowledge_kl_resourcetoken_tl - \KAuxWriteX - {\exp_not:N\KAuxAutorefTarget - \exp_not:o\knowledge_kl_resourcearguments_tl}} + \expandafter\ktuple_countintro_gincr:N + \knowledge_kl_resourcetoken_tl + \KAuxWriteX + {\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 @@ -3472,15 +3478,15 @@ Content of the file knowledge-sources.zip: \knowledgenewvariant\kl{ - namespace=default, - default style={kl,autoref link}, + namespace= default, + default style= {kl,autoref link}, unknown style= kl unknown, - unknown style cont=kl unknown cont, + unknown style cont= kl unknown cont, style directive={style} } \knowledgenewvariant\intro{ - namespace=default, - default style={intro,autoref target}, + namespace= default, + default style= {intro,autoref target}, unknown style= intro unknown, unknown style cont= intro unknown cont, style directive= intro style @@ -3634,7 +3640,7 @@ Content of the file knowledge-sources.zip: \exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl % \end{macrocode} % \begin{macrocode} -\ScopeActivate +%\ScopeActivate % \end{macrocode} % % diff --git a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx index 961ebf925b6..9e8ede9bd8b 100644 --- a/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx +++ b/Master/texmf-dist/source/latex/knowledge/knowledge-utils.dtx @@ -102,6 +102,13 @@ {} {\tl_set_eq:Nc\c_sys_jobname_str{c_job_name_tl}} % \end{macrocode} +% The interface of expl3 since Mars 2018 has changed and a small patch is required: +% \begin{macrocode} +%\tl_if_exist:NTF +% \ior_str_get:NN +% {} +% {\tl_set_eq:NN\ior_str_get:NN\ior_get_str:NN} +% \end{macrocode} % Some useful adding (newset). % \begin{macrocode} \cs_new:Nn\tl_new:Nn @@ -976,7 +983,7 @@ \bool_do_until:Nn\l_tmpa_bool{ \ior_if_eof:NTF\klg_tmpa_ior {\bool_set_true:N\l_tmpa_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl \exp_args:NNV @@ -1011,10 +1018,10 @@ {\ior_if_eof:NTF\klg_tmpb_ior {\bool_set_true:N\l_tmpa_bool \bool_set_false:N\l_tmp_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl - \ior_get_str:NN + \ior_str_get:NN \klg_tmpb_ior \l_tmpb_tl \tl_if_eq:NNF @@ -1064,17 +1071,43 @@ % % \subsubsection{Overloading command} % Overloading a command is similar in syntax to |\NewDocumentCommand| -% of the \texttt{xparse} package, but it further offer the macro |\SUPERcommand| +% of the \texttt{xparse} package, but it further offers the macro |\SUPERcommand| % (where |\command| is the token under definition), which can be used for calling the original code. -% It is often used in combination with |\XparseArgs| for recreating the arguments if necesssary. -% -% +% Formally, the syntax is:\\ +% |\OverloadCommand\command{arguments}[variant name]{code}|\\ +% The arguments follox the \texttt{xparse} syntax. The variant name is by default ``\texttt{NEW}''. +% Other variants of the commands can be defined by changing this text. +% The macro |\ChooseCommand| allows to choose between the variant. It takes as first argument a control sequence (or a chain of control sequences), and as second argument the variant that should be taken. +% Hence |\ChooseCommand\command{SUPER}| reverts |\command| to its original behaviour. % \begin{macrocode} +\cs_new:Npn\commandVariant#1#2{#2\cs_to_str:N#1} + \cs_generate_variant:Nn\cs_gset_eq:NN{cN,cc} -\NewDocumentCommand\OverloadCommand{mmm} - {\exp_args:Nc\cs_gset_eq:NN{SUPER\cs_to_str:N#1}#1 - \exp_args:Nc\NewDocumentCommand{NEW\cs_to_str:N#1}{#2}{#3} - \cs_gset_eq:Nc#1{NEW\cs_to_str:N#1}} +\NewDocumentCommand\OverloadCommand{mmO{NEW}m} + {\cs_if_exist:cTF + {\commandVariant#1{switch~}} + {} + {\exp_args:Nc\cs_gset_eq:NN + {\commandVariant#1{SUPER}} + #1 + \exp_args:NNx\cs_gset:Npn + #1{\exp_not:c{\commandVariant#1{switch~}}} + } + \exp_args:Nc\NewDocumentCommand + {\commandVariant#1{#3}}{#2}{#4} + \ChooseCommand#1{#3} +} +\NewDocumentCommand\ChooseCommand{mm}{ + \tl_map_inline:nn{#1} + {\cs_if_exist:cTF + {\commandVariant##1{#2}} + {\cs_gset_eq:cc + {\commandVariant##1{switch~}} + {\commandVariant##1{#2}}} + {\tl_show:n + {knowledge_utils~ERROR:~##1~has~no~variant~{#2}}} + } +} % \end{macrocode} % % diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty index 6838bb84372..e575f417c54 100644 --- a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty +++ b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty @@ -23,7 +23,7 @@ %% LaTeX version 1999/12/01 or later. %% \usepackage{expl3} -\ProvidesExplPackage{knowledge}{2018/02/17}{1.10}{} +\ProvidesExplPackage{knowledge}{2018/05/17}{1.11}{} %%%%%%%%%% \RequirePackage{l3keys2e} \RequirePackage{etoolbox} @@ -612,7 +612,7 @@ \bool_do_until:Nn\l_tmpa_bool{ \ior_if_eof:NTF\klg_tmpa_ior {\bool_set_true:N\l_tmpa_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl \exp_args:NNV @@ -647,10 +647,10 @@ {\ior_if_eof:NTF\klg_tmpb_ior {\bool_set_true:N\l_tmpa_bool \bool_set_false:N\l_tmp_bool} - {\ior_get_str:NN + {\ior_str_get:NN \klg_tmpa_ior \l_tmpa_tl - \ior_get_str:NN + \ior_str_get:NN \klg_tmpb_ior \l_tmpb_tl \tl_if_eq:NNF @@ -673,11 +673,34 @@ \ior_new:N\klg_tmpa_ior \ior_new:N\klg_tmpb_ior \iow_new:N\klg_tmpa_iow +\cs_new:Npn\commandVariant#1#2{#2\cs_to_str:N#1} + \cs_generate_variant:Nn\cs_gset_eq:NN{cN,cc} -\NewDocumentCommand\OverloadCommand{mmm} - {\exp_args:Nc\cs_gset_eq:NN{SUPER\cs_to_str:N#1}#1 - \exp_args:Nc\NewDocumentCommand{NEW\cs_to_str:N#1}{#2}{#3} - \cs_gset_eq:Nc#1{NEW\cs_to_str:N#1}} +\NewDocumentCommand\OverloadCommand{mmO{NEW}m} + {\cs_if_exist:cTF + {\commandVariant#1{switch~}} +{} + {\exp_args:Nc\cs_gset_eq:NN +{\commandVariant#1{SUPER}} +#1 + \exp_args:NNx\cs_gset:Npn + #1{\exp_not:c{\commandVariant#1{switch~}}} + } + \exp_args:Nc\NewDocumentCommand + {\commandVariant#1{#3}}{#2}{#4} + \ChooseCommand#1{#3} +} +\NewDocumentCommand\ChooseCommand{mm}{ + \tl_map_inline:nn{#1} + {\cs_if_exist:cTF + {\commandVariant##1{#2}} + {\cs_gset_eq:cc + {\commandVariant##1{switch~}} + {\commandVariant##1{#2}}} + {\tl_show:n + {knowledge_utils~ERROR:~##1~has~no~variant~{#2}}} + } +} \NewDocumentCommand\XparseArgs{mm} {\kutils_reverting_args:Nn#1{#2}} \DeclareExpandableDocumentCommand\ExpXparseArgs{mm} @@ -1278,6 +1301,7 @@ \scope_area_push_ii:n{#1}}} } \cs_new:Nn\scope_internal_push:n { + \ScopeActivate \tl_gset:Nn\scope_top_area_tl{#1} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].nesting_int} \int_gincr:c{\scope_tl.area[\scope_top_area_tl].count_int} @@ -1453,11 +1477,12 @@ \let\label\scopeLabel } \NewDocumentCommand\ScopeActivate{}{ - \scope_internal_push:n{base} \cs_gset_eq:NN\ScopeActivate\relax + \scope_internal_push:n{base} } \AtBeginDocument{\ScopeActivate} \AtBeginDocument{\ScopeHackEnvironments} +\AtEndDocument{\scope_area_pop:n{document}} \scope_area_set:nn{document,base,body} { environment=false } @@ -1480,7 +1505,7 @@ {body}{knowledge=none} % \newenvironment{scope} - {\mode_if_preamble:TF{\scope_area_push:n{scope}}{}} + {\mode_if_preamble:TF{\ScopeActivate\scope_area_push:n{scope}}{}} {\mode_if_preamble:TF{\scope_area_pop:n{scope}}{}} \knowledgeconfigureenvironment{scope}{} \scope_area_set:nn{knowledge~context~internal} @@ -1954,7 +1979,7 @@ {\tl_set:Nn\knowledge_knowledgedefault_tl{#2}} \kl_hide_end: } -\NewDocumentCommand\__kl:w{d() o d() m}{ +\NewDocumentCommand\knowledge_kl:w{d() o d() m}{ \IfNoValueTF{#1} {\IfNoValueTF{#3} {\IfNoValueTF{#2} @@ -2264,7 +2289,7 @@ % \NewDocumentCommand#1{s} {\knowledge_kl_modifiers_add:N#1 - \IfBooleanF{##1}{\__kl:w}} + \IfBooleanF{##1}{\knowledge_kl:w}} % \tl_new_eq:cN {knowledge_kl_\cs_to_str:N#1_namespace_tl} @@ -2616,11 +2641,11 @@ {\int_compare:nNnTF\l_tmpa_int=1 {} {\int_to_alph:n\l_tmpa_int}} \exp_args:Nx\label{\exp_not:V\knowledge_kl_autoref_tl\l_tmpa_tl}} - \expandafter\ktuple_countintro_gincr:N - \knowledge_kl_resourcetoken_tl - \KAuxWriteX - {\exp_not:N\KAuxAutorefTarget - \exp_not:o\knowledge_kl_resourcearguments_tl}} + \expandafter\ktuple_countintro_gincr:N + \knowledge_kl_resourcetoken_tl + \KAuxWriteX + {\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 @@ -2974,15 +2999,15 @@ \knowledgestyle{invisible}{invisible} \knowledgenewvariant\kl{ - namespace=default, - default style={kl,autoref link}, + namespace= default, + default style= {kl,autoref link}, unknown style= kl unknown, - unknown style cont=kl unknown cont, + unknown style cont= kl unknown cont, style directive={style} } \knowledgenewvariant\intro{ - namespace=default, - default style={intro,autoref target}, + namespace= default, + default style= {intro,autoref target}, unknown style= intro unknown, unknown style cont= intro unknown cont, style directive= intro style @@ -3189,7 +3214,6 @@ %%%%%%%%%% \ExplSyntaxOn \exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl -\ScopeActivate \endinput %% -- cgit v1.2.3