diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/README.md | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/knowledge.pdf | bin | 734028 -> 767239 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/knowledge.tex | 459 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/knowledge/knowledge-code.dtx | 574 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/knowledge/knowledge.sty | 460 |
5 files changed, 1138 insertions, 359 deletions
diff --git a/Master/texmf-dist/doc/latex/knowledge/README.md b/Master/texmf-dist/doc/latex/knowledge/README.md index 5292d7886d0..aeb2b6ed6d6 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.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 diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf Binary files differindex 4afd478edc9..3937cecefaa 100644 --- a/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf +++ b/Master/texmf-dist/doc/latex/knowledge/knowledge.pdf diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex index ba4b94a5989..b0d40485a8b 100644 --- a/Master/texmf-dist/doc/latex/knowledge/knowledge.tex +++ b/Master/texmf-dist/doc/latex/knowledge/knowledge.tex @@ -5,6 +5,7 @@ \usepackage[svgnames]{xcolor} \usepackage{expl3} \usepackage{hyperref} +\usepackage{cleveref} %\usepackage{complexity} \usepackage[quotation,scope,silent]{knowledge} \knowledgeconfigure{visible anchor points=false} @@ -128,7 +129,9 @@ unknown warning=false, unknown diagnose=true, suggestion=cs, - PDF string={\detokenize{#1}}} + PDF string={\detokenize{#1}} +} + \knowledgestyle{cs}{wrap=\Robustdisplay,typewriter,up,md,color=NavyBlue} \knowledgestyle{cs unknown}{wrap=\Robustdisplay,typewriter,up,md,color=black} @@ -292,11 +295,13 @@ \knowledge{link scope=}{directive} \knowledge{style=}{directive} \knowledge{intro style=}{directive} +\knowledge{no index}[no index=]{directive} \knowledge{wrap=}{directive} \knowledge{scope=}{directive} \knowledge{export=}[export]{directive} \knowledge{now}{directive} - +\knowledge{directive} + | automatic in command \knowledge{protect link}{directive} \knowledge{strict}{directive} @@ -347,6 +352,7 @@ \knowledge{hyperref}{option} \knowledge{xcolor}{option} \knowledge{makeidx}{option} + \knowledge{cleveref}{option} \knowledge{scope}{option} \knowledge{quotation}[quotation=]{option} \knowledge{notion}{option} @@ -354,6 +360,7 @@ \end{scope} \knowledge{hyperref option}{link=hyperref,link scope=option} \knowledge{makeidx option}{link=makeidx,link scope=option} +\knowledge{cleveref option}{link=cleveref,link scope=option} \knowledge{scope option}{link=scope,link scope=option} \knowledge{xcolor option}{link=xcolor,link scope=option} \knowledge{notion option}{link=notion,link scope=option} @@ -361,6 +368,9 @@ \knowledge{visible anchor points}[visible AP|visible AP=|visible anchor points=]{option} +\knowledge{anchor point shape}[anchor point shape=|AP shape=|AP shape]{option} +\knowledge{anchor point color}[anchor point color=|AP color=|AP color]{option} +\knowledge{anchor point shift}[anchor point shift=|AP shift=|AP shift]{option} \knowledge{protect quotation}[protect quotation=]{option} \knowledge{protect link co}{option,text=protect link} \knowledge{unprotect link co}{option,text=unprotect link} @@ -397,6 +407,7 @@ \knowledge{standalone}{package,url={https://www.ctan.org/pkg/standalone}} \knowledge{xcolor}{package,url={https://www.ctan.org/pkg/xcolor}} \knowledge{makeidx}{package,url={https://www.ctan.org/pkg/makeidx}} + \knowledge{cleveref}{package,url={https://www.ctan.org/pkg/cleveref}} \knowledge{etoolbox}{package,url={https://www.ctan.org/pkg/etoolbox}} \knowledge{xparse}{package,url={https://www.ctan.org/pkg/xparse}} \knowledge{amsmath}{package,url={https://www.ctan.org/pkg/amsmath}} @@ -404,6 +415,8 @@ \knowledge{mathcommand}{package,url={https://www.ctan.org/pkg/mathcommand}} \end{scope} +\knowledge{arXiv}{package,url={https://arxiv.org/}} + \knowledgedirective{environment}{typewriter} \begin{scope}\label{env} @@ -414,6 +427,7 @@ \knowledge{tikzcd}{environment,ref=section:tikzcd} \knowledge{thebibliography}{environment,ref=section:thebibliography} \knowledge{document}{environment} + \knowledge{picture}{environment} \end{scope} \knowledge{variant directives}[variant directive|Variant directives]{doc notion} @@ -428,6 +442,7 @@ \knowledge {unknown warning=}{directive} \knowledge {unknown diagnose=}{directive} \knowledge {suggestion=}{directive} + \knowledge {display code=}{directive} \knowledge {PDF string=}{directive} \knowledge {stared sequence}{doc notion} \knowledge {modifier}[modifiers|Modifiers]{doc notion} @@ -440,7 +455,7 @@ \knowledge{label}{} -\knowledge{variant of \cs{\kl}}[variants of \cs{\kl}|Variants of \cs{\kl}]{doc notion} +\knowledge{variant of \cs{\kl}}[variants of \cs{\kl}|Variants of \cs{\kl}|variants|variant]{doc notion} \knowledge{scoping}[Scoping]{doc notion} \knowledge{package option}[package options|Package options]{doc notion} \knowledge{configuration option}[configuration options|Configuration options]{link=package option} @@ -610,8 +625,8 @@ \maketitle \begin{abstract}\phantomintro(package){knowledge}% -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. +The "knowledge@@package" package offers commands and notations for handling semantical notions in a document. +This allows to easily 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}}{} @@ -753,8 +768,13 @@ I have seen Till Tantau who explained me how to test whether a material is displ \item[2020-03-05] Now \texttt{hidelinks} and \texttt{breaklinks} are automatically activated unless the new option \kl{no patch} is activated. Doc update. V1.22 on CTAN. \item[2020-04-25] Made the package compatible with 2016 versions of LaTeX. Useful when \texttt{knowledge.sty} is included with and compile in arXiv. V1.23 on CTAN. \item[2020-05-02] Doc update ("acmart@@package" colors, thanks to Daniela Petri\c san). -\item[2020-09-22] Adding the "silent" option as suggested by Patrick Lambein-Monette. V1.24 on CTAN -\item[2021-03-31] Correcting a bug caused by a change of semantics in "expl3@@package". V1.25 on CTAN +\item[2020-09-22] Adding the "silent" option as suggested by Patrick Lambein-Monette. V1.24. +\item[2021-03-31] Correcting a bug caused by a change of semantics in "expl3@@package". V1.25. +\item[2021-05-25] Added the \cs\kref, \cs\kpageref, \cs\kcref, and \cs\kCref\ commands a suggested by Ziv Scully. +\item[2021-05-26] Corrected wrongly used default parameter in \cs\knowledgedirective. +\item[2021-05-27] The explicit text given in a \cs\kl-command now overrides the "text=" directive. +\item[2021-07-18] Adding the "no index" directive. +\item[2021-12-20] Adding options "anchor point shape", "anchor point color", "anchor point shift" (rom request of RĂ©mi Morvan). \end{compactdesc} \normalsize %\restoregeometry @@ -902,7 +922,7 @@ makes it possible to use the notions in many contexts: In the above code all quoted parts send the reader to the same wikipedia page about groups. Note in particular that \smallcode{\kl"morphism@@GROUP\kl"} simply displays `morphism' at compilation. The \smallcode{GROUP} part is a "scope". -In another part of the document, \smallcode{\kl"morphism@@RING\kl"} can be safely using while using an unspecialised \smallcode{\kl"morphism\kl"} would become quickly unmanageable. +In another part of the document, \smallcode{\kl"morphism@@RING\kl"} can be safely used whereas using an generic \smallcode{\kl"morphism\kl"} would become quickly unmanageable. @@ -1032,6 +1052,15 @@ These \kl(ex1)[semigroup]{algebraic objects} \kl{[...]} \end{PDFoutput}\noindent The term is properly linked to the definition of semigroups. +Another possibility is to refer to the location of the definition, using commands \cs\kref, \cs\kpageref, and even better their improvements \cs\kcref, \cs\kCref, etc (when using the "cleveref@@option" package). For instance, +\begin{code} +\kl"Semigroups\kl" are introduced in \cs\kCref\{semigroup\},\\ Page~\cs\kpageref\{semigroup\}. +\end{code} +\noindent yields: +\begin{PDFoutput}[10cm] + \kl(ex1)[semigroups]{Semigroups} are introduced in \kCref(ex1){semigroups}, + Page~\kpageref(ex1){semigroups}. +\end{PDFoutput} Finally, in particular for large documents, it is good to have an "index". For this, one should load the package "makeidx@@package" before "knowledge@@package". Then use it normally: putting \cs{\makeindex} in the preamble and \cs{\printindex} at the end of the document. @@ -1047,9 +1076,9 @@ Finally, the \cs{knowledge} commands are adapted in a straightforward manner: \indent~~~\klbn|~~morphism@SG\\ \indent~~~\klbn|~~morphisms@SG \end{code}\noindent -Now, the index (after running \texttt{makeidx}) contains all entries and references to the use of semigroups and semigroup morphisms. +Now, the index (after running \texttt{makeindex}) contains all entries and references to the use of semigroups and semigroup morphisms. -See Section~\ref{subsection:makeidx option} for more details on making an index. +See \kCref(option){makeidx} for more details on making an index. % %\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. @@ -1060,33 +1089,17 @@ See Section~\ref{subsection:makeidx option} for more details on making an index. \subsection{Mathematics} \label{subsection:mathematics scenario} -The examples above show various techniques for using \kl{knowledges} for enhancing the information associated to terms. In fact, these techniques are not incompatible with mathematics. Imagine, for instance that you would like each time a macro \kl[@token]{\monoid} is met, to display $\mathcal M$, you would do for instance: -\begin{code}[7cm] -\cs\newrobustcmd\kl[@token]\monoid\{\cs\mathcal\ M\} -\end{code}\noindent -Imagine that furthermore, you would like to hyperlink to the definition of a monoid. A standard \cs{\kl} command does the job\footnote{It is highly advised to not use the "quotation notation" in math mode or macros.}: -% -\marginpar{% - \begin{hint} - Defining new macros is best done using \cs{\newrobustcmd} - (of the "etoolbox@@package" package), rather than \cs{\newcommand} as usual in \LaTeX. - This remark is general independently of the use of "knowledge@@package". - \end{hint} - \begin{hint} - The package "mathcommand@@package" offers severals capabilities for redefining commands for math mode. - See Section~\ref{subsubsection:mathcommand} for more. - \end{hint}} -% +The examples above show various techniques for using \kl{knowledges} for enhancing the information associated to terms. In fact, these techniques are not incompatible with mathematics. Some special syntax is even offered: \begin{code}[9cm] -\cs\newrobustcmd\kl[@token]\monoid\{\cs\kl -monoid]\{\cs\mathcal\ M\}\}\\~ -What is \$\kl[@token]\monoid\$ ? +\cs\knowledgenewrobustcmd\cs\closure[1]\{\cs\cmdkl\{\cs\langle\}\#1\cs\cmdkl\{\cs\rangle\}\}\}\\ +{[...]}\\ +The closure of~\$X\$ under product is denoted~\$\cs\intro*\cs\closure\{X\}\$ \end{code}\noindent \noindent would yield: \begin{PDFoutput}[4cm] -\newcommand \monoid{\kl[monoid]{\mathcal M}} -What is $\monoid$ ? +\knowledgenewrobustcmd \monoid{\cmdkl{\mathcal M}} +A monoid is $\monoid$ ! \end{PDFoutput} \begin{problem} But I want more. I want to be able to introduce variables. @@ -1364,6 +1377,9 @@ A certain number of Boolean directives are available without any options. These (that leaves it in the default state, or the one determined by surrounding knowledges). The general boolean \kl[\knowledge directives]{directives} are the following: \begin{description} +\itemAP[\kl{autoref}] activates the ability to introduce once, use several times an instance. This is often used for defining links inside a document (see the "hyperref@@option" in \kCref*"hyperref@@option"). This can also be used for constructing the index (see the "makeidx@@option" in \kCref*"makeidx@@option"). It can simply be used for referencing the number of the environment or the proper page of introduction (see \cs\kref\ and \cs\kpageref\ commands and their more powerful "cleveref@@option" in \kCref*"cleveref@@option"). +\itemAP[\kl{autorefhere}] puts immediately a label at the location of the definition, and makes all \cs{\kl} occurrences of this \kl{knowledge} +hyperlink to this location. \itemAP[\intro{emphasize}] forces the text to be emphasized using `\cs{\emph}', \itemAP[\intro{italic}/\intro{up}] forces/unforces italic ("up" does nothing in math mode), \itemAP[\intro{boldface}/\intro{md}] forces/unforces boldface (be it in math or text mode), @@ -1451,12 +1467,12 @@ A certain number of \intro{default styles} are also offered, that in particular \label{subsubsection:macro directives} When defining \kl{knowledges}, it is often the case that the same -sequence of directives are used. \intro{Macro directives} are here for simplifying this situation (see also \cs{\knowledgedefault} and \cs{\knowledgestyle}). This is achieved using the \cs{\knowledgedirective} directive: +sequence of directives are used. \intro{Macro directives} are here for simplifying this situation (see also \cs{\knowledgedefault} and \cs{\knowledgestyle}). This is achieved using the \cs{\knowledgedirective} macro: \marginpar{\begin{hint} This should not be confused with \kl{styles} which offer another way to control the display.\end{hint}} \begin{center} \smallcode{\csintro{\knowledgedirective}*\{name\}[optional parameter]\{directives\}} \end{center} -After such a command has been issued, `name' becomes a \kl[\knowledge directives]{directive} +After execution of the command, `name' becomes a \kl[\knowledge directives]{directive} usable in \cs{\knowledge} commands, that amounts to execute the comma separated list `directives'. The newly created \kl[\knowledge directives]{directive} may receive a value, that is accessible as \texttt{\#1} in `directives'. By default, it does not allow the redefinition of a directive. This can be forced using the optional \texttt*. The `optional parameter' gives a default value. For instance: \begin{code} @@ -1518,9 +1534,12 @@ The optional star does not reset the \kl{default directives} but simply add new -\subsection{The \cs{\kl} command} +\subsection{The \cs{\kl} command and variants} \label{subsection:kl command} +The \cs\kl\ command is used for displaying a knowledge in the text, while using the data associated to it +(introducing a target link, linking to its definition, linking to an outer document, changing color, putting an entry in the index, etc). + \subsubsection{The standard syntax} \marginpar{\begin{hint} Note that the \cs{\kl} command can often be replaced by the @@ -1535,20 +1554,19 @@ or\quad& \smallcode{\csreintro{\kl}[\kl[knowledge name]{optional knowledge name}](\kl[klab]{optional scope})\{text\}}\ . \end{tabular} \end{center} -Its meaning is to search for the `optional knowledge name' if present, or for `text' otherwise. How this is exactly performed depends on the presence of the \kl[klab]{optional label}. +Its meaning is to search for the `optional knowledge name' if present, or for `text' otherwise. How this is exactly performed depends on the presence of the \kl[klab]{optional scope}. The search process is as follows: \begin{asparaitem} -\itemAP if an \intro[klab]{optional label} is given, the \kl{knowledge} is searched in the corresponding scope. +\itemAP if an \intro[klab]{optional scope} is given, the \kl{knowledge} is searched in the corresponding scope. \itemAP otherwise, the \kl{stack of visible scope instances} is processed through (starting from the inner most) - until a \kl{knowledge} of name `\kl{knowledge name}' or `text', of \kl{namespace} `default' and this \kl{scope} - is found. + until a \kl{knowledge} of name `\kl{knowledge name}' (or `text' if not optional \kl{knowledge name} has been given), of \kl{namespace} `default', and this \kl{scope} is found. If the `knowledge name/text' has not been found, the \kl{style} `"kl unknown@@style"' (or similar "styles", as defined by the "unknown style=@@variant" or "unknown style cont=@@variant") is used, and the text displayed. \item Otherwise, the \kl{knowledge} is executed. If it is a \kl{link=} or \kl{synonym} defined \kl{knowledge}, the link is followed, and the process continues. \item Finally, all the definitions involved in the \kl{knowledge} are processed, following a \kl{style=} if defined, the \kl{knowledge} is updated (essentially incrementing the counter of use), and the \kl{knowledge} is displayed. \end{asparaitem} -This general mechanism is used also by other commands that are variations around \cs{\kl} such as in particular \cs{\intro}. +This general mechanism is used also by other commands that are "variants of \cs{\kl}" such as \cs{\intro}, \cs{\reintro}, \cs{\kref}, \cs{\kpageref}, and so on. \subsubsection{The "quotation notation"} @@ -1602,7 +1620,22 @@ There are nevertheless some situations in which one would prefer to use the orig -\subsubsection{\kl{Variants of \cs{\kl}}, \cs{\knowledgenewvariant}, \cs{\knowledgevariantmodifier} } +\subsubsection{\kl{Variants of \cs{\kl}}} +Several variants of the \cs\kl-command are defined by default. The syntax for their use is the same (including "scopes", \dots). +The following variants are linked to the "autoref" directive: +\begin{itemize} +\item \cs\intro\ is used to introduce a knowledge. +\item \cs\reintro\ displays like for introducing the knowledge, but does not do it. +\item \cs\rekl\ behaves like \cs\kl\ acts as a modifier and transforms \cs\intro\ into \cs\reintro. +\item \cs\phantomintro\ performs the introduction, but does display anything. +\itemAP \csintro\kref\ displays the number of the environment in which the introduction took place. +\itemAP \csintro\kpageref\ displays the number of the page in which the knowledge introduction took place. +\item \csintro\kcref, \csintro\kCref, \csintro\kcpageref, \csintro\kCpageref, \csintro\knamecref, \csintro\knameCref, +\csintro\knamerefs, and \csintro\knameCrefs, display informations about the place of introduction of a "knowledge", +following the semantics of the corresponding functions in the "cleveref@@package" package (see \kCref*"cleveref@@option"). +\end{itemize} + +\subsubsection{Defining your own \kl{variants of \cs{\kl}}} \label{subsubsection:variants} \phantomintro{variant of \cs{\kl}}% It may happen for several reasons that we may want to define new variants of the \cs{\kl} macros, that essentially perform the same task, but are configured differently. Typical examples may be: @@ -1639,6 +1672,7 @@ These command define/modify a/the macro \cs{\variant} that uses the same syntax \itemAP[""suggestion=@@variant""\{directives\}] configures the "directives" to be suggested in the "diagnose file" when the "knowledge" is unknown. \itemAP[""PDF string=@@variant""\{code\}] gives a substitute text for "hyperref@@package" to use for producing the bookmarks. This code has to be expandable. The code may use three parameters; $\sharp1$ is the main text of the command, $\sharp 2$ is the optional parameter, and $\sharp 3$ is the scope. The macro \cs{\IfNoValueTF} of the package "xparse@@package" can be used to test if the second and third arguments are present. By default, the code is \texttt{\{$\sharp1$\}}. Note that the star syntax cannot be used in this context. It the expected result cannot be achieved using this directive, the less convenient macro \cs{\texorpdfstring} of the "hyperref@@package" package should be used. +\item[""display code=@@variant""] can be used to shortcut the standard code for display. See the code for more details. Typical examples are the "variants" \cs\kref,\ \cs\kpageref\ and so on, which do not display the knowledge itself, but instead treat the underlying label associated. \end{compactdesc} \smallskip @@ -1686,13 +1720,14 @@ Note that \cs{\reintro} and \cs{\phantomintro} are defined using similar code. \AP The second code example is used in this document (the documentation of the package) and consists of two macros \csintro{\cs} and \csintro{\csintro} which have the following semantics: \begin{itemize} -\item these have the same syntax as \cs{\kl} and \cs{\intro} respectively. -\item these are used to display control sequences without executing it, -\item if \cs{\csintro} is never used, it appears in black, -\item is \cs{\csintro} is used, then it is in color blue, and the calls to \cs{\cs} - are in dark blue, and furthermore, the \cs{\cs} calls possess an hyperlink to - the call to \cs{\csintro}. -\item no \cs{\knowledge} command is necessary, and no warnings are issued. +\item these correspond, and have the same syntax as, \cs{\kl} and \cs{\intro} respectively, +\item these are used to display control sequences without executing them, +\itemAP if \smallcode{\cs{\csintro}\{\cs[\ucommand]\command\}} is used, then it displays \csintro\command\ in color blue, and + every occurrences of \smallcode{\cs\cs\{\cs\command\}} yields \cs\command\ being displayed in dark blue + and linking to the introduction point, +\item if \smallcode{\cs\csintro\{\cs[\ucommand]\command\}} is never used, + then \smallcode{\cs\cs\{\cs[\ucommand]\command\}} simply displays \cs[\ucommand]\command\ in black, +\item no \cs{\knowledge} command is necessary, and no warning is issued if a command is unknown. \end{itemize} \begin{code} \cs\knowledgestyle\{cs\}\par @@ -1715,14 +1750,12 @@ following semantics: \cs\knowledgenewvariant\cs\csintro\{\par ~~~~"namespace=@@variant"cs,\par ~~~~"auto knowledge=@@variant"\{"autoref","scope="document,"also now"\},\par -~~~~"default style=@@variant"\{autoref target,csintro\},\par +~~~~"default style=@@variant"\{"autoref target",csintro\},\par ~~~~"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\csintro*\cs\cs\}\cs\csintro\par -\cs\knowledgevariantmodifier\{\cs\cs*\cs\kl\}\cs\cs\par -\cs\knowledgevariantmodifier\{\cs\csintro*\cs\kl\}\cs\csintro \end{code} Several things can be noted about this code: \begin{asparaitem} @@ -1732,7 +1765,7 @@ Several things can be noted about this code: \item when a \cs{\csintro} command is met, the corresponding \cs{\knowledge} command is automatically issued, in particular with `"scope="document' for guaranteeing the visibility of each command everywhere in the document, \item the "also now" directive is necessary for the compilation to (possibly) stabilize in two iterations, since it uses the proper \cs{\label} already at the first iteration (without "also now", it would be performed on the second one only, and with just "now", it would be visible only by the uses after the introduction). -\item warnings and diagnose information is explicitly eliminated. +\item warnings and diagnose pieces of information are explicitly eliminated. \end{asparaitem} @@ -1754,10 +1787,10 @@ the "quotation notation": \begin{tabular}{ccc} \smallcode{\cs\kl(scope name)\{knowledge\}}% &~or~&% - \smallcode{\cs\kl(scope name)[knowledge]\{displayed text\}}\\ + \smallcode{\cs\kl(scope name)[knowledge]\{text\}}\\ \smallcode{\klqn"knowledge\klqn{@@}scope\klqn"}% &~or~&% - \smallcode{\klqn"displayed text\klqn@knowledge\klqn@scope\klqn"} + \smallcode{\klqn"text\klqn@knowledge\klqn@scope\klqn"} \end{tabular} \end{center} It works also for \cs{\intro} and with double quotes. @@ -1823,12 +1856,12 @@ This is convenient, in particular for having synonyms in different scopes: Here, general \klqn"groups\klqn" are not defined but \klqn"groups\klqn{@@}abelian\klqn" are,\\ and correspond to \klqn"abelian groups\klqn".\\ \cs\begin\{"scope@@env"\}\cs\knowledgeimport\{abelian\}\\ -\indent~~Her, all \klqn"groups\klqn" here are abelian.\\ +\indent~~All \klqn"groups\klqn" here are abelian.\\ \cs\end\{"scope@@env"\} \end{code} -"Scopes" can also be attached to areas in the code. It is convenient to use the usual \cs{\label} command to name them (though a priori two different spaces of naming are used). +"Scopes" can also be attached to areas in the code. It is convenient to use the usual \cs{\label} command to name them (though, in practive, two different naming spaces are used). \begin{code} \textcolor{gray}{\% We declare first in the preamble the environments that can have}\\ \textcolor{gray}{\% knowledges attached to them.}\\ @@ -1963,7 +1996,7 @@ For instance: \noindent will induce the corresponding environments to have internal knowledges. -Most of the times, it is not necessary to use "scope directives". +Most of the time, it is not necessary to use "scope directives". \begin{remark} Note that (in the current implementation) it is necessary to use the @@ -1977,10 +2010,11 @@ commands \cs{\begin} and \cs{\end}. Hence \cs{\proof}\dots\cs{\endproof} would \itemAP[\intro(area){scope=}\texttt{true/false}] tells whether an environment should induce a scope. For the moment, this is not used (as soon as configured, it always behaves like a scope). \itemAP[\intro(area){label=}\texttt{none/accepts}] tells whether a \cs{\label} command can refer to an "instance" of this "area", \itemAP[\intro(area){environment=}\texttt{true/false}] should be set to true if the scope has to be opened whenever an environment of same name is opened using the \cs{\begin} and \cs{\end} commands of "latex". - \itemAP[\intro(area){autoclose=}\texttt{true/false}] means that the closure is triggered by another event (closure of another enclosing instance, or pushing of an area that requires its closure). It should be true for "latex" environments, and false when configuring, e.g, \cs{\section} to open an "scope" (since the end of the section is automatic: when another section is opened, or some higher level sectioning command). - \itemAP[\intro(area){parents=}\{"area1@area","area2@area",\dots\}] takes a comma separated list of areas that are allowed as parent. For opening the area, some enclosing instances may be automatically closed for reaching such a parent (if their "autoclose=@@area" "directive@scope directive" is set to true). - \itemAP[\intro(area){push code=}\texttt{\{code\}}] defines the code to be executed when the area is pushed (each time, these are added). - \itemAP[\intro(area){pop code=}\texttt{\{code\}}] defines the code to be exected when the are is popped (added too). + \itemAP[\intro(area){autoclose=}\texttt{true/false}] means that the closure is triggered by another event (closure of another enclosing instance, or pushing of an area that requires its closure). It should be true for "latex" environments, and false when configuring, e.g, \cs{\section} opens a "scope" and its closure should be automatic when another section begins. + \itemAP[\intro(area){parents=}\{"area1@area","area2@area",\dots\}] takes a comma separated list of areas that are allowed as parent. For opening the area, some enclosing instances may be automatically closed for reaching such a parent (if their "autoclose=@@area" "directive@scope directive" is set to true). For instance, the parent of a subsection should be a section: + Hence when a subsection begins, the currently opened subsection and subsubsection are closed. + \itemAP[\intro(area){push code=}\texttt{\{code\}}] defines some code to be executed when the area is pushed (each time, these are added). + \itemAP[\intro(area){pop code=}\texttt{\{code\}}] defines some code to be executed when the area is popped (added too). \itemAP[\intro(area){occurrences=}\texttt{once/multiple/recursive}] can be one of `\texttt{once}' if the area can only have one instance in the document, `\texttt{multiple}' if there can be several instances, but not nested, and `\texttt{recursive}', if there is no restriction. \itemAP[\intro(area){forces=}"area"] requires a specific area as an ancestor of this area. This ancestor is implicitly pushed if necessary. \end{compactdesc} @@ -1993,7 +2027,7 @@ By default, the "knowledge@@package" package tries to not stop the compilation u \AP Very often there is some \kl[undefined knowledge]{undefined knowledge}. -Such \kl{knowledges} are displayed using "kl unknown@@style" and "kl unknown cont@@style") +Such \kl{knowledges} are displayed using the "kl unknown@@style" and "kl unknown cont@@style") \kl{styles} when issued by \cs{\kl}; using "intro unknown@@style" and "intro unknown cont@@style" when issued by \cs{\intro}. The detail of the problems are then gathered in the \kl{diagnose file}. @@ -2147,10 +2181,6 @@ deactivates or reactivates the links. \item[\intro{url=}]\texttt{\{url address\}} puts an hyperlink to an (external) url (the braces can be omitted when there is no comma). \marginpar{\begin{hint} You may have to use \texttt{$\backslash$\~} instead of \texttt{\~} in url's addresses.\end{hint}} -\item[\kl{autoref}] activates the ability to introduce once, use several times an instance. This is very convenient when writing scientific documents with many notions. This is the basic directive activating -the features of the \cs{\intro} command. -\item[\kl{autorefhere}] puts immediately a label at the location of the definition, and makes all \cs{\kl} occurrences of this \kl{knowledge} -hyperlink to this location. \end{description} \subsubsubsection{The \kl{autoref} directive} @@ -2343,10 +2373,28 @@ and a \intro{unit2} to be One can check that the different knowledges are properly hyperlinked, and that precise targets are the one described by \cs{\AP} and \cs{\itemAP}. For helping debugging the \kl{anchor points}, these are by default made visible as (red) corners on output. When the "knowledge@@package" package is loaded with the \kl{paper} option this graphical help disappears. -This can also be desactivated using:\phantomintro{visible anchor points} - \begin{code}[9cm] - \cs\knowledgeconfigure\{\kl{visible anchor points=}false\} - \end{code} +This can also be deactivated using:\phantomintro{visible anchor points} +\begin{quote} + \smallcode{\cs\knowledgeconfigure\{\kl{visible anchor points=}false\}}. +\end{quote} +\AP The color of "anchor points" can be changed using (in which colors are defined as in the package "xcolor@@package"): +\begin{quote} + \smallcode{\cs\knowledgeconfigure\{""anchor point color=""color\}}, or \\ + \smallcode{\cs\knowledgeconfigure\{""AP color=""color\}}. +\end{quote} +\AP The shape of "anchor points" can be changed using (in which shape can be one of + \texttt{tiny corner}, \texttt{small corner}, \texttt{corner}, \texttt{large corner}, + \texttt{tiny cross}, \texttt{small cross}, \texttt{cross}, \texttt{large cross}, or some code to be used in the "picture@@env" environment): +\begin{quote} + \smallcode{\cs\knowledgeconfigure\{""anchor point shape=""shape\}}, or \\ + \smallcode{\cs\knowledgeconfigure\{""AP shape=""shape\}}. +\end{quote} +Finally, the "anchor points" reference point can be shifted, using: +\begin{quote} + \smallcode{\cs\knowledgeconfigure\{""anchor point shift=""\{$x$,$y$\}}, or \\ + \smallcode{\cs\knowledgeconfigure\{""AP shift=""\{$x$,$y$\}\}}, +\end{quote}\noindent +in which $x$ and $y$ are by default in unit \texttt{em} (note the use of curly braces and of no parenthesis, which is mandatory). \subsubsection{The \kl{makeidx option}} @@ -2373,7 +2421,36 @@ The following \kl[\knowledge directives]{directives} are to be used: \cs\def\cs\knowledgeIntroIndexStyle\#1\{\cs\fbox\{\#1\}\} \end{code} \end{description} +\AP +The "directive" ""no index"", deactivates the index feature for a knowledge. This is meant to be used in a "style". +For instance +\begin{code} +\cs\knowledgedirective\{standard\}\par\noindent~~~~~ + \{"autoref","style="standard,"intro style="intro standard\}\\ +\cs\knowledgestyle\{standard\}\{"no index"\}\\ +\cs\knowledgestyle\{intro standard\}\{"emphasize"\}\\ + +\cs\knowledge\{test\}\{standard,"index=" test\} +\end{code}\noindent +result in that the introductions of `test' will be gathered in the index, but not the other uses. +\subsubsection{The \kl{cleveref option}} + +The \intro(option){cleveref} option loads the "cleveref@@package" package and gives access to new commands: +\csintro\kcref, \csintro\kCref, \csintro\kcpageref, \csintro\kCpageref, \csintro\knamecref, \csintro\knameCref, +\csintro\knamerefs, and \csintro\knameCrefs\ which are respectively equivalent to \cs\cref, \cs\Cref, \cs\cpageref, \cs\Cpageref, +\cs\namecref, and \cs\nameCref\ of the "cleveref@@package" package, but applied to the label corresponding to the "knowledge" (see the documentation of "cleveref@@package" for more details). +These commands are variants of \cs\kl\ and hence are subject to the same syntax. + +For instance, +\begin{code} + \kl{"}Anchor points\kl{"} have been described in~\cs\kCref\{anchor point\},\\ + Page \cs\kpageref\{anchor point\}. +\end{code}\noindent +would typeset as +\begin{PDFoutput}[10cm] + "Anchor points" have been introduced in~\kCref{anchor point}, Page \kpageref{anchor point}. +\end{PDFoutput} \subsection{Dealing with math} \label{subsection:math} @@ -2381,22 +2458,156 @@ The following \kl[\knowledge directives]{directives} are to be used: 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. +should point to the same introduction location. This way of doing is covered intensively in the \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. +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. This is doable with the package, using scoping, but is not described yet in the documentation. \end{description} -The first use is fairly easy. The second one requires a bit more care. We review them one after the other, after some advertisements for the "mathcommand@@package" package. + + + + +\subsubsection{Defining knowledge-aware macros} +\label{subsubsection:knowledgenewcommands} + +It is possible to use the \cs\kl\ command inside , and in math mode (however, the "quotation notation" should really be avoided). +Nevertheless, this may cause problematic results in various situations. For this reason, specialized tools are offered. + +In this first section, we describe the simplest way to define macros that are linked to "knowledge". +This covers almost all situations, as long as one is not interested in having the knowledge dependant of the parameters of the macro. +In the subsequent sections, some more explanations are given covering the case of parameters. + + +\knowledgenewcommand\floor[1]{\cmdkl{\lfloor}#1\cmdkl{\rfloor}} + +\paragraph*{The use through an example}\AP +Let us define the $\intro*\floor{x}$ command representing the +floor rounding of~$x$, and use it in $\floor{1.5}$. This is achieved by first defining a macro \cs\floor\ (for instance in the preamble): +\begin{code} + \cs\knowledgenewrobustcmd\cs\floor[1]\{\cs\cmdkl\{\cs\lfloor\}\#1\cs\cmdkl\{\cs\rfloor\}\} +\end{code}\noindent +and then use it in a natural way: +\begin{code} + \cs\AP\ Let us define the \$\cs\intro*\cs\floor\ x\$ command representing the floor rounding of \$x\$, + and use it in \$\cs\floor\{1.5\}\$. +\end{code}\noindent +There, we used a special command, \cs\knowledgenewrobustcmd, which is similar to the \cs\newrobustcmd\footnote{It has the same syntax as \cs\newcommand\ and should always be used instead as far as a good reason for not to do it is given.} +and at the same time introduces a "knowledge" for the macro name (defined using the directive "automatic in command"). +It sets the contexts such that \cs\cmdkl\ implements the code for using this "knowledge". It is somehow similar to: +\begin{code} + \cs\newrobustcmd\cs\floor[1]\{\cs\kl[\cs\floor]\{\cs\lfloor\}\#1\cs\kl[\cs\floor]\{\cs\rfloor\}\}\\ + \cs\knowledge\{\cs\floor\}\{"automatic in command"\} +\end{code}\noindent +but is shorter to write and also corrects some bugs of this direct implementation\footnote{For instance, with this wrong implementation, + \smallcode{\cs\intro*\cs\floor\ x} would display in \cs\intro\ aspect the `\cs\lfloor'\ symbol but not the `\cs\rfloor' one.}. + +\AP As explained above, the \cs\knowledge\ command is implicit when defining such macros. The "knowledge" name is the macro name itself, and the directive used is ""automatic in command"". +Hence, you can modify the behavior by redefining the directive: +\begin{quote} + \cs\knowledgedirective*\{"automatic in command"\}\{\dots\} +\end{quote} + + +\paragraph{Defining new commands} +We have used \cs\knowledgenewrobustcmd\ in the above example. +In fact, several commands are available for defining such knowledge-enhanced macros. +Each of them corresponds to a normal command (from \LaTeX, or "xparse@@package", or "mathcommand@@package"), prefixed with `\texttt{knowledge}' or `\texttt{Knowledge}'. +The behavior of these commands is identical to the original ones, and furthemore activates the ability to use \cs\cmdkl. +(Note that it is forbidden for your macro to absorb anything more than the parameters described during its definition.) +\AP +The commands +\begin{quote} + \csintro\knowledgerenewcommand,\\ + \csintro\knowledgenewrobustcmd, and \\ + \csintro\knowledgenewcommand\footnote{You should always prefer \cs\knowledgenewrobustcmd\ instead. It is just here for completeness.}, +\end{quote} +correspond to \cs\newcommand, \cs\renewcommand, and \cs\newrobustcmd\ (from "etoolbox@@package") respectively. +\AP +The commands +\begin{quote} + \csintro\KnowledgeNewDocumentCommand, \\ + \csintro\KnowledgeRenewDocumentCommand, \\ + \csintro\KnowledgeProvideDocumentCommand, and \\ + \csintro\KnowledgeDeclareDocumentCommand +\end{quote} +extend the corresponding commands from the "xparse@@package" package (it offers more complete possibilities to define the signature of macros, and do it in a cleaner and more systematic way). + +\AP Finally, the commands of the "mathcommand@@package" package (see~\Cref{subsubsection:mathcommand}) +are also extended (provided it has been loaded before the package "knowledge@@package"), yielding: +\begin{quote} + \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. +\end{quote} + +\subsubsection{The combination \cs\withkl/\cs\cmdkl} +\label{subsubsection:withkl} + +In fact, inside commands like~\cs\knowledgenewrobustcmd, the command~\cs\withkl\ is used. +It has to be used in combination with \cs\cmdkl: +\begin{center} + \smallcode{\csintro\withkl\{\cs\kl-like command\}\{\dots\csintro\cmdkl\{A\}\dots\csreintro\cmdkl\{B\}\dots\}} +\end{center} +Inside the right argument of \cs\withkl, \cs\cmdkl\ stands for a shorthand for the \cs\kl-like command, with the following specificities: +the "modifiers@@variant" used before the \cs\withkl\ are absorbed and reinjected for each use of~\cs\cmdkl. Furthermore, all the uses of \cs\cmdkl, but the first one, get to be preceded of the \csintro\rekl* "modifier@@variant", which transformes in particular \cs\intro\ into \cs\reintro. Hence, +\smallcode{\cs\intro*\cs\withkl\{\cs\kl[example]\}\{\dots\cs\cmdkl\{A\}\dots\cs\cmdkl\{B\}\dots\}} +gets to be evaluated as +\smallcode{\dots\cs\intro[example]\{A\}\dots\cs\reintro[example]\{B\}\dots} + +An example of use of this technique is if we want "knowledges" aware of the parameters of a macro. +Imagine that you use the norms $1$ and $2$ of a function: +\begin{code} +\cs\newrobustcmd\cs\norm[2]\par + ~~~~\{\cs\withkl\{\cs\kl[\cs\norm\{\#1\}]\}\{\cs\cmdkl\{\cs\|\}\#2\cs\cmdkl\{\cs\|\}\_\{\cs\cmdkl\{\#1\}\}\}\}\\ +\cs\knowledge\{\cs\norm\{1\}\}\{notion\}\\ +\cs\knowledge\{\cs\norm\{2\}\}\{notion\} +\end{code}\noindent +Now, the norm $1$ and the norm $2$ can be defined in different places since "knowledge" is specific to each case. +\begin{code} + \cs\AP\ The norm~\$1\$ of a function~\$f\$ is denoted \$\cs\intro*\cs\norm1f\$.\\ + {}[...]\\ + \cs\AP\ The norm~\$2\$ of a function~\$f\$ is denoted \$\cs\intro*\cs\norm2f\$.\\ + {}[...]\\ + Here, \$\cs\norm 1g\$ and \$\cs\norm2h\$ link to the proper place, while\\\$\cs\norm3g\$ is an undefined knowledge. +\end{code} + \subsubsection{Defining macros for math: the "mathcommand@@package" package} \label{subsubsection:mathcommand} -Defining macros is standard in \TeX, and it should be used systematically in writing scientific documents. +Defining macros is standard in \TeX, and it should be used systematically when writing scientific documents. This is particularly true 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). +package (it has the same syntax). Generally speaking, the "xparse@@package" package, which gives easier syntax for describing commands, possibly with more complex parameter templates, should be preferred. -Another package "mathcommand@@package" has been designed to be used in conjunction with "knowledge@@package". +Another package, "mathcommand@@package", has been designed to be used in conjunction with +"knowledge@@package"\footnote{Note that all the commands for defining macros also exist in a "knowledge"-compatible form (see \Cref{subsubsection:knowledgenewcommands})}. 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: @@ -2411,6 +2622,10 @@ We shall use it in the advanced examples below. It allows: 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. + Even better is to use the knowledge-aware version: + \begin{code} + \cs\knowledgerenewmathcommand\cs\pi\{\cs\cmdkl\{\cs\LaTeXpi\}\} + \end{code} \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). \item Finally, it offers some commodity for redefining many variables in one command. @@ -2433,14 +2648,14 @@ Five points have to be kept in mind: \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. + This does not cause problems and is easier to maintain. This is automatically done when + commands such as \cs\knowledgenewrobustcmd\ are used. \item Use the \cs{\intro*} notation for introducing macros. -\item The surrounding typography is broken when using the command \cs{\kl} (if someone knows how to solve that, please contact me). Commands such as \cs\mathrel\ should be used to recover it. +\item The surrounding typography may be broken when using the command \cs{\kl}, or \cs\cmdkl\ (if someone knows how to solve that, please contact me). Commands such as \cs\mathrel\ should be used to recover it. \end{itemize} These five points are illustrated in the following code: \begin{code} -\cs\newrobustcmd\cs\comp\{\cs\mathrel\{\cs\kl[\cs\comp]\{\cs\circ\}\}\}\\ -\cs\knowledge\cs\comp\{notion\}\\ +\cs\knowledgenewrobustcmd\cs\comp\{\cs\mathrel\{\cs\cmdkl\{\cs\circ\}\}\}\\ {[...]}\\ \cs\AP\ Composition is denoted \$\cs{\intro*}\cs\comp\$.\\ {[...]}\\ @@ -2453,34 +2668,27 @@ Two variation may be comfortable to use. 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\circ\\ -\cs\suggestcommand\cs\rho\{Use instead \cs\comp\ for function composition.\}\\ -\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. +\csintro\disablecommand\cs\circ\\ +\csintro\suggestcommand\cs\circ\{Use instead \cs\comp\ for function composition.\}\\ +\cs\knowledgenewrobustcmd\cs\comp\{\cs\cmdkl\{\cs\LaTeXcirc\}\}\\ \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. +\noindent The result is that if one uses \cs\circ\ in the code, an error will be issued, and \cs\comp\ will be suggested as a replacement. +Note that more than one suggestions can be attached to the macro (if several macros use the symbol~\cs\comp\ with different meanings). Note also that in the definition of \cs\comp, \cs\LaTeXcirc\ is used instead of~\cs\circ. Indeed, \cs\circ\ has been deactivated, +but~\cs\LaTeXcirc\ 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 of \cs\myFunction\ (simply because this is more convenient and easy to remember, and we know in advance that no confusion may arise). +Another situation is that one would like to use the \cs\circ\ control sequence for accessing our function instead of \cs\comp\ (simply because this is more convenient and easy to remember, and we know in advance that no confusion may arise). 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\}\\ +\cs\knowledgerenewmathcommand\cs\circ\{\cs\mathrel\{\cs\cmdkl\{\cs\LaTeXcirc\}\}\}\\ {[...]}\\ -\cs\AP\ Let \$\cs{\intro*}\cs\rho(x)=[...]\$\\ +\cs\AP\ Let \$g\cs{\intro*}\cs\circ\ f\$ denote the composition of functions.\\ {[...]}\\ -Now, each use of \$\cs\rho\$ points to its introduction. +Now, each use of \$\cs\circ\$ 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. +The effect of \cs\knowledgerenewmathcommand\ is that it sets~\cs\LaTeXcirc\ to have the same effect as the original \cs\circ\ command, +and then redefines~\cs\circ. \subsubsection{Context dependent variables} @@ -2505,19 +2713,6 @@ For obtaining this, this requires: \fi - -\subsection{Fixes} -\label{subsection:fixes} - -In this section, we present some fixes that have been added to help the user solve problems. - -\paragraph{Hyperref and twocolumn} It happens that the "hyperref@@package" and two-column mode together may yield a fatal error. This happens when a link spans across the boundary between two pages. This is an issue which is not related to the "knowledge@@package" package, but becomes severely more annoying when more links have to be used. -A \emph{workaround} can be tried by using using -\begin{center} -\smallcode{\cs\knowledgeconfigure\{""fix hyperref twocolumn""\}}. -\end{center} -I do not know to which extend it is compatible with various classes... - \subsection{Predefined configuration} \subsubsection{The "notion@@option" directive} @@ -2550,6 +2745,19 @@ A typical document using notion could start by the following commands: \end{code}\noindent Then the paper is displayed in a colorful way. + + +\subsection{Fixes} +\label{subsection:fixes} + +In this section, we present some fixes that have been added to help the user solve problems. + +\paragraph{Hyperref and twocolumn} It happens that the "hyperref@@package" and two-column mode together may yield a fatal error. This happens when a link spans across the boundary between two pages. This is an issue which is not related to the "knowledge@@package" package, but becomes severely more annoying when more links have to be used. +A \emph{workaround} can be tried by using using +\begin{center} +\smallcode{\cs\knowledgeconfigure\{""fix hyperref twocolumn""\}}. +\end{center} +I do not know to which extend it is compatible with various classes... \newpage \section{Some questions and some answers} @@ -2719,10 +2927,10 @@ and \cs\compAP\ for "complexity@@package", \subsection{Incorrect display} -\subsubsection{Incorrect breaking at the end of lines (in Arxiv for instance)} +\subsubsection{Incorrect breaking at the end of lines (in "arXiv" for instance)} It may happen that some hyperlinks generated by "knowledge@@package" are not broken properly -at the end of lines. This is an issue with the \kl(package){hyperref} package. This happens in particular for files compiled by the Arxiv system while the file on the local computer was not having any problem. A workaround is to use the \kl{breaklinks} option of \kl(package){hyperref}. If you need this for Arxiv, then you also have to force the use of \cs\pdflatex\ (because the \kl{breaklinks} option does not work if compiled via the ancestral sequence TEX$\rightarrow$DVI$\rightarrow$PS$\rightarrow$PDF). This can be obtained by adding \smallcode{\cs\pdfoutput=1} within the five first lines of the preamble. +at the end of lines. This is an issue with the \kl(package){hyperref} package. This happens in particular for files compiled by the "arXiv" system while the file on the local computer was not having any problem. A workaround is to use the \kl{breaklinks} option of \kl(package){hyperref}. If you need this for "arXiv", then you also have to force the use of \cs\pdflatex\ (because the \kl{breaklinks} option does not work if compiled via the ancestral sequence TEX$\rightarrow$DVI$\rightarrow$PS$\rightarrow$PDF). This can be obtained by adding \smallcode{\cs\pdfoutput=1} within the five first lines of the preamble. The preamble thus looks like: \begin{code}[9cm] @@ -2749,6 +2957,16 @@ Some classes, like \kl(package){acmart}, change the default color of the hyperli \cs\knowledgestyle\{"notion@@style"\}\{"color="black\}\\ \cs{\ fi} \end{code} + +\subsubsection{Unexepected color in margin paragraph} +This is a problem of the combination of the package "xcolor@@package" with \cs\marginpar: when a colored text gets to be broken into separated lines and the \cs\marginpar\ be inserted at this place, the colors leaks in to the margin text. +It is independent of "knowledge@@package", but is more likely to occur when colors are often used. +A correction is to force going the use of color black whenever inside a \cs\marginpar. For instance: +\begin{code} +\cs\let\cs\LaTeXmarginpar\cs\marginpar\\ +\cs\def\cs\marginpar\#1\{\cs\LaTeXmarginpar\{\cs\textcolor\{black\}\{\#1\}\}\} +\end{code} + \subsection{Problems with scope} \subsubsection{Problems in combination with \cs{\bibitem} and "thebibliography@@env"} @@ -2818,6 +3036,7 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \begin{compactdesc} \item[\cs\AP] introduces an "anchor point". \item[\cs\intro] searches for a \kl{knowledge} and put an anchor to it (to be used with the \kl{autoref} directive). +\item[\cs\kcref, \cs\kCref, \cs\kcpageref, \cs\kCpageref, \cs\knamecref, \cs\knameCref, \cs\knamecref] and \cs\knameCref\ display some information concerning the place of introduction of a "knowledge" as the \cs\cref, \cs\Cref, \cs\cpageref, \cs\Cpageref, \cs\namecref, \cs\nameCref, \cs\namecref\ and \cs\nameCref\ commands of the \kl(package){cleveref} package. \item[\cs\kl] searches for a \kl{knowledge} and displays it accordingly. \item[\cs\knowledge] defines new \kl{knowledges}. \item[\cs\knowledgeconfigure] configures the package. @@ -2828,6 +3047,8 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \item[\cs\knowledgesetvariant] configures a "variant of \cs{\kl}". \item[\cs\knowledgestyle] defines a new \kl{style}. \item[\cs\knowledgevariantmodifier] declares a meaning of \cs{*} in "variants of \cs{\kl}". +\item[\cs\kpageref] displays the page number of a reference, +\item[\cs\kref] displays the number associated to a reference introduction. \item[\cs\nointro] declares that the knowledge will never be introduced (does not work properly yet). \item[\cs\phantomintro] performs an invisible \cs\intro. \item[\cs\reintro] uses the \kl{display style} of \cs{\intro} without introducing an anchor. @@ -2845,7 +3066,7 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \begin{compactdesc} -\item["autoref"] Activates the \cs{\intro} feature (requires the "hyperref@@package"). +\item["autoref"] Activates the \cs{\intro} feature. \item["autoref link"] activates an hyperlink to the target. \item["autoref target"] puts a target for a hyperlink. \item[\kl{autorefhere}] creates an \kl{anchor point} that points to the \cs{\knowledge} command (Requires the \kl{hyperref option}). @@ -2875,6 +3096,7 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr if present. \item[\kl{lowercase}] Put all letters of the output in lowercase. \item[\kl{mathord}, \kl{mathop}, \kl{mathbin}, \kl{mathrel}, \kl{mathopen}, \kl{mathclose}, \kl{mathpunct}] Selects a spacing behaviour in math mode. +\item[\kl{no index}] avoids the indexing of the term. \item[\kl{protect link}] Disables the hyperlinks inside the link. \item[\kl{ref=}] Links to a label inside the document. \item[\kl{scope=}] Choose the \kl{scope} of the definition. @@ -2891,10 +3113,15 @@ If other kind of problems occur, report them to \texttt{thomas.colcombet@irif.fr \item[\kl{wrap=}] A macro used to process the displayed text. \end{compactdesc} -\subsection{List of \kl{configuration directives} (to use with \cs{\knowledgeconfigure})} +\subsection{List of \kl{configuration directives}} \label{subsection:configuration directive list} +The following directives can be used as options when loading the package, or later using \cs{\knowledgeconfigure}. \begin{compactdesc} +\item["anchor point color="color] changes the color of "anchor point", +\item["anchor point shape="shape] changes the shape of "anchor points", in which shape can be \texttt{tiny corner}, \texttt{small corner}, \texttt{corner}, \texttt{large corner}, + \texttt{tiny cross}, \texttt{small cross}, \texttt{cross}, \texttt{large cross}, or some code to be execute in the "picture@@env" environment, +\item["anchor point shift="\{$x$,$y$\}] shifts the "anchor point" (in \texttt{em} unit), \item["diagnose bar="\textmd{\{true,false\}}] activates the \kl{`\vbar'-notation} in the "diagnose file" (default is false) \item["composition"] switches to "composition mode", \item["cyclic colors=@@option"] fixes the cyclic list of colors used by the "directive" "cyclic color". 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} diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty index f05eb931fc9..887f9a50ae1 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}{2021/03/31}{1.25}{} +\ProvidesExplPackage{knowledge}{2021/12/20}{1.26}{} %%%%%%%%%% \RequirePackage{l3keys2e} \RequirePackage{etoolbox} @@ -829,7 +829,7 @@ \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}} @@ -842,25 +842,25 @@ \cs_generate_variant:Nn\knowledge_warning:n{x} \cs_generate_variant:Nn\knowledge_error:n{x} \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} \msg_new:nnn{ knowledge }{ knowledge~recursion } @@ -1022,10 +1022,66 @@ {\tl_set:Nn\knowledge_option_complexityAP_command_tl{#1}} {\knowledge_error:n{Package~option~'complexity~AP'~must~be~followed~by~a~single~control~sequence.}} } +\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} + } + } \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} @@ -1048,6 +1104,7 @@ \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} \cs_new:Nn\knowledge_option_aci_define:n{ \keys_define:nn{ knowledge~package~options } { #1 .choice: , @@ -1074,6 +1131,7 @@ \knowledge_option_aci_define:n{hyperref} \knowledge_option_aci_define:n{xcolor} \knowledge_option_aci_define:n{makeidx} +\knowledge_option_aci_define:n{cleveref} \ProcessKeysOptions{knowledge~package~options} \bool_new:N\knowledge_option_composition_bool @@ -1121,6 +1179,7 @@ \knowledge_option_aci_autoload:nnn{ hyperref }{}{} \knowledge_option_aci_autoload:nn{ xcolor }{} \knowledge_option_aci_autoload:nn{ makeidx }{} +\knowledge_option_aci_autoload:nn{ cleveref }{} \tl_const:Nn\scope_tl{SC@PE} \tl_const:Nn\scopept_tl{SC@PE2} \seq_new:N\scope_instances_stack_seq @@ -2195,7 +2254,7 @@ \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: } @@ -2203,10 +2262,10 @@ \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}}} } \tl_new:N\knowledge_knowledgedefault_tl \NewDocumentCommand\knowledgedefault{sm}{ @@ -2259,7 +2318,7 @@ {\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} @@ -2616,6 +2675,8 @@ \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} } % @@ -2647,6 +2708,9 @@ 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}}, % @@ -2851,6 +2915,11 @@ \cs_generate_variant:Nn\knowledge_kl_display_generic:n{x} \cs_generate_variant:Nn\knowledge_kl_display_generic_cond:Nn{Nx} \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: +} +\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} @@ -2872,6 +2941,9 @@ % \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: % @@ -2915,8 +2987,6 @@ {\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 @@ -2944,21 +3014,8 @@ {\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: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.}} @@ -2991,6 +3048,23 @@ {\exp_not:V\knowledge_kl_text_tl} } } +\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 \NewDocumentCommand\knowledge_anchor_point_cs:{} {\bool_if:NT\knowledge_hyperref_active_bool {\strut\vadjust{\knowledge_AP_internal:}}} @@ -3033,16 +3107,16 @@ \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}} @@ -3103,62 +3177,136 @@ pop~code={\knowledgeconfigure{quotation=true}}}} } -\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: - } - -\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: +\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} + +\knowledgedirective{automatic~in~command}{notion} + +\tl_gset:Nn\knowledge_inner_modifer_re_tl{\rekl*} + +\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} + +\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: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} +} + +\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.}} + } } - -\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:} - } - -\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:} - } - -\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:} - } -\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 - -\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\klparse_absorbopt_ii:NnNn - {\tl_set:Nn #1 {#4} #2 } -\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 +} +\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.}} + } + } +} +\KnowledgifyNewcommand\newcommand +\KnowledgifyNewcommand\renewcommand +\KnowledgifyNewcommand\newrobustcmd +\KnowledgifyNewDocumentCommand\NewDocumentCommand +\KnowledgifyNewDocumentCommand\RenewDocumentCommand +\KnowledgifyNewDocumentCommand\ProvideDocumentCommand +\KnowledgifyNewDocumentCommand\DeclareDocumentCommand +\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 \cs_new:Nn\knowledge_directives_require_aci_package:nn {\bool_if:cTF{knowledge_#2_syntax_bool}{}{ \NewKnowledgeParamPackageError{#1}{#2}}} @@ -3187,15 +3335,28 @@ } \NewKnowledgeParamTl*{url} \NewKnowledgeParamTl*{ref} - \knowledge_directives_require_aci_package:nn - {url,ref,autoref}{hyperref} + {url}{hyperref} \bool_if:NT\knowledge_hyperref_active_bool{ \DeclareExpandableDocumentCommand\knowledge_fake_klTKS{mmm}{#1} \pdfstringdefDisableCommands{% \let\klTKS\knowledge_fake_klTKS } } +\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}{} + }}{} + } +} \def\knowledgeIntroIndexStyle#1{\textbf{#1}} \NewKnowledgeParamTl{index} \keys_define:nn { knowledge~directives } @@ -3209,6 +3370,85 @@ \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 +\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 +} \ExplSyntaxOff\makeatletter \newcommand\knowledgeFixHyperrefTwocolumn{ \RequirePackage{etoolbox} @@ -3318,7 +3558,23 @@ 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} |