texlive[53572] Master/texmf-dist: knowledge (27jan20)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 27 22:55:12 CET 2020


Revision: 53572
          http://tug.org/svn/texlive?view=revision&revision=53572
Author:   karl
Date:     2020-01-27 22:55:12 +0100 (Mon, 27 Jan 2020)
Log Message:
-----------
knowledge (27jan20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/knowledge/README.md
    trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf
    trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.tex
    trunk/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx
    trunk/Master/texmf-dist/tex/latex/knowledge/knowledge.sty

Modified: trunk/Master/texmf-dist/doc/latex/knowledge/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/knowledge/README.md	2020-01-27 21:55:00 UTC (rev 53571)
+++ trunk/Master/texmf-dist/doc/latex/knowledge/README.md	2020-01-27 21:55:12 UTC (rev 53572)
@@ -3,8 +3,8 @@
 
   name: knowledge
   license: LaTeX Project Public License version 1.2 or above
-  version: v1.20
-  date: 2019/12/03
+  version: v1.21
+  date: 2020/01/26
   author: Thomas Colcombet
   mail: thomas.colcombet at irif.fr
   web: https://www.irif.fr/~colcombe/knowledge_en.html

Modified: trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.tex	2020-01-27 21:55:00 UTC (rev 53571)
+++ trunk/Master/texmf-dist/doc/latex/knowledge/knowledge.tex	2020-01-27 21:55:12 UTC (rev 53572)
@@ -391,6 +391,7 @@
    \knowledge{xparse}{package,url={https://www.ctan.org/pkg/xparse}}
    \knowledge{amsmath}{package,url={https://www.ctan.org/pkg/amsmath}}
    \knowledge{amssymb}{package,url={https://www.ctan.org/pkg/amssymb}}
+   \knowledge{mathcommand}{package,url={https://www.ctan.org/pkg/mathcommand}}
 \end{scope}
 
 
@@ -599,11 +600,8 @@
 \maketitle
 
 \begin{abstract}\phantomintro(package){knowledge}%
-The "knowledge@@package" package offers automatic tools and commands
-for helping the writer of a (scientific) document to have all notions (hyper)linked 
-to places where these are defined. Using the standard tools of \LaTeX{} for doing
-that would be extremely tedious.
-Eventually, it is intended to use the package for producing scientific semantic aware documents.
+The "knowledge@@package" package offers commands and notations for handling semantical notions in a (scientific) document.
+This allows to link the use of a notion to its definition, to add it to the index automatically, etc.
 \end{abstract}
 
 \ifcodeTF{\begin{quote}This version of the documentation includes a good part of the code. A casual user should \textit{a priori} not use this version of the documentation.\end{quote}}{}
@@ -636,8 +634,7 @@
 \begin{asparaitem}
 \item deactivate quotation by default in the preamble in particular for avoiding clashes with commands such as \cs\DeclareMathDelimiter.
 \item make knowledge compatible with beamer (request of Patrick Aiyao He), probably use hypertarget and hyperlink instead of hyperlabel and hyperref.  Seems complicated because I do not know how to know if some material is going to be displayed, and this is necessary for a complete working solution.
-I have seen Till Tantau who explained me how to test whether a material is displayed. For this, one has to check that the material is displayed.
-This involves testing  the counter |beamer at coveringdepth| which if higher than one when 'not displayed'.
+I have seen Till Tantau who explained me how to test whether a material is displayed. This involves testing  the counter |beamer at coveringdepth| which if higher than one when 'not displayed'.
 |beamer at slideinframe| could also be intersting.
 \item make quotation work properly in the titles of section...,
 \item allow to protect quotation in commands, and not only environments (for instance xymatrix)
@@ -739,8 +736,10 @@
 \item[2019-10-27] Bug correction and added the `\textbf{patch label}' configuration directive (thanks to \href{https://becca.ooo/}{Rebecca Turner}). V1.18.
 \item[2019-11-19] Now the labels are evaluated before being written to the "kaux file" in a \cs\KAuxNewLinkScopetagInstance\ command (bug fix). V1.19.
 \item[2019-11-29] Help added in the "diagnose file". \textbf{bar suggestion} (still working) renamed to "diagnose bar", and activated by default. \textbf{patch label} is renamed into "label scope". 
-\item[2019-12-02] The "kaux file" is now checked for completeness befre being used. This should avoid errors when the previous compilation failed.
-\item[2019-12-03] Corrected bug in the scope access. V1.20
+\item[2019-12-02] The "kaux file" is now checked for completeness befor being used. This should avoid errors when the previous compilation failed.
+\item[2019-12-03] Corrected bug in the scope access. V1.20.
+\item[2020-01-25] Corrected bug when "knowledge@@package" is used without "hyperref@@package" (thanks to Rémi Nollet).
+\item[2020-01-25] Corrected bug that made the kaux file not stabilize (thanks to Rémi Nollet). V1.21 on CTAN.
 \end{compactdesc}
 \normalsize
 %\restoregeometry
@@ -791,7 +790,7 @@
 \noindent or even better:
 \begin{code}[8cm]
 \cs\usepackage["hidelinks"]\{\kl(package){hyperref}\}\\
-\cs\usepackage[\kl(option){quotation}\footnote{If you want to use the \kl{"}$\cdots$\kl{"} notation.}]\{"knowledge@@package"\}
+\cs\usepackage[\kl(option){quotation}\footnote{If you want to use the \kl{"..."} notation.}]\{"knowledge@@package"\}
 \end{code}
 
 Then, in the preamble (or in an external file), one uses commands of the form:
@@ -804,8 +803,8 @@
 
 Finally in the body of the paper, the sole extra command \cs{\kl} (or the \kl"-symbol if the \kl(option){quotation} option is activated) is used,
 with as parameter a text. This text is searched for, and the directives attached to it (here "url="),
-are used for formatting its printing\footnote{This resembles a lot a macro so far. It nevertheless differs in that: (a) if not defined, it does not make the compilation fail as a macro would, and thus does not interfere with the writing process, (b) any text can be used and not only alphabetic letters as in \TeX, (c) you do not have to care about the space after, and (d)
-in fact the machinery for resolving the meaning of a knowledge is much more powerful than simple macro execution.}.
+are used for formatting its printing\footnote{This resembles a lot a macro so far. It nevertheless differs in that: (a) if not defined, it does not make the compilation fail as a macro would, and thus does not interfere with the writing process, (b) any text can be used and not only alphabetic letters as in default \TeX, (c) you do not have to care about the space after, and (d)
+in fact the machinery for resolving the meaning of a knowledge is much more powerful than simple macro expansion.}.
 Hence:
   \marginpar{\begin{hint}
   If the knowledge is not defined, this does not make the compilation fail.
@@ -914,10 +913,8 @@
 
 
 \begin{problem}
-I am writing a long scientific document with many notions tied together
-(typically, I have made all my best for clarifying but nevertheless
-it remains obscure,
-or it is a long survey involving many subfields, or a book, or a PhD thesis\footnote{Reviewers should appreciate...}).
+I am writing a scientific document with many different definitions, typically a journal article, a PhD thesis\footnote{Reviewers should appreciate...}, or a book.
+
 I would like all the notions to be linked inside the document for being able 
 in one click, whenever something is used, to jump to its definition. I also want to easily write an index.
 However, I do not want it to be a hassle when writing.
@@ -934,10 +931,10 @@
 
 %
 %
-Then write the document using \cs{\intro} (or \kl{""}$\cdots$\kl{""} if \kl(option){quotation} is activated) when a notion is defined/introduced, and
+Then write the document using \cs{\intro} (or \kl{""...""} if \kl(option){quotation} is activated) when a notion is defined/introduced, and
 \marginpar{\begin{hint} Using an \cs{\AP} command is strongly advised,
       and allows to control more precisely where the target of hyperreferences is: at the beginning of a paragraph is better than the beginning of the section several pages before...\end{hint}}
-\cs{\kl}  (or \kl{"}$\cdots$\kl{"} if \kl(option){quotation} is activated) when it is used. For instance:
+\cs{\kl}  (or \kl{"..."} if \kl(option){quotation} is activated) when it is used. For instance:
 \begin{code}[12cm]
 \cs\AP{}
 A \cs\intro\{semigroup\} is an ordered pair \verb|$(S,\cdot)$| where \verb|$\cdot$| is an
@@ -998,7 +995,7 @@
 \end{PDFoutput}
 \knowledgeconfigure{visible anchor points=false}%
 %
-Clicking on `semigroup' now jumps to the place it was introduced, and very precisely at the
+Clicking on `semigroup' now jumps to the place where it was introduced, and very precisely at the
 location of the red corner depicting the presence of the \cs{\AP}-command.
 If now one adds the option \kl{electronic} while loading the package, then the red corners disappear as well as the brownish undefined knowledges which become black. When using the option \kl{paper}, the links are still there, but all texts are in black.
 
@@ -1010,7 +1007,7 @@
 \cs\knowledge\{monoid\}[monoid\vbar Monoids]\{\kl{notion}\}
 \end{code}
 \noindent
-or, using the modre readable "`\vbar'-notation":
+or, using the more readable "`\vbar'-notation":
 \begin{code}[10.7cm]
 \cs\knowledge\{\kl{notion}\}\\
 \indent~~~\klbn|~~semigroup\\
@@ -1040,6 +1037,9 @@
 \indent~~~\vbar~~monoids\\
 \indent~~~\vbar~~Monoids
 \end{code}
+\noindent
+Now, the index (after running \texttt{makeidx}) contains all entries and references to the use of semigroups and monoids.
+
 See Section~\ref{subsection:makeidx option} for more details on making an index.
 %
 %\subsection{Managing an index}
@@ -1141,7 +1141,7 @@
 \begin{itemize}
 \itemAP In ""paper"" mode, the paper is rendered as for printing: in particular, no informative colors are visible. Hyperlinks are nevertheless present.
 \itemAP In ""electronic"" mode, the document has some colors witnessing the existence of the links for the reader to know that clicking is available.
-\itemAP In ""composition"" mode, the document has colors helping the writing: "undefined knowledges" appear explicitly, "anchor points" are displayed, and so on. 
+\itemAP In ""composition"" mode (the default), the document has colors helping the writing: "undefined knowledges" appear explicitly, "anchor points" are displayed, and so on. 
 \end{itemize}
 Activating the modes is obtained either at load time using one of:\\
 \begin{tabular}[t]{ll}
@@ -1205,7 +1205,7 @@
 \itemAP[\intro{active}] The package will be loaded, and all the capabilities that it triggers are activated.
 This is the implicit meaning when nothing more is specified.
 \item[\intro{inactive}] The package is not loaded, and no capabilities are activated (even if it had been loaded previously by another |\usepackage| command).
-\item[\intro{compatibility}] The package is not loaded. The directives it used do not cause any error, but have no effect. 
+\item[\intro{compatibility}] The package is not loaded. The directives it uses do not cause any error, but have no effect. 
 \item[\intro{auto}] If the package was loaded before, then the associated capabilities are activated. This is the default behavior when the package is not named while loading.
 \end{description}
 Currently, the packages that can be loaded are:
@@ -1629,7 +1629,7 @@
 \end{center}\AP 
 in which the ""stared sequence@@variant"" is of the form `\cs{variant1}*\cs{variant2}*\dots*\cs{variantk}'.
 This sequence is declared to reduce to \cs{\variant}.
-For instance, \smallcode{\cs{\knowledgevariantmodifier}\{\cs\intro*\cs\kl\}\cs\intro} declares `\cs{\intro}*\cs{\kl}' to reduce to `\cs{\intro}'.
+For instance, \smallcode{\cs{\knowledgevariantmodifier}\{\cs{\intro*}\cs\kl\}\cs\intro} declares `\cs{\intro}*\cs{\kl}' to reduce to `\cs{\intro}'.
 
 \subsubsection{Examples of \kl{variants of \cs{\kl}}}
 
@@ -1657,7 +1657,7 @@
 ~~~~"unknown style cont=@@variant"  "intro unknown cont@@style",\par
 ~~~~"style directive=@@variant" "intro style at intro style="\par
 \}\par
-\cs\knowledgevariantmodifier\{\cs\intro*\cs\kl\}\cs\intro
+\cs\knowledgevariantmodifier\{\cs{\intro*}\cs\kl\}\cs\intro
 \end{code}
 Note that \cs{\reintro} and \cs{\phantomintro} are defined using similar code.
 
@@ -1699,7 +1699,7 @@
 ~~~~"unknown style=@@variant"csintro unknown,\par
 ~~~~"unknown style cont=@@variant"csintro unknown,\par
 \}\par
-\cs\knowledgevariantmodifier\{\cs\intro*\cs\cs\}\cs\csintro\par
+\cs\knowledgevariantmodifier\{\cs{\intro*}\cs\cs\}\cs\csintro\par
 \cs\knowledgevariantmodifier\{\cs\csintro*\cs\cs\}\cs\csintro\par
 \cs\knowledgevariantmodifier\{\cs\cs*\cs\kl\}\cs\cs\par
 \cs\knowledgevariantmodifier\{\cs\csintro*\cs\kl\}\cs\csintro
@@ -2138,6 +2138,7 @@
     than simply the \kl{autoref} directive. Its use it already configured. \end{hint}}
 \phantomintro{""}
 The \intro{autoref} \kl[\knowledge directives]{directive} is among the most useful offered by the "knowledge@@package" package.
+It is very often used indirectly through directives like "notion".
 When set, the \kl{knowledge} should be used with both \csintro{\intro} (exactly once) --
 or the \kl{""...""} and \kl{""... at ...""} notations (and variants) if \kl(option){quotation} is active -- and \cs{\kl} (possibly several times) -- or the \kl{"..."} notation if \kl(option){quotation} is active. The use of \cs{\kl}
 will hyperlink to the location of the \cs{\intro}. The syntax of \cs{\intro} is the same as
@@ -2356,9 +2357,115 @@
 \subsection{Dealing with math}
 \label{subsection:math}
 
-This part is under development.
+There are essentially two ways in which one would like to use "knowledge@@package" with mathematics:
+\begin{description}
+\item[Single introduction] Some mathematical objects are introduced once and for all in the paper. In this case, all the use of the object 
+should point to the same introduction location.
+\item[Variables] The more advanced case is when one wants to track variables. For instance, a macro variable~\cs\x\ could have a different meaning in two distinct theorems. This case is more similar to variables in a programming language, that have a scope.
+Here the situation is  slightly more complicated since a variable could be introduced in a theorem, and then used many pages later in a proof section for instance.
+\end{description}
+The first use is fairly easy. The second one requires a bit more care. We review them one after the other.
 
+\subsubsection{Defining macros for math}
+
+Defining macros is standard in \TeX, and it should be used systematically in writing scientific documents, in particular
+when using the "knowledge@@package" package.
+The standard way in \LaTeX\ for defining macros is to use \cs\newcommand. However, the resulting macro, if it has
+no optional parameters, is then expandable, and it is better to avoid it using instead \cs\newrobustcmd\ from the "etoolbox@@package"
+package (it has the same syntax).
+
+Another package "mathcommand@@package" has been designed to be used in conjunction with "knowledge@@package".
+We shall use it in the advanced examples below
+It allows:
+\begin{itemize}
+\item to define/redefine commands to be used in math mode only. This allows for instance to use the macro \cs\c\ for producing as usual a cedilla in text mode, and at the same time some variable $\mathbf c$ in math mode. This is achieved using for instance:
+ \smallcode{\cs\renewmathcommand\cs\c\{\cs\mathbf\{c\}\}}.
+\item When redefining a command, it automatically stores the original command \cs\macro\ as \cs\LaTeXmacro. So for instance, if one wants to introduce the constant~$\pi$ in a document and have it linked, one can use:
+  \begin{code}
+  \cs\renewmathcommand\cs\pi\{\cs\kl[\cs\pi]\{\cs\LaTeXpi\}\}\\
+  \cs\knowledge\cs\pi\{notion\}\\
+  {[...]}\\
+  \cs\AP\ Let \$\cs{\intro*}\cs\pi=3.1415\$.\\
+  {[...]}\\
+  Now \$\cs\pi\$ points to the above sentence.  
+  \end{code}
+  This code works because a different name \cs\LaTeXpi\ stores the original macro. Using~\cs\pi\ instead would yield an infinite loop.
+\item The package also gives access to the exponents and indices as well as primes that follow a command (see the documentation).
+\item It also has some facilities for disabling \LaTeX\ commands and provide suggestions of replacement (useful for remembering the macros and working with colleagues).
+\end{itemize}
+
+\subsubsection{Mathematical objects that are singly introduced}
+
+In this case, this is essentially as in text mode. 
+Four points have to be kept in mind:
+\begin{itemize}
+\item Do not use the "quotation notation"  in math mode and in macros. Indeed,
+  some packages, like "tikzcd@@package" use the double-quote symbol in their
+  (math) syntax. In this context, quotes have to be deactivated, and hence macros
+  that would use the "quotation notation" would suddenly not have the expected result.
+\item Do not mix the "knowledge" concerning math commands and normal text. It is in practice
+  difficult to maintain.
+\item Use the control sequence of the macro itself as the "knowledge" name.
+    This does not cause problems and is easier to maintain.
+\item Use the \cs{\intro*} notation for introducing macros. 
+\end{itemize}
+These four points are illustrated in the following code:
+\begin{code}
+\cs\newrobustcmd\cs\myFunction\{\cs\kl[\cs\myFunction]\{\cs\rho\}\}\\
+\cs\knowledge\cs\myFunction\{notion\}\\
+{[...]}\\
+\AP Let \$\cs{\intro*}\cs\myFunction(x)=[...]\$\\
+{[...]}\\
+Now, each use of \$\cs\myFunction\$ points to its introduction.
+\end{code}
+
+Two variation may be comfortable to use.
+
+\paragraph{Disabling commands} 
+When writing a paper, in particular with coauthors, one may be tempted to not always use the macros designed for each case.
+For helping to remember the macro, one can use instead (using the "mathcommand@@package" package):
+\begin{code}
+\cs\disablecommand\cs\rho\\
+\cs\suggestcommand\cs\rho\{Use \cs\myFunction.\}\\
+\cs\newrobustcmd\cs\myFunction\{\cs\kl[\cs\myFunction]\{\cs\LaTeXrho\}\}\\
+\cs\knowledge\cs\myFunction\{notion\}\\
+{[...]}\\
+\AP Let \$\cs{\intro*}\cs\myFunction(x)=[...]\$\\
+{[...]}\\
+Now, each use of \$\cs\myFunction\$ points to its introduction.
+\end{code}
+\noindent The result is that if one uses \cs\rho\ in the code, an error will be issued, and \cs\myFunction\ be suggested as a replacement.
+Note that more than one suggestions can be attached to the macro (if several macros use the symbol~$\rho$). Note also
+that in the definition of \cs\myFunction, \cs\LaTeXrho\ is used instead of~\cs\rho. Indeed, \cs\rho\ has been deactivated,
+but~\cs\LaTeXrho\ gives access to its original meaning.
+
+\paragraph{Redefining the original \TeX\ macro}
+Another situation is that one would like to use the \cs\rho\ control sequence for accessing our function instead \cs\myFunction. Smply because this is more convenient and easy to remember.
+In this case, the "mathcommand@@package" package can also be of some help:
+\begin{code}
+\cs\renewmathcommand\cs\rho\{\cs\kl[\cs\rho]\{\cs\LaTeXrho\}\}\\
+\cs\knowledge\cs\rho\{notion\}\\
+{[...]}\\
+\AP Let \$\cs{\intro*}\cs\rho(x)=[...]\$\\
+{[...]}\\
+Now, each use of \$\cs\rho\$ points to its introduction.
+\end{code}
+\noindent
+The effect of \cs\renewmathcommand\ is that it sets~\cs\LaTeXrho\ to have the same effect as the original \cs\rho\ command,
+and then redefines~\cs\rho.
+
+\subsection{Context dependent variables}
+
+We enter now a more advanced situation. We want to track all the variables in a mathematic document...
+the first thing to do is to give access to the "knowledge@@package" package to the scope of the document.
+The easiest way to do that is to declare in the preamble what are the environments that we want to use.
+\begin{code}
+\cs\knowledgeconfigureenvironment\{theorem,lemma,proof\}\{\}\par\noindent
+\end{code}
+
 \iffalse
+
+%\iffalse
 The "knowledge@@package" package offers several tools for dealing with mathematics. It is mostly still experimental.
 The essential goal is to be able to track the identity variables and to point each of them to its introduction.
 For obtaining this, this requires:
@@ -2389,7 +2496,7 @@
 \smallcode{\cs\knowledgeconfigure\{\kl(option){notion}\}}
 \end{center}\noindent
 \AP It automatically configures a \kl[\knowledge directives]{directive} \intro{notion}
-which is an \kl{autoref} displayed properly:
+which is an \kl{autoref} configured to be displayed in a configurable way:
 \begin{itemize}
 \item In \kl{paper mode}, the \cs{\intro} commands (not in math mode) are emphasized, while the \cs{\kl} commands are displayed as normal. It has the aspect of a normal paper.
 \item In "electronic mode" and \kl{composition mode} (with the "xcolor@@package" package), notions are furthermore typeset in blue when introduced, and in dark blue when used. Without the \kl(package){xcolor} package, underlining draw the attention to the knowledges (not in math mode).
@@ -2454,7 +2561,7 @@
 \cs\end\{document\}
 \end{code}\end{center}\noindent
 will result in that both \kl{knowledges} are considered unknown in the table of contents.
-For the first one, this is due to the expansion of~$\texttt{\robustdisplay\Ltwo}$. For the second, this is due to an implicit translation of the accentuated letter into an internal sequence of commands (for instance `\'e' is translated into the internal sequence `\verb|\IeC {\'e}|'). Some solutions are as follows:
+For the first one, this is due to the expansion of~\cs\Ltwo. For the second, this is due to an implicit translation of the accentuated letter into an internal sequence of commands (for instance `\'e' is translated into the internal sequence `\verb|\IeC {\'e}|'). Some solutions are as follows:
 \begin{itemize}
 \item Make the macros non-expandable, for instance using \cs{\newrobustcmd} (of the \kl(package){etoolbox} package) or \cs{\NewDocumentCommand} (of the \kl(package){xparse} package, with a different handling of arguments) instead of \cs{\newcommand}. Hence:
 \begin{code}
@@ -2500,7 +2607,7 @@
 \label{section:tikzcd}
 
 The package "tikzcd@@package" uses (heavily) the quotes. Thus, it conflicts with the "quotation notation".
-Some other packages may do the same. For solving this issue, the only thingd to do are:
+Some other packages may do the same. For solving this issue, the only things to do are:
 \begin{itemize}
 \item be sure to load these packages before "knowledge@@package", or at least be sure that the "quotation notation" is not
 active when you do so, and
@@ -2536,7 +2643,7 @@
  does not work&&works\\
      \begin{code}[5cm]
      \cs\begin\{\kl{align*}\}\\
-     \cs\intro*\texttt{\robustdisplay{\SomeCommand}}\\
+     \cs{\intro*}\texttt{\robustdisplay{\SomeCommand}}\\
      \cs\end\{\kl{align*}\}\\
    \end{code}
   &&
@@ -2578,7 +2685,11 @@
 \cs\usepackage{["hidelinks"]}\{"hyperref@@package"\}\par\noindent
 \cs\usepackage\{\kl(package){knowledge}\}\par\noindent
 \end{code}
-
+If the package "hyperref@@package" is loaded indirectly (maybe by the class), then the "hidelinks" option can be activated
+at any moment, as soon as "hyperref@@package" is loaded, using \cs\hypersetup:
+\begin{code}[9cm]
+\cs\hypersetup\{"hidelinks"\}
+\end{code}
 \subsection{Problems with scope}
 
 \subsubsection{Problems in combination with \cs{\bibitem} and "thebibliography@@env"}

Modified: trunk/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx	2020-01-27 21:55:00 UTC (rev 53571)
+++ trunk/Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx	2020-01-27 21:55:12 UTC (rev 53572)
@@ -6,7 +6,7 @@
 %
 %  meta-comment
 %
-% Copyright (C) 2017-2019 by Thomas Colcombet
+% Copyright (C) 2017-2020 by Thomas Colcombet
 % -----------------------------------
 %
 % This file may be distributed and/or modified under the
@@ -23,7 +23,7 @@
 %
 % \iffalse
 %<head>\usepackage{expl3}
-%<head>\ProvidesExplPackage{knowledge}{2019/12/03}{1.20}{}
+%<head>\ProvidesExplPackage{knowledge}{2020/01/26}{1.21}{}
 %<*driver>
 \def\knowledgecode{active}
 \input{knowledge.tex}
@@ -53,6 +53,7 @@
 % \changes{1.18}{2019/10/03}{bug fix/improvement} %
 % \changes{1.19}{2019/11/19}{bug fix} %
 % \changes{1.20}{2019/12/03}{bug fix} %
+% \changes{1.21}{2020/01/26}{bug fix} %
 % \GetFileInfo{knowledge.sty} %
 % \DoNotIndex{}
 %
@@ -72,8 +73,8 @@
 
   name: knowledge
   license: LaTeX Project Public License version 1.2 or above
-  version: v1.20
-  date: 2019/12/03
+  version: v1.21
+  date: 2020/01/26
   author: Thomas Colcombet
   mail: thomas.colcombet at irif.fr
   web: https://www.irif.fr/~colcombe/knowledge_en.html
@@ -1291,8 +1292,8 @@
     \knowledge_scopetag_ensure:n{#1}
     \bool_if:cTF{\knowledge_scopetag_tl[#1]_bool}
       {}
-      {\KAuxWriteX*{\exp_not:N\KAuxDeclaredScopeTag{#1}}
-       \bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}}
+      {\bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}}
+    \KAuxWriteX*{\exp_not:N\KAuxDeclaredScopeTag{#1}}
 }
 %    \end{macrocode}
 % \AP The command \csintro{\knowledgescope} associates an "instance" to one or more "scopetags":
@@ -1321,22 +1322,22 @@
 \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{patch~label}
 \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{label~scope}
 %    \end{macrocode}
-% \noindent\AP\csintro{\knowledgelabel} implicitly adds a call to \cs{\knowledgescope} (if \cs{\knowledge_configuration_label_autoscope_bool} is set to true), and then calls the original \cs{\label} code.
+% One first changes the behavior of \cs\label\ in the preamble.
 %    \begin{macrocode}
-\NewDocumentCommand\knowledgelabel{m}{
-    \kl_hide_begin:
-       \bool_if:NTF
+\global\let\knowledge_label_before_loading_package:n\label
+\cs_gset:Npn\label{
+   \mode_if_preamble:TF
+       \knowledge_label_in_preamble:n
+       \knowledge_label_before_loading_package:n
+}
+\cs_new:Npn\knowledge_label_in_preamble:n{
+     \bool_if:NTF
          \knowledge_configuration_label_autoscope_bool
          \knowledge_knowledgescope_one:n
          \use_none:n
-         {#1}
-    \kl_hide_end:
-    \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}
 }
-\let\scopeLabel\knowledgelabel%for backward compatibility
-\let\label\knowledgelabel
 %    \end{macrocode}
-% \AP In order to cicumvent this overloading, the normal \cs{\label} command
+% \AP In order to circumvent this overloading, the normal \cs{\label} command
 % can be used using \csintro{\knowledge_latex_label:n}:
 %    \begin{macrocode}
 \cs_new:Npn\knowledge_latex_label:n{
@@ -1443,9 +1444,14 @@
      \scope_if_triggers_area:nTF{##1}
        {\scope_area_pop:n{##1}}
        {}}
-   \kutils_secure_latex_command:N\label
-   \let\label\knowledgelabel
 }
+\AtBeginDocument{
+  \kutils_secure_latex_command:N\label
+  \def\label#1{\bool_if:NT
+         \knowledge_configuration_label_autoscope_bool
+        {\knowledge_knowledgescope_one:n{#1}}
+     \LaTeXlabel{#1}}
+}
 %    \end{macrocode}
 % 
 % This command will activate the scope package.
@@ -1516,7 +1522,7 @@
   {\scope_area_pop:n{knowledge~import~internal}}
 \NewDocumentEnvironment{knowledge~context}{m}
   {\ScopeActivate\scope_area_push:n{knowledge~context~internal}
-    \knowledgelabel{#1}}
+    \knowledgescope{#1}}
   {\scope_area_pop:n{knowledge~context~internal}}
 %    \end{macrocode}
 % \subsection{Files}

Modified: trunk/Master/texmf-dist/tex/latex/knowledge/knowledge.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/knowledge/knowledge.sty	2020-01-27 21:55:00 UTC (rev 53571)
+++ trunk/Master/texmf-dist/tex/latex/knowledge/knowledge.sty	2020-01-27 21:55:12 UTC (rev 53572)
@@ -23,7 +23,7 @@
 %% LaTeX version 1999/12/01 or later.
 %% 
 \usepackage{expl3}
-\ProvidesExplPackage{knowledge}{2019/12/03}{1.20}{}
+\ProvidesExplPackage{knowledge}{2020/01/26}{1.21}{}
 %%%%%%%%%%
 \RequirePackage{l3keys2e}
 \RequirePackage{etoolbox}
@@ -1476,8 +1476,8 @@
     \knowledge_scopetag_ensure:n{#1}
     \bool_if:cTF{\knowledge_scopetag_tl[#1]_bool}
       {}
-      {\KAuxWriteX*{\exp_not:N\KAuxDeclaredScopeTag{#1}}
-       \bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}}
+      {\bool_gset_true:c{\knowledge_scopetag_tl[#1]_bool}}
+    \KAuxWriteX*{\exp_not:N\KAuxDeclaredScopeTag{#1}}
 }
 \NewDocumentCommand\knowledgescope{ >{\SplitList{,}}m }{
     \kl_hide_begin:\group_begin:
@@ -1493,18 +1493,18 @@
 \bool_gset_true:N\knowledge_configuration_label_autoscope_bool
 \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{patch~label}
 \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{label~scope}
-\NewDocumentCommand\knowledgelabel{m}{
-    \kl_hide_begin:
-       \bool_if:NTF
+\global\let\knowledge_label_before_loading_package:n\label
+\cs_gset:Npn\label{
+   \mode_if_preamble:TF
+       \knowledge_label_in_preamble:n
+       \knowledge_label_before_loading_package:n
+}
+\cs_new:Npn\knowledge_label_in_preamble:n{
+     \bool_if:NTF
          \knowledge_configuration_label_autoscope_bool
          \knowledge_knowledgescope_one:n
          \use_none:n
-         {#1}
-    \kl_hide_end:
-    \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}
 }
-\let\scopeLabel\knowledgelabel%for backward compatibility
-\let\label\knowledgelabel
 \cs_new:Npn\knowledge_latex_label:n{
   \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\label
 }
@@ -1578,9 +1578,14 @@
      \scope_if_triggers_area:nTF{##1}
        {\scope_area_pop:n{##1}}
        {}}
-   \kutils_secure_latex_command:N\label
-   \let\label\knowledgelabel
 }
+\AtBeginDocument{
+  \kutils_secure_latex_command:N\label
+  \def\label#1{\bool_if:NT
+         \knowledge_configuration_label_autoscope_bool
+        {\knowledge_knowledgescope_one:n{#1}}
+     \LaTeXlabel{#1}}
+}
 \NewDocumentCommand\ScopeActivate{}{
   \cs_gset_eq:NN\ScopeActivate\relax
   \scope_internal_push:n{base}
@@ -1633,7 +1638,7 @@
   {\scope_area_pop:n{knowledge~import~internal}}
 \NewDocumentEnvironment{knowledge~context}{m}
   {\ScopeActivate\scope_area_push:n{knowledge~context~internal}
-    \knowledgelabel{#1}}
+    \knowledgescope{#1}}
   {\scope_area_pop:n{knowledge~context~internal}}
 \KAuxBefore{\IfKAuxReadyTF{\KAuxProcess{init}}{}}
 \KAuxInit{}



More information about the tex-live-commits mailing list.