summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-03-11 03:00:51 +0000
committerNorbert Preining <norbert@preining.info>2021-03-11 03:00:51 +0000
commit8379a45cf223651b1c06ebf5c680db900d83c6a5 (patch)
tree38feea3589200f62c13997bfe3954ce9359e83cb /macros
parentf808c98da8e34907b93b8b1c2ef473539b88c504 (diff)
CTAN sync 202103110300
Diffstat (limited to 'macros')
-rw-r--r--macros/generic/tokcycle/tokcycle-doc.pdfbin258406 -> 569457 bytes
-rw-r--r--macros/generic/tokcycle/tokcycle-doc.tex431
-rw-r--r--macros/generic/tokcycle/tokcycle-examples.pdfbin261160 -> 568281 bytes
-rw-r--r--macros/generic/tokcycle/tokcycle-examples.tex593
-rw-r--r--macros/generic/tokcycle/tokcycle.tex102
-rw-r--r--macros/latex/contrib/easybook/doc/appendix.tex (renamed from macros/latex/contrib/easybook/doc/pages/appendix.tex)0
-rw-r--r--macros/latex/contrib/easybook/doc/chapter1.tex (renamed from macros/latex/contrib/easybook/doc/pages/chapter1.tex)0
-rw-r--r--macros/latex/contrib/easybook/doc/chapter2.tex (renamed from macros/latex/contrib/easybook/doc/pages/chapter2.tex)4
-rw-r--r--macros/latex/contrib/easybook/doc/chapter3.tex (renamed from macros/latex/contrib/easybook/doc/pages/chapter3.tex)0
-rw-r--r--macros/latex/contrib/easybook/doc/easybook-demo.pdfbin290244 -> 290263 bytes
-rw-r--r--macros/latex/contrib/easybook/doc/easybook-demo.tex10
-rw-r--r--macros/latex/contrib/easybook/doc/easybook.pdfbin234909 -> 234637 bytes
-rw-r--r--macros/latex/contrib/easybook/doc/easybook.tex22
-rw-r--r--macros/latex/contrib/easybook/doc/refs.bib (renamed from macros/latex/contrib/easybook/doc/ref/refs.bib)0
-rw-r--r--macros/latex/contrib/easybook/easybook.cls77
-rw-r--r--macros/latex/contrib/mindflow/README.md15
-rw-r--r--macros/latex/contrib/mindflow/mindflow.dtx206
-rw-r--r--macros/latex/contrib/mindflow/mindflow.ins54
-rw-r--r--macros/latex/contrib/mindflow/mindflow.pdfbin0 -> 123615 bytes
-rw-r--r--macros/latex/contrib/newverbs/README2
-rw-r--r--macros/latex/contrib/newverbs/newverbs.dtx27
-rw-r--r--macros/latex/contrib/newverbs/newverbs.pdfbin221177 -> 221688 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.pdfbin420606 -> 424997 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.tex652
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx1810
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.pdfbin1133328 -> 1166775 bytes
26 files changed, 2929 insertions, 1076 deletions
diff --git a/macros/generic/tokcycle/tokcycle-doc.pdf b/macros/generic/tokcycle/tokcycle-doc.pdf
index c707af4f15..3e4fe83347 100644
--- a/macros/generic/tokcycle/tokcycle-doc.pdf
+++ b/macros/generic/tokcycle/tokcycle-doc.pdf
Binary files differ
diff --git a/macros/generic/tokcycle/tokcycle-doc.tex b/macros/generic/tokcycle/tokcycle-doc.tex
index 612ab5baf2..dfacfd2e61 100644
--- a/macros/generic/tokcycle/tokcycle-doc.tex
+++ b/macros/generic/tokcycle/tokcycle-doc.tex
@@ -1,6 +1,6 @@
\documentclass{article}
\usepackage[T1]{fontenc}
-\usepackage{xcolor,tokcycle,verbatimbox,tabstackengine,lipsum}
+\usepackage{xcolor,tokcycle,verbatimbox,tabstackengine,lipsum,lmodern}
\colorlet{bred}{red!90!blue}
\usepackage{caption}
\captionsetup{font={sf, footnotesize},labelfont={sf},textfont={footnotesize}}
@@ -26,6 +26,7 @@
\newcommand\CGMS{\textit{C-G-M-S}}
\newcommand\CGMnS{\textit{C}, \textit{G}, \textit{M}, and \textit{S}}
\newcommand\macname[1]{\texttt{\char92#1}}
+\newcommand\thevbox{\medskip\theverbbox\par\medskip\noindent}
\newenvironment{specfig}
{\par\bigskip\vbox\bgroup\small\sffamily\centering}
{\egroup\medskip\par}
@@ -46,7 +47,7 @@
{\centering{\LARGE Package \TokCycle{} \Large (v\tcver)\par}
Steven B Segletes
-{\footnotesize $<$steven.b.segletes.civ@mail.mil$>$}
+{\footnotesize $<$SSegletes@verizon.net$>$}
\\\small{contributor: Christian Tellechea}\footnote{
{I am extremely grateful to Christian $<$unbonpetit@netc.fr$>$}
for his assistance in the development of this package.
@@ -111,7 +112,7 @@ The macros operate within the document's current scope, but do not typeset the
result automatically.
In the case of both macros and pseudo-environments, the transformed result
is available for later use, being stored in the package
- token register named \macname{cytoks}.
+ token list named \macname{cytoks}.
\item Two macros and one pseudo-environment containing the
phrase ``\texttt{xpress}''.
@@ -156,12 +157,16 @@ The \TokCycle{} categories by which the input stream
Catcode-0 tokens are directed to the \Macro{} directive for processing.
Catcode-10 tokens are directed to the \Space{} directive.
-When an explicit catcode-1 token is encountered in the \TokCycle{} input
+When an explicit catcode-1 token\footnote{
+ Throughout this document the terms \textit{catcode-} and \textit{cat-}
+ are used interchangeably.
+}
+ is encountered in the \TokCycle{} input
stream, the contents of the entire group (sans the grouping) are directed
to the \Group{} directive for further processing, which may in turn,
redirect the individual tokens to the other categories.
The handling options of implicit cat-1 and 2 tokens are described later in
- this document.
+ this document (section~\ref{s:impgrp}).
Valid tokens that are neither catcode 0, 1, 2, nor 10, except where noted,
are directed to the \Character{} directive for processing.
@@ -185,20 +190,20 @@ or, alternately, for the pseudo-environment,
{<Macro processing directive>}
{<Space processing directive>}<token input stream>\endtokencycle
\end{verbbox}
-\medskip\theverbbox\medskip\par\noindent
+\thevbox
For the \texttt{xpress} macros, the syntax is
\begin{verbbox}[\vbdelim]
\tokcyclexpress <<or>> \expandedtokcyclexpress
{<token input stream>}
\end{verbbox}
-\medskip\theverbbox\medskip\par\noindent\medskip
+\thevbox
or, alternately, for the \texttt{xpress}-pseudo-environment,
\begin{verbbox}[\vbdelim]
-\tokencycleexpress<token input stream>\endtokencyclexpress
+\tokencyclexpress<token input stream>\endtokencyclexpress
\end{verbbox}
-\theverbbox\medskip
+\thevbox
\begin{sloppypar}
In addition to the above macros/environments, the means is
@@ -211,14 +216,55 @@ In addition to the above macros/environments, the means is
{<Macro processing directive>}
{<Space processing directive>}
\end{verbbox}
-\medskip\theverbbox\medskip\par\noindent
+\thevbox
This will then permit simplified invocations of the form
\begin{verbbox}[\vbdelim]
\environment_name<token input stream>\endenvironment_name
\end{verbbox}
-\medskip\theverbbox\medskip\par\noindent
+\thevbox
+More recently, an even more versatile \textit{extended} version has
+ been made available:
+\begin{verbbox}[\vbdelim]
+\xtokcycleenvironment\environment_name
+ {<Character processing directive>}
+ {<Group-content processing directive>}
+ {<Macro processing directive>}
+ {<Space processing directive>}
+ {<Set-up code>}
+ {<Close-out code>}
+\end{verbbox}
+\thevbox
+This will also permit simplified invocations of the form
+
+\begin{verbbox}[\vbdelim]
+\environment_name<token input stream>\endenvironment_name
+\end{verbbox}
+\thevbox
+However, with this extended environment definition, additional
+ set-up and close-out code will be executed prior to and following
+ the token cycle, within the scope of the environment.
+The close-out code, while executed after the token cycle, occurs
+ before the \macname{cytoks} token list is actually typeset; therefore
+ the close-out code can both execute macros and/or add tokens
+ to the imminently-typeset token list.
+Any definitions or counters that change as a result of executing
+ the \CGMS{} directives are, in fact, \textit{past tense} when the
+ close-out code is executed.
+
+Finally, the set-up and close-out code, as well as the \CGMS{} directives
+ can invoke \macname{tcafterenv}, whose argument is executed upon the
+ exit from the scope of \textit{this} defined environment.\footnote{
+The \macname{tcafterenv} macro is recognized \textit{only} in the
+ context of an extended \macname{xtokcycleenvironment} definition.
+It is not available for direct use in the package's \macname{tokencycle}
+ pseudo-environment, nor in \macname{tokcycleenvironment} definitions.
+}
+As with all \TokCycle{} environments, those created by way
+ of \macname{tokcycleenvironment} and \macname{xtokcycleenvironment},
+ while operating in the scope of a group, will preserve the contents
+ of \macname{cytoks} when exiting their scope.
\subsection{Externally specified directives and directive resets}
@@ -251,13 +297,15 @@ The default directives at package outset and upon reset are
\stripgroupingfalse
\stripimplicitgroupingcase{0}
\end{verbbox}
-\medskip\theverbbox\medskip\noindent
-
+\thevbox
The interpretation of these directives will be explained in the
remainder of this document.
Let it suffice for now to say that the default directive settings
pass through the input stream to the output stream, without
- change.
+ change.\footnote{
+ Except, possibly, in the case of catcode-6 tokens, which will be
+ later addressed in sections~\ref{s:cat6} and \ref{s:whennot}.
+}
@@ -293,7 +341,7 @@ Its mandatory argument consists of tokens denoting \textit{what} you
the letter \texttt{[x]}).
When the optional argument is omitted, the specified tokens are appended
- \texttt{literally} to the register (without expansion).
+ \textit{literally} to the register (without expansion).
An integer option, call it \textit{n}, takes the
the mandatory argument, and expands it $n$-times, and appends the
result to \macname{cytoks}.
@@ -303,23 +351,59 @@ The \texttt{[x]} option employs the \macname{expanded} primitive to maximally
The \texttt{[x]} option will prove useful when the \Character{} or other
directives involve a transformation that is fully expandable.
Its use will allow the expanded
- result of the transformation to be placed in the token register, rather
+ result of the transformation to be placed in the token list, rather
than the unexpanded transformation instructions.
\subsubsection{\argone}
In the context of the \CGMnS{} processing directives, one may refer to
- \argone{} (e.g., in the argument to \macname{addcytoks}).
+ \argone{} (for example, in the argument to \macname{addcytoks} or
+ \macname{processtoks}).
\TeX{} users know that the first parameter to a \TeX{} macro is denoted
as \argone.
The specification of all \TokCycle{} processing directives is structured
in such a way that ``\argone{}'' may be directly employed to indicate
the current token (or group) under consideration in the input stream.
+\subsubsection{Transforming the Input Stream}
+
+Within the \TokCycle{} \CGMS{} directives, the command
+ \verb|\addcytoks{#1}| is used to echo the token being processed to
+ the output stream that is being collected in the \macname{cytoks}
+ token list.
+However, one may do more than merely echo the input---one may transform
+ it.
+If the user creates a macro, let's call it \macname{xform}, to take
+ a single character of input and convert it in some way to something
+ else, then this macro can be used inside the \Character{} directive
+ as \verb|\addcytoks{\xform{#1}}|.
+In this case, if an `\texttt{e}' were the token under consideration
+ by the \Character{} directive, `\verb|\xform{e}|' would be added
+ to the \macname{cytoks} token list.
+Since \TokCycle{} operates upon each successive token in the input
+ stream, this \macname{xform} macro that operates on a single token
+ can be used to completely transform the \TokCycle{} input stream.
+
+If the \macname{xform} macro is expandable, reaching its termination in
+ a known number, $n$, of expansions, \macname{addcytoks} can take
+ advantage of that with its optional argument, performing the
+ said number of expansions of \macname{xform} \textit{before}
+ adding the result to \macname{cytoks}.
+If the expandability of \macname{xform} is known, but the number $n$ is
+ not, the optional argument \verb|[x]| to \macname{addcytoks} may
+ be used to fully expand the argument (by way of the
+ \macname{expanded} primitive).
+In that case, the resulting \macname{cytoks} result will show
+ no evidence of the \macname{xform} macro, but only the results
+ of its transformation.
+
+The accompanying examples document, \texttt{tokcycle-examples.pdf},
+ is full of examples showing specific \TokCycle-induced transformations.
+
\subsection{\Group{} directive: \macname{ifstripgrouping}, and \macname{processtoks}}
The \Group{} directive is unique, in that it is the only directive whose
- argument (\texttt{\#1}) may consist of more than a single token.
+ argument (\argone) may consist of more than a single token.
There are two issues to consider when handling the tokens comprising a group:
do I retain or remove the grouping (cat-1,2 tokens)?
Do I process the group's token content
@@ -334,21 +418,85 @@ The alternative, \macname{stripgroupingtrue}, is dangerous
in the sense that it will strip the cat-1,2 grouping from the
group's tokens, thereby
affecting or even breaking code that utilizes such grouping for macro arguments.
-Modify \macname{ifstripgrouping} with care.
+Apply \macname{stripgroupingtrue} with care.
The issue of treating the tokens comprising the content of a
group individually or collectively
is determined by the choice of macro inside the \Group{} directive.
-Within the \Group{} directive, the argument \texttt{\#1} contains the
+Within the \Group{} directive, the argument \argone{} contains the
collective tokens of the group (absent the outer cat-1,2 grouping).
-The default directive \macname{processtoks\{\#1\}} will recommit the
+The default directive \macname{processtoks\{\argone\}} will recommit the
group's tokens individually to be processed through the token cycle.
-In contrast, the command \macname{addcytoks\{\#1\}} in the \Group{}
+In contrast, the command \macname{addcytoks\{\argone\}} in the \Group{}
directive would directly add the collective group
of tokens to the \macname{cytoks} register, without being processed
individually by \TokCycle.
+\subsubsection{The \macname{groupedcytoks} macro for more sophisticated
+ group processing}
+\label{s:grpcy}
+
+\begin{sloppypar}
+To this point, there have been presented two options for handling grouped
+ material in the token cycle: process each of the grouped tokens (via
+ \macname{processtoks}) or echo the grouped tokens (via
+ \macname{addcytoks}). Obviously, one may also discard the grouped
+ tokens altogether by employing neither of the above choices in the
+ context of the \Group{} directive.
+\end{sloppypar}
+
+However, there are times where you might wish to perform a macro task
+ (for example, one that might add additional tokens to \macname{cytoks})
+ immediately \textit{outside} of the group, before or after.
+If you were to add the task macro before or after the \macname{processtoks}
+ invocation, it will still be performed, by default, \textit{inside}
+ the \macname{cytoks} group.
+
+The macro \macname{groupedcytoks} allows one to manually specify the
+ grouping duties of the \Group{} directive.
+Thus, the following two group-processing configurations are
+ functionally identical: the default
+
+\begin{verbbox}[\vbdelim]
+ \stripgroupingfalse
+ \Groupdirective{\processtoks{#1}}
+\end{verbbox}
+\thevbox
+and
+
+\begin{verbbox}[\vbdelim]
+ \stripgroupingtrue
+ \Groupdirective{\groupedcytoks{\processtoks{#1}}}
+\end{verbbox}
+\thevbox
+Therefore, unless the goal is to introduce additional nesting levels
+ into the input stream, the first rule of using \macname{groupedcytoks}
+ is to \macname{stripgroupingtrue} before entering the token cycle.
+The argument of \macname{groupedcytoks} specifies the tasks that are to
+ occur inside a \macname{cytoks} grouping.
+So, in the following example
+
+\begin{verbbox}[\vbdelim]
+ \stripgroupingtrue
+ \Groupdirective{\taskA
+ \groupedcytoks{\taskB\processtoks{#1}\taskC}%
+ \taskD}
+\end{verbbox}
+\thevbox
+the tasks A and D will occur \textit{outside} of the \macname{cytoks}
+ group.
+Tasks B and C occur inside the group, immediately before and after processing
+ the tokens of the group, respectively.
+Thus, the use of \macname{groupedcytoks} in this way permits \TokCycle{}
+ taskings to occur outside of the grouping applied to the output.
+
+If \macname{stripgroupingtrue} had been omitted while still using
+ \macname{groupedcytoks}, tasks A and D would have been in the
+ explicit group, and tasks B and C, along with the grouped tokens
+ \argone{}, would have been nested within an additional group.
+
\subsubsection{Implicit grouping tokens: \macname{stripimplicitgroupingcase}}
+\label{s:impgrp}
Implicit grouping tokens (e.g., \macname{bgroup} \& \macname{egroup})
can be handled in one of \textit{three} separate ways.
@@ -370,6 +518,139 @@ Finally, the special case of $-$1 indicates that the implicit-group
Such a special treatment has limited application---for example,
when the intent is to detokenize these tokens.
+\subsection{Truncating the input stream}
+
+The basic process of \TokCycle{} is one in which an input stream (or argument)
+ of tokens is examined and processed based on directives
+ set up by the user.
+Typically, the input stream is processed token-by-token to exhaustion, which
+ occurs when a defined terminating token is reached.
+In section~\ref{s:escape}, we will see how a sequence of tokens can be exempted
+ from any processing that would otherwise occur in the directive,
+ and be passed instead directly to the output stream.
+
+However, in this section, we will examine how \TokCycle{} can be directed
+ to \textit{dynamically} truncate, that is, discard the remaining
+ input stream based on the tokens found therein.
+Truncation commands may be issued within the \Character, \Macro,
+ and \Space{} directives.
+More will be said about the \Group{} directive in section~\ref{s:truncingrp}.
+
+Truncation can be made to apply either to the remainder of the current
+ \TokCycle-nesting level (corresponding to an explicit catcode-1,2
+ group in the input stream)\footnote{
+Note that implicit groups ({\ttfamily\macname{bgroup}...\macname{egroup}})
+ do not create a new \TokCycle{} nesting level, nor do
+ {\ttfamily\macname{begingroup}...\macname{endgroup}}.
+Only explicit catcode-1,2 groups, in the nature of {\ttfamily\{...\}},
+ create a nested \TokCycle{} level.
+The current \TokCycle{} nesting level may be obtained from the \TeX{} count
+ \macname{tcdepth}, which starts at zero upon \TokCycle{} entry.
+This count is incremented and decremented as groups are entered and
+ exited in the input stream.
+It may be examined within the \CGMS{} directives in order to
+ guide decisions.
+}
+ or for the remainder of the total \TokCycle{}
+ input stream.
+
+\subsubsection{\macname{truncategroup} and \macname{truncategroupiftokis}}
+\label{s:truncgrp}
+
+As to truncating the input stream for the remainder of the \TokCycle{}
+ nesting level, the command is simply \macname{truncategroup}.
+So, for example, the directive
+
+\begin{verbbox}[\vbdelim]
+ \Spacedirective{\truncategroup}
+\end{verbbox}
+\thevbox
+would direct \TokCycle{}, if it ever finds a (catcode-10) space token
+ in the input stream, to discard the remainder of the tokens within
+ the group in which that space was initially found.
+
+More often, however, one would desire to issue the truncation
+ \textit{conditionally}.
+One could use one of the conditional commands of section~\ref{s:misc},
+ for example,
+
+\begin{verbbox}[\vbdelim]
+\tctestifcon{<condition>}{\truncategroup}{<code if condition not met>}
+\end{verbbox}
+\thevbox
+Alternatively, if the \textit{condition} is the occurrence of a particular
+ single token in the input stream, one may use an abbreviated syntax:
+
+\begin{verbbox}[\vbdelim]
+\truncategroupiftokis{<tok>}{<code if condition not met>}
+\end{verbbox}
+\thevbox
+Thus, an example to echo macro tokens to the output stream, unless
+ a \macname{relax} token is found, in which case terminate the group,
+ would be
+
+\begin{verbbox}[\vbdelim]
+\Macrodirective{\truncategroupiftokis{\relax}{\addcytoks{#1}}}
+\end{verbbox}
+\thevbox
+Obviously, checks for particular character tokens would be placed in the
+ \Character{} directive, rather than the \Macro{} directive.
+
+\subsubsection{\macname{truncatecycle} and \macname{truncatecycleiftokis}}
+
+There are two commands that are in every way analogous to the
+ group-\hspace{0pt}terminating macros of section~\ref{s:truncgrp}.
+These commands are \macname{truncatecycle} and
+ \macname{truncatecycleiftokis}.
+But in this case, all tokens are discarded to the end of the input
+ stream, not just the current group (i.e., \TokCycle-nesting level).
+One point to note, however, is that open group levels will be
+ closed by the \macname{truncatecycle} command, so that the tokens,
+ both those being executed as well as those retained in
+ \macname{cytoks}, will be group-balanced.
+
+\subsubsection{Truncating from within the \Group{} Directive}
+\label{s:truncingrp}
+
+The truncate commands described in prior sections may \textit{not}
+ be executed from the \Group{} directive, as has already been
+ mentioned.
+What does termination even mean in the \macname{Groupdirective}
+ context?
+The \Group{} directive is executed whenever an explicit catcode-1,2
+ group is encountered in the input stream.
+The argument, \argone, to that directive will be the complete
+ contents of the group (sans the catcode-1,2 delimiters).
+
+So, to truncate the group from the outset, not doing anything with
+ \argone{} will accomplish the desired result.
+For example, to truncate all group-level-3 tokens, you could say,
+ using the conditional commands of section~\ref{s:misc},
+
+\begin{verbbox}[\vbdelim]
+\Groupdirective{\tctestifnum{\tcdepth=3}{}{\processtoks{#1}}}
+\end{verbbox}
+\thevbox
+There is no need to use an explicit \macname{truncategroup} macro
+ to accomplish it.
+
+On the other hand, to truncate the complete token cycle if, for example,
+ group-level-3 tokens are encountered, you have to set some sort of
+ flag that is immediately picked up by one of the other directives.
+Here is an example of how that can be done:
+
+\begin{verbbox}[\vbdelim]
+\Groupdirective{\tctestifnum{\tcdepth=3}{\processtoks{\truncatenow}}%
+ {\processtoks{#1}}}
+\Macrodirective{\truncatecycleiftokis{\truncatenow}{\addcytoks{#1}}}
+\end{verbbox}
+\thevbox
+Note that, as long as \macname{stripgroupingfalse} is active, the above
+ examples will result in empty, rather than absent, level-3 groups,
+ since the group open occurs before the truncation is processed.
+If the presence of even an empty group is to be avoided in such a case,
+ one may employ the \macname{groupedcytoks} techniques described in
+ section~\ref{s:grpcy}.
\subsection{Escaping content from \TokCycle{} processing\label{s:escape}}
@@ -474,16 +755,14 @@ For example, in the following code, \texttt{Q} is made both active and implicit:
\catcode`Q=\active
\let Qx
\end{verbbox}
-\medskip\theverbbox\medskip\noindent
-
-\noindent
+\thevbox
In general, both \macname{ifactivetok} and \macname{ifimplicittok}
tests can be performed together to determine such cases.
This is true even in the case of active-implicit catcode-10 spaces, which
- are always processed through the Space directive.
+ are always processed through the \Space{} directive.
However, because of the process \TokCycle{} uses in digesting space
- tokens, the actual token passed to the Space directive (so-called
+ tokens, the actual token passed to the \Space{} directive (so-called
\verb|#1|), when an active-implicit space is encountered in the input
stream, is a generic implicit space token named \macname{tc@sptoken}.
However, the catcode-12 version of the active character that
@@ -495,14 +774,15 @@ Such an example is described in the \texttt{tokcycle-examples}
\subsubsection{Parameter (cat-6) tokens (e.g., \texttt{\#}): \macname{ifcatSIX}}
+\label{s:cat6}
Typically, category-code 6 tokens (like \texttt{\#}) are used to
- designate a parameter (e.g., \texttt{\#1}--\texttt{\#9}).
+ designate a parameter (e.g., \argone--\texttt{\#9}).
Since they are unlikely to be used in that capacity inside a
tokcycle input stream, the package behavior is to convert them
into something cat-12 and set the \textit{if}-condition \macname{catSIXtrue}.
In this manner, \macname{ifcatSIX} can be used inside the
- Character directive to trap and convert cat-6 tokens into something of
+ \Character{} directive to trap and convert cat-6 tokens into something of
the user's choosing.
\begin{sloppypar}
@@ -515,8 +795,9 @@ On the other hand, implicit cat-6 macros (e.g., \verb|\let\myhash#|)
implicit-macro name.
\end{sloppypar}
-\subsubsection{Parameters (\texttt{\#1}--\texttt{\#9}):
+\subsubsection{Parameters (\argone--\texttt{\#9}):
\macname{whennotprocessingparameter}}
+\label{s:whennot}
While, generally, one would not intend to use parameters
in the \TokCycle{} input stream, the package provides, not a flag,
@@ -528,17 +809,18 @@ The macro is to be used \textit{within} the \Character{} directive
\whennotprocessingparameter#1{<non-parameter-processing-directive>}\end{verbbox}
\theverbbox\smallskip
-\noindent Here, the \texttt{\#1} doesn't refer to \texttt{\#1}
- as it appears in the input stream, but to the sole parameter of
+\noindent Here, the \argone{} doesn't refer to \argone{} as
+ it might appear in the input stream, but to the sole parameter of
the \Character{} directive, referring to the current token being
processed.
With this syntax, when the token under consideration is a
- parameter (e.g., \texttt{\#1}--\texttt{\#9}), that parameter is
+ parameter (e.g., \argone--\texttt{\#9}), that parameter is
added to the \macname{cytoks} register.
If the token under consideration is not a parameter, the code
in the final argument is executed.
\subsection{Misc: general \textit{if}-condition tools}
+\label{s:misc}
\TeX{} comes equipped with a variety of \macname{if...} condition
primitives.
@@ -547,34 +829,53 @@ When dealing with macros for which the order of expansion is important,
of proper expansion and execution.
These four restructured \textit{if} macros came in handy writing the
package, and may be of use in creating your directives,
- without \macname{else} and \macname{fi} getting in the way:\medskip
+ preventing \macname{else} and \macname{fi} from getting in the
+ way:\medskip
\begin{verbbox}[\vbdelim]
\tctestifcon{<TeX-if-condition>}{<true-code>}{<false-code>}
\tctestifx{<\ifx-comparison-toks>}{<true-code>}{<false-code>}
\tctestifnum{<\ifnum-condition>}{<true-code>}{<false-code>}
-\tctestifcatnx<\ifcat\noexpand-comparison-toks>{<true-code>}{<false-code>}
+\tctestifcatnx<tok1><tok2>{<true-code>}{<false-code>}
\end{verbbox}
\theverbbox
+\medskip\noindent
+Note that unlike those macros requiring three arguments, the lone
+ exception is \macname{tctestifcatnx}, which requires four, comparing the
+ catcodes of the two input toks \textbf{without expansion} (\texttt{nx}
+ denotes \macname{noexpand}).
-\subsection{\TokCycle{} macro close-out: \macname{aftertokcycle}}
+\subsection{\TokCycle{} Completion: \macname{aftertokcycle}
+ and \macname{tcendgroup}}
-The \TokCycle{} macros, upon completion, do nothing.
-Unlike \macname{tokencycle} environments, they don't even
+The \TokCycle{} \textit{macros}, upon completion, do nothing.
+Unlike \macname{tokencycle} \textit{environments}, they don't even
output \macname{the}\macname{cytoks} token register.
A command has been provided, \macname{aftertokcycle}, which takes
an argument to denote the actions to be executed following
- completion of \textit{all} subsequent \TokCycle{} invocations.
-It might be as simple as \verb|\aftertokcycle{\the\cytoks}|, to
- have the output stream automatically typeset.
+ completion of \textit{all} subsequent \TokCycle{} \textit{macro}
+ invocations within the scope of the current group.
+It might be specified as simply as \verb|\aftertokcycle{\the\cytoks}|,
+ so as to have the output stream automatically typeset by
+ future invocations of the \macname{tokcycle} macro.
The meaning of \macname{aftertokcycle} can be reset with
\macname{aftertokcycle\{\}}, but is also reset as part of
\macname{resettokcycle}.
Unlike macros, the \TokCycle{} environments are unaffected
by \macname{aftertokcycle}, as they actually set it locally
- (within their scope) to accomplish their own purposes.
+ (within their grouped scope) to accomplish their own purposes.
+
+Speaking of the \TokCycle{} environments, there is a command employed by
+ the environments \macname{tokencycle} and \macname{tokencyclexpress}
+ that is likewise available to the user: \macname{tcendgroup}.
+This is a version of \macname{endgroup} that additionally transmits the
+ current value of the \macname{cytoks} token list \textit{outside of
+ the group}.
+So if a user wishes to confine certain \TokCycle{} activity inside a
+ group, but wishes to have access to the \macname{cytoks} result afterward,
+ he may simply wrap the activity in \verb|\begingroup...\tcendgroup|.
\subsection{Accommodating catcode-1,2 changes: \macname{settcGrouping}%
\label{s:grouping}}
@@ -631,17 +932,36 @@ If I can't fix them, I can at least disclaim and declaim them below:
be detected), even if the package is not notified.
See section~\ref{s:grouping}.
-\item Should one need to keep track of the \textit{names} of implicit tokens,
- then only one named implicit cat-6 token (e.g., \verb|\let\svhash#|)
- may appear in the input
- stream (though it can appear multiple times).
-There is no limit on explicit cat-6 toks.
-This limitation occurs because implicit cat-6 tokens are converted
- into the fixed-name implicit macro \macname{implicitsixtok} which
- contains the \macname{string} of the most recently used
- implicit cat-6 token name.
-In any event, all cat-6 tokens are trapped and flag \texttt{true}
- the \macname{ifcatSIX} condition.
+\item Should one need to keep track of the \textit{names} of implicit
+ cat-6 tokens (e.g., \verb|\svhash| following \verb|\let\svhash#|),
+ care must be exercised.
+When encountered in the input stream, a cat-12 \macname{string} of
+ the implicit-cat-6 token \textit{name} is stored in the \macname{implicitsixtok}
+ macro.
+It is the \macname{implicitsixtok} token which is passed to the
+ \Character{} directive as \verb|#1|, in lieu of the actual cat-6 token.
+If there is at most a single implicit-cat-6 named token in the input stream,
+ then \macname{implicitsixtok} will reflect its name.
+However, if there is more than one, \macname{implicitsixtok} will be redefined
+ on the fly with each occurrence.
+
+Therefore, should one intend to add more than one such token \textit{name}
+ to the token list by way of \macname{addcytoks}, \textit{it must be expanded
+ first} (e.g., \macname{addcytoks[1]\{\argone\}}), in order to capture the
+ \textit{name} of that particular cat-6 implicit token, rather than the name
+ of the last one in the input stream.
+There is no similar problem for explicit cat-6 tokens.
+In any event, all cat-6 tokens are trapped and flag as \texttt{true}
+ the \macname{ifcatSIX} condition, which is how the user should detect
+ their presence.
+
+\item A similar warning is to be made for active-implicit spaces as was
+ made for implicit-cat-6 tokens.
+In the case of active-implicit spaces, the name of the active character is
+ momentarily stored in the \macname{theactivespace} macro.
+If one wishes to output the active \textit{name} to the \macname{cytoks} token list,
+ one must make sure that \macname{theactivespace} is expanded once before
+ being added to the token list.
\end{itemize}
@@ -660,10 +980,13 @@ The \texttt{tex.stackexchange} site provides a wonderful
opportunity to interact with the leading developers and
practitioners of \TeX{} and \LaTeX{}.
+\vspace{1in}
\section*{Source Code}
+%\vspace{-0.1in}
\Large\texttt{tokcycle.sty}
-\verbfilenobox[\footnotesize]{tokcycle.sty}\vspace{0.5in}
+\verbfilenobox[\footnotesize]{tokcycle.sty}%
+%\vspace{-0.1in}
\noindent\texttt{tokcycle.tex}
\verbfilenobox[\footnotesize]{tokcycle.tex}
diff --git a/macros/generic/tokcycle/tokcycle-examples.pdf b/macros/generic/tokcycle/tokcycle-examples.pdf
index 0c1f565132..b5604b382a 100644
--- a/macros/generic/tokcycle/tokcycle-examples.pdf
+++ b/macros/generic/tokcycle/tokcycle-examples.pdf
Binary files differ
diff --git a/macros/generic/tokcycle/tokcycle-examples.tex b/macros/generic/tokcycle/tokcycle-examples.tex
index 49fbe6c66c..891741bd4b 100644
--- a/macros/generic/tokcycle/tokcycle-examples.tex
+++ b/macros/generic/tokcycle/tokcycle-examples.tex
@@ -1,7 +1,7 @@
\documentclass[10pt]{article}
\usepackage[margin=1.3in]{geometry}
\usepackage[T1]{fontenc}
-\usepackage{tokcycle,xcolor,manfnt}
+\usepackage{tokcycle,xcolor,manfnt,lmodern}
\colorlet{bred}{red!90!blue}
\usepackage{tikz}
% MACROS: REDEFINE TO ALLOW \cytoks TO ESCAPE SCOPE OF exampleA
@@ -25,7 +25,6 @@
sidebyside,
title=#2,#1}
-
\newtcblisting{exampleB}[2][]{%
colframe=red!50!yellow!50!black,
colback=red!50!yellow!5!white,%white,
@@ -49,7 +48,8 @@
\def\altdecytoks{\par\medskip\begingroup\noindent\macname{cytoks}
\ \textit{alt}detokenization:\\\raggedright\footnotesize\ttfamily
- \expandafter\altdetokenize\expandafter{\the\cytoks}\par\endgroup}
+ \expandafter\altdetokenize\expandafter{\the\cytoks}\normalsize\par\endgroup}
+
\newcommand\TokCycle{\textsf{tokcycle}}
\parindent0pt
@@ -78,9 +78,10 @@
\newif\ifmacro
\newcommand\altdetokenize[1]{\begingroup\stripgroupingtrue\macrofalse
+ \stripimplicitgroupingcase{-1}%
\tokcycle
{\ifmacro\def\tmp{##1}\ifcat\tmp A\else\unskip\allowbreak\fi\macrofalse\fi
- \detokenize{##1}}
+ \detokenize{##1}\ifx##1\bgroup\unskip\fi\ifx##1\egroup\unskip\fi}
{\ifmacro\unskip\macrofalse\fi\{\processtoks{##1}\ifmacro\unskip\fi\}\allowbreak}
{\tctestifx{\\##1}{\\}{\ifmacro\unskip\allowbreak\fi
\allowbreak\detokenize{##1}\macrotrue}}
@@ -152,7 +153,7 @@
{\addcytoks{##1}}
\newcommand*\tcmapto[2]{\expandafter\def\csname tcmapto#1\endcsname{#2}}
\newcommand*\tcremap[1]{\ifcsname tcmapto#1\endcsname
- \csname tcmapto#1\endcsname\else#1\fi}
+ \csname tcmapto#1\expandafter\endcsname\else\expandafter#1\fi}
\tcmapto am \tcmapto bf \tcmapto cz \tcmapto de \tcmapto ey
\tcmapto fl \tcmapto gx \tcmapto hb \tcmapto ic \tcmapto jn
\tcmapto ki \tcmapto lr \tcmapto mh \tcmapto nt \tcmapto ok
@@ -160,6 +161,12 @@
\tcmapto uj \tcmapto vp \tcmapto wd \tcmapto xg \tcmapto yu
\tcmapto zv
+\tokcycleenvironment\greek% NEW TOKCYCLE ENVIRONMENT:
+{\addcytoks[4]{\tcremap{##1}}}% HOW TO TREAT CHARACTERS
+{\processtoks{##1}}% HOW TO TREAT GROUP CONTENTS
+{\addcytoks{##1}}% HOW TO TREAT MACROS
+{\addcytoks{##1}}% HOW TO TREAT SPACES
+
\newcommand\findinstring[2]{\begingroup%
\stripgroupingtrue
\setcounter{runcount}{0}%
@@ -197,6 +204,72 @@
\newcommand\detokenizespacetok[1]{\tctestifcon{\ifimplicittok}%
{\tctestifcon{\ifactivetok}{\theactivespace}{\string#1}}{\detokenize{#1}}}
+\newcounter{sigd}
+\newcounter{trailingz}
+\newcommand\sigdigits[1]{%
+ \setcounter{sigd}{0}% SIGNIFICANT DIGIT COUNT
+ \setcounter{trailingz}{0}% TRAILING ZERO COUNT
+ \def\founddot{F}% MADE T WHEN DECIMAL HAS BEEN 1ST LOCATED
+ \def\zerosig{F}% MADE T WHEN ZERO BECOMES SIGNIFICANT
+ \tokcycle% CYCLE THROOUGH EACH TOKEN
+ {\tctestifx{.##1}%
+ {\if T\founddot\throwerr\fi\def\founddot{T}}% IF .
+ {\tctestifnum{`##1>`/}%
+ {\tctestifnum{`##1<`:}%
+ {\tctestifnum{##1>0}%
+ {\stepcounter{sigd}\def\zerosig{T}\setcounter{trailingz}{0}}% IF 1-9
+ {\if T\zerosig\stepcounter{sigd}\fi\stepcounter{trailingz}}% IF 0
+ }%
+ {\throwerr}% IF ASCII > `9
+ }%
+ {\throwerr}% IF ASCII < `0
+ }%
+ }% APPLY ABOVE LOGIC FOR CHAR TOKENS
+ {\throwerr}% IF BRACES
+ {\throwerr}% IF CONTROL SEQUENCE
+ {}% IGNORE SPACES
+ {#1}% THE ARGUMENT
+ \addtocounter{sigd}{-\thetrailingz}% SUBTRACT TRAILING ZEROS
+ \expandafter\ifx\expandafter\relax\detokenize\expandafter{\the\cytoks}%
+ \relax\else\setcounter{sigd}{-1}\fi% CHECK FOR INVALID INPUT
+ \thesigd
+}
+\newcommand\throwerr{\addcytoks{##1}}% ADD INVALID TOKS TO \cytoks
+
+\newcounter{Tcount}
+\xtokcycleenvironment\capTive% ENVIRONMENT NAME
+{\tctestifx{t##1}{\stepcounter{Tcount}\addcytoks{T}}{\addcytoks{##1}}}% CHAR. DIRECTIVE
+{\processtoks{##1}}% GROUP DIRECTIVE
+{\addcytoks{##1}}% MACRO DIRECTIVE
+{\addcytoks{##1}}% SPACE DIRECTIVE
+{\setcounter{Tcount}{0}\color{red}\tcafterenv{\ Here}}% INITIALIZATION CODE
+{\theTcount{} t's capitalized: \addcytoks{!!}}% CLOSE-OUT CODE
+
+\newcounter{wordcount}
+\newcounter{lettercount}
+\newif\ifinword
+\newif\ifrunningcount
+\newcommand\dumpword{%
+ \addcytoks[1]{\accumword}%
+ \tctestifcon\ifinword{\stepcounter{wordcount}%
+ \ifrunningcount\addcytoks[x]{$^{\thewordcount,\thelettercount}$}\fi}{}%
+ \inwordfalse\def\accumword{}}
+\makeatletter
+\newcommand\addletter[1]{%
+ \tctestifcatnx A#1{\stepcounter{lettercount}\inwordtrue}{\dumpword}%
+ \tc@defx\accumword{\accumword#1}}
+\makeatother
+
+\xtokcycleenvironment\countem
+ {\addletter{##1}}
+ {\processtoks{##1}\dumpword}
+ {\dumpword\addcytoks{##1}}
+ {\dumpword\addcytoks{##1}}
+ {\def\accumword{}\setcounter{wordcount}{0}\setcounter{lettercount}{0}}
+ {\dumpword\ifrunningcount\else\tcafterenv{\par(Wordcount=\thewordcount,
+ Lettercount=\thelettercount)}\fi}
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Examples, examples, and more examples}
@@ -240,11 +313,13 @@ Default escape character is $|$. One can change it with
\begingroup
-\begin{exampleC}[]{The unexpandable \macname{plusl} macro}
+\begin{exampleC}[]{The unexpandable \macname{plusl} macro to increase
+ the ASCII value of tokens by 1}
\newcommand\plusl[1]{\char\numexpr`#1+1\relax}
\end{exampleC}
-\begin{exampleA}[lefthand width=5cm]{Escaping text in the input stream}
+\begin{exampleA}[lefthand width=5cm]{Escaping text and macro parameters
+ in the input stream}
\tokcycle
{\addcytoks{\plusl{#1}}}
{\processtoks{#1}}
@@ -265,9 +340,9 @@ Default escape character is $|$. One can change it with
\begingroup
This section concerns the issue of whether the characters of the input
stream are transformed before or after being placed in the
- output token register (\macname{cytoks}).\medskip
+ output token list (\macname{cytoks}).
-\noindent\begin{minipage}[t]{\textwidth}
+\medskip
Transform characters (+1 ASCII) via unexpandable macro:\medskip
\begin{exampleA}[lefthand width=8.3cm]
@@ -283,8 +358,11 @@ Transform characters (+1 ASCII) via unexpandable macro:\medskip
\altdecytoks
+Note how the above detokenization shows the actual transformation
+ instructions involving \macname{plusl}.
+This is done because \macname{plusl} is not expandable.
+
\par\noindent\hrulefill\medskip
-\end{minipage}
\endgroup
\noindent\begin{minipage}[t]{\textwidth}
@@ -316,6 +394,12 @@ Capitalize vowels (but don't expand the character directive)
\altdecytoks
+\medskip
+The above detokenization also shows the transformation macro,
+ \macname{vowelcap}, as part of \macname{cytoks}.
+But because \macname{vowelcap} is expandable, we did not need to
+ leave it at this stage, as the next example shows.
+
\par\noindent\hrulefill\medskip
\endgroup
\end{minipage}
@@ -336,6 +420,9 @@ Capitalize vowels (expanding the character directive)
\altdecytoks
+\medskip
+Here, we see no vestiges of \macname{vowelcap} in \macname{cytoks},
+ but only the transformed result.
\endgroup
\subsubsection{Unexpanded vs. pre-expanded input stream}
@@ -359,6 +446,10 @@ Capitalize vowels (expanding the character directive)
\altdecytoks
+\medskip
+In the above case, vowel-capping is not applied to the date, because
+ \macname{today} remains unexpanded in the \macname{cytoks} token list.
+
\noindent\hrulefill\strut
\end{minipage}
@@ -377,6 +468,14 @@ Note that, when pre-expanding the input stream, one must
\altdecytoks
+\medskip
+Here, we see the date subjected to vowel-capping, because the \TokCycle{}
+ input was expanded prior to the token cycle.
+Thus \macname{today} no longer appears \textit{explicitly} in the
+ \macname{cytoks} token list.
+Its pre-expansion into character tokens is now subject to the
+ \macname{vowelcap}.
+
\endgroup
\subsection{Grouping}
@@ -442,7 +541,7 @@ These are embodied in the if-condition \macname{ifstripgrouping}
Regardless of which condition is set, the tokens within the explicit
group are still passed to the Group directive for processing.
-
+\medskip
Permutations of the following code are used in the subsequent examples.
Group stripping, brought about by \macname{stripgroupingtrue},
involves removing the grouping braces from around the group.
@@ -451,6 +550,7 @@ The choice of \macname{processtoks} vs.\@ \macname{addcytoks}
to \TokCycle{} for processing, or are merely sent to the output
register in their original unprocessed form.
+\medskip
Note that, in these examples, underdots and visible spaces
will only appear on characters and spaces that have been directed
to the Character and Space directives, respectively.
@@ -547,15 +647,73 @@ Note that the content of groups can be altogether eliminated if
{1{{3{{5{{7{{9{1{}0}}8}}6}}4}}2}}}
\the\cytoks
\end{exampleA}
+Note, above, that \TokCycle{} does not rely on an argument-based nesting
+ algorithm that would otherwise be limited to 9 embedded groups.
+\endgroup
+
+\subsubsection{The use of \macname{groupedcytoks} for more sophisticated
+ group processing}
+
+\begingroup
+
+\begin{sloppypar}
+By default, \TokCycle{} processes groups such that whatever additions to the
+ \macname{cytoks} token list you accomplish in the Group directive will be
+ encased in an explicit grouped scope.
+This is the token-cycle behavior with the default \macname{stripgroupingfalse}
+ declaration.
+However, for more sophisticated tasks associated with the processing of
+ group content, one may override the default (by way of
+ \macname{stripgroupingtrue}) and manually dictate the groupings associated
+ with the Group directive, with the use of \macname{groupedcytoks\{...\}}.
+\end{sloppypar}
+
+\medskip In the following example, tasks A and D are performed \textit{outside}
+ of the explicit grouping otherwise introduced with \macname{groupedcytoks},
+ whereas tasks B and C fall inside of that explicit group.
+The fact that, in the output, \texttt{d} is not italic confirms the
+ fact that task D occurs after the conclusion of the explicit \macname{cytoks}
+ group that encompasses the italic `bxc'.
+The fact that none of \texttt{a}, \texttt{b}, \texttt{c}, nor \texttt{d} are
+ encased in an \macname{fbox} indicates that they were not processed through
+ the Character directive, but arose from direct additions to \macname{cytoks},
+ by way of their tasks.
+
+\begin{exampleA}[lefthand width=10cm]{Use of the \macname{groupedcytoks}
+ macro}
+\stripgroupingtrue
+\Characterdirective{\addcytoks{\fbox{#1}}}
+\Groupdirective{\taskA%
+ \groupedcytoks{\taskB\processtoks{#1}\taskC}%
+ \taskD}
+\def\taskA{\addcytoks{\bgroup\LARGE a}}
+\def\taskB{\addcytoks{\itshape b}}
+\def\taskC{\addcytoks{c}}
+\def\taskD{\addcytoks{d\egroup}}
+
+\tokcyclexpress{x\textbf{x}x}
+\the\cytoks
+\end{exampleA}
+
+The final disposition of the \macname{cytoks} token list shows the effects of
+ \macname{stripgroupingtrue} and \macname{groupedcytoks} more explicitly:
+
+\altdecytoks
+
+\medskip
+Without \macname{stripgroupingtrue}, all tasks, A,B,C, and D, would have
+ been contained within the explicit \texttt{\{...\}} group.
\endgroup
+
\subsection{Direct use of \TokCycle}
-\TokCycle{} (in regular or \texttt{xpress} form) may be invoked
+The \TokCycle{} macros and pseudo-environments
+ (in regular or \texttt{xpress} form) may be invoked
directly from the document, without
- being first encapsulated within a macro or environment.
+ being first encapsulated within a separate macro or environment.
\subsubsection{Modifying counters as part of the Character
directive}
@@ -563,7 +721,7 @@ Note that the content of groups can be altogether eliminated if
\begingroup
\begin{exampleA}[lefthand width=8.5cm]{Using a period token (.) to
- reset a changing color}
+ reset a changing color every sentence}
\restorecolor
\tokencycle
{\addcytoks{\bgroup\reducecolor{3}#1\egroup}%
@@ -610,6 +768,9 @@ is long.} Now, it is short.
Back to regular text.
\end{exampleA}
+Note that embedded macros such as \macname{textit} and \macname{textbf}
+ do not adversely affect the capability of the \macname{spaceouttext}
+ macro.
\endgroup
@@ -623,7 +784,7 @@ It is \textbf{not} to be confused as a replacement for
In certain applications, it may offer a more pleasingly formatted
typesetting of detokenized material.
-It is an unusual application of \TokCycle{} in that it does not
+\medskip It is an unusual application of \TokCycle{} in that it does not
actually use the \macname{cytoks} token register to collect
its output.
This is only possible because all macros in the input stream
@@ -634,9 +795,10 @@ This is only possible because all macros in the input stream
\begin{exampleC}[]{The \macname{altdetokenize }\ macro}
\newif\ifmacro
\newcommand\altdetokenize[1]{\begingroup\stripgroupingtrue\macrofalse
+ \stripimplicitgroupingcase{-1}%
\tokcycle
{\ifmacro\def\tmp{##1}\ifcat\tmp A\else\unskip\allowbreak\fi\macrofalse\fi
- \detokenize{##1}}
+ \detokenize{##1}\ifx##1\bgroup\unskip\fi\ifx##1\egroup\unskip\fi}
{\ifmacro\unskip\macrofalse\fi\{\processtoks{##1}\ifmacro\unskip\fi\}\allowbreak}
{\tctestifx{\\##1}{\\}{\ifmacro\unskip\allowbreak\fi
\allowbreak\detokenize{##1}\macrotrue}}
@@ -652,7 +814,7 @@ This is only possible because all macros in the input stream
\string\altdetokenize: \\
\texttt{\altdetokenize{a\mac a \mac2 {\mac}\mac{a\mac\mac}\mac}}!
-\string\detokenize: \\
+versus \string\detokenize: \\
\texttt{\detokenize{a\mac a \mac2 {\mac}\mac{a\mac\mac}\mac}}!
\end{exampleA}
\endgroup
@@ -786,12 +948,92 @@ This is only possible because all macros in the input stream
\endgroup
+\subsubsection{Counting the significant digits in a number}
+
+\begingroup
-\subsection{\TokCycle-based environments}
+The problem of counting the significant digits in a number is an interesting
+ one, in that leading and trailing zeros are not significant, but zeros
+ in the middle of the number are significant.
+In a problem like this, the \macname{cytoks} token list is not used to
+ carry a transformation of the input tokens, but only to carry a record
+ of errant tokens from the input (as seen from the helper macro
+ \macname{throwerr}).
+If \macname{the\textbackslash cytoks} is anything other than empty when the
+ macro completes, the macro will set the significant-digit counter
+ \texttt{sigd} to a value of -1 to signify an error condition.
+
+\medskip
+The macro expects its input to comprise digits in the 0--9 range, an [optional]
+ single decimal point, and ignorable spaces. Any other token will throw
+ an error.
+
+\medskip
+The main work of the \macname{sigdigits} macro is to use the counters
+ \texttt{sigd} to count significant digits and \texttt{trailingz} to
+ tabulate the number of trailing-zeros with which to decrement
+ \texttt{sigd}.
+
+\begin{exampleC}[]{The \macname{sigdigits} macro for counting significant digits}
+\newcounter{sigd}
+\newcounter{trailingz}
+\newcommand\sigdigits[1]{%
+ \setcounter{sigd}{0}% SIGNIFICANT DIGIT COUNT
+ \setcounter{trailingz}{0}% TRAILING ZERO COUNT
+ \def\founddot{F}% MADE T WHEN DECIMAL HAS BEEN 1ST LOCATED
+ \def\zerosig{F}% MADE T WHEN ZERO BECOMES SIGNIFICANT
+ \tokcycle% CYCLE THROOUGH EACH TOKEN
+ {\tctestifx{.##1}%
+ {\if T\founddot\throwerr\fi\def\founddot{T}}% IF .
+ {\tctestifnum{`##1>`/}%
+ {\tctestifnum{`##1<`:}%
+ {\tctestifnum{##1>0}%
+ {\stepcounter{sigd}\def\zerosig{T}\setcounter{trailingz}{0}}% IF 1-9
+ {\if T\zerosig\stepcounter{sigd}\fi\stepcounter{trailingz}}% IF 0
+ }%
+ {\throwerr}% IF ASCII > `9
+ }%
+ {\throwerr}% IF ASCII < `0
+ }%
+ }% APPLY ABOVE LOGIC FOR CHAR TOKENS
+ {\throwerr}% IF BRACES
+ {\throwerr}% IF CONTROL SEQUENCE
+ {}% IGNORE SPACES
+ {#1}% THE ARGUMENT
+ \addtocounter{sigd}{-\thetrailingz}% SUBTRACT TRAILING ZEROS
+ \expandafter\ifx\expandafter\relax\detokenize\expandafter{\the\cytoks}%
+ \relax\else\setcounter{sigd}{-1}\fi% CHECK FOR INVALID INPUT
+ \thesigd
+}
+\newcommand\throwerr{\addcytoks{##1}}% ADD INVALID TOKS TO \cytoks
+\end{exampleC}
+
+\begin{exampleA}[lefthand width=8.0cm]{Example use of the \macname{sigdigits}
+ macro}
+1) \sigdigits{12.3}\\
+2) \sigdigits{0.123}\\
+3) \sigdigits{1.2.3}\\
+4) \sigdigits{1.3\today}\\
+5) \sigdigits{321.345 678}\\
+6) \sigdigits{000321.305}\\
+7) \sigdigits{.000 300 345}\\
+8) \sigdigits{0003x1.345}\\
+9) \sigdigits{123000}\\
+A) \sigdigits{123.000}\\
+B) \sigdigits{0003;345}
+\end{exampleA}
+
+\endgroup
+
+
+\subsection{Creating your own \TokCycle-based environments}
The \macname{tokcycleenvironment} macro allows users to define
their own \TokCycle{} environments.
-Here are some examples.
+The more recently introduced \macname{xtokcycleenvironment} macro extends
+ that capability to allow initialization and postprocessing when defining
+ a named \TokCycle{} environment.
+Here are some examples of both types.
\subsubsection{``Removing'' spaces, but still breakable/hyphenatable}
@@ -805,7 +1047,8 @@ Here are some examples.
{\addcytoks{\hspace{.2pt plus .2pt minus .8pt}}}%
\end{exampleC}
-\begin{exampleA}[lefthand width=6.0cm]{}
+\begin{exampleA}[lefthand width=6.0cm]{Example of using the \macname{spaceBgone}
+ environment}
\spaceBgone
Here we have a \textit{test} of
whether the spaces are removed.
@@ -834,7 +1077,7 @@ Here are some examples.
{\addcytoks{##1}}
\newcommand*\tcmapto[2]{\expandafter\def\csname tcmapto#1\endcsname{#2}}
\newcommand*\tcremap[1]{\ifcsname tcmapto#1\endcsname
- \csname tcmapto#1\endcsname\else#1\fi}
+ \csname tcmapto#1\expandafter\endcsname\else\expandafter#1\fi}
\tcmapto am \tcmapto bf \tcmapto cz \tcmapto de \tcmapto ey
\tcmapto fl \tcmapto gx \tcmapto hb \tcmapto ic \tcmapto jn
\tcmapto ki \tcmapto lr \tcmapto mh \tcmapto nt \tcmapto ok
@@ -859,11 +1102,259 @@ Because \macname{tcremap} is expandable, the original text is totally absent
\endgroup
\end{minipage}
+\bigskip
+\begingroup
+
+This approach can be used, for example, to temporarily remap Latin into Greek in
+ math mode.
+In the example given below, only several of the Latin letters are remapped
+ for demonstration purposes, but others can be added.
+Also, remember that one can use the \verb+|...|+ delimiters to escape back to
+ Latin within the environment.
+
+\begin{exampleC}[]{The \macname{greek} environment with
+ supporting macros}
+\tokcycleenvironment\greek% NEW TOKCYCLE ENVIRONMENT:
+{\addcytoks[4]{\tcremap{##1}}}% HOW TO TREAT CHARACTERS
+{\processtoks{##1}}% HOW TO TREAT GROUP CONTENTS
+{\addcytoks{##1}}% HOW TO TREAT MACROS
+{\addcytoks{##1}}% HOW TO TREAT SPACES
+\newcommand*\tcmapto[2]{\expandafter\def\csname tcmapto#1\endcsname{#2}}
+\newcommand*\tcremap[1]{\ifcsname tcmapto#1\endcsname
+ \csname tcmapto#1\expandafter\endcsname\else\expandafter#1\fi}
+\tcmapto a\alpha \tcmapto b\beta \tcmapto e\epsilon
+\tcmapto g\gamma \tcmapto p\pi
+\end{exampleC}
+
+\tcmapto a\alpha \tcmapto b\beta \tcmapto e\epsilon
+\tcmapto g\gamma \tcmapto p\pi
+
+\begin{exampleA}[lefthand width=8.5cm]{Demo of \macname{greek}}
+\[
+ y =
+ \greek a^2b\frac{2e}{2 + p^|p| + g}\endgreek
+ + x
+\]
+\end{exampleA}
+
+\endgroup
+
+\subsubsection{Creating an ``extended'' \TokCycle{} environment}
+
+\begingroup
+The \macname{xtokcycleenvironment} macro extends the capability of
+ \macname{tokcycleenvironment} by adding two arguments that correspond,
+ respectively, to initialization code and ``close-out'' code that is run
+ after the token cycle is complete (but before it is typeset).
+Let's say I wanted an environment that capitalizes instances of the letter
+ `\texttt{t}', but I want it to tell me how many
+ letter \texttt{t}'s are affected before typesetting the result.
+Furthermore, I want it always to set the result in red and add two
+ exclamation points to the end of the environment output.
+
+\begin{exampleC}[]{The \macname{capTive} extended-environment definition}
+\newcounter{Tcount}
+\xtokcycleenvironment\capTive% ENVIRONMENT NAME
+{\tctestifx{t##1}{\stepcounter{Tcount}\addcytoks{T}}{\addcytoks{##1}}}% CHAR. DIRECTIVE
+{\processtoks{##1}}% GROUP DIRECTIVE
+{\addcytoks{##1}}% MACRO DIRECTIVE
+{\addcytoks{##1}}% SPACE DIRECTIVE
+{\setcounter{Tcount}{0}\color{red}\tcafterenv{\ Here}}% INITIALIZATION CODE
+{\theTcount{} t's capitalized: \addcytoks{!!}}% CLOSE-OUT CODE
+\end{exampleC}
+
+\begin{exampleA}[lefthand width=7.9cm]{Demo of \macname{capTive}
+ environment}
+Before \capTive the cytoks \footnotesize token list\endcapTive After
+\end{exampleA}
+
+In the initialization code, the \texttt{Tcount} counter is reset and the color
+ of what follows is made red.
+It also makes use of the specialized \macname{tcafterenv} macro that can
+ \textbf{only be used in \macname{xtokcycle\-environment} definitions}.
+This macro indicates code to execute \textit{after} the \texttt{capTive}
+ environment scope is exited.
+This invocation typesets the word `Here'.
+We see that in the output, it occurs at normal size and in black, because
+ it is no longer subject to the color and fontsize that was left inside
+ the environment.
+The \macname{tcafterenv} macro is unique in that it is an appending, rather
+ than a defining, macro.
+Therefore, multiple invocations of it will append multiple code segments,
+ each of which will be executed upon environment exit.
+It may be invoked in any of the directives, as well as the initialization and
+ close-out code segments.
+
+\medskip
+For the close-out code, because it is executed after the token cycle is
+ complete, but before it is typeset, the updated value of \texttt{Tcount}
+ is available.
+Anything typeset directly in the close-out code will occur before the
+ \macname{cytoks} token-list output is typeset.
+Thus, the ``...t's capitalized.'' phrase is typeset before \macname{cytoks}
+ itself, even as \macname{theTcount} is accurate.
+The \macname{addcytoks} occurring in the close-out code is placed at the
+ end of \macname{cytoks} and thus takes on the \macname{footnotesize}
+ declaration that is still in force.
+\endgroup
+
+\begingroup
+\medskip
+Next, we consider a \TokCycle{} extended environment that counts words and
+ letters.
+We try to build some features into the code so that, for example, spaces
+ and punctuation do not count as letters.
+Further, we try to build the logic so that the following cases would
+ count as two words, not one: ``here...now'', ``Case(number)''.
+
+\medskip
+We provide two modes of output: one that provides an ending summary, and
+ the other that keeps a running count.
+As with other \TokCycle{} environments and macros, portions can be
+ exempted from the count (for example macro arguments) by using the
+ escape delimiters provided.
+
+\begin{exampleC}[]{The \macname{countem} extended-environment definition
+ and supporting macros}
+\newcounter{wordcount}
+\newcounter{lettercount}
+\newif\ifinword
+\newif\ifrunningcount
+\newcommand\dumpword{%
+ \addcytoks[1]{\accumword}%
+ \tctestifcon\ifinword{\stepcounter{wordcount}%
+ \ifrunningcount\addcytoks[x]{$^{\thewordcount,\thelettercount}$}\fi}{}%
+ \inwordfalse\def\accumword{}}
+\makeatletter
+\newcommand\addletter[1]{%
+ \tctestifcatnx A#1{\stepcounter{lettercount}\inwordtrue}{\dumpword}%
+ \tc@defx\accumword{\accumword#1}}
+\makeatother
+
+\xtokcycleenvironment\countem
+ {\addletter{##1}}
+ {\processtoks{##1}\dumpword}
+ {\dumpword\addcytoks{##1}}
+ {\dumpword\addcytoks{##1}}
+ {\def\accumword{}\setcounter{wordcount}{0}\setcounter{lettercount}{0}}
+ {\dumpword\ifrunningcount\else\tcafterenv{\par(Wordcount=\thewordcount,
+ Lettercount=\thelettercount)}\fi}
+\end{exampleC}
+
+\begin{exampleA}[lefthand width=5.6cm]{Demo of the two modes of
+ \macname{countem}}
+\countem
+This is a test.
+
+But...punctuation does not count.
+\endcountem
+
+\bigskip\runningcounttrue
+\countem
+This is a test.
+
+But...punctuation does not count.
+\endcountem
+\end{exampleA}
+
+\endgroup
+
+\subsection{Truncation of input}
+
+\begingroup
+
+\TokCycle{} has several facilities for truncating input, either
+ to the end of the current group or to the end of the input stream.
+The basic commands are \macname{truncategroup} and \macname{truncatecycle},
+ which can be part of the Character, Macro, or Space directives (see the
+ package documentation for truncation from the Group directive).
+
+\medskip
+These commands may be issued directly or they may be placed as
+ one fork of a conditional test.
+If the conditional test is the occurrence of a particular token in the
+ input stream, special conditional shortcuts have been formulated:
+ \macname{truncategroupiftokis} and \macname{truncatecycleiftokis}.
+Both of these commands take two arguments: the first is the comparison
+ token against which to compare the tokens of the input stream, and the
+ second is the directive to follow for tokens that fail the
+ comparison test.
+If the input stream token matches the comparitor, the relevant
+ truncation command is executed.
+
+\medskip
+The description below shows the truncations to a given input text,
+ resulting from several different forms of truncating directives.
+In the first case, the token cycle is to be truncated if a space
+ is found in the input stream.
+Comparing to the input text, we see that the space occurs after the
+ word ``until'', and that is indeed where the \TokCycle{} output
+ ceases.
+
+\medskip
+In the second case, the truncation is limited to the current group,
+ rather than the remainder of the input stream.
+Again, the space following ``until'' is found, and the words
+ ``certain token'' are excised from the input stream until the
+ end-of-group is located.
+The cycle continues successfully with ``-is'' until the next space
+ is found before ``located''.
+Since this space is found in the top grouping level of the input,
+ the remainder of the input stream is thereafter truncated.
+
+\medskip
+In the third case, the cycle is to be truncated in the event the
+ letter `a' is found in the input stream.
+Examining the input text, the first `a' is in the word ``certain'' and
+ so the input is truncated after the string ``cert'' is digested.
+
+\medskip
+The final case, calls for group truncation if an `a' is found in the
+ input stream.
+As before, the first `a' is found after ``cert''.
+However, in the group case, only the remaining group content, consisting
+ of ``ain token'', is discarded.
+At group end, the cycle successfully resumes until the `a' in
+ ``located'' is reached.
+Thus, ``-is loc'' is also added to the output stream.
+
+\def\thetext{Continue-\textit{until certain token}-is located.}
+
+\newcommand\rundemowith[1]{%
+ {\footnotesize\ttfamily\altdetokenize{#1}}:
+ \resettokcycle#1\expandafter\tokencyclexpress\thetext\endtokencyclexpress
+}
+
+\begin{exampleB}[text only, righthand width=0.01cm, colback=white]%
+{Effects of various truncation directives}
+{\footnotesize\ttfamily Input text}: \expandafter\altdetokenize\expandafter
+ {\thetext}
+
+\rundemowith{\Spacedirective{\truncatecycle}}
+
+\rundemowith{\Spacedirective{\truncategroup}}
+
+\rundemowith{\Characterdirective{\truncatecycleiftokis{a}{\addcytoks{#1}}}}
+
+\rundemowith{\Characterdirective{\truncategroupiftokis{a}{\addcytoks{#1}}}}
+\end{exampleB}
+
+Note how the macro function, in this case \macname{textit}, is not
+ disrupted by the truncation.
+Even as tokens are truncated from the input stream, group closures
+ are retained so that the final output is group-balanced.
+For example, a detokenization of the final case reveals this to be
+ the case:
+
+\altdecytoks
+
+\endgroup
+
\subsection{Advanced topics: implicit tokens and catcode changes}
\subsubsection{Trap Active Characters (catcode 13)}
-\begin{minipage}[t]{\textwidth}
+%\begin{minipage}[t]{\textwidth}
\begingroup
Active characters in the \TokCycle{} input stream are processed in
their original form.
@@ -886,26 +1377,27 @@ For information on how to process active spaces, please refer to
\begin{exampleA}[lefthand width=7.8cm]{Processing active characters}
\resettokcycle
\tokencyclexpress
-This is a test!!\endtokencyclexpress
+1. This is a test!!\endtokencyclexpress
-\catcode`!=\active
-\def !{?}
+2. \catcode`!=\active
+\def !{?}%
\tokencyclexpress
This is a test!!\endtokencyclexpress
+3.
\Characterdirective{\tctestifcon\ifactivetok
- {\addcytoks{\fbox{#1-chr}}}{\addcytoks{#1}}}
+ {\addcytoks{\fbox{#1-chr}}}{\addcytoks{#1}}}%
\Macrodirective{\tctestifcon\ifactivetok
- {\addcytoks{\fbox{#1-mac}}}{\addcytoks{#1}}}
+ {\addcytoks{\fbox{#1-mac}}}{\addcytoks{#1}}}%
\tokencyclexpress
This is a test!!\endtokencyclexpress
-\catcode`T=\active
-\let T+
+4. \catcode`T=\active
+\let T+%
\tokencyclexpress
This is a test!!\endtokencyclexpress
-\detokenize\expandafter{\the\cytoks}
+5. \detokenize\expandafter{\the\cytoks}
\end{exampleA}
%%%
@@ -916,15 +1408,16 @@ This is a test!!\endtokencyclexpress
are made before reaching \TokCycle{} processing.
\svt hey are, thus, no longer detected as active, unless
\macname{noexpand} is applied before the pre-expansion.
-In this example, the \texttt{!} that is not \macname{noexpand}\kern.3pted
- is converted to a \texttt{?} prior to reaching \TokCycle{}
- processing (and thus, not detected as \macname{active}):
+In this example, the `\texttt{!}' that is not \macname{noexpand}\kern.3pted
+ is converted to a `\texttt{?}' prior to reaching \TokCycle{}
+ processing (and thus, not detected as \macname{active}).
+Likewise, the `\texttt{T}' is pre-converted to a `\texttt{+}':
\catcode`!=\active
\def !{?}
\catcode`T=\active
\let T+
-\begin{exampleA}[lefthand width=7.8cm]{Expanded input stream acts
+\begin{exampleA}[lefthand width=7.0cm]{Expanded input stream acts
upon active \macname{def}ed characters unless \macname{noexpand} is applied}
\expandedtokcyclexpress{This is a test!\noexpand!}
\the\cytoks\par
@@ -942,7 +1435,7 @@ However, pre-tokenization does not suffer this behavior:
%%%
\endgroup
-\end{minipage}
+%\end{minipage}
\begingroup
\ddbend One aspect of \TeX{} to remember is that catcodes
@@ -955,6 +1448,7 @@ But if the cat-13 active definition is changed prior to the
execution of the \macname{def}'ed token, the revised
token assignment will apply.
+\medskip
The following example demonstrates this concept, while showing,
without changing the input in any way, that \TokCycle{}
can properly digest active and implicit grouping (cat-1,2) characters:
@@ -996,6 +1490,7 @@ In this manner, \macname{ifcatSIX} can be used inside the
Character directive to convert cat-6 tokens into something of
the user's choosing.
+\medskip
As to this cat-12 conversion, explicit cat-6 characters are converted
into the same character with cat-12.
On the other hand, implicit cat-6 control sequences (e.g., \verb|\let\myhash#|)
@@ -1003,6 +1498,7 @@ On the other hand, implicit cat-6 control sequences (e.g., \verb|\let\myhash#|)
whose cat-12 substitution text is a \macname{string} of the original
implicit-macro name.
+\begingroup
\resettokcycle
\Characterdirective{\ifcatSIX
\addcytoks{\fbox{#1}}
@@ -1045,6 +1541,7 @@ On the other hand, implicit cat-6 control sequences (e.g., \verb|\let\myhash#|)
\catcode`Q=11
\hrulefill
+\endgroup
\ddbend For what is, perhaps, a rare situation, one can even process input
streams that contain cat-6 macro parameters.
@@ -1054,10 +1551,6 @@ A package macro, \macname{whennotprocessingparameter\#1\{<}%
In this example, a macro is defined and then executed, subject to
token replacements brought about by the expandable Character directive.
-\Characterdirective{%
- \whennotprocessingparameter#1{\addcytoks[x]{\vowelcap{#1}}}}
-\aftertokcycle{\global\cytoks\expandafter{\the\cytoks}}
-\def\Characterdirective#1{}
\begin{exampleA}[lefthand width=7cm]{Preserving parameters (e.g.
\texttt{\#1, \#2}) in the \TokCycle{} input stream}
\Characterdirective{%
@@ -1172,6 +1665,7 @@ Changing grouping tokens (catcodes 1,2) may require something more,
In the following examples, pay attention to the
detokenized grouping around the argument to \macname{fbox}.
+\medskip
As we will see, the issues raised here only affect the situation
when detokenization of the output stream is required.
\medskip
@@ -1336,21 +1830,13 @@ The next two examples introduce implicit and active-implicit spaces.
The latter example also demonstrates detokenization of such spaces.
\medskip
-Here is a useful macro for detokenizing space tokens in the context of
- \TokCycle{}.
+Here is a useful expandable macro for detokenizing space tokens
+ in the context of \TokCycle{}.
It can process not only explicit cat-10 spaces, but also implicit and
active-implicit spaces.
To add it to the \macname{cytoks} token list, make sure you use the
\verb|[x]| fully expanded option to \macname{addcytoks}.
-\medskip
-\begin{exampleC}[]{The \macname{detokenizespacetok} macro for handling
- implicit and active-implicit spaces}
-\newcommand\detokenizespacetok[1]{\tctestifcon{\ifimplicittok}%
- {\tctestifcon{\ifactivetok}{\theactivespace}{\string#1}}{\detokenize{#1}}}
-\end{exampleC}
-\medskip
-
%%%
\resettokcycle
\Characterdirective{\addcytoks{\underdot{#1}}}
@@ -1367,6 +1853,13 @@ To add it to the \macname{cytoks} token list, make sure you use the
\endtokencyclexpress
\end{exampleA}
+\begin{minipage}[t]{\textwidth}
+\begin{exampleC}[]{The \macname{detokenizespacetok} macro for handling
+ implicit and active-implicit spaces}
+\newcommand\detokenizespacetok[1]{\tctestifcon{\ifimplicittok}%
+ {\tctestifcon{\ifactivetok}{\theactivespace}{\string#1}}{\detokenize{#1}}}
+\end{exampleC}
+
\begin{exampleA}[lefthand width=10cm]{Active Implicit spaces work{,} too}
\resettokcycle
\Characterdirective{\addcytoks{\underdot{#1}}}
@@ -1389,7 +1882,7 @@ xQx x_x\z{}x%
xQx x_x\z{}x%
\endtokencyclexpress
\end{exampleA}
-
+\end{minipage}
\endgroup
diff --git a/macros/generic/tokcycle/tokcycle.tex b/macros/generic/tokcycle/tokcycle.tex
index eeba320682..9aaec68b72 100644
--- a/macros/generic/tokcycle/tokcycle.tex
+++ b/macros/generic/tokcycle/tokcycle.tex
@@ -1,7 +1,7 @@
\def\tcname {tokcycle}
-\def\tcver {1.2}
+\def\tcver {1.3}
%
-\def\tcdate {2020/10/01}
+\def\tcdate {2021/03/10}
%
% Author : Steven B Segletes, Christian Tellechea (contributor)
% Maintainer : Steven B Segletes
@@ -22,8 +22,7 @@
\expandafter\the\expandafter\cytoks\expanded{#5}\endtokcycraw}
% ENVIRONMENT FORM
\long\def\tokencycle#1#2#3#4{\begingroup\let\endtokencycle\endtokcycraw
- \aftertokcycle{\the\cytoks\expandafter\endgroup\expandafter\tcenvscope
- \expandafter{\the\cytoks}}\tokcycraw{#1}{#2}{#3}{#4}}
+ \aftertokcycle{\the\cytoks\tcendgroup}\tokcycraw{#1}{#2}{#3}{#4}}
% XPRESS-INTERFACE MACRO FORM
\long\def\tokcyclexpress#1{\tokcycrawxpress#1\endtokcycraw}
% XPRESS-INTERFACE \expanded-ARGUMENT MACRO FORM
@@ -31,16 +30,16 @@
\expandafter\tokcycrawxpress\expanded{#1}\endtokcycraw}
% XPRESS-INTERFACE ENVIRONMENT FORM
\def\tokencyclexpress{\begingroup\let\endtokencyclexpress\endtokcycraw
- \aftertokcycle{\the\cytoks\expandafter\endgroup\expandafter\tcenvscope
- \expandafter{\the\cytoks}}\tokcycrawxpress}
+ \aftertokcycle{\the\cytoks\tcendgroup}\tokcycrawxpress}
% INITIALIZATION & INTERNAL TOOLS
+\def\tcendgroup{\expandafter\endgroup\expandafter\tcenvscope\expandafter{\the\cytoks}}
\def\tcenvscope{\cytoks}% CAN SET TO \global\cytoks TO OVERCOME SCOPE LIMITS
\edef\restorecatcode{\catcode\number`\@=\number\catcode`\@\relax}
\catcode`\@11
\newif\iftc@implicitgrp
\newif\if@argnext
\newtoks\tc@tok
-\newcount\tc@depth
+\newcount\tcdepth
\def\tc@gobble#1{}
\def\tc@deftok#1#2{\let#1= #2\empty}
\tc@deftok\tc@sptoken{ }
@@ -54,9 +53,8 @@
\long\def\tc@testxifx{\tc@earg\tctestifx}
\long\def\test@ifmacro#1{\tctestifcatnx#1\relax}
\def\tc@addtoks#1#2{\toks#1\expandafter{\the\toks#1#2}}
-\def\addtc@depth{\advance\tc@depth 1}
-\def\subtc@depth{\tc@depth=\numexpr\tc@depth-1\relax}
-\def\tc@resetifs{\activetokfalse\implicittokfalse\tc@implicitgrpfalse
+\def\add@tcdepth{\advance\tcdepth 1\relax}
+\def\sub@tcdepth{\advance\tcdepth-1\relax}\def\tc@resetifs{\activetokfalse\implicittokfalse\tc@implicitgrpfalse
\catSIXfalse\activecharfalse\activetokunexpandablefalse
\def\theactivespace{}}
\long\def\count@stringtoks#1{\tc@earg\count@toks{\string#1}}
@@ -79,18 +77,29 @@
\long\def\tokcycleenvironment#1#2#3#4#5{\expandafter\def\expandafter#1%
\expandafter{\expandafter\let\csname end\expandafter\tc@gobble
\string#1\endcsname\endtokcycraw\tokencycle{#2}{#3}{#4}{#5}}}
-\long\def\processtoks#1{\addtc@depth\@tokcycle#1\endtokcycraw }
+\long\def\xtokcycleenvironment#1#2#3#4#5#6#7{\expandafter\def\expandafter
+ #1\expandafter{\expandafter\let\csname end\expandafter\tc@gobble
+ \string#1\endcsname\endtokcycraw\begingroup
+ \long\def\tcafterenv####1{\tc@defx\tcendgroup{\tcendgroup####1}}%
+ \aftertokcycle{#7\the\cytoks\tcendgroup}#6\tokcycraw{#2}{#3}{#4}{#5}}}
+\long\def\processtoks#1{\@tokcycle#1\endtokcycraw}
\def\whennotprocessingparameter#1#2{\tctestifcon\if@argnext{\@argnextfalse\cytoks
\expandafter{\the\cytoks###1}}{\tctestifcon\ifcatSIX{\@argnexttrue}{#2}}}
+\long\def\truncategroup#1{\tctestifx{\endtokcycraw#1}{#1}{\truncategroup}}
+\long\def\truncatecycle#1{\tctestifx{\endtokcycraw#1}{\tctestifnum{\tcdepth=0}
+ {#1}{\truncatecycle}}{\tctestifx{\sub@tcdepth#1}{#1}
+ {\tctestifx{\exit@grouped#1}{#1}{}}\truncatecycle}}
+\long\def\truncategroupiftokis#1#2{\tctestifx{\tc@next#1}{\truncategroup}{#2}}
+\long\def\truncatecycleiftokis#1#2{\tctestifx{\tc@next#1}{\truncatecycle}{#2}}
% ESSENTIAL METHOD: STREAMING MACRO WITH TERMINATOR:
% \tokcycraw{<Char>}{<Group>}{<Macro>}{<Space>}<input-stream>\endtokcycraw
\long\def\tokcycraw#1#2#3#4{\def\@chrT##1{#1}\long\def\@grpT##1{#2}%
\long\def\@macT##1{#3}\def\@spcT##1{#4}\tokcycrawxpress}
% ENTRY POINT FOR XPRESS METHOD WITHOUT EXPLICIT ARGUMENTS
-\def\tokcycrawxpress{\cytoks{}\tc@depth=1\relax\@tokcycle}
+\def\tokcycrawxpress{\cytoks{}\tcdepth=0\relax\@tokcycle}
% CODE TO EXECUTE AT COMPLETION
\long\def\aftertokcycle#1{\def\@aftertokcycle{#1}}
-\def\endtokcycraw{\subtc@depth\tctestifnum{\tc@depth=0}{\@aftertokcycle}{}}
+\def\endtokcycraw{\tctestifnum{\tcdepth=0}{\@aftertokcycle}{}}
% LOOP ENTRY POINT
\def\@tokcycle{\tc@resetifs\futurelet\tc@next\detect@CANTabsorb}
\def\detect@CANTabsorb{\tctestifx{\tc@next\tc@sptoken}{\stringify\@@@@@@spcT}%
@@ -126,8 +135,8 @@
{\begingroup\catcode`#1=\active \xdef\@tmp{\scantokens{#1\noexpand}}\endgroup
\expandafter\implicitgrpfork\@tmp\@tokcycle}% ACTIVE CHAR \bgroup
}}
-\def\@@grpT#1{\tctestifcon\ifstripgrouping{\@grpT{#1}}%
- {\groupedcytoks{\@grpT{#1}}}\@tokcycle}
+\long\def\@@grpT#1{\add@tcdepth\tctestifcon{\ifstripgrouping}{%
+ \@grpT{#1}}{\groupedcytoks{\@grpT{#1}}}\sub@tcdepth\@tokcycle}
% \ COMMANDS (MACROS AND IMPLICITS)
\long\def\backslashcmds#1{%
\test@ifmacro#1{\tctestifcon\ifcatSIX{\implicittoktrue\@chrT#1}{\@macT#1}}%
@@ -146,12 +155,12 @@
\global\let\implicitsixtok\six@str\tc@tok{\implicitsixtok}}%
{\tc@tok\expandafter{\string#1}\tctestifnum{\number\catcode`#1=6}%
{}{\activetoktrue\implicittoktrue}}}
-% DIRECTIVES FOR HANDLING GROUPS RECURSIVELY; DEFINE tokcycle GROUPING CHARS
-\def\@defgroupedcytoks#1{\long\def\groupedcytoks##1{%
- \begingroup\cytoks{}##1\expandafter\endgroup\expandafter
+% DIRECTIVES FOR HANDLING GROUPED OUTPUT; DEFINE tokcycle GROUPING CHARS
+\long\def\groupedcytoks#1{\begingroup\cytoks{}#1\exit@grouped}
+\def\defineexit@grouped#1{\def\exit@grouped{\expandafter\endgroup\expandafter
\addcytoks\expandafter{\expandafter#1}}}
\def\settcGrouping#1{\def\@tmp##1{#1}\tc@defx\@@tmp{\@tmp{\the\cytoks}}%
- \tc@earg\@defgroupedcytoks{\@@tmp}}
+ \tc@earg\defineexit@grouped{\@@tmp}}
% FAUX TOKENIZATION OF COMMAND NAME (WHEN cat0 TOKEN HAS BEEN MADE cat12)
\def\csmk#1{\def\csaftermk{#1}\toks0{}\@csmkA}
\def\@csmkA{\futurelet\@tmp\@csmkB}
@@ -208,10 +217,10 @@
\endinput
EDIT HISTORY
-v1.0 2019/8/21
+v1.0 2019/08/21
- Initial release
-v1.1 2019/9/27
+v1.1 2019/09/27
- Introduced \ifactivechar, \ifactivetokunexpandable
- Tightened up consistent definition of implicit (to exclude primitives)
- Rewrote active token trapping logic, to differentiate between active
@@ -230,10 +239,47 @@ v1.12 2020/02/11
- Redefined \tc@defx and \tc@earg to omit #2 as part of definition
- Corrected \trapcatSIXb definition to account for revised \tc@earg definition.
-v1.2 2020/10/1
- -Added/fixed capability to handle active-implicit spaces. While the
- #1 passed to the \Spacedirective, in such a case, is an implicit
- space \tc@sptoken, the name of the active character from whence it
- originated in the input stream is stored as an explicit cat-12 token
- in the definition \theactivespace. The flags \implicittok and \activetok
- are both set true, and the \activechar flag is checked, as well. \ No newline at end of file
+v1.2 2020/10/01
+ - Added/fixed capability to handle active-implicit spaces. While the
+ #1 passed to the \Spacedirective, in such a case, is an implicit
+ space \tc@sptoken, the name of the active character from whence it
+ originated in the input stream is stored as an explicit cat-12 token
+ in the definition \theactivespace. The flags \implicittok and \activetok
+ are both set true, and the \activechar flag is checked, as well.
+
+v1.3 2021/03/09
+ - Introduced \xtokcycleenvironment, similar to \tokcycleenvironment, but
+ allows two additional arguments, defining the setup and trailing code
+ that will be run prior to the invocation and following conclusion of the
+ token cycle.
+ - Introduced \truncategroup, a directive to discard remaining tokens in the
+ current token-cycle group and close the group.
+ - Introduced \truncatecycle, a directive to discard remaining tokens in the
+ token-cycle input stream, but closing any open groups.
+ - Introduced \truncategroupiftokis{}{} to conditionally issue a \truncategroup
+ if the current token under consideration matches the 1st argument.
+ - Introduced \truncatecycleiftokis{}{} to conditionally issue a \truncatecycle
+ if the current token under consideration matches the 1st argument.
+ - Introduced \tcendgroup as a form of \endgroup that saves contents of
+ \cytoks upon group exit. Gives clarity to definitions of \tokencycle
+ and \tokencyclexpress environments. Available for general used.
+ - Fixed bug. Made \@@grpT \long, in the event that \par occurs inside a
+ group.
+ - Fixed bug. Added \relax to end of \add@tcdepth definition, the absence
+ of which had prevented timely update of the \tcdepth count.
+ - Documentation correction: improved explanation of implicit-cat-6 token
+ limitations. Likewise, added warning regarding active-implicit spaces.
+ - Documentation prepared with lmodern font, rather than default cm,
+ for reasons of better PDF hinting.
+ - Introduced \exit@grouped to the \groupedcytoks definition, for clarity and
+ ease of \expandafter.
+ - Reworked logic so that \tcdepth is associated with nested calls to the
+ Group directive, rather than with each invocation of \processtoks.
+ This primarily required redefinition of \@@grpT and its components.
+ - Changed name of \tc@depth to \tcdepth, as it may be a useful parameter for
+ users to check the token-cycle nesting depth. Therefore, also renamed
+ \subtc@depth to \sub@tcdepth, \addtc@depth to \add@tcdepth.
+ - Excised \sub@tcdepth from \endtokcycraw as part of new logic making
+ \tcdepth associated with the Group directive (also, outer token cycle
+ operates with depth = 0 rather than 1).
+ - Renamed \@defgroupedcytoks to \defineexit@grouped, to better match function.
diff --git a/macros/latex/contrib/easybook/doc/pages/appendix.tex b/macros/latex/contrib/easybook/doc/appendix.tex
index e05362d02d..e05362d02d 100644
--- a/macros/latex/contrib/easybook/doc/pages/appendix.tex
+++ b/macros/latex/contrib/easybook/doc/appendix.tex
diff --git a/macros/latex/contrib/easybook/doc/pages/chapter1.tex b/macros/latex/contrib/easybook/doc/chapter1.tex
index fa4dfb8869..fa4dfb8869 100644
--- a/macros/latex/contrib/easybook/doc/pages/chapter1.tex
+++ b/macros/latex/contrib/easybook/doc/chapter1.tex
diff --git a/macros/latex/contrib/easybook/doc/pages/chapter2.tex b/macros/latex/contrib/easybook/doc/chapter2.tex
index 01bfdf7dc2..4cf3e8113c 100644
--- a/macros/latex/contrib/easybook/doc/pages/chapter2.tex
+++ b/macros/latex/contrib/easybook/doc/chapter2.tex
@@ -26,9 +26,9 @@
\index{d@定理!s@Stokes formula}
Let $\Gamma$ be a piecewise smooth directed closed curve, $\Sigma$ is a piecewise smooth directed surface bounded by $\Gamma$, the side of $\Gamma$ and the positive direction of $\Sigma$ According to the right-hand rule, if the function $P(x,y,z)$, $Q(x,y,z)$, $R(x,y,z)$ has a first-order continuous deviation on the curve $\Sigma$ Derivative, then
\begin{multline}
- \iint_\Sigma\left(\frac{\partial R}{\partial y} - \frac{\partial Q}{\partial z}\right)\mathrm{d}y\mathrm{d}z + \left(\frac{\partial P}{\partial z} - \frac{\partial R}{\partial x}\right)\mathrm{d}z\mathrm{d}x + \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right)\mathrm{d}x\mathrm{d}y
+ \iint_\Sigma\left(\frac{\partial R}{\partial y} - \frac{\partial Q}{\partial z}\right)\mathrm{d}y\mathrm{d}z + \left(\frac{\partial P}{\partial z} - \frac{\partial R}{\partial x}\right)\mathrm{d}z\mathrm{d}x
\\
- = \oint_\Gamma P\mathrm{d}x + Q\mathrm{d}y + R\mathrm{d}z
+ + \left(\frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}\right)\mathrm{d}x\mathrm{d}y = \oint_\Gamma P\mathrm{d}x + Q\mathrm{d}y + R\mathrm{d}z
\end{multline}
The Stokes formula is an extension of the basic calculus formula in the case of surface integration. It is also an extension of the Green formula. This formula gives the second type of surface integral on the surface block and the second type of curve on the boundary curve Link between points.
\end{definition}
diff --git a/macros/latex/contrib/easybook/doc/pages/chapter3.tex b/macros/latex/contrib/easybook/doc/chapter3.tex
index 3d0a88bb1f..3d0a88bb1f 100644
--- a/macros/latex/contrib/easybook/doc/pages/chapter3.tex
+++ b/macros/latex/contrib/easybook/doc/chapter3.tex
diff --git a/macros/latex/contrib/easybook/doc/easybook-demo.pdf b/macros/latex/contrib/easybook/doc/easybook-demo.pdf
index ae62d0c279..22cc5d8266 100644
--- a/macros/latex/contrib/easybook/doc/easybook-demo.pdf
+++ b/macros/latex/contrib/easybook/doc/easybook-demo.pdf
Binary files differ
diff --git a/macros/latex/contrib/easybook/doc/easybook-demo.tex b/macros/latex/contrib/easybook/doc/easybook-demo.tex
index e33a779991..697baf76b9 100644
--- a/macros/latex/contrib/easybook/doc/easybook-demo.tex
+++ b/macros/latex/contrib/easybook/doc/easybook-demo.tex
@@ -98,7 +98,7 @@
\github~\url{https://github.com/texl3/easybook} \\
\edge~\url{https://latexstudio.net}
}
-\date{2021/03/09\hskip\ccwd\relax v1.23l}
+\date{2021/03/10\hskip\ccwd\relax v1.23m}
\frontmatter[roman]
\maketitle
@@ -106,10 +106,10 @@
\mainmatter*
\part{使用示例}
-\include{pages/chapter1}
-\include{pages/chapter2}
-\include{pages/chapter3}
-\include{pages/appendix}
+\include{chapter1}
+\include{chapter2}
+\include{chapter3}
+\include{appendix}
\backmatter
\printbibliography
diff --git a/macros/latex/contrib/easybook/doc/easybook.pdf b/macros/latex/contrib/easybook/doc/easybook.pdf
index ca56aed0fa..9809242c07 100644
--- a/macros/latex/contrib/easybook/doc/easybook.pdf
+++ b/macros/latex/contrib/easybook/doc/easybook.pdf
Binary files differ
diff --git a/macros/latex/contrib/easybook/doc/easybook.tex b/macros/latex/contrib/easybook/doc/easybook.tex
index 0ed2640a8e..2db86a5b56 100644
--- a/macros/latex/contrib/easybook/doc/easybook.tex
+++ b/macros/latex/contrib/easybook/doc/easybook.tex
@@ -3,7 +3,7 @@
\title{\sffamily easybook书籍文档类}
\author{瞿毅}
-\date{2021/03/09\hskip\ccwd\relax v1.23l\thanks{\url{https://gitee.com/texl3/easybook}}}
+\date{2021/03/10\hskip\ccwd\relax v1.23m\thanks{\url{https://gitee.com/texl3/easybook}}}
\begin{document}
\maketitle
@@ -98,7 +98,7 @@
\tn{frontmatter}\oarg{编号格式|(Roman)}
\tn{printindex}\oarg{索引名}
\end{syntax}
-\changes{v1.23l}{2021/02/20}{重新定义文档结构划分命令。}
+\changes{v1.23m}{2021/02/20}{重新定义文档结构划分命令。}
\tn{frontmatter} 为前言区命令,章标题不编号,页码可设置为例如 \opt{roman}、\opt{Alph} 等格式,带有星号的命令 \tn{frontmatter*} 不使用 \tn{cleardoublepage}。\tn{mainmatter} 为主文区命令,章标题正常编号且页码为从1开始计数的阿拉伯数字,\tn{mainmatter*} 命令不使用 \tn{cleardoublepage}。\tn{backmatter} 为后记区命令,页码格式与编号保持不变,章标题不编号。\tn{listoffigures} 命令输出图片目录,\tn{listoftables} 命令输出表格目录,\tn{listoflistings} 命令输出代码目录。
\end{function}
@@ -132,8 +132,8 @@
uppercase = <(true)|false>
\end{syntax}
\changes{v1.10}{2021/01/08}{更改颜色实现方式与选项名。}
-\changes{v1.23l}{2021/02/02}{noto风格的数学字体独立出来,可自定义设置。}
-\changes{v1.23l}{2021/02/09}{增加控制页面横线粗细的选项。}
+\changes{v1.23m}{2021/02/02}{noto风格的数学字体独立出来,可自定义设置。}
+\changes{v1.23m}{2021/02/09}{增加控制页面横线粗细的选项。}
\opt{style} 选项控制文章的风格。
\end{function}
@@ -190,7 +190,7 @@
footnote = <(1)>
\end{syntax}
\changes{v1.21}{2021/01/12}{增加脚注线间的距离选项。}
-\changes{v1.23l}{2021/02/09}{取消使用 \pkg{zhlineskip} 宏包设置数学间距。}
+\changes{v1.23m}{2021/02/09}{取消使用 \pkg{zhlineskip} 宏包设置数学间距。}
行距因子用于设置各种行距倍数,只能是浮点数,不能带有长度单位。\tn{ctexset} 原有的行距选项\opt{linespread}失效。各行距既可在导言区全局设置也可正文中设置对后面生效,行距的意义为
\end{function}
@@ -212,7 +212,7 @@
marginpart = <\tn{rmfamily}\tn{footnotesize}>
\end{syntax}
\changes{v1.10}{2021/01/08}{加入自定义非正文字体选项。}
-\changes{v1.23l}{2021/02/08}{修复使用 \tn{zihao} 命令设置字体失效的问题。}
+\changes{v1.23m}{2021/02/08}{修复使用 \tn{zihao} 命令设置字体失效的问题。}
\end{function}
\begin{optdesc}
@@ -229,18 +229,18 @@
backend = <(bibtex)|biblatex>
bib-style = <(numerical)|authoryear|其它格式>
cite-style = <标注风格>
- bibfile = <ref/refs.bib>
+ bibfile = <refs.bib>
\tn{printbibliography}\oarg{选项列表}
\end{syntax}
\changes{v1.21}{2021/01/11}{增加 \opt{bibset} 选项,可以使用 \hologo{BibTeX} 或 \hologo{biber} 编译参考文献。}
-\changes{v1.23l}{2021/02/23}{使用 \opt{bibset} 选项时可设置标注风格。}
+\changes{v1.23m}{2021/02/23}{使用 \opt{bibset} 选项时可设置标注风格。}
\end{function}
\begin{optdesc}
\item[backend] 参考文献处理后端,默认用传统的 \hologo{BibTeX} 处理参考文献。
\item[bib-style] 参考文献格式为中国的参考文献推荐标准GB/T 7714-2015,有顺序编码制和著者-出版年制两种风格,理工科类一般使用顺序编码制,文科类一般使用著者-出版年制。若使用其它格式,使用 \hologo{BibTeX} 处理时需确保正确的 \opt{bst} 文件,使用 \hologo{biber} 处理可使用 \pkg{biblatex} 宏包支持的参考文献风格名称。
\item[cite-style] 标注参考文献的风格,\opt{backend = bibtex} 选项下可使用 \opt{super}(数字上标标注,默认)或 \opt{numbers}(数字标注)等 \pkg{natbib} 宏包带有的标注风格,\opt{backend = biblatex} 选项下可使用 \pkg{biblatex} 宏包支持的标注风格名称。
- \item[bibfile] 参考文献的数据文件,使用 \hologo{biber} 处理时要带有 \opt{bib} 后缀,默认为一个在 \opt{ref} 文件夹中以 \opt{refs.bib} 命名的文件。
+ \item[bibfile] 参考文献的数据文件,使用 \hologo{biber} 处理时要带有 \opt{bib} 后缀,默认为一个以 \opt{refs.bib} 命名的文件。
\item[\tn{printbibliography}] 两种方式\textbf{均使用}此命令打印参考文献,其中可选项仅在 \hologo{biber} 处理时有效。
\end{optdesc}
@@ -317,7 +317,7 @@
\end{syntax}
\changes{v1.21}{2021/01/11}{修复单面文档时页眉横线消失的问题。}
\changes{v1.21}{2021/01/13}{增加配置页眉页脚的选项。}
-\changes{v1.23l}{2021/03/08}{优化页眉页脚设置,增加 \opt{chap-mark} 和 \opt{sec-mark} 选项。}
+\changes{v1.23m}{2021/03/08}{优化页眉页脚设置,增加 \opt{chap-mark} 和 \opt{sec-mark} 选项。}
\opt{hdrset} 设置的命令由 \pkg{fancyhdr} 宏包提供支持,命令 \tn{easyhead} 和 \tn{easyfoot} 的含义与 \tn{fancyhead} 和 \tn{fancyfoot} 相同,它们用于 \opt{head-foot} 选项中,设置的是一个名为 \opt{fancy} 的页面风格。\pkg{fancyhdr} 将页眉页脚分成了左中右和奇数页(odd)、偶数页(even)共12个部分,可选参数中E、O代表偶数、奇数,L、C、R代表左、中、右部分。单面打印时,含有偶数的选项无效。
\begin{ctexexam}
\ctexset
@@ -438,7 +438,7 @@
\tn{item} <习题内容>
\tn{end}\marg{exercise}
\end{syntax}
-\changes{v1.23l}{2021/02/08}{增加准确的习题盒子标题目录锚点。}
+\changes{v1.23m}{2021/02/08}{增加准确的习题盒子标题目录锚点。}
习题环境 \opt{exercise} 的标题紧接上一节编号并加入目录与页眉,当使用星号环境时不进行编号。三个可选参数中颜色为自定义或 \pkg{xcolor} 包含的颜色名称,正文编号格式与小节 \ref{sort list} 排序列表相同,标题名默认为摘要,参数只能\textbf{从右往左}省略。
\begin{ctexexam}
\begin{exercise}[LightYellow][1.][习题]
diff --git a/macros/latex/contrib/easybook/doc/ref/refs.bib b/macros/latex/contrib/easybook/doc/refs.bib
index 01b14bd82c..01b14bd82c 100644
--- a/macros/latex/contrib/easybook/doc/ref/refs.bib
+++ b/macros/latex/contrib/easybook/doc/refs.bib
diff --git a/macros/latex/contrib/easybook/easybook.cls b/macros/latex/contrib/easybook/easybook.cls
index a502518987..055b403aed 100644
--- a/macros/latex/contrib/easybook/easybook.cls
+++ b/macros/latex/contrib/easybook/easybook.cls
@@ -9,7 +9,7 @@
%% https://creativecommons.org/licenses/by/4.0/legalcode
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{l3keys2e}
-\ProvidesExplClass{easybook}{2021/03/09}{1.23l}{}
+\ProvidesExplClass{easybook}{2021/03/10}{1.23m}{}
\cs_generate_variant:Nn \keys_define:nn {nx}
\cs_generate_variant:Nn \int_to_arabic:n {v}
@@ -425,25 +425,25 @@
part/rule .tl_set:N = \l__toc_part_rule_tl,
part/rule .initial:n = \tocrule{}[\bfseries],
- chapter/format .tl_set:N = \l__toc_chap_format_tl,
+ chapter/format .tl_set:N = \l__toc_chapter_format_tl,
chapter/format .initial:n = \addvspace{1pc}\sffamily\large,
- chapter/indent .tl_set:N = \l__toc_chap_indent_tl,
+ chapter/indent .tl_set:N = \l__toc_chapter_indent_tl,
chapter/indent .initial:n = 0\ccwd,
- chapter/rule .tl_set:N = \l__toc_chap_rule_tl,
+ chapter/rule .tl_set:N = \l__toc_chapter_rule_tl,
chapter/rule .initial:n = \tocrule{$\cdot$}[\bfseries],
- section/format .tl_set:N = \l__toc_sec_format_tl,
+ section/format .tl_set:N = \l__toc_section_format_tl,
section/format .initial:n = \addvspace{0.35pc},
- section/indent .tl_set:N = \l__toc_sec_indent_tl,
+ section/indent .tl_set:N = \l__toc_section_indent_tl,
section/indent .initial:n = 1.5\ccwd,
- section/rule .tl_set:N = \l__toc_sec_rule_tl,
+ section/rule .tl_set:N = \l__toc_section_rule_tl,
section/rule .initial:n = \tocrule{$\cdot$},
- subsection/format .tl_set:N = \l__toc_subsec_format_tl,
+ subsection/format .tl_set:N = \l__toc_subsection_format_tl,
subsection/format .initial:n = \addvspace{0.35pc},
- subsection/indent .tl_set:N = \l__toc_subsec_indent_tl,
+ subsection/indent .tl_set:N = \l__toc_subsection_indent_tl,
subsection/indent .initial:n = 3.8\ccwd,
- subsection/rule .tl_set:N = \l__toc_subsec_rule_tl,
+ subsection/rule .tl_set:N = \l__toc_subsection_rule_tl,
subsection/rule .initial:n = \tocrule{$\cdot$},
lists/format .tl_set:N = \l__toc_lists_format_tl,
@@ -466,35 +466,24 @@
\normalsize\normalfont
\titlerule*[#1]{\scalebox{#2}{#3}}#4\contentspage
}
-\titlecontents{part}
- [\l__toc_part_indent_tl]
- {\l__toc_part_format_tl}{}{}
- {\l__toc_part_rule_tl}
-\titlecontents{chapter}
- [\l__toc_chap_indent_tl]
- {\l__toc_chap_format_tl}{}{}
- {\l__toc_chap_rule_tl}
-\titlecontents{section}
- [\l__toc_sec_indent_tl]
- {\l__toc_sec_format_tl}{}{}
- {\l__toc_sec_rule_tl}
-\titlecontents{subsection}
- [\l__toc_subsec_indent_tl]
- {\l__toc_subsec_format_tl}{}{}
- {\l__toc_subsec_rule_tl}
-\titlecontents{figure}
- [\l__toc_lists_indent_tl]
- {\l__toc_lists_format_tl}{}{}
- {\l__toc_lists_rule_tl}
-\titlecontents{table}
- [\l__toc_lists_indent_tl]
- {\l__toc_lists_format_tl}{}{}
- {\l__toc_lists_rule_tl}
+\cs_new_protected:Npn \__titlecontents_set:nn #1#2
+ {
+ \titlecontents{#1}
+ [\use:c {l__toc_#2_indent_tl}]
+ {\use:c {l__toc_#2_format_tl}}{}{}
+ {\use:c {l__toc_#2_rule_tl}}
+ }
\contentsuse{lstlisting}{lol}
-\titlecontents{lstlisting}
- [\l__toc_lists_indent_tl]
- {\l__toc_lists_format_tl}{}{}
- {\l__toc_lists_rule_tl}
+\clist_map_inline:nn
+ {
+ {part}{part},
+ {chapter}{chapter},
+ {section}{section},
+ {subsection}{subsection},
+ {figure}{lists},
+ {table}{lists},
+ {lstlisting}{lists}
+ }{\__titlecontents_set:nn #1}
\ctex_patch_cmd:Nnn \caption@@@addcontentsline
{\addcontentsline{#1}{#2}{\protect\numberline{#3}{#4}}}
{\addcontentsline{#1}{#2}{#3\hspace{\ccwd}#4}}
@@ -763,7 +752,7 @@
\skip_set:Nn \plitemsep{.75ex plus .1ex}
\skip_set:Nn \plparsep{0ex}
-\cs_new_protected:Npn \__thmname_set:n #1#2
+\cs_new_protected:Npn \__thmname_set:nn #1#2
{\tl_const:cn {c__name_#1_tl}{#2}}
\bool_if:NTF \l__lang_chinese_bool
{
@@ -777,7 +766,7 @@
{example}{例},
{remark}{注},
{exercise}{练习}
- }{\__thmname_set:n #1}
+ }{\__thmname_set:nn #1}
}{
\clist_map_inline:nn
{
@@ -789,7 +778,7 @@
{example}{Example},
{remark}{Remark},
{exercise}{Exercise}
- }{\__thmname_set:n #1}
+ }{\__thmname_set:nn #1}
}
\bool_new:N \l__thmbox_bool
@@ -1070,7 +1059,7 @@
cite-style .code:n =
{\tl_set:Nn \l__bib_citestyle_tl{#1}},
bibfile .tl_set:N = \l__bib_file_tl,
- bibfile .initial:n = ref/refs.bib
+ bibfile .initial:n = refs.bib
}
\cs_new_protected:Npn \__bibtex_set:
@@ -1274,7 +1263,7 @@
{skyblue, 0000ff,004986,eb6877},
{crimson, dc143c,00c1c9,afcd20}
}
- \__linkcolor_set:n,
+ \__linkcolor_set:n
linkcolor .default:n = fresh,
linkcolor .initial:n = fresh,
@@ -1295,7 +1284,7 @@
{energy, f39800,00a0e9,893895},
{cyberpunk, 601986,eb6877,a4005b}
}
- \__themecolor_set:n,
+ \__themecolor_set:n
color .initial:n = none
}
diff --git a/macros/latex/contrib/mindflow/README.md b/macros/latex/contrib/mindflow/README.md
new file mode 100644
index 0000000000..1a62ed0956
--- /dev/null
+++ b/macros/latex/contrib/mindflow/README.md
@@ -0,0 +1,15 @@
+# The mindflow package
+
+This package provides an environment that is separated from the main text and
+has its own line numbers, for writing ideas or annotations.
+
+# License
+
+This file may be distributed and/or modified under the conditions of the LaTeX
+Project Public License, either version 1.3 of this license or (at your option)
+any later version. The latest version of this license is in:
+
+ http://www.latex-project.org/lppl.txt
+
+and version 1.3 or later is part of all distributions of LaTeX version
+2005/12/01 or later.
diff --git a/macros/latex/contrib/mindflow/mindflow.dtx b/macros/latex/contrib/mindflow/mindflow.dtx
new file mode 100644
index 0000000000..6f193ab5df
--- /dev/null
+++ b/macros/latex/contrib/mindflow/mindflow.dtx
@@ -0,0 +1,206 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2021 by Jinwen XU
+% -------------------------------
+%
+% This file may be distributed and/or modified under the conditions of the LaTeX
+% Project Public License, either version 1.3 of this license or (at your option)
+% any later version. The latest version of this license is in:
+%
+% http://www.latex-project.org/lppl.txt
+%
+% and version 1.3 or later is part of all distributions of LaTeX version
+% 2005/12/01 or later.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{mindflow.dtx}
+%</driver>
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{mindflow}
+%<*package>
+ [2021/03/09 Mindflow environment]
+%</package>
+%
+%<*driver>
+\documentclass{article}
+\usepackage{doc}
+\usepackage[a4paper,margin=1.8in]{geometry}
+\usepackage{titling}
+\setlength{\droptitle}{-.5in}
+\usepackage[linenumber,rightmarker]{mindflow}
+\usepackage{enumitem}
+\setlist{noitemsep}
+\usepackage{newpxtext}
+\usepackage{parskip}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{mindflow.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \GetFileInfo{mindflow.dtx}
+%
+%
+% \title{The {\normalfont\textsf{mindflow}} package}
+% \author{\scshape Jinwen Xu}
+% \date{\filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% The \textsf{mindflow} package provides you a way to write your ideas,
+% annotations or writing plans. For example (with option
+% \verb|linenumber| and \verb|rightmarker|):
+% \begin{mindflow}
+% What to write next:
+% \begin{itemize}
+% \item usage;
+% \item some internal macros;
+% \item the complete code.
+% \end{itemize}
+% \end{mindflow}
+%
+% \section{Usage}
+%
+% Simply load the package with \verb|\usepackage{mindflow}|. By default
+% it has no line numbers or markers. You can use the following options:
+%
+% \begin{tabular}{ll}
+% \verb|linenumber| & Enable line numbers\\
+% \verb|leftmarker| & Enable left marker, by default it is a ``\verb|*|''\\
+% \verb|rightmarker| & Enable right marker, by default it is a ``\verb|*|''\\
+% \verb|off| & Hide all the \verb|mindflow| environments
+% \end{tabular}
+%
+% \DescribeEnv{mindflow}
+% Then you can use the mindflow environment as
+% \begin{verbatim}
+% \begin{mindflow}
+% ...
+% \end{mindflow}
+% \end{verbatim}
+%
+% \section{Some technical details}
+%
+% \DescribeMacro{\mindflowFont}
+% \DescribeMacro{\mindflowNumFont}
+% The font for texts and line numbers within the \verb|mindflow|
+% environments can be specified by redefining \verb|\mindflowFont| and
+% \verb|\mindflowNumFont|. By default they are defined as:
+% \begin{verbatim}
+% \newcommand{\mindflowFont}{\normalfont\footnotesize}
+% \newcommand{\mindflowNumFont}{\normalfont\scriptsize\ttfamily}
+% \end{verbatim}
+% \DescribeMacro{\mindflowLeft}
+% \DescribeMacro{\mindflowRight}
+% The left and right marker can be changed by redefining
+% \verb|\mindflowLeft| and \verb|\mindflowRight|. Both have the default
+% value as ``\verb|*|''.
+%
+% And finally, the color of \verb|mindflow| environments is called
+% \verb|mindflow|. By default, it is the current text color with opacity
+% 30\%.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+% Below is the complete source code of this package.
+%
+% \begin{macrocode}
+\RequirePackage{kvoptions}
+\SetupKeyvalOptions{%
+ family = @mindflow,
+ prefix = @mindflow@
+}
+\DeclareBoolOption[false]{off} % Turn off mindflow
+\DeclareBoolOption[false]{leftmarker} % Left marker
+\DeclareBoolOption[false]{rightmarker} % Right marker
+\DeclareBoolOption[false]{linenumber} % Line numbers
+
+\ProcessKeyvalOptions*\relax
+
+%%================================
+%% Initialization
+%%================================
+\newcommand{\mindflowFont}{\normalfont\footnotesize}
+\newcommand{\mindflowNumFont}{\normalfont\scriptsize\ttfamily}
+
+\RequirePackage{lineno}
+\RequirePackage{xcolor}
+
+\colorlet{mfSavedColor}{.}
+\colorlet{mindflow}{mfSavedColor!30}
+
+\newcommand{\mindflowLeft}{%
+ \if@mindflow@leftmarker%
+ {*}%
+ \fi%
+}
+\newcommand{\mindflowRight}{%
+ \if@mindflow@rightmarker%
+ {*}%
+ \fi%
+}
+
+%%================================
+%% The mindflow environment
+%%================================
+\newif\ifLNturnsON
+
+\newcommand*{\mfSepLine}{%
+ \parskip=0pt
+ \LNturnsONfalse%
+ \ifLineNumbers\LNturnsONtrue\fi\nolinenumbers%
+ \par\noindent\nopagebreak%
+ \makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}%
+ \nopagebreak\par%
+ \ifLNturnsON\linenumbers\fi%
+}
+
+\newcounter{recordLN}
+\newcounter{mfLN}
+\setcounter{mfLN}{1}
+
+\if@mindflow@off
+ \RequirePackage{verbatim}
+ \let\mindflow=\comment
+ \let\endmindflow=\endcomment
+\else
+ \newenvironment{mindflow}
+ {%
+ \setcounter{recordLN}{\value{linenumber}}
+ \setcounter{linenumber}{\value{mfLN}}
+ \LNturnsONfalse%
+ \ifLineNumbers\LNturnsONtrue\fi\nolinenumbers%
+ \mindflowFont\color{mindflow}%
+ \mfSepLine%
+ \linenumbers%
+ \renewcommand\makeLineNumber{%
+ \hss\color{mindflow!25}%
+ \if@mindflow@linenumber%
+ \mindflowNumFont\LineNumber~%
+ \fi%
+ \mindflowLeft\hspace{1em}\rlap{\hskip\textwidth\hspace{1em}\mindflowRight}%
+ }%
+ }
+ {%
+ \par%
+ \vspace{-.5\baselineskip}\mfSepLine%
+ \ifLNturnsON\linenumbers\fi%
+ \setcounter{mfLN}{\value{linenumber}}
+ \setcounter{linenumber}{\value{recordLN}}
+ }
+\fi
+% \end{macrocode}
+%
+% \Finale
+\endinput
diff --git a/macros/latex/contrib/mindflow/mindflow.ins b/macros/latex/contrib/mindflow/mindflow.ins
new file mode 100644
index 0000000000..fdc7beb6d7
--- /dev/null
+++ b/macros/latex/contrib/mindflow/mindflow.ins
@@ -0,0 +1,54 @@
+%%
+%% Copyright (C) 2021 by Jinwen XU
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of LaTeX version
+%% 2005/12/01 or later.
+%%
+
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+
+\usedir{tex/latex/mindflow}
+
+\preamble
+
+Copyright (C) 2021 by Jinwen XU
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.3 of this license
+or (at your option) any later version. The latest version of this
+license is in:
+
+ http://www.latex-project.org/lppl.txt
+
+and version 1.3 or later is part of all distributions of LaTeX version
+2005/12/01 or later.
+
+\endpreamble
+
+\generate{\file{mindflow.sty}{\from{mindflow.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* mindflow.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file mindflow.dtx *}
+\Msg{* through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/mindflow/mindflow.pdf b/macros/latex/contrib/mindflow/mindflow.pdf
new file mode 100644
index 0000000000..4489a85570
--- /dev/null
+++ b/macros/latex/contrib/mindflow/mindflow.pdf
Binary files differ
diff --git a/macros/latex/contrib/newverbs/README b/macros/latex/contrib/newverbs/README
index 09968f8584..8d6c410c79 100644
--- a/macros/latex/contrib/newverbs/README
+++ b/macros/latex/contrib/newverbs/README
@@ -1,6 +1,6 @@
The 'newverbs' LaTeX package
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Copyright (c) 2010-2020 by Martin Scharrer <martin@scharrer-online.de>
+Copyright (c) 2010-2021 by Martin Scharrer <martin@scharrer-online.de>
Code repository: https://sourceforge.net/projects/newfloat/
This package allows the definition of \verb variants which add TeX code before
diff --git a/macros/latex/contrib/newverbs/newverbs.dtx b/macros/latex/contrib/newverbs/newverbs.dtx
index efc74a3981..8c22b0229d 100644
--- a/macros/latex/contrib/newverbs/newverbs.dtx
+++ b/macros/latex/contrib/newverbs/newverbs.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%<=*COPYRIGHT>
-%% Copyright (C) 2012-2020 by Martin Scharrer <martin@scharrer-online.de>
+%% Copyright (C) 2012-2021 by Martin Scharrer <martin@scharrer-online.de>
%% --------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -23,10 +23,10 @@
%<*driver>
\ProvidesFile{newverbs.dtx}[%
%<=*DATE>
- 2010/09/02
+ 2021/01/06
%<=/DATE>
%<=*VERSION>
- v1.5
+ v1.6
%<=/VERSION>
newverbs DTX file]
\documentclass{ydoc}
@@ -70,6 +70,7 @@
% \changes{v1.3}{2011/07/24}{Added macros to collect verbatim arguments.}
% \changes{v1.4}{2019/09/09}{Added several suggested changes.}
% \changes{v1.5}{2020/09/02}{Added support for mathmode.}
+% \changes{v1.6}{2021/01/06}{Changed \cs{Verbdef} to define robust commands.}
%
% \DoNotIndex{\newcommand,\newenvironment,\providecommand}
%
@@ -88,13 +89,15 @@
%
% \subsection{Defining new variants of \cs{verb}}
%
-% \DescribeMacro\newverbcommand {<\textbackslash macro>}{<code before>}{<code after>}
-% \DescribeMacro\renewverbcommand {<\textbackslash macro>}{<code before>}{<code after>}
-% \DescribeMacro\provideverbcommand {<\textbackslash macro>}{<code before>}{<code after>}
-% This macros allow the definition of \cs{verb} variants. The verbatim content is processed using \cs{verb}, but the
-% variants can add \TeX\ code before and after it.
-% The three definition macros use |\newcommand*|, |\renewcommand*| and |\providecommand*| internally to define \meta{macro}, respectively.
-% Afterwards \meta{macro} can be used like \cs{verb}. The star version of \meta{macro} will use \cs{verb}|*|.
+% \DescribeMacro\newverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
+% \DescribeMacro\renewverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
+% \DescribeMacro\provideverbcommand {<\textbackslash macro>}[<\textbackslash verbmacro>]{<code before>}{<code after>}
+% This macros allow the definition of \cs{verb} variants.
+% The verbatim content is first processed using \meta{\textbackslash verbmacro} which defaults to \cs{verb}, then the
+% given \TeX\ code is added before and afterwards.
+% The three definition macros use |\newcommand*|, |\renewcommand*| and |\providecommand*| internally to define \meta{\textbackslash macro}, respectively.
+% Afterwards \meta{\textbackslash macro} can be used like \cs{verb}.
+% The star version of \meta{\textbackslash macro} will use \meta{\textbackslash verbmacro}|*| (default: \cs{verb}|*|).
%
% See the implementation of \cs{qverb} in section~\ref{sec:impl} for an example.
%
@@ -288,7 +291,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\new@verbcommand}[5]{underlying definition macro}{verb macro to be used}{macro to define}{code before}{code after}
+% \begin{macro}{\new@verbcommand}[5]{underlying definition macro}{macro to define}{verb macro to be used}{code before}{code after}
% The trailing code is inserted by patching \cs{verb@egroup} which is called by \cs{verb}
% after the verbatim content.
% \begin{macrocode}
@@ -760,7 +763,7 @@
% \begin{macro}{\@Verbdef}[2]{<star or empty>}{<macro to be defined>}
% \begin{macrocode}
\def\@Verbdef#1#2{%
- \Collectverb#1{\def#2}%
+ \Collectverb#1{\DeclareRobustCommand#2}%
}
% \end{macrocode}
% \end{macro}
diff --git a/macros/latex/contrib/newverbs/newverbs.pdf b/macros/latex/contrib/newverbs/newverbs.pdf
index 6d914fab80..2e8c79c684 100644
--- a/macros/latex/contrib/newverbs/newverbs.pdf
+++ b/macros/latex/contrib/newverbs/newverbs.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
index 7c58a0449c..21154fbe67 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex
index 75a1954df9..9ae1a3a8ab 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.tex
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex
@@ -232,8 +232,8 @@ l'extension \pkg{nicematrix} propose deux clés |cell-space-top-limit| et
|cell-space-bottom-limit| qui sont similaires aux deux paramètres
|\cellspacetoplimit| et |\cellspacebottomlimit| proposés par \pkg{cellspace}.
-\colorbox{yellow!30}{Nouveau 5.9}\enskip Il existe aussi une clé
-|cell-space-limits| pour régler simultanément les deux paramètres.
+Il existe aussi une clé |cell-space-limits| pour régler simultanément les deux
+paramètres.
La valeur initiale de ces paramètres est $0$~pt pour que les environnements de
\pkg{nicematrix} aient par défaut le même comportement que ceux de \pkg{array}
@@ -409,7 +409,7 @@ Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande
|\Block| pour placer un élément au centre d'un rectangle de cases fusionnées.
La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc
-avec deux arguments.
+avec deux arguments obligatoires.
\begin{itemize}
\item Le premier argument est la taille de ce bloc avec la syntaxe $i$-$j$ où
@@ -500,10 +500,34 @@ $\begin{bNiceArray}{ccc|c}[margin]
\end{bNiceArray}$
+
+\interitem
+La commande |\Block| accepte en fait en premier argument optionnel (entre
+crochets) une liste de couples clé-valeur. Les clés sont les suivantes :
+\begin{itemize}
+\item les clés |l|, |c| et |r| réglent le positionnement horizontal comme dit
+précédemment ;
+\item la clé |fill| prend en argument une couleur et remplit le bloc avec cette
+couleur ;
+\item la clé |draw| prend en argument une couleur et trace le cadre avec cette
+couleur (la valeur par défaut de cette clé est la couleur courante des filets du
+tableau) ;
+\item la clé |color| prend en argument une couleur et l'applique au contenu et
+trace également le cadre avec cette couleur.
+\item la clé |line-width| fixe la largeur des filets servant pour le cadre (n'a
+d'intérêt que si |draw| est utilisée) ;
+\item \colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip la clé
+|rounded-corners| impose des coins arrondis (pour le cadre dessiné par |draw| et
+le fond dessiné par |fill|) avec un rayon égal à la valeur de cette clé (la
+valeur par défaut est 4~pt\footnote{Cette valeur par défaut est la valeur
+ initiale des \emph{rounded corners} de Tikz.}).
+\end{itemize}
+
+
\interitem
\textbf{On doit remarquer que, par défaut, les blocs ne créent pas d'espace}. Il
n'y a exception que pour les blocs mono-rangée et les blocs mono-colonne comme
-expliqué juste après.
+expliqué plus loin.
\medskip
@@ -512,10 +536,11 @@ construction |wc{...}| de \pkg{array}).
\medskip
\begin{BVerbatim}
-\begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@
+\begin{NiceTabular}{cwc{2cm}wc{3cm}c}
rose & tulipe & marguerite & dahlia \\
violette
-& \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
+& ~emphase#\Block[draw=red,fill=red!15,rounded-corners]{2-2}{\LARGE De très jolies fleurs}@
+ & & souci \\
pervenche & & & lys \\
arum & iris & jacinthe & muguet
\end{NiceTabular}
@@ -526,20 +551,13 @@ arum & iris & jacinthe & muguet
\begin{center}
\begin{NiceTabular}{cwc{2cm}wc{3cm}c}
rose & tulipe & marguerite & dahlia \\
-violette & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
+violette & \Block[draw=red,fill=red!15,rounded-corners]{2-2}
+ {\LARGE De très jolies fleurs} & & souci \\
pervenche & & & lys \\
arum & iris & jacinthe & muguet
\end{NiceTabular}
\end{center}
-\medskip
-Comme on le voit sur cet exemple, on peut fixer la couleur de fond avec la clé
-|fill| et la couleur du cadre avec la clé |draw|\footnote{Si la clé |draw| est
- utilisée sans valeur, c'est la couleur par défaut des filets de tableaux qui
- est utilisée.}. On peut aussi fixer l'épaisseur du trait avec la clé
-|line-width|.
-
-
\subsection{Les blocs mono-colonne}
@@ -616,7 +634,8 @@ bloc sur plusieurs lignes.
la consigne générale donnée dans le préambule pour cette colonne.
\item On peut tracer un cadre autour du bloc avec la clé |draw| de la commande
-|\Block|.\footnote{Pour colorier le fond d'une case, il n'y a pas besoin
+|\Block| ou colorier le fond avec des bords arrondis avec les clés |fill| et
+|rounded-corners|.\footnote{Pour colorier simplement le fond d'une case, il n'y a pas besoin
d'utiliser un bloc mono-case : on peut utiliser la commande |\cellcolor| si la
clé |colortbl-like| est utilisée : voir p.~\pageref{colortbl-like}.}
\end{itemize}
@@ -885,11 +904,11 @@ p.~\pageref{OnlyMainNiceMatrix}.
\subsection{Les clés hlines et vlines}
La clé |hlines| demande un tracé de tous les filets horizontaux et la clé
-|vlines| demande un tracé de tous les filets verticaux (sauf dans les blocs et
-dans les blocs virtuels déterminés par des lignes en pointillés). En fait, dans les
-environnements avec délimiteurs (comme |{pNiceMatrix}| ou |{bNiceArray}|), les
-filets extérieurs ne sont pas tracés (ce qui est le comportement certainement
-attendu).
+|vlines| demande un tracé de tous les filets verticaux (sauf dans les blocs,
+créés par |\Block| et dans les blocs virtuels déterminés par des lignes en
+pointillés : |\Cdots|, |\Vdots|, etc.). En fait, dans les environnements avec
+délimiteurs (comme |{pNiceMatrix}| ou |{bNiceArray}|), les filets extérieurs ne
+sont pas tracés (ce qui est le comportement certainement attendu).
\medskip
@@ -1143,16 +1162,33 @@ inconvénients.
\subsection{Les outils de nicematrix dans le code-before}
-L'extension \pkg{nicematrix} proposent des outils (indépendants de
-\pkg{colortbl}) pour tracer d'abord les rectangles colorés, puis le contenu des
-cases et les filets. Cette manière de faire est plus dans l'esprit du «modèle du
-peintre» des formats PostScript et \textsc{pdf} et convient donc mieux aux
-lecteurs de \textsc{pdf}. L'inconvénient est qu'elle nécessite plusieurs
-compilations successives.
+L'extension \pkg{nicematrix} propose des outils (indépendants de \pkg{colortbl})
+pour tracer d'abord les rectangles colorés, puis le contenu des cases et les
+filets. Cette manière de faire est plus dans l'esprit du «modèle du peintre» des
+formats PostScript et \textsc{pdf} et convient donc mieux aux lecteurs de
+\textsc{pdf}. L'inconvénient est qu'elle nécessite plusieurs compilations
+successives.
\medskip
L'extension \pkg{nicematrix} fournit une clé |code-before| pour du code qui sera
-exécuté avant le tracé du tableau. De nouvelles commandes y sont disponibles :
+exécuté avant le tracé du tableau.
+
+\smallskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Une syntaxe alternative est
+proposée : on peut placer le contenu de ce |code-before| entre les mots-clés
+|\CodeBefore| et |\Body| juste au début de l'environnement.
+
+\begin{Verbatim}
+\begin{pNiceArray}{~textsl#preamble@}
+~emphase#\CodeBefore@
+~textsl#instructions du code-before@
+~emphase#\Body@
+~textsl#contenu de l'environnement@
+\end{pNiceArray}
+\end{Verbatim}
+
+\smallskip
+De nouvelles commandes sont disponibles dans ce |\CodeBefore| :
|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| et
|\chessboardcolors|.\footnote{On pourra remarquer que, dans le
\verb|code-before|, des nœuds PGF/Tikz correspondant à la position des filets
@@ -1176,14 +1212,20 @@ format $i$-$j$ où $i$ est le numéro de ligne et $j$ le numéro de colonne.
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[boxwidth=10cm,baseline=c]
-\begin{NiceTabular}{|c|c|c|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
+\begin{NiceTabular}{|c|c|c|}
+\CodeBefore
+ ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@
+\Body
\hline
a & b & c \\ \hline
e & f & g \\ \hline
h & i & j \\ \hline
\end{NiceTabular}
\end{BVerbatim}
-\begin{NiceTabular}{|c|c|c|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}]
+\begin{NiceTabular}{|c|c|c|}
+\CodeBefore
+ \cellcolor{red!15}{3-1,2-2,1-3}
+\Body
\hline
a & b & c \\ \hline
e & f & g \\ \hline
@@ -1201,14 +1243,20 @@ et la case en bas à droite du rectangle.
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[boxwidth=10cm,baseline=c]
-\begin{NiceTabular}{|c|c|c|}[code-before = ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@]
+\begin{NiceTabular}{|c|c|c|}
+\CodeBefore
+ ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@
+\Body
\hline
a & b & c \\ \hline
e & f & g \\ \hline
h & i & j \\ \hline
\end{NiceTabular}
\end{BVerbatim}
-\begin{NiceTabular}{|c|c|c|}[code-before = \rectanglecolor{blue!15}{2-2}{3-3}]
+\begin{NiceTabular}{|c|c|c|}
+\CodeBefore
+ \rectanglecolor{blue!15}{2-2}{3-3}
+\Body
\hline
a & b & c \\ \hline
e & f & g \\ \hline
@@ -1230,7 +1278,10 @@ partir de la rangée~$a$).
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[boxwidth=9cm,baseline=c]
-$\begin{NiceArray}{lll}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
+$\begin{NiceArray}{lll}[hvlines]
+\CodeBefore
+ ~emphase#\rowcolor{red!15}{1,3-5,8-}@
+\Body
a_1 & b_1 & c_1 \\
a_2 & b_2 & c_2 \\
a_3 & b_3 & c_3 \\
@@ -1244,8 +1295,10 @@ a_{10} & b_{10} & c_{10} \\
\end{NiceArray}$
\end{BVerbatim}
%
-$\begin{NiceArray}{lll}%
-[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
+$\begin{NiceArray}{lll}[baseline=4,hvlines]
+\CodeBefore
+ \rowcolor{red!15}{1,3-5,8-}
+\Body
a_1 & b_1 & c_1 \\
a_2 & b_2 & c_2 \\
a_3 & b_3 & c_3 \\
@@ -1281,7 +1334,7 @@ l'intervalle constitué de toutes les rangées du tableau à partir de la rangé
\bigskip
-La commande |\rowcolors| accepte une liste de paires clé-valeur comme argument
+La commande |\rowcolors| accepte une liste de couples clé-valeur comme argument
optionnel en dernière position (l'argument optionel en première position
correspond à l'espace colorimétrique). Les clés disponibles sont |cols|,
|restart| et |respect-blocks|.
@@ -1306,8 +1359,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-\begin{NiceTabular}{clr}%
- [hvlines,code-before = ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@]
+\begin{NiceTabular}{clr}[hvlines]
+\CodeBefore
+ ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@
+\Body
\Block{1-*}{Résultats} \\
\Block{2-1}{A}& Pierre & 12 \\
& Jacques & 8 \\
@@ -1317,8 +1372,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page
& Estelle & 15
\end{NiceTabular}
\end{BVerbatim}
-\begin{NiceTabular}{clr}[hvlines,
- code-before = {\rowcolors{2}{blue!10}{}[cols=2-3,restart]},baseline=2]
+\begin{NiceTabular}{clr}[hvlines,baseline=2]
+\CodeBefore
+ \rowcolors{2}{blue!10}{}[cols=2-3,restart]
+\Body
\Block{1-*}{Résultats} \\
\Block{2-1}{A}& Pierre & 12 \\
& Jacques & 8 \\
@@ -1335,8 +1392,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[baseline=c,boxwidth=11cm]
-\begin{NiceTabular}{lr}[hvlines,code-before =
-~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@]
+\begin{NiceTabular}{lr}[hvlines]
+\CodeBefore
+ ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@
+\Body
\Block{2-1}{Pierre} & 12 \\
& 13 \\
Jacques & 8 \\
@@ -1349,8 +1408,10 @@ Henri & 14 \\
& 19
\end{NiceTabular}
\end{BVerbatim}
-\begin{NiceTabular}{lr}[hvlines,code-before =
-\rowcolors{1}{blue!10}{}[respect-blocks],baseline=c]
+\begin{NiceTabular}{lr}[hvlines,baseline=c]
+\CodeBefore
+ \rowcolors{1}{blue!10}{}[respect-blocks]
+\Body
\Block{2-1}{Pierre} & 12 \\
& 13 \\
Jacques & 8 \\
@@ -1376,14 +1437,19 @@ couleurs et colorie les cases en quinconces avec les deux couleurs.
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-$\begin{pNiceMatrix}[r,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
+$\begin{pNiceMatrix}[r,margin]
+\CodeBefore
+ ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@
+\Body
1 & -1 & 1 \\
-1 & 1 & -1 \\
1 & -1 & 1
\end{pNiceMatrix}$
\end{BVerbatim}
-$\begin{pNiceMatrix}%
-[baseline=1, r, margin, code-before = \chessboardcolors{red!15}{blue!15}]
+$\begin{pNiceMatrix}[baseline=1, r, margin]
+\CodeBefore
+ \chessboardcolors{red!15}{blue!15}
+\Body
1 & -1 & 1 \\
-1 & 1 & -1 \\
1 & -1 & 1
@@ -1404,8 +1470,11 @@ l'extension \pkg{booktabs} n'est pas chargée par \pkg{nicematrix}.
\begin{scope}
\hfuzz=10cm
\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-\begin{NiceTabular}{lSSSS}%
-[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+\begin{NiceTabular}{lSSSS}
+\CodeBefore
+ \rowcolor{red!15}{1-2}
+ \rowcolors{3}{blue!15}{}
+\Body
~emphase#\toprule@
\Block{2-1}{Produit} &
\Block{1-3}{dimensions (cm)} & & &
@@ -1421,8 +1490,11 @@ spécial & 12 & 12 & 0.5 & 70 \\
~emphase#\bottomrule@
\end{NiceTabular}
\end{BVerbatim}
-\begin{NiceTabular}[c]{lSSSS}%
-[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+\begin{NiceTabular}[c]{lSSSS}
+\CodeBefore
+ \rowcolor{red!15}{1-2}
+ \rowcolors{3}{blue!15}{}
+\Body
\toprule
\Block{2-1}{Produit} &
\Block{1-3}{dimensions (cm)} & & &
@@ -2062,7 +2134,7 @@ C[a_1,a_1] & \Cdots & C[a_1,a_n]
& ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\
C[a_n,a_1] & \Cdots & C[a_n,a_n]
& & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
-\rule{0pt}{15mm} & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\
+\rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\
C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n]
& & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
\Vdots & \Ddots & \Vdots
@@ -2077,7 +2149,7 @@ C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n]
C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\
\Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
-\rule{0pt}{15mm} & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\
+\rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\
C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
\Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}]
@@ -2359,7 +2431,7 @@ p.~\pageref{customization}).
\label{sub-matrix}
-\colorbox{yellow!50}{\textbf{Nouveau 5.10}}\enskip
+\colorbox{yellow!30}{Nouveau 5.10}\enskip
La commande |\SubMatrix| permet de positionner des délimiteurs sur une partie du
tableau, partie qui est considérée comme une sous-matrice. La commande
|\SubMatrix| prend cinq arguments :
@@ -2373,7 +2445,11 @@ la syntaxe $i$|-|$j$ où $i$ est le numéro de rangée et $j$ le numéro de colo
\item le troisième argument est le coin inférieur droit avec la même syntaxe ;
\item la quatrième argument est le délimiteur droit ;
\item le cinquième argument, optionnel, entre crochets, est une liste de couples
-clé-valeur.
+clé-valeur.\footnote{Il n'y a pas d'argument optionnel entre crochets en première
+position car un crochet ouvrant juste après \verb|\SubMatrix| doit pouvoir être
+interprété comme le premier argument (obligatoire) de \verb|\SubMatrix|: ce
+crochet est alors le délimiteur gauche de la sous-matrice (ex. :
+\verb|\SubMatrix[{2-2}{4-7}]|).}
\end{itemize}
On remarquera que la commande |\SubMatrix| trace les délimiteurs après la
@@ -2392,8 +2468,8 @@ colonne avec |@{\hspace{1.5em}}| dans le préambule du tableau.
\dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
1 & 2 & 3 & z
\CodeAfter
-~emphase#\SubMatrix({1-1}{3-3})+
-~emphase#\SubMatrix({1-4}{3-4})+
+ ~emphase#\SubMatrix({1-1}{3-3})+
+ ~emphase#\SubMatrix({1-4}{3-4})+
\end{NiceArray}\]
\end{BVerbatim}
\end{scope}
@@ -2402,8 +2478,8 @@ $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin]
\dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
1 & 2 & 3 & z
\CodeAfter
-\SubMatrix({1-1}{3-3})
-\SubMatrix({1-4}{3-4})
+ \SubMatrix({1-1}{3-3})
+ \SubMatrix({1-4}{3-4})
\end{NiceArray}$
\bigskip
@@ -2429,6 +2505,21 @@ environnements de \pkg{nicematrix} ou comme option de |\CodeAfter| avec le
préfixe |sub-matrix|, c'est-à-dire qu'elles sont alors nommées
|sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc.
+\medskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Il y a aussi les clés
+suivantes, qui ne sont accessibles que pour une commande |\SubMatrix|
+individuelle :
+%
+\begin{itemize}
+\item |vlines| contient une liste de numéros de filets verticaux à tracer dans
+la sous-matrice (si cette clé est utilisée sans valeur, tous les filets
+verticaux sont tracés) ;
+\item |hlines| est similaire à |vlines| mais pour les filets horizontaux ;
+\item |hvlines|, qui s'utilise sans valeur, trace tous les filets dans la sous-matrice.
+\end{itemize}
+On remarquera que tous ces filets sont dessinés après la construction du tableau
+principal : les colonnes et les rangées ne sont pas écartées.
+
\bigskip
\begin{scope}
\hfuzz=12cm
@@ -2440,9 +2531,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
a & b & \frac12a+\frac14b \\
c & d & \frac12c+\frac14d \\
\CodeAfter
-\SubMatrix({1-3}{2-3})
-\SubMatrix({3-1}{4-2})
-\SubMatrix({3-3}{4-3})
+ \SubMatrix({1-3}{2-3})
+ \SubMatrix({3-1}{4-2})
+ \SubMatrix({3-3}{4-3})
\end{NiceArray}$
\end{BVerbatim}
\end{scope}
@@ -2452,9 +2543,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
a & b & \frac12a+\frac14b \\
c & d & \frac12c+\frac14d \\
\CodeAfter
-\SubMatrix({1-3}{2-3})
-\SubMatrix({3-1}{4-2})
-\SubMatrix({3-3}{4-3})
+ \SubMatrix({1-3}{2-3})
+ \SubMatrix({3-1}{4-2})
+ \SubMatrix({3-3}{4-3})
\end{NiceArray}$
\medskip
@@ -2471,9 +2562,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
a & b & \frac12a+\frac14b \\
c & d & \frac12c+\frac14d \\
\CodeAfter
-\SubMatrix({1-3}{2-3})[~emphase#slim!]
-\SubMatrix({3-1}{4-2})
-\SubMatrix({3-3}{4-3})
+ \SubMatrix({1-3}{2-3})[~emphase#slim!]
+ \SubMatrix({3-1}{4-2})
+ \SubMatrix({3-3}{4-3})
\end{NiceArray}$
\end{BVerbatim}
\end{scope}
@@ -2484,9 +2575,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt]
a & b & \frac12a+\frac14b \\
c & d & \frac12c+\frac14d \\
\CodeAfter
-\SubMatrix({1-3}{2-3})[slim]
-\SubMatrix({3-1}{4-2})
-\SubMatrix({3-3}{4-3})
+ \SubMatrix({1-3}{2-3})[slim]
+ \SubMatrix({3-1}{4-2})
+ \SubMatrix({3-3}{4-3})
\end{NiceArray}$
@@ -3488,7 +3579,7 @@ noix & noisette & brugnon
\label{noeuds-i}
-\colorbox{yellow!50}{\textbf{Nouveau 5.11}}\enskip L'extension \pkg{nicematrix}
+\colorbox{yellow!30}{Nouveau 5.11}\enskip L'extension \pkg{nicematrix}
crée un nœud PGF-Tikz nommé simplement $i$ (précédé du préfixe habituel) à
l'intersection du filet horizontal de numéro $i$ et du filet vertical de
numéro~$j$ (ou plutôt la position potentielle de ces filets car ils ne sont
@@ -3521,13 +3612,10 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|.
\medskip
\begin{Verbatim}
-\[\begin{NiceMatrix}[
- code-before =
- {
-~emphase# \tikz \draw [fill = red!15] @
-~emphase# (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; @
- }
-]
+\begin{NiceMatrix}
+\CodeBefore
+~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@
+\Body
1 \\
1 & 1 \\
1 & 2 & 1 \\
@@ -3537,16 +3625,13 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|.
1 & 6 & 15 & 20 & 15 & 6 & 1 \\
1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
-\end{NiceMatrix}\]
+\end{NiceMatrix}
\end{Verbatim}
%
-\[\begin{NiceMatrix}[
- code-before =
- {
- \tikz \draw [fill = red!15]
- (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ;
- }
-]
+\[\begin{NiceMatrix}
+\CodeBefore
+\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;
+\Body
1 \\
1 & 1 \\
1 & 2 & 1 \\
@@ -3563,7 +3648,7 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|.
\label{node-sub-matrix}
-\colorbox{yellow!50}{\textbf{Nouveau 5.10}}\enskip
+\colorbox{yellow!30}{Nouveau 5.10}\enskip
La commande |\SubMatrix| disponible dans le |\CodeAfter| a été présentée
p.~\pageref{sub-matrix}.
@@ -3636,10 +3721,8 @@ bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|).
\ExplSyntaxOn
\cs_new_protected:Nn \__pantigny_hatch:nnn
{
- \begin { tikzpicture }
- \fill [ pattern = north~west~lines , pattern~color = #3 ]
- ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
- \end { tikzpicture }
+ \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
+ ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
}
\NewDocumentCommand \hatchcell { ! O { black } }
@@ -3654,10 +3737,8 @@ bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|).
\ExplSyntaxOn
\cs_new_protected:Nn \__pantigny_hatch:nnn
{
- \begin { tikzpicture }
- \fill [ pattern = north~west~lines , pattern~color = #3 ]
- ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
- \end { tikzpicture }
+ \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
+ ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
}
\NewDocumentCommand \hatchcell { ! O { black } }
@@ -4150,96 +4231,224 @@ $\begin{pNiceMatrix}[first-row,first-col]
-\subsection{Largeur des colonnes}
+\subsection{Empilements de matrices}
+
+On a souvent besoin de présetner des matrices empilées les unes au-dessus des
+autres (par exemple pour la résolutiond de systèmes linéaires).
+
\medskip
-Dans l'exemple suivant, nous utilisons |{NiceMatrixBlock}| avec l'option
-|auto-columns-width| parce que nous voulons la même largeur (automatique) pour
-toutes les colonnes.
+Pour avoir les colonnes alignées les unes sous les autres, on peut imposer une
+largeur commune à toutes les colonnes, ce que l'on fait dans l'exemple suivant
+avec l'environnement |{NiceMatrixBlock}| et l'option |auto-columns-width|.
-\bigskip
-\begin{BVerbatim}
+\begin{Verbatim}[formatcom=\small\color{gray}]
~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
\NiceMatrixOptions
- { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax}
+ {
+ light-syntax,
+ last-col, code-for-last-col = \color{blue} \scriptstyle,
+ }
\setlength{\extrarowheight}{1mm}
-$\begin{pNiceArray}{cccc:c}
- 1 1 1 1 1 { } ;
- 2 4 8 16 9 ;
- 3 9 27 81 36 ;
- 4 16 64 256 100
+
+$\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+ 3 -18 12 1 4 ;
+-3 -46 29 -2 -15 ;
+ 9 10 -5 4 7
\end{pNiceArray}$
-\medskip
-$\begin{pNiceArray}{cccc:c}
- 1 1 1 1 1 ;
- 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ;
- 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ;
- 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 }
+
+\smallskip
+$\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
\end{pNiceArray}$
-...
+
+\smallskip
+$\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 ;
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+\end{pNiceArray}$
+
+\smallskip
+$\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+0 64 -41 1 19 ;
+\end{pNiceArray}$
+
~emphase#\end{NiceMatrixBlock}@
-\end{BVerbatim}
+\end{Verbatim}
\bigskip
-
-\begin{multicols}{2}
\begin{NiceMatrixBlock}[auto-columns-width]
-\NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax}
+\NiceMatrixOptions
+ {
+ light-syntax,
+ last-col, code-for-last-col = \color{blue} \scriptstyle ,
+ }
\setlength{\extrarowheight}{1mm}
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 { } ;
-2 4 8 16 9 ;
-3 9 27 81 36 ;
-4 16 64 256 100
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+ 3 -18 12 1 4 ;
+-3 -46 29 -2 -15 ;
+ 9 10 -5 4 7
\end{pNiceArray}$
-\medskip
-
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 ;
-0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ;
-0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ;
-0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 }
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
\end{pNiceArray}$
-\medskip
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 ;
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+\end{pNiceArray}$
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 ;
-0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ;
-0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ;
-0 1 5 21 8 { L_4 \gets \frac1{12} L_4 }
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+0 64 -41 1 19 ;
\end{pNiceArray}$
+\end{NiceMatrixBlock}
+
+\bigskip
+On constate que la dernière matrice n'est pas parfaitement alignée avec les
+précédentes. C'est que les parenthèses, en LaTeX, n'ont pas toutes la même
+largeur suivant leur taille.
\medskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Pour résoudre ce problème, on
+peut demander que les délimiteurs soient composés avec leur largeur maximale
+grâce à la clé booléenne |delimiters/max-width|.
+
+\begin{Verbatim}[formatcom=\small\color{gray}]
+~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
+\NiceMatrixOptions
+ {
+ ~emphase#delimiters/max-width@,
+ light-syntax,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ }
+\setlength{\extrarowheight}{1mm}
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 ;
-0 1 3 7 \frac72 ;
-0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ;
-0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 }
+$\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+ 3 -18 12 1 4 ;
+-3 -46 29 -2 -15 ;
+ 9 10 -5 4 7
\end{pNiceArray}$
-\medskip
+...
+~emphase#\end{NiceMatrixBlock}@
+\end{Verbatim}
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 ;
-0 1 3 7 \frac72 ;
-0 0 1 6 2 { L_3 \gets \frac13 L_3 } ;
-0 0 -2 -14 -\frac92
+\bigskip
+\begin{NiceMatrixBlock}[auto-columns-width]
+\NiceMatrixOptions
+ {
+ delimiters/max-width,
+ light-syntax,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ }
+\setlength{\extrarowheight}{1mm}
+
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+ 3 -18 12 1 4 ;
+-3 -46 29 -2 -15 ;
+ 9 10 -5 4 7
\end{pNiceArray}$
-\medskip
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
+\end{pNiceArray}$
-\enskip $\begin{pNiceArray}{cccc:c}
-1 1 1 1 1 ;
-0 1 3 7 \frac72 ;
-0 0 1 6 2 ;
-0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 }
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 ;
+0 64 -41 1 19 ;
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
\end{pNiceArray}$
+
+\smallskip
+\quad $\begin{pNiceArray}{rrrr|r}
+12 -8 7 5 3 {} ;
+0 64 -41 1 19 ;
+\end{pNiceArray}$
+
\end{NiceMatrixBlock}
-\end{multicols}
+
+
+\interitem
+Si on souhaite un alignement des colonnes des différentes matrices sans imposer
+la même largeur à toutes les colonnes, on peut utiliser un grand tableau unique
+et placer les parenthèses avec des commandes |\SubMatrix| dans le |\CodeAfter|.
+Bien sûr, ce tableau ne pourra pas être coupé par un saut de page.
+
+\medskip
+\begin{Verbatim}
+\setlength{\extrarowheight}{1mm}
+\[\begin{NiceMatrix}%
+ [ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
+12 & -8 & 7 & 5 & 3 \\
+ 3 & -18 & 12 & 1 & 4 \\
+-3 & -46 & 29 &-2 &-15 \\
+ 9 & 10 &-5 &4 & 7 \\[1mm]
+12 & -8 & 7 &5 & 3 \\
+0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+12 & -8 &7 &5 & 3 \\
+0 & 64 &-41 &1 &19 \\
+0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+12 & -8 &7 &5 & 3 \\
+0 & 64 &-41 & 1 & 19 \\
+~emphase#\CodeAfter@
+~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@
+~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@
+~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@
+~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@
+\end{NiceMatrix}\]
+\end{Verbatim}
+
+\medskip
+\begin{scope}
+\setlength{\extrarowheight}{1mm}
+\[\begin{NiceMatrix}%
+ [ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
+12 & -8 & 7 & 5 & 3 \\
+ 3 & -18 & 12 & 1 & 4 \\
+-3 & -46 & 29 &-2 &-15 \\
+ 9 & 10 &-5 &4 & 7 \\[1mm]
+12 & -8 & 7 &5 & 3 \\
+0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+12 & -8 &7 &5 & 3 \\
+0 & 64 &-41 &1 &19 \\
+0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+12 & -8 &7 &5 & 3 \\
+0 & 64 &-41 & 1 & 19 \\
+\CodeAfter
+ \SubMatrix({1-1}{4-5})[vlines=4]
+ \SubMatrix({5-1}{8-5})[vlines=4]
+ \SubMatrix({9-1}{11-5})[vlines=4]
+ \SubMatrix({12-1}{13-5})[vlines=4]
+\end{NiceMatrix}\]
+\end{scope}
\subsection{Comment surligner les cases d'une matrice}
@@ -4280,7 +4489,7 @@ matrice.\footnote{Pour la commande |\cline|, voir la remarque
\vspace{1cm}
Il est possible de colorier une rangée avec |\rowcolor| dans le |code-before|
-(ou avec |\rowcolor| dans la première case de la rangée si on utilise la clé
+(ou avec |\rowcolor| dans une case de la rangée si on utilise la clé
|colortbl-like| − même si \pkg{colortbl} n'est pas chargé).
@@ -4491,112 +4700,43 @@ a & a & a & L_3 \\
-\subsection{Utilisation directe des nœuds Tikz}
-
-Dans l'exemple suivant, on souhaite illustrer le produit mathématique de deux matrices.
-
-\medskip
-L'utilisation de |{NiceMatrixBlock}| avec l'option |auto-columns-width| va
-permettre que toutes les colonnes aient la même largeur ce qui permettra un
-alignement des deux matrices superposées.
-\begin{Verbatim}
-\begin{NiceMatrixBlock}[auto-columns-width]
-\end{Verbatim}
-
-\begin{Verbatim}
-\NiceMatrixOptions{nullify-dots}
-\end{Verbatim}
+\subsection{Utilisation de \textbackslash SubMatrix dans le code-before}
-Les trois matrices vont être disposées les unes par rapport aux autres grâce à un tableau de LaTeX.
-\begin{Verbatim}
-$\begin{array}{cc}
-&
-\end{Verbatim}
+Dans l'exemple suivant, on illustre le produit mathématique de deux matrices.
-La matrice $B$ a une «première rangée» (pour $C_j$) d'où l'option |first-row|.
-\begin{Verbatim}
-\begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row]
- & & ~emphase#C_j@ \\
-b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
-\Vdots & & \Vdots & & \Vdots \\
- & & b_{kj} \\
- & & \Vdots \\
- b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn}
-\end{bNiceArray} \\ \\
-\end{Verbatim}
+L'ensemble de la figure est un environnement |{NiceArray}| et les trois paires
+de parenthèses ont été rajoutées avec |\SubMatrix| dans le |code-before|.
-La matrice $A$ a une «première colonne» (pour $L_i$) d'où l'option |first-col|.
-\begin{Verbatim}
-\begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col]
+Ceux qui sont intéressés par le code correspondant le trouveront dans le fichier
+source de ce document.
+%
+%
+%
+\[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots]
+\CodeBefore
+ \SubMatrix({2-7}{6-11})
+ \SubMatrix({7-2}{11-6})
+ \SubMatrix({7-7}{11-11})
+\Body
+ & & & & & & & & \color{blue}\scriptstyle C_j \\
+ & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
+ & & & & & & \Vdots & & \Vdots & & \Vdots \\
+ & & & & & & & & b_{kj} \\
+ & & & & & & & & \Vdots \\
+ & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm]
& a_{11} & \Cdots & & & a_{1n} \\
+ & \Vdots & & & & \Vdots & & & \Vdots \\
+\color{blue}\scriptstyle L_i
+ & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\
& \Vdots & & & & \Vdots \\
-~emphase#L_i@ & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\
- & \Vdots & & & & \Vdots \\
- & a_{n1} & \Cdots & & & a_{nn}
-\end{bNiceArray}
-&
-\end{Verbatim}
-
-Dans la matrice produit, on remarquera que les lignes en pointillés sont «semi-ouvertes».
-\begin{Verbatim}
-\begin{bNiceArray}{cc>{\strut}ccc}
- & & & & \\
- & & \Vdots \\
-\Cdots & & c_{ij} \\
-\\
-\\
-\end{bNiceArray}
-\end{array}$
-
-\end{NiceMatrixBlock}
-\end{Verbatim}
-
-\begin{Verbatim}
-\begin{tikzpicture}[remember picture, overlay]
- \node [highlight = (A-3-1) (A-3-5) ] {} ;
- \node [highlight = (B-1-3) (B-5-3) ] {} ;
- \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ;
-\end{tikzpicture}
-\end{Verbatim}
-
-
-
-\begin{NiceMatrixBlock}[auto-columns-width]
-\NiceMatrixOptions{nullify-dots}
-$\begin{array}{cc}
-&
-\begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row]
- & & C_j \\
-b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
-\Vdots & & \Vdots & & \Vdots \\
- & & b_{kj} \\
- & & \Vdots \\
- b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn}
-\end{bNiceArray} \\ \\
-\begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col]
- & a_{11} & \Cdots & & & a_{1n} \\
- & \Vdots & & & & \Vdots \\
-L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\
- & \Vdots & & & & \Vdots \\
- & a_{n1} & \Cdots & & & a_{nn} \\
-\end{bNiceArray}
-&
-\begin{bNiceArray}{cc>{\strut}ccc}
- & & & & \\
- & & \Vdots \\
-\Cdots & & c_{ij} \\
-\\
-\\
-\end{bNiceArray}
-\end{array}$
-
-\end{NiceMatrixBlock}
-
-\begin{tikzpicture}[remember picture, overlay]
- \node [highlight = (A-3-1) (A-3-5) ] {} ;
- \node [highlight = (B-1-3) (B-5-3) ] {} ;
- \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ;
+ & a_{n1} & \Cdots & & & a_{nn} \\
+\CodeAfter
+\begin{tikzpicture}
+\node [highlight = (9-2) (9-6)] { } ;
+\node [highlight = (2-9) (6-9)] { } ;
+\draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
\end{tikzpicture}
+\end{NiceArray}\]
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 24732c133c..a84069b7c8 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{5.11}
-\def\myfiledate{2021/02/22}
+\def\myfileversion{5.12}
+\def\myfiledate{2021/03/10}
%
%
%<*batchfile>
@@ -279,8 +279,7 @@ version 2005/12/01 or later.
% |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and
% |\cellspacebottomlimit| of \pkg{cellspace}.
%
-% \colorbox{yellow!30}{New 5.9}\enskip There is also a key |cell-space-limits|
-% to set both parameters at once.
+% There is also a key |cell-space-limits| to set both parameters at once.
%
% The initial value of these parameters is $0$~pt in order to have for the
% environments of \pkg{nicematrix} the same behaviour as those of \pkg{array}
@@ -546,7 +545,29 @@ version 2005/12/01 or later.
% 0 & \Cdots& 0 & 0
% \end{bNiceArray}$
%
-%
+% \interitem
+% In fact, the command |\Block| accepts as first optional argument (between
+% square brackets) a list of couples key-value. The available keys are as
+% follows:
+% \begin{itemize}
+% \item the keys |l|, |c| and |r| are used to fix the horizontal position of the
+% content of the block, as explained previously;
+% \item the key |fill| takes in as value a color and fills the block with that
+% color;
+% \item the key |draw| takes in as value a color and strokes the frame of the
+% block with that color (the default value of that key is the current color of
+% the rules of the array);
+% \item the key |color| takes in as value a color and apply that color the
+% content of the block but draws also the frame of the block with that color;
+% \item the key |line-width| is the width (thickness) of the frame (this key
+% should be used only when the key |draw| is in force);
+% \item \colorbox{yellow!50}{\textbf{New 5.12}}\enskip the key |rounded-corners|
+% requires rounded corners (for the frame drawn by |draw| and the shape drawn by
+% |fill|) with a radius equal to the value of that key (the default value is
+% 4~pt\footnote{This value is the initial value of the \emph{rounded corners} of
+% Tikz.}).
+% \end{itemize}
+%
% \interitem
% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}.
% There is exception only for the blocks mono-row and the blocks mono-column as
@@ -556,35 +577,29 @@ version 2005/12/01 or later.
% In the following example, we have had to enlarge by hand the columns 2 and 3
% (with the construction |wc{...}| of \pkg{array}).
%
-% \medskip
+% \bigskip
% \begin{BVerbatim}
-% \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@
+% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
% rose & tulipe & marguerite & dahlia \\
% violette
-% & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
+% & ~emphase#\Block[draw=red,fill=red!15,rounded-corners]{2-2}{\LARGE De très jolies fleurs}@
+% & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
% \end{BVerbatim}
%
-%
% \medskip
% \begin{center}
% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
% rose & tulipe & marguerite & dahlia \\
-% violette &
-% \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\
+% violette & \Block[draw=red,fill=red!15,rounded-corners]{2-2}
+% {\LARGE De très jolies fleurs} & & souci \\
% pervenche & & & lys \\
% arum & iris & jacinthe & muguet
% \end{NiceTabular}
% \end{center}
%
-% As we can see on this example, it's possible to fill the block by using the
-% key |fill| and to draw the frame with the key |draw|\footnote{If the key
-% |draw| is used without value, the default color the rules of the tabulars is
-% used}. It's also possible to change the width (thickness) of that rules with
-% the key |line-width|.
-%
% \subsection{The mono-column blocks}
%
% The mono-column blocks have a special behaviour.
@@ -655,9 +670,11 @@ version 2005/12/01 or later.
% derogation of the type of column given in the preamble of the array.
%
% \item It's possible do draw a frame around the cell with the key |draw| of the
-% command |\Block|.\footnote{If one wishes to color the background of a unique
-% celle, there is no point using the command |\Block|: it's possible to use the
-% command |\cellcolor| (when the key |colortbl-like| is used).}
+% command |\Block| and to fill the background with rounded corners with the keys
+% |fill| and |rounded-corners|.\footnote{If one simply wishes to color the
+% background of a unique celle, there is no point using the command |\Block|:
+% it's possible to use the command |\cellcolor| (when the key |colortbl-like| is
+% used).}
% \end{itemize}
%
% \bigskip
@@ -908,10 +925,10 @@ version 2005/12/01 or later.
% \subsection{The keys hlines and vlines}
%
% The key |hlines| draws all the horizontal rules and the key |vlines| draws all
-% the vertical rules excepted in the blocks (and the virtual blocks determined
-% by dotted lines). In fact, in the environments with delimiters (as
-% |{pNiceMatrix}| or |{bNiceArray}|) the exteriors rules are not drawn (as
-% expected).
+% the vertical rules excepted in the blocks, created by |\Block| and the virtual
+% blocks determined by dotted lines: |\Cdots|, |\Vdots|, etc.. In fact, in the
+% environments with delimiters (as |{pNiceMatrix}| or |{bNiceArray}|) the
+% exteriors rules are not drawn (as expected).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -1164,11 +1181,27 @@ version 2005/12/01 or later.
%
% \medskip
% The extension \pkg{nicematrix} provides a key |code-before| for some code that
-% will be executed before the drawing of the tabular. In this |code-before|, new
-% commands are available: |\cellcolor|, |\rectanglecolor|, |\rowcolor|,
-% |\columncolor|, |\rowcolors| and |\chessboardcolors|.\footnote{Remark that, in
-% the \verb|code-before|, some PGF/Tikz nodes corresponding to the position to
-% the potential rules are available: cf.~p.~\pageref{nodes-i}.}
+% will be executed before the drawing of the tabular.
+%
+% \medskip
+% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip An alternative syntax is
+% provided: it's possible to put the content of that |code-before| between the
+% keywords |\CodeBefore| and |\Body| at the beginning of the environment.
+%
+% \begin{Verbatim}
+% \begin{pNiceArray}{~textsl#preamble@}
+% ~emphase#\CodeBefore@
+% ~textsl#instructions of the code-before@
+% ~emphase#\Body@
+% ~textsl#contents of the environnement@
+% \end{pNiceArray}
+% \end{Verbatim}
+%
+% New commands are available in that |\CodeBefore|: |\cellcolor|,
+% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| and
+% |\chessboardcolors|.\footnote{Remark that, in the \verb|code-before|, some
+% PGF/Tikz nodes corresponding to the position to the potential rules are
+% available: cf.~p.~\pageref{nodes-i}.}
% \label{code-before}
%
% \medskip
@@ -1189,16 +1222,20 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|c|c|c|}[code-before =
-% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
+% \begin{NiceTabular}{|c|c|c|}
+% \CodeBefore
+% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@
+% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{|c|c|c|}[code-before =
-% \cellcolor{red!15}{3-1,2-2,1-3}]
+% \begin{NiceTabular}{|c|c|c|}
+% \CodeBefore
+% \cellcolor{red!15}{3-1,2-2,1-3}
+% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
@@ -1215,16 +1252,20 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|c|c|c|}[code-before =
-% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@]
+% \begin{NiceTabular}{|c|c|c|}
+% \CodeBefore
+% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@
+% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
% h & i & j \\ \hline
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{|c|c|c|}[code-before =
-% \rectanglecolor{blue!15}{2-2}{3-3}]
+% \begin{NiceTabular}{|c|c|c|}
+% \CodeBefore
+% \rectanglecolor{blue!15}{2-2}{3-3}
+% \Body
% \hline
% a & b & c \\ \hline
% e & f & g \\ \hline
@@ -1244,7 +1285,10 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz = 10cm
% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
-% $\begin{NiceArray}{lll}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
+% $\begin{NiceArray}{lll}[hvlines]
+% \CodeBefore
+% ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@
+% \Body
% a_1 & b_1 & c_1 \\
% a_2 & b_2 & c_2 \\
% a_3 & b_3 & c_3 \\
@@ -1257,7 +1301,10 @@ version 2005/12/01 or later.
% a_{10} & b_{10} & c_{10} \\
% \end{NiceArray}$
% \end{BVerbatim}
-% $\begin{NiceArray}{lll}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
+% $\begin{NiceArray}{lll}[baseline=4,hvlines]
+% \CodeBefore
+% \rowcolor{red!15}{1,3-5,8-}
+% \Body
% a_1 & b_1 & c_1 \\
% a_2 & b_2 & c_2 \\
% a_3 & b_3 & c_3 \\
@@ -1314,9 +1361,11 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% \begin{NiceTabular}{clr}
-% [hvlines,code-before = ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@]
-% \Block{1-}{Results} \\
+% \begin{NiceTabular}{clr}[hvlines]
+% \CodeBefore
+% ~emphase#\rowcolors{2}{blue!10}{}[cols=2-3,restart]@
+% \Body
+% \Block{1-*}{Results} \\
% John & 12 \\
% Stephen & 8 \\
% Sarah & 18 \\
@@ -1325,9 +1374,11 @@ version 2005/12/01 or later.
% Madison & 15
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{clr}[hvlines,code-before =
-% {\rowcolors{2}{blue!10}{}[cols=2-3,restart]},baseline=2]
-% \Block{1-}{Results} \\
+% \begin{NiceTabular}{clr}[hvlines,baseline=2]
+% \CodeBefore
+% \rowcolors{2}{blue!10}{}[cols=2-3,restart]
+% \Body
+% \Block{1-*}{Results} \\
% \Block{2-1}{A}& John & 12 \\
% & Stephen & 8 \\
% \Block{4-1}{B}& Sarah & 18 \\
@@ -1341,8 +1392,10 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% \begin{NiceTabular}{lr}[hvlines,code-before =
-% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@]
+% \begin{NiceTabular}{lr}[hvlines]
+% \CodeBefore
+% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@
+% \Body
% \Block{2-1}{John} & 12 \\
% & 13 \\
% Steph & 8 \\
@@ -1355,8 +1408,10 @@ version 2005/12/01 or later.
% & 19
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{lr}[hvlines,code-before =
-% \rowcolors{1}{blue!10}{}[respect-blocks],baseline=c]
+% \begin{NiceTabular}{lr}[hvlines,baseline=c]
+% \CodeBefore
+% \rowcolors{1}{blue!10}{}[respect-blocks]
+% \Body
% \Block{2-1}{John} & 12 \\
% & 13 \\
% Steph & 8 \\
@@ -1379,13 +1434,19 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% $\begin{pNiceMatrix}[r,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
+% $\begin{pNiceMatrix}[r,margin]
+% \CodeBefore
+% ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@
+% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
% 1 & -1 & 1
% \end{pNiceMatrix}$
% \end{BVerbatim}
-% $\begin{pNiceMatrix}[r,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}]
+% $\begin{pNiceMatrix}[r,baseline=1, margin]
+% \CodeBefore
+% \chessboardcolors{red!15}{blue!15}
+% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
% 1 & -1 & 1
@@ -1407,8 +1468,11 @@ version 2005/12/01 or later.
% \begin{scope}
% \hfuzz=10cm
% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-% \begin{NiceTabular}[c]{lSSSS}%
-% [code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+% \begin{NiceTabular}[c]{lSSSS}
+% \CodeBefore
+% \rowcolor{red!15}{1-2}
+% \rowcolors{3}{blue!15}{}
+% \Body
% ~emphase#\toprule@
% \Block{2-1}{Product} &
% \Block{1-3}{dimensions (cm)} & & &
@@ -1424,8 +1488,11 @@ version 2005/12/01 or later.
% ~emphase#\bottomrule@
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}[c]{lSSSS}[code-before = \rowcolor{red!15}{1-2}
-% \rowcolors{3}{blue!15}{}]
+% \begin{NiceTabular}[c]{lSSSS}
+% \CodeBefore
+% \rowcolor{red!15}{1-2}
+% \rowcolors{3}{blue!15}{}
+% \Body
% \toprule
% \Block{2-1}{Product} &
% \Block{1-3}{dimensions (cm)} & & &
@@ -1645,7 +1712,6 @@ version 2005/12/01 or later.
% for the potential ``first column''.
%
% \begin{Verbatim}
-% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@]
% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
% & C_1 & \Cdots & & C_4 & \\
% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
@@ -1654,7 +1720,6 @@ version 2005/12/01 or later.
% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
% & C_1 & \Cdots & & C_4 &
% \end{pNiceMatrix}$
-% \end{pNiceMatrix}$
% \end{Verbatim}
%
% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
@@ -2053,7 +2118,7 @@ version 2005/12/01 or later.
% & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\
% C[a_n,a_1] & \Cdots & C[a_n,a_n]
% & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
-% \rule{0pt}{15mm} & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\
+% \rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\
% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n]
% & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots
@@ -2068,7 +2133,7 @@ version 2005/12/01 or later.
% C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
% C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\
-% \rule{0pt}{15mm} & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\
+% \rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\
% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\
% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\
% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}]
@@ -2340,7 +2405,7 @@ version 2005/12/01 or later.
%
% \label{sub-matrix}
%
-% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip
+% \colorbox{yellow!30}{New 5.10}\enskip
% The command |\SubMatrix| provides a way to put delimiters on a portion
% of the array considered as a submatrix. The command |\SubMatrix| takes in five
% arguments:
@@ -2352,7 +2417,12 @@ version 2005/12/01 or later.
% syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column;
% \item the third argument is the lower-right corner with the same syntax;
% \item the fourth argument is the right delimiter;
-% \item the last argument, which is optional, is a list of key-value pairs.
+% \item the last argument, which is optional, is a list of key-value
+% pairs.\footnote{There is no optional argument between square brackets in first
+% position because a square bracket just after |\SubMatrix| must be interpreted
+% as the first (mandatory) argument of the command |\SubMatrix|: that bracket is
+% the left delimiter of the sub-matrix to construct (eg.:
+% |\SubMatrix[{2-2}{4-7}]|).}
% \end{itemize}
%
% One should remark that the command |\SubMatrix| draws the delimiters after the
@@ -2371,8 +2441,8 @@ version 2005/12/01 or later.
% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
% 1 & 2 & 3 & z
% \CodeAfter
-% ~emphase#\SubMatrix({1-1}{3-3})+
-% ~emphase#\SubMatrix({1-4}{3-4})+
+% ~emphase#\SubMatrix({1-1}{3-3})+
+% ~emphase#\SubMatrix({1-4}{3-4})+
% \end{NiceArray}\]
% \end{BVerbatim}
% \end{scope}
@@ -2381,8 +2451,8 @@ version 2005/12/01 or later.
% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\
% 1 & 2 & 3 & z
% \CodeAfter
-% \SubMatrix({1-1}{3-3})
-% \SubMatrix({1-4}{3-4})
+% \SubMatrix({1-1}{3-3})
+% \SubMatrix({1-4}{3-4})
% \end{NiceArray}$
%
% \bigskip
@@ -2394,7 +2464,7 @@ version 2005/12/01 or later.
% (height |\ht| + depth |\dp|);
% \item |delimiters/color| fixes the color of the delimiters (also
% available in |\NiceMatrixOptions|, in the environments with delimiters and as
-% option of the command |\CodeAfter|);
+% option of the keyword |\CodeAfter|);
% \item |slim| is a boolean key: when that key is in force, the horizontal
% position of the delimiters is computed by using only the contents of the cells
% of the submatrix whereas, in the general case, the position is computed by
@@ -2407,6 +2477,24 @@ version 2005/12/01 or later.
% the prefix |sub-matrix| which means that their names are therefore
% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc.
%
+% \bigskip
+% \medskip
+% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip There is also the following
+% keys, which are available only for an individual command |\SubMatrix|:
+%
+% \begin{itemize}
+% \item |vlines| contents a list of numbers of vertical rules that will be drawn in
+% the sub-matrix (if this key is used without value, all the vertical rules of
+% the sub-matrix are drawn);
+%
+% \item |hlines| is similar to |vlines| but for the horizontal rules;
+%
+% \item |hvlines|, which must be used without value, draws all the vertical and
+% horizontal rules.
+% \end{itemize}
+% One should remark that these keys add their rules after the construction of
+% the main matrix: no space is added between the rows and the columns of the
+% array for theses rules.
%
% \bigskip
% \begin{scope}
@@ -2419,9 +2507,9 @@ version 2005/12/01 or later.
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
-% \SubMatrix({1-3}{2-3})
-% \SubMatrix({3-1}{4-2})
-% \SubMatrix({3-3}{4-3})
+% \SubMatrix({1-3}{2-3})
+% \SubMatrix({3-1}{4-2})
+% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
% \end{BVerbatim}
% \end{scope}
@@ -2431,9 +2519,9 @@ version 2005/12/01 or later.
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
-% \SubMatrix({1-3}{2-3})
-% \SubMatrix({3-1}{4-2})
-% \SubMatrix({3-3}{4-3})
+% \SubMatrix({1-3}{2-3})
+% \SubMatrix({3-1}{4-2})
+% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
%
% \medskip
@@ -2450,9 +2538,9 @@ version 2005/12/01 or later.
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
-% \SubMatrix({1-3}{2-3})[~emphase#slim!]
-% \SubMatrix({3-1}{4-2})
-% \SubMatrix({3-3}{4-3})
+% \SubMatrix({1-3}{2-3})[~emphase#slim!]
+% \SubMatrix({3-1}{4-2})
+% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
% \end{BVerbatim}
% \end{scope}
@@ -2462,15 +2550,15 @@ version 2005/12/01 or later.
% a & b & \frac12a+\frac14b \\
% c & d & \frac12c+\frac14d \\
% \CodeAfter
-% \SubMatrix({1-3}{2-3})[slim]
-% \SubMatrix({3-1}{4-2})
-% \SubMatrix({3-3}{4-3})
+% \SubMatrix({1-3}{2-3})[slim]
+% \SubMatrix({3-1}{4-2})
+% \SubMatrix({3-3}{4-3})
% \end{NiceArray}$
%
%
% \bigskip
% There is also a key |name| which gives a name to the submatrix created by
-% |\SubMatrix|. That name is used to created PGF/Tikz nodes: cf
+% |\SubMatrix|. That name is used to create PGF/Tikz nodes: cf
% p.~\pageref{node-sub-matrix}.
%
% \section{The notes in the tabulars}
@@ -3196,7 +3284,7 @@ version 2005/12/01 or later.
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \CodeAfter
-% \tikz \draw ~emphase#(2-2)@ circle (2mm) ;
+% \tikz \draw ~emphase#(2-2)@ circle (2mm) ;
% \end{pNiceMatrix}$
% \end{BVerbatim}
% $\begin{pNiceMatrix}
@@ -3204,7 +3292,7 @@ version 2005/12/01 or later.
% 4 & 5 & 6 \\
% 7 & 8 & 9
% \CodeAfter
-% \tikz \draw (2-2) circle (2mm) ;
+% \tikz \draw (2-2) circle (2mm) ;
% \end{pNiceMatrix}$
%
%
@@ -3444,7 +3532,7 @@ version 2005/12/01 or later.
% \subsection{The nodes which indicate the position of the rules}
%
% \label{nodes-i}
-% \colorbox{yellow!50}{\textbf{New 5.11}}\enskip The package \pkg{nicematrix}
+% \colorbox{yellow!30}{New 5.11}\enskip The package \pkg{nicematrix}
% creates a PGF/Tikz node merely called $i$ (with the classical prefix) at the
% intersection of the horizontal rule of number~$i$ and the vertical rule of
% number~$j$ (more specifically the potential position of those rules because
@@ -3456,32 +3544,30 @@ version 2005/12/01 or later.
% arum & iris & violette \\
% muguet & dahlia & souci
% \CodeAfter
-% \tiny
-% \begin{tikzpicture}
-% \foreach \i in {1,2,3,4}
-% {
-% \fill [red] (\i) circle (0.5mm) ;
-% \node [red,above right] at (\i) {\i} ;
-% }
-% \end{tikzpicture}
+% \tiny
+% \begin{tikzpicture}
+% \foreach \i in {1,2,3,4}
+% {
+% \fill [red] (\i) circle (0.5mm) ;
+% \node [red,above right] at (\i) {\i} ;
+% }
+% \end{tikzpicture}
% \end{NiceTabular}
% \end{center}
%
% \bigskip
% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default,
% by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the
-% |\CodeAfter| but also in the |code-before|) to the intersection of the horizontal
-% rule~$i$ and the vertical rule~$j$ with the syntax |(|$i$\verb+-|+$j$|)|.
+% |\CodeAfter| but also in the |code-before|, to the intersection of the
+% (potential) horizontal rule~$i$ and the (potential) vertical rule~$j$ with the
+% syntax |(|$i$\verb+-|+$j$|)|.
%
% \medskip
% \begin{Verbatim}
-% \[\begin{NiceMatrix}[
-% code-before =
-% {
-% ~emphase# \tikz \draw [fill = red!15] @
-% ~emphase# (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; @
-% }
-% ]
+% \begin{NiceMatrix}
+% \CodeBefore
+% ~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@
+% \Body
% 1 \\
% 1 & 1 \\
% 1 & 2 & 1 \\
@@ -3491,15 +3577,13 @@ version 2005/12/01 or later.
% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
-% \end{NiceMatrix}\]
+% \end{NiceMatrix}
% \end{Verbatim}
-% \[\begin{NiceMatrix}[
-% code-before =
-% {
-% \tikz \draw [fill = red!15]
-% (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ;
-% }
-% ]
+% %
+% \[\begin{NiceMatrix}
+% \CodeBefore
+% \tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;
+% \Body
% 1 \\
% 1 & 1 \\
% 1 & 2 & 1 \\
@@ -3515,7 +3599,7 @@ version 2005/12/01 or later.
%
% \label{node-sub-matrix}
%
-% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip
+% \colorbox{yellow!30}{New 5.10}\enskip
% The command |\SubMatrix| available in the |\CodeAfter| has been described
% p.~\pageref{sub-matrix}.
%
@@ -3540,14 +3624,14 @@ version 2005/12/01 or later.
% 3462 & 38458 & 34 & 294 \\
% 34 & 7 & 78 & 309 \\
% \CodeAfter
-% \SubMatrix\{{2-2}{3-3}\}[name=A]
-% \begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0 pt}]
-% \node [fit = (A),fill = red!15] {} ;
-% \node [fit = (A-left),fill = blue!15] {} ;
-% \node [fit = (A-right),fill = blue!15] {} ;
-% \end{tikzpicture}
+% \SubMatrix\{{2-2}{3-3}\}[name=A]
+% \begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0 pt}]
+% \node [fit = (A),fill = red!15] {} ;
+% \node [fit = (A-left),fill = blue!15] {} ;
+% \node [fit = (A-right),fill = blue!15] {} ;
+% \end{tikzpicture}
% \end{pNiceMatrix}\]
%
% \section{API for the developpers}
@@ -3588,10 +3672,8 @@ version 2005/12/01 or later.
%\ExplSyntaxOn
% \cs_new_protected:Nn \__pantigny_hatch:nnn
% {
-% \begin { tikzpicture }
-% \fill [ pattern = north~west~lines , pattern~color = #3 ]
-% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
-% \end { tikzpicture }
+% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
+% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
% \NewDocumentCommand \hatchcell { ! O { black } }
@@ -3607,10 +3689,8 @@ version 2005/12/01 or later.
% \ExplSyntaxOn
% \cs_new_protected:Nn \__pantigny_hatch:nnn
% {
-% \begin { tikzpicture }
-% \fill [ pattern = north~west~lines , pattern~color = #3 ]
-% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
-% \end { tikzpicture }
+% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
+% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
% \NewDocumentCommand \hatchcell { ! O { black } }
@@ -4085,97 +4165,223 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}\]
% \end{scope}
%
-% \subsection{Width of the columns}
-%
+%
+% \subsection{Stacks of matrices}
+%
+% We often need to compose mathematical matrices on top on each other (for
+% example for the resolution of linear systems).
%
% \medskip
-% In the following example, we use |{NiceMatrixBlock}| with the option
-% |auto-columns-width| because we want the same automatic width for all the
-% columns of the matrices.
+% In order to have the columns aligned one above the other, it's possible to
+% fix a width for all the columns. That's what is done in the following example
+% with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|.
%
-% \bigskip
-% \begin{BVerbatim}
+% \begin{Verbatim}[formatcom=\small\color{gray}]
% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
% \NiceMatrixOptions
-% { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax}
+% {
+% light-syntax,
+% last-col, code-for-last-col = \color{blue} \scriptstyle,
+% }
% \setlength{\extrarowheight}{1mm}
-% $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 {} ;
-% 2 4 8 16 9 ;
-% 3 9 27 81 36 ;
-% 4 16 64 256 100
+%
+% $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 3 -18 12 1 4 ;
+% -3 -46 29 -2 -15 ;
+% 9 10 -5 4 7
% \end{pNiceArray}$
-% \medskip
-% $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ;
-% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ;
-% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 }
+%
+% \smallskip
+% $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
% \end{pNiceArray}$
-% ...
+%
+% \smallskip
+% $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 ;
+% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+% \end{pNiceArray}$
+%
+% \smallskip
+% $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 0 64 -41 1 19 ;
+% \end{pNiceArray}$
+%
% ~emphase#\end{NiceMatrixBlock}@
-% \end{BVerbatim}
+% \end{Verbatim}
%
% \bigskip
-%
-% \begin{multicols}{2}
% \begin{NiceMatrixBlock}[auto-columns-width]
-% \NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax}
+% \NiceMatrixOptions
+% {
+% light-syntax,
+% last-col, code-for-last-col = \color{blue} \scriptstyle ,
+% }
% \setlength{\extrarowheight}{1mm}
%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 {} ;
-% 2 4 8 16 9 ;
-% 3 9 27 81 36 ;
-% 4 16 64 256 100
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 3 -18 12 1 4 ;
+% -3 -46 29 -2 -15 ;
+% 9 10 -5 4 7
% \end{pNiceArray}$
%
-% \medskip
-%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ;
-% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ;
-% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 }
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
% \end{pNiceArray}$
%
-% \medskip
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 ;
+% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+% \end{pNiceArray}$
%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ;
-% 0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ;
-% 0 1 5 21 8 { L_4 \gets \frac1{12} L_4 }
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 0 64 -41 1 19 ;
% \end{pNiceArray}$
+% \end{NiceMatrixBlock}
+%
+% \bigskip
+% However, one can see that the last matrix is not perfectly aligned with the
+% other. That's why, in LaTeX, the parenthesis have not exactly the same width
+% (smaller parenthesis are a bit slimer).
%
% \medskip
+% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip In order the solve that
+% problem, it's possible to require the delimiters to be composed with the
+% maximal width, thanks to the boolean key |delimiters/max-width|.
%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 1 3 7 \frac72 ;
-% 0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ;
-% 0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 }
+% \begin{Verbatim}[formatcom=\small\color{gray}]
+% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
+% \NiceMatrixOptions
+% {
+% ~emphase#delimiters/max-width@,
+% light-syntax,
+% last-col, code-for-last-col = \color{blue}\scriptstyle,
+% }
+% \setlength{\extrarowheight}{1mm}
+%
+% $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 3 -18 12 1 4 ;
+% -3 -46 29 -2 -15 ;
+% 9 10 -5 4 7
% \end{pNiceArray}$
%
-% \medskip
+% ...
+% ~emphase#\end{NiceMatrixBlock}@
+% \end{Verbatim}
%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 1 3 7 \frac72 ;
-% 0 0 1 6 2 { L_3 \gets \frac13 L_3 } ;
-% 0 0 -2 -14 -\frac92
+% \bigskip
+% \begin{NiceMatrixBlock}[auto-columns-width]
+% \NiceMatrixOptions
+% {
+% delimiters/max-width,
+% light-syntax,
+% last-col, code-for-last-col = \color{blue}\scriptstyle,
+% }
+% \setlength{\extrarowheight}{1mm}
+%
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 3 -18 12 1 4 ;
+% -3 -46 29 -2 -15 ;
+% 9 10 -5 4 7
% \end{pNiceArray}$
%
-% \medskip
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
+% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
+% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
+% \end{pNiceArray}$
%
-% \enskip $\begin{pNiceArray}{cccc:c}
-% 1 1 1 1 1 ;
-% 0 1 3 7 \frac72 ;
-% 0 0 1 6 2 ;
-% 0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 }
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 ;
+% 0 64 -41 1 19 ;
+% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+% \end{pNiceArray}$
+%
+% \smallskip
+% \quad $\begin{pNiceArray}{rrrr|r}
+% 12 -8 7 5 3 {} ;
+% 0 64 -41 1 19 ;
% \end{pNiceArray}$
+%
% \end{NiceMatrixBlock}
-% \end{multicols}
+%
+%
+% \interitem
+% If you wish an alignment of the different matrices without the same width
+% for all the columns, you can construct a unique array and place the
+% parenthesis with commands |\SubMatrix| in the |\CodeAfter|. Of course, that
+% array can't be broken by a page break.
+%
+% \medskip
+% \begin{Verbatim}
+% \setlength{\extrarowheight}{1mm}
+% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
+% 12 & -8 & 7 & 5 & 3 \\
+% 3 & -18 & 12 & 1 & 4 \\
+% -3 & -46 & 29 &-2 &-15 \\
+% 9 & 10 &-5 &4 & 7 \\[1mm]
+% 12 & -8 & 7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 &1 &19 \\
+% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 \\
+% ~emphase#\CodeAfter@
+% ~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@
+% ~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@
+% ~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@
+% ~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@
+% \end{NiceMatrix}\]
+% \end{Verbatim}
+%
+% \medskip
+% \begin{scope}
+% \setlength{\extrarowheight}{1mm}
+% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ]
+% 12 & -8 & 7 & 5 & 3 \\
+% 3 & -18 & 12 & 1 & 4 \\
+% -3 & -46 & 29 &-2 &-15 \\
+% 9 & 10 &-5 &4 & 7 \\[1mm]
+% 12 & -8 & 7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\
+% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\
+% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 &1 &19 \\
+% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
+% 12 & -8 &7 &5 & 3 \\
+% 0 & 64 &-41 & 1 & 19 \\
+% \CodeAfter
+% \SubMatrix({1-1}{4-5})[vlines=4]
+% \SubMatrix({5-1}{8-5})[vlines=4]
+% \SubMatrix({9-1}{11-5})[vlines=4]
+% \SubMatrix({12-1}{13-5})[vlines=4]
+% \end{NiceMatrix}\]
+% \end{scope}
+%
%
%
% \subsection{How to highlight cells of a matrix}
@@ -4320,7 +4526,7 @@ version 2005/12/01 or later.
% & & & 0 \\
% 0 & \Cdots& 0 & 0
% \CodeAfter
-% \tikz \node [highlight = (1-1-block-medium)] {} ;
+% \tikz \node [highlight = (1-1-block-medium)] {} ;
% \end{pNiceMatrix}$
%
%
@@ -4424,117 +4630,42 @@ version 2005/12/01 or later.
% \end{pNiceArray}\]
%
%
-% \subsection{Direct use of the Tikz nodes}
+% \subsection{Utilisation of \textbackslash SubMatrix in the code-before}
%
% In the following example, we illustrate the mathematical product of two
% matrices.
%
-% \medskip
-% The use of |{NiceMatrixBlock}| with the option |auto-columns-width|
-% gives the same width for all the columns and, therefore, a perfect alignment
-% of the two superposed matrices.
-% \begin{Verbatim}
-% \begin{NiceMatrixBlock}[auto-columns-width]
-% \end{Verbatim}
-%
-% \begin{Verbatim}
-% \NiceMatrixOptions{nullify-dots}
-% \end{Verbatim}
-%
-% The three matrices will be displayed using an environment |{array}| (an
-% environment |{tabular}| may also be possible).
-% \begin{Verbatim}
-% $\begin{array}{cc}
-% &
-% \end{Verbatim}
-%
-% The matrix $B$ has a ``first row'' (for $C_j$) and that's why we use the key
-% |first-row|.
-% \begin{Verbatim}
-% \begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row]
-% & & C_j \\
-% b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
-% \Vdots & & \Vdots & & \Vdots \\
-% & & b_{kj} \\
-% & & \Vdots \\
-% b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn}
-% \end{bNiceArray} \\ \\
-% \end{Verbatim}
-%
-% The matrix $A$ has a ``first column'' (for $L_i$) and that's why we use the
-% key |first-col|.
-% \begin{Verbatim}
-% \begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col]
+% The whole figure is an environment |{NiceArray}| and the three pairs of
+% parenthesis have been added with |\SubMatrix| in the |code-before|.
+%
+% You will find the LaTeX code of that figure in the source file of this
+% document.
+%
+% \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots]
+% \CodeBefore
+% \SubMatrix({2-7}{6-11})
+% \SubMatrix({7-2}{11-6})
+% \SubMatrix({7-7}{11-11})
+% \Body
+% & & & & & & & & \color{blue}\scriptstyle C_j \\
+% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
+% & & & & & & \Vdots & & \Vdots & & \Vdots \\
+% & & & & & & & & b_{kj} \\
+% & & & & & & & & \Vdots \\
+% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm]
% & a_{11} & \Cdots & & & a_{1n} \\
+% & \Vdots & & & & \Vdots & & & \Vdots \\
+% \color{blue}\scriptstyle L_i
+% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\
% & \Vdots & & & & \Vdots \\
-% L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\
-% & \Vdots & & & & \Vdots \\
-% & a_{n1} & \Cdots & & & a_{nn}
-% \end{bNiceArray}
-% &
-% \end{Verbatim}
-%
-% In the matrix product, the two dotted lines have an open extremity.
-% \begin{Verbatim}
-% \begin{bNiceArray}{cc>{\strut}ccc}
-% & & & & \\
-% & & \Vdots \\
-% \Cdots & & c_{ij} \\
-% \\
-% \\
-% \end{bNiceArray}
-% \end{array}$
-%
-% \end{NiceMatrixBlock}
-% \end{Verbatim}
-%
-% \begin{Verbatim}
-% \begin{tikzpicture}[remember picture, overlay]
-% \node [highlight = (A-3-1) (A-3-5) ] {} ;
-% \node [highlight = (B-1-3) (B-5-3) ] {} ;
-% \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ;
-% \end{tikzpicture}
-% \end{Verbatim}
-%
-%
-% \begin{NiceMatrixBlock}[auto-columns-width]
-% \NiceMatrixOptions{nullify-dots}
-% $\begin{array}{cc}
-% &
-% \begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row]
-% & & C_j \\
-% b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\
-% \Vdots & & \Vdots & & \Vdots \\
-% & & b_{kj} \\
-% & & \Vdots \\
-% b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn}
-% \end{bNiceArray} \\ \\
-% \begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col]
-% & a_{11} & \Cdots & & & a_{1n} \\
-% & \Vdots & & & & \Vdots \\
-% L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\
-% & \Vdots & & & & \Vdots \\
-% & a_{n1} & \Cdots & & & a_{nn} \\
-% \end{bNiceArray}
-% &
-% \begin{bNiceArray}{cc>{\strut}ccc}
-% & & & & \\
-% & & \Vdots \\
-% \Cdots & & c_{ij} \\
-% \\
-% \\
-% \end{bNiceArray}
-% \end{array}$
-%
-% \end{NiceMatrixBlock}
-%
-% \begin{tikzpicture}[remember picture, overlay]
-% \node [highlight = (A-3-1) (A-3-5) ] {} ;
-% \node [highlight = (B-1-3) (B-5-3) ] {} ;
-% \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ;
-% \end{tikzpicture}
-%
-%
+% & a_{n1} & \Cdots & & & a_{nn} \\
+% \CodeAfter
+% \begin{tikzpicture}
+% \node [highlight = (9-2) (9-6)] { } ;
+% \node [highlight = (2-9) (6-9)] { } ;
+% \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ;
+% \end{tikzpicture}
+% \end{NiceArray}\]
%
%\section{Implementation}
%
@@ -4897,7 +5028,11 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
-%
+% \bigskip
+% \begin{macrocode}
+\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor
+% \end{macrocode}
+%
% \bigskip
% \textbf{The column S of siunitx}\par\nobreak
%
@@ -5271,6 +5406,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% For the key |code| of the command |\SubMatrix| (itself in the main
+% |\CodeAfter|), we will use the following token list.
+% \begin{macrocode}
+\tl_new:N \l_@@_code_tl
+% \end{macrocode}
+%
+% \bigskip
% The following token list has a function similar to
% |\g_nicematrix_code_after_tl| but it is used internally by \pkg{nicematrix}.
% In fact, we have to distinguish between |\g_nicematrix_code_after_tl| and
@@ -5335,8 +5477,9 @@ version 2005/12/01 or later.
% |\g_@@_code_before_|\textsl{i}|_tl| (where \textsl{i} is the number of the
% environment) and, at the beginning of the environment, it will be put in
% |\l_@@_code_before_tl|.
-% \item The final user can explicitely add material in |\l_@@_code_before_tl| by
-% using the key |code-before|.
+% \item The final user can explicitly add material in |\l_@@_code_before_tl| by
+% using the key |code-before| or the keyword |\CodeBefore| (with the keyword
+% |\Body|).
% \end{itemize}
% \begin{macrocode}
\tl_new:N \l_@@_code_before_tl
@@ -5432,8 +5575,29 @@ version 2005/12/01 or later.
\seq_new:N \g_@@_submatrix_names_seq
% \end{macrocode}
%
+% \medskip
+% The following counters will be used when searching the extremities of a dotted
+% line (we need these counters because of the potential ``open'' lines in the
+% |\SubMatrix|---the |\SubMatrix| in the |code-before|).
+% \begin{macrocode}
+\int_new:N \l_@@_row_min_int
+\int_new:N \l_@@_row_max_int
+\int_new:N \l_@@_col_min_int
+\int_new:N \l_@@_col_max_int
+% \end{macrocode}
%
% \medskip
+% The following sequence will be used when the command |\SubMatrix| is used in
+% the |code-before| (and not in the |\CodeAfter|). It will contain the position of
+% all the sub-matrices specified in the |code-before|. Each sub-matrix is
+% represented by an ``object'' of the forme |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
+% where $i$ and $j$ are the number of row and column of the upper-left cell and
+% $k$ and $l$ the number of row and column of the lower-right cell.
+% \begin{macrocode}
+\seq_new:N \g_@@_submatrix_seq
+% \end{macrocode}
+%
+% \medskip
% We are able to determine the number of columns specified in the preamble (for
% the environments with explicit preamble, of course and without the potential
% exterior columns).
@@ -5442,11 +5606,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% The following token lists correspond to the keys |fill| and |draw| of
-% a command |\Block|.
+% The following parameters correspond to the keys |fill|, |draw| and
+% |rounded-corners| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_fill_tl
\tl_new:N \l_@@_draw_tl
+\dim_new:N \l_@@_rounded_corners_dim
% \end{macrocode}
%
% \medskip
@@ -5492,8 +5657,8 @@ version 2005/12/01 or later.
\dim_new:N \l_@@_submatrix_extra_height_dim
\dim_new:N \l_@@_submatrix_left_xshift_dim
\dim_new:N \l_@@_submatrix_right_xshift_dim
-\clist_new:N \l_@@_submatrix_hlines_clist
-\clist_new:N \l_@@_submatrix_vlines_clist
+\clist_new:N \l_@@_hlines_clist
+\clist_new:N \l_@@_vlines_clist
% \end{macrocode}
%
%
@@ -5586,7 +5751,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_new:N \g_@@_last_col_found_bool
% \end{macrocode}
-% This boolean is set to |false| at the end of |\@@_pre_array:|.
+% This boolean is set to |false| at the end of |\@@_pre_array_ii:|.
% \end{itemize}
%
% \bigskip
@@ -5957,21 +6122,6 @@ version 2005/12/01 or later.
\bool_set_true:N \l_@@_parallelize_diags_bool
% \end{macrocode}
%
-% \bigskip
-% If the flag |\l_@@_vlines_bool| is raised, horizontal space will be reserved
-% in the the preamble of the array (for the vertical rules) and, after the
-% construction of the array, the vertical rules will be drawn.
-% \begin{macrocode}
-\bool_new:N \l_@@_vlines_bool
-% \end{macrocode}
-%
-% \bigskip
-% If the flag |\l_@@_hlines_bool| is raised, vertical space will be reserved
-% between the rows of the array (for the horizontal rules) and, after the
-% construction of the array, the vertical rules will be drawn.
-% \begin{macrocode}
-\bool_new:N \l_@@_hlines_bool
-% \end{macrocode}
%
% \bigskip
% The flag |\l_@@_except_corners_bool| will be raised when the key
@@ -6076,11 +6226,11 @@ version 2005/12/01 or later.
% |{NiceMatrixBlock}|). However, even if we use the same type of delimiters, the
% width of the delimiters may be different from an array to another because the
% width of the delimiter is fonction of its size. That's why we create an option
-% called |max-delimiter-width| which will give to the delimiters the width of
+% called |delimiters/max-width| which will give to the delimiters the width of
% a delimiter (of the same type) of big size. The following boolean corresponds
% to this option.
% \begin{macrocode}
-\bool_new:N \l_@@_max_delimiter_width_bool
+\bool_new:N \l_@@_delimiters_max_width_bool
% \end{macrocode}
%
% \bigskip
@@ -6153,9 +6303,8 @@ version 2005/12/01 or later.
cell-space-top-limit = #1 ,
cell-space-bottom-limit = #1 ,
} ,
- cell-spaces-limits .value_required:n = true ,
+ cell-space-limits .value_required:n = true ,
xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } ,
- max-delimiter-width .bool_set:N = \l_@@_max_delimiter_width_bool ,
light-syntax .bool_set:N = \l_@@_light_syntax_bool ,
light-syntax .default:n = true ,
end-of-row .tl_set:N = \l_@@_end_of_row_tl ,
@@ -6172,8 +6321,10 @@ version 2005/12/01 or later.
code-for-first-row .value_required:n = true ,
code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl ,
code-for-last-row .value_required:n = true ,
- hlines .bool_set:N = \l_@@_hlines_bool ,
- vlines .bool_set:N = \l_@@_vlines_bool ,
+ hlines .clist_set:N = \l_@@_hlines_clist ,
+ vlines .clist_set:N = \l_@@_vlines_clist ,
+ hlines .default:n = all ,
+ vlines .default:n = all ,
vlines-in-sub-matrix .code:n =
{
\tl_if_single_token:nTF { #1 }
@@ -6183,8 +6334,8 @@ version 2005/12/01 or later.
vlines-in-sub-matrix .value_required:n = true ,
hvlines .code:n =
{
- \bool_set_true:N \l_@@_vlines_bool
- \bool_set_true:N \l_@@_hlines_bool
+ \clist_set:Nn \l_@@_vlines_clist { all }
+ \clist_set:Nn \l_@@_hlines_clist { all }
} ,
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool ,
% \end{macrocode}
@@ -6221,13 +6372,14 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Env }
{
+ delimiters/max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
except-corners .clist_set:N = \l_@@_except_corners_clist ,
except-corners .default:n = { NW , SW , NE , SE } ,
hvlines-except-corners .code:n =
{
\clist_set:Nn \l_@@_except_corners_clist { #1 }
- \bool_set_true:N \l_@@_vlines_bool
- \bool_set_true:N \l_@@_hlines_bool
+ \clist_set:Nn \l_@@_vlines_clist { all }
+ \clist_set:Nn \l_@@_hlines_clist { all }
} ,
hvlines-except-corners .default:n = { NW , SW , NE , SE } ,
code-before .code:n =
@@ -6385,6 +6537,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
+ delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool ,
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
delimiters-color .tl_set:N = \l_@@_delimiters_color_tl ,
@@ -6539,6 +6692,8 @@ version 2005/12/01 or later.
delimiters-color .value_required:n = true ,
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
+ r .code:n = \@@_error:n { r~or~l~with~preamble } ,
+ l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray }
}
% \end{macrocode}
@@ -6555,6 +6710,8 @@ version 2005/12/01 or later.
first-row .code:n = \int_zero:N \l_@@_first_row_int ,
small .bool_set:N = \l_@@_small_bool ,
small .value_forbidden:n = true ,
+ r .code:n = \@@_error:n { r~or~l~with~preamble } ,
+ l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix }
}
% \end{macrocode}
@@ -6575,6 +6732,8 @@ version 2005/12/01 or later.
last-col .code:n = \tl_if_empty:nF {#1}
{ \@@_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l_@@_last_col_int ,
+ r .code:n = \@@_error:n { r~or~l~with~preamble } ,
+ l .code:n = \@@_error:n { r~or~l~with~preamble } ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceTabular }
}
% \end{macrocode}
@@ -6999,24 +7158,33 @@ version 2005/12/01 or later.
% We don't draw the rules of the key |hlines| (or |hvlines|) but we reserve the
% vertical space for theses rules.
% \begin{macrocode}
- \bool_if:NT \l_@@_hlines_bool
+ \tl_if_empty:NF \l_@@_hlines_clist
{
+ \tl_if_eq:NnF \l_@@_hlines_clist { all }
+ {
+ \exp_args:NNx
+ \clist_if_in:NnT
+ \l_@@_hlines_clist
+ { \@@_succ:n \c@iRow }
+ }
+ {
% \end{macrocode}
% The counter |\c@iRow| has the value $-1$ only if there is a ``first
% row'' and that we are before that ``first row'', i.e. just before the
% beginning of the array.
% \begin{macrocode}
- \int_compare:nNnT \c@iRow > { -1 }
- {
- \int_compare:nNnF \c@iRow = \l_@@_last_row_int
+ \int_compare:nNnT \c@iRow > { -1 }
+ {
+ \int_compare:nNnF \c@iRow = \l_@@_last_row_int
% \end{macrocode}
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
% the rules in the array. The package \pkg{nicematrix} uses it even if
% \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope
% of |\CT@arc@|.
% \begin{macrocode}
- { \hrule height \arrayrulewidth width \c_zero_dim }
- }
+ { \hrule height \arrayrulewidth width \c_zero_dim }
+ }
+ }
}
}
}
@@ -7064,12 +7232,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The following code |\@@_pre_array:| is used in |{NiceArrayWithDelims}|. It
+% The following code |\@@_pre_array_ii:| is used in |{NiceArrayWithDelims}|. It
% exists as a standalone macro only for legibility.
% \label{prearray}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_pre_array:
+\cs_new_protected:Npn \@@_pre_array_ii:
{
% \end{macrocode}
% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is
@@ -7260,124 +7428,8 @@ version 2005/12/01 or later.
\tl_gclear_new:N \g_nicematrix_code_before_tl
}
% \end{macrocode}
-% This is the end of |\@@_pre_array:|.
-%
-%
-% \bigskip
-% \subsection*{The environment \{NiceArrayWithDelims\}}
-%
-% \begin{macrocode}
-\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } }
- {
- \@@_provide_pgfsyspdfmark:
- \bool_if:NT \c_@@_footnote_bool \savenotes
-% \end{macrocode}
-% The aim of the following |\bgroup| (the corresponding |\egroup| is, of course,
-% at the end of the environment) is to be able to put an exposant to a matrix in
-% a mathematical formula.
-% \begin{macrocode}
- \bgroup
-% \end{macrocode}
-%
-% \bigskip
-% \begin{macrocode}
- \tl_set:Nn \l_@@_left_delim_tl { #1 }
- \tl_set:Nn \l_@@_right_delim_tl { #2 }
- \tl_gset:Nn \g_@@_preamble_tl { #4 }
-% \end{macrocode}
-%
-%
-% \bigskip
-%
-% \begin{macrocode}
- \int_gzero:N \g_@@_block_box_int
- \dim_zero:N \g_@@_width_last_col_dim
- \dim_zero:N \g_@@_width_first_col_dim
- \bool_gset_false:N \g_@@_row_of_col_done_bool
- \str_if_empty:NT \g_@@_name_env_str
- { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } }
- \@@_adapt_S_column:
- \bool_if:NTF \l_@@_NiceTabular_bool
- \mode_leave_vertical:
- \@@_test_if_math_mode:
- \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } }
- \bool_set_true:N \l_@@_in_env_bool
-% \end{macrocode}
-% The command |\CT@arc@| contains the instruction of color for the rules of the
-% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but
-% we use it also for compatibility with \pkg{colortbl}. But we want also to be
-% able to use color for the rules of the array when \pkg{colortbl} is \emph{not}
-% loaded. That's why we do the following instruction which is in the patch of
-% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the
-% value of |\CT@arc@| at the end of our environment.
-% \begin{macrocode}
- \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@
-% \end{macrocode}
-%
-% We deactivate Tikz externalization because we will use \textsc{pgf} pictures
-% with the options |overlay| and |remember picture| (or equivalent forms). We
-% deactivate with |\tikzexternaldisable| and not with
-% |\tikzset{external/export=false}| which is \emph{not} equivalent.
-% \begin{macrocode}
- \cs_if_exist:NT \tikz@library@external@loaded
- {
- \tikzexternaldisable
- \cs_if_exist:NT \ifstandalone
- { \tikzset { external / optimize = false } }
- }
-% \end{macrocode}
-%
-% We increment the counter |\g_@@_env_int| which counts the environments
-% of the package.
-% \begin{macrocode}
- \int_gincr:N \g_@@_env_int
- \bool_if:NF \l_@@_block_auto_columns_width_bool
- { \dim_gzero_new:N \g_@@_max_cell_width_dim }
-% \end{macrocode}
-%
-%
-% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks
-% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq|
-% will contain only the position of the blocks. Of course, this is redundant but
-% it's for efficiency.
-% \begin{macrocode}
- \seq_gclear:N \g_@@_blocks_seq
- \seq_gclear:N \g_@@_pos_of_blocks_seq
-% \end{macrocode}
-% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the
-% positions of the cells with a |\diagbox|.
+% This is the end of |\@@_pre_array_ii:|.
%
-% \begin{macrocode}
- \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq
- \seq_gclear:N \g_@@_pos_of_xdots_seq
-% \end{macrocode}
-%
-% \begin{macrocode}
- \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl }
- {
- \bool_set_true:N \l_@@_code_before_bool
- \exp_args:NNv \tl_put_right:Nn \l_@@_code_before_tl
- { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl }
- }
-% \end{macrocode}
-%
-% The set of keys is not exactly the same for |{NiceArray}| and for the variants
-% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
-% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
-% \begin{macrocode}
- \bool_if:NTF \l_@@_NiceArray_bool
- { \keys_set:nn { NiceMatrix / NiceArray } }
- { \keys_set:nn { NiceMatrix / pNiceArray } }
- { #3 , #5 }
-% \end{macrocode}
-%
-% \bigskip
-% \begin{macrocode}
- \tl_if_empty:NF \l_@@_rules_color_tl
- { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
-% \end{macrocode}
-%
-%
% \bigskip
% If the key |code-before| is used, we have to create the |col| nodes and the
% |row| nodes before the creation of the array. First, we have to test whether
@@ -7385,6 +7437,9 @@ version 2005/12/01 or later.
% this case, a command |\@@_size_|{\slshape\ttfamily nb_of_env}|:| has been
% created.
% \begin{macrocode}
+\cs_new_protected:Npn \@@_pre_array:
+ {
+ \seq_gclear:N \g_@@_submatrix_seq
\bool_if:NT \l_@@_code_before_bool
{
\seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq }
@@ -7448,7 +7503,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% Now, yet another settings before the executation of the |code-before|.
+% Now, yet other settings before the execution of the |code-before|.
% \begin{macrocode}
\group_begin:
\bool_if:NT \c_@@_tikz_loaded_bool
@@ -7461,17 +7516,30 @@ version 2005/12/01 or later.
}
\cs_set_eq:NN \cellcolor \@@_cellcolor
\cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
+ \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \@@_rowcolor
\cs_set_eq:NN \rowcolors \@@_rowcolors
\cs_set_eq:NN \columncolor \@@_columncolor
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
+ \cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
% \end{macrocode}
% We compose the |code-before| in math mode in order to nullify the spaces put
% by the user between instructions in the |code-before|.
% \begin{macrocode}
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
\seq_clear_new:N \l_@@_colors_seq
- \l_@@_code_before_tl
+% \end{macrocode}
+% Here is the |\CodeBefore|. As of now, the keys that may be provided to the
+% keyword |\CodeBefore| are the same as keys that may be provided to
+% |\CodeAfter|, hence the |\@@_CodeAfter_keys:|.
+% \begin{macrocode}
+ \exp_last_unbraced:NV \@@_CodeAfter_keys: \l_@@_code_before_tl
+% \end{macrocode}
+% Now, all the cells which are specified to be colored by instructions in the
+% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we
+% want to draw all the cells with the same color at the same time to absolutely
+% avoid thin white lines in some \textsc{pdf} viewers.
+% \begin{macrocode}
\@@_actually_color:
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
\group_end:
@@ -7547,9 +7615,9 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \interitem
-% The code in |\@@_pre_array:| is used only by |{NiceArrayWithDelims}|.
+% The code in |\@@_pre_array_ii:| is used only by |{NiceArrayWithDelims}|.
% \begin{macrocode}
- \@@_pre_array:
+ \@@_pre_array_ii:
% \end{macrocode}
%
% \medskip
@@ -7617,6 +7685,150 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% The following command |\@@_pre_array_i:w| will be used when the keyword
+% |\CodeBefore| is present at the beginning of the environment.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_pre_array_i:w #1 \Body
+ {
+ \tl_put_right:Nn \l_@@_code_before_tl { #1 }
+ \bool_set_true:N \l_@@_code_before_bool
+% \end{macrocode}
+% We go on with |\@@_pre_array:| which will (among other) execute the
+% |\CodeBefore| (specified in the key |code-before| or after the keyword
+% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the
+% body of the array...
+% \begin{macrocode}
+ \@@_pre_array:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \subsection*{The environment \{NiceArrayWithDelims\}}
+%
+% \begin{macrocode}
+\NewDocumentEnvironment { NiceArrayWithDelims }
+ { m m O { } m ! O { } t \CodeBefore }
+ {
+ \@@_provide_pgfsyspdfmark:
+ \bool_if:NT \c_@@_footnote_bool \savenotes
+% \end{macrocode}
+% The aim of the following |\bgroup| (the corresponding |\egroup| is, of course,
+% at the end of the environment) is to be able to put an exposant to a matrix in
+% a mathematical formula.
+% \begin{macrocode}
+ \bgroup
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+ \tl_set:Nn \l_@@_left_delim_tl { #1 }
+ \tl_set:Nn \l_@@_right_delim_tl { #2 }
+ \tl_gset:Nn \g_@@_preamble_tl { #4 }
+% \end{macrocode}
+%
+%
+% \bigskip
+%
+% \begin{macrocode}
+ \int_gzero:N \g_@@_block_box_int
+ \dim_zero:N \g_@@_width_last_col_dim
+ \dim_zero:N \g_@@_width_first_col_dim
+ \bool_gset_false:N \g_@@_row_of_col_done_bool
+ \str_if_empty:NT \g_@@_name_env_str
+ { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } }
+ \@@_adapt_S_column:
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ \mode_leave_vertical:
+ \@@_test_if_math_mode:
+ \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } }
+ \bool_set_true:N \l_@@_in_env_bool
+% \end{macrocode}
+% The command |\CT@arc@| contains the instruction of color for the rules of the
+% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but
+% we use it also for compatibility with \pkg{colortbl}. But we want also to be
+% able to use color for the rules of the array when \pkg{colortbl} is \emph{not}
+% loaded. That's why we do the following instruction which is in the patch of
+% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the
+% value of |\CT@arc@| at the end of our environment.
+% \begin{macrocode}
+ \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@
+% \end{macrocode}
+%
+% We deactivate Tikz externalization because we will use \textsc{pgf} pictures
+% with the options |overlay| and |remember picture| (or equivalent forms). We
+% deactivate with |\tikzexternaldisable| and not with
+% |\tikzset{external/export=false}| which is \emph{not} equivalent.
+% \begin{macrocode}
+ \cs_if_exist:NT \tikz@library@external@loaded
+ {
+ \tikzexternaldisable
+ \cs_if_exist:NT \ifstandalone
+ { \tikzset { external / optimize = false } }
+ }
+% \end{macrocode}
+%
+% We increment the counter |\g_@@_env_int| which counts the environments
+% of the package.
+% \begin{macrocode}
+ \int_gincr:N \g_@@_env_int
+ \bool_if:NF \l_@@_block_auto_columns_width_bool
+ { \dim_gzero_new:N \g_@@_max_cell_width_dim }
+% \end{macrocode}
+%
+%
+% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks
+% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq|
+% will contain only the position of the blocks. Of course, this is redundant but
+% it's for efficiency.
+% \begin{macrocode}
+ \seq_gclear:N \g_@@_blocks_seq
+ \seq_gclear:N \g_@@_pos_of_blocks_seq
+% \end{macrocode}
+% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the
+% positions of the cells with a |\diagbox|.
+%
+% \begin{macrocode}
+ \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq
+ \seq_gclear:N \g_@@_pos_of_xdots_seq
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl }
+ {
+ \bool_set_true:N \l_@@_code_before_bool
+ \exp_args:NNv \tl_put_right:Nn \l_@@_code_before_tl
+ { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl }
+ }
+% \end{macrocode}
+%
+% The set of keys is not exactly the same for |{NiceArray}| and for the variants
+% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
+% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
+% \begin{macrocode}
+ \bool_if:NTF \l_@@_NiceArray_bool
+ { \keys_set:nn { NiceMatrix / NiceArray } }
+ { \keys_set:nn { NiceMatrix / pNiceArray } }
+ { #3 , #5 }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_rules_color_tl
+ { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
+% \bigskip
+% \end{macrocode}
+% The argument |#6| is the last argument of |{NiceArrayWithDelims}|. With that
+% argument of type ``|t \CodeBefore|'', we test whether there is the keyword
+% |\CodeBefore| at the beginning of the environment. If that keyword is present,
+% we have now to extract all the content between that keyword |\CodeBefore| and
+% the (other) keyword |\Body|. It's the job that will do the command
+% |\@@_pre_array_i:w|. After that job, the command |\@@_pre_array_i:w| will go
+% on with |\@@_pre_array:|.
+% \begin{macrocode}
+ \IfBooleanTF { #6 } \@@_pre_array_i:w \@@_pre_array:
+ }
+% \end{macrocode}
%
% \begin{macrocode}
{
@@ -7761,6 +7973,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\skip_vertical:N -\l_tmpb_dim
}
+% \end{macrocode}
+% Curiously, we have to put again the following specification of color.
+% Otherwise, with XeLaTeX (and not with the other engines), the closing
+% delimiter is not colored.
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_delimiters_color_tl
+ { \color { \l_@@_delimiters_color_tl } }
\exp_after:wN \right \l_@@_right_delim_tl
\c_math_toggle_token
}
@@ -7769,9 +7988,9 @@ version 2005/12/01 or later.
%
% \smallskip
% We will put the box in the TeX flow. However, we have a small work to do
-% when the option |max-delimiter-width| is used.
+% when the option |delimiters/max-width| is used.
% \begin{macrocode}
- \bool_if:NTF \l_@@_max_delimiter_width_bool
+ \bool_if:NTF \l_@@_delimiters_max_width_bool
{ \@@_put_box_in_flow_bis:nn { #1 } { #2 } }
\@@_put_box_in_flow:
}
@@ -7877,12 +8096,19 @@ version 2005/12/01 or later.
% counter |\c@jCol|.
% \begin{macrocode}
\int_gzero_new:N \c@jCol
- \bool_if:NTF \l_@@_vlines_bool
+ \tl_gclear:N \g_@@_preamble_tl
+ \tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
\tl_gset:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
- { \tl_gclear:N \g_@@_preamble_tl }
+ {
+ \clist_if_in:NnT \l_@@_vlines_clist 1
+ {
+ \tl_gset:Nn \g_@@_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ }
% \end{macrocode}
% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns
% where you will to have to draw vertical lines in the potential sub-matrices
@@ -7925,7 +8151,7 @@ version 2005/12/01 or later.
{
\l_@@_NiceArray_bool
{ \bool_not_p:n \l_@@_NiceTabular_bool }
- { \bool_not_p:n \l_@@_vlines_bool }
+ { \tl_if_empty_p:N \l_@@_vlines_clist }
{ \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
}
{ \tl_gput_left:Nn \g_@@_preamble_tl { @ { } } }
@@ -7937,7 +8163,7 @@ version 2005/12/01 or later.
{
\l_@@_NiceArray_bool
{ \bool_not_p:n \l_@@_NiceTabular_bool }
- { \bool_not_p:n \l_@@_vlines_bool }
+ { \tl_if_empty_p:N \l_@@_vlines_clist }
{ \bool_not_p:n \l_@@_exterior_arraycolsep_bool }
}
{ \tl_gput_right:Nn \g_@@_preamble_tl { @ { } } }
@@ -8242,11 +8468,19 @@ version 2005/12/01 or later.
\str_if_eq:nnTF { #1 } { < }
\@@_patch_preamble_ix:n
{
- \bool_if:NT \l_@@_vlines_bool
+ \tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
\tl_gput_right:Nn \g_@@_preamble_tl
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
+ {
+ \exp_args:NNx
+ \clist_if_in:NnT \l_@@_vlines_clist { \@@_succ:n \c@jCol }
+ {
+ \tl_gput_right:Nn \g_@@_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ }
\@@_patch_preamble:n { #1 }
}
}
@@ -8506,7 +8740,7 @@ version 2005/12/01 or later.
%
% \bigskip
% The command |\@@_put_box_in_flow_bis:| is used when the option
-% |max-delimiter-width| is used because, in this case, we have to adjust the
+% |delimiters/max-width| is used because, in this case, we have to adjust the
% widths of the delimiters. The arguments |#1| and |#2| are the delimiters
% specified by the user.
% \begin{macrocode}
@@ -9380,17 +9614,16 @@ version 2005/12/01 or later.
\cs_set_eq:NN \@@_vline_i:nn \@@_vline_i_complete:nn
\cs_set_eq:NN \@@_hline_i:nn \@@_hline_i_complete:nn
}
- \bool_if:NT \l_@@_hlines_bool \@@_draw_hlines:
- \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ \tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines:
+ \tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines:
% \end{macrocode}
%
% \begin{macrocode}
- \g_@@_internal_code_after_tl
- \tl_gclear:N \g_@@_internal_code_after_tl
+ \cs_set_eq:NN \SubMatrix \@@_SubMatrix
% \end{macrocode}
%
% \bigskip
-% Now, the |\CodeAfter|.
+% Now, the internal |code-after| and then, the |\CodeAfter|.
% \begin{macrocode}
\bool_if:NT \c_@@_tikz_loaded_bool
{
@@ -9405,7 +9638,8 @@ version 2005/12/01 or later.
}
}
\cs_set_eq:NN \line \@@_line
- \cs_set_eq:NN \SubMatrix \@@_SubMatrix
+ \g_@@_internal_code_after_tl
+ \tl_gclear:N \g_@@_internal_code_after_tl
% \end{macrocode}
% When |light-syntax| is used, we insert systematically a |\CodeAfter| in the
% flow. Thus, it's possible to have two instructions |\CodeAfter| and the second
@@ -9654,23 +9888,23 @@ version 2005/12/01 or later.
% We test if we are still in the matrix.
% \begin{macrocode}
\bool_set_false:N \l_@@_final_open_bool
- \int_compare:nNnTF \l_@@_final_i_int > \c@iRow
+ \int_compare:nNnTF \l_@@_final_i_int > \l_@@_row_max_int
{
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l_@@_final_open_bool }
{
- \int_compare:nNnT \l_@@_final_j_int > \c@jCol
+ \int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int
{ \bool_set_true:N \l_@@_final_open_bool }
}
}
{
- \int_compare:nNnTF \l_@@_final_j_int < 1
+ \int_compare:nNnTF \l_@@_final_j_int < \l_@@_col_min_int
{
\int_compare:nNnT { #4 } = { -1 }
{ \bool_set_true:N \l_@@_final_open_bool }
}
{
- \int_compare:nNnT \l_@@_final_j_int > \c@jCol
+ \int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int
{
\int_compare:nNnT { #4 } = 1
{ \bool_set_true:N \l_@@_final_open_bool }
@@ -9722,7 +9956,7 @@ version 2005/12/01 or later.
% a dotted line have to be marked as ``dotted'' because we don't want
% intersections between dotted lines. We recall that the research of the
% extremities of the lines are all done in the same TeX group (the group of the
-% environnement), even though, when the extremities are found, each line is
+% environment), even though, when the extremities are found, each line is
% drawn in a TeX group that we will open for the options of the line.
% \begin{macrocode}
{
@@ -9749,23 +9983,23 @@ version 2005/12/01 or later.
\int_sub:Nn \l_@@_initial_i_int { #3 }
\int_sub:Nn \l_@@_initial_j_int { #4 }
\bool_set_false:N \l_@@_initial_open_bool
- \int_compare:nNnTF \l_@@_initial_i_int < 1
+ \int_compare:nNnTF \l_@@_initial_i_int < \l_@@_row_min_int
{
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l_@@_initial_open_bool }
{
- \int_compare:nNnT \l_@@_initial_j_int = 0
+ \int_compare:nNnT \l_@@_initial_j_int = { \l_@@_col_min_int -1 }
{ \bool_set_true:N \l_@@_initial_open_bool }
}
}
{
- \int_compare:nNnTF \l_@@_initial_j_int < 1
+ \int_compare:nNnTF \l_@@_initial_j_int < \l_@@_col_min_int
{
\int_compare:nNnT { #4 } = 1
{ \bool_set_true:N \l_@@_initial_open_bool }
}
{
- \int_compare:nNnT \l_@@_initial_j_int > \c@jCol
+ \int_compare:nNnT \l_@@_initial_j_int > \l_@@_col_max_int
{
\int_compare:nNnT { #4 } = { -1 }
{ \bool_set_true:N \l_@@_initial_open_bool }
@@ -9827,6 +10061,51 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
+% The following commmand (\emph{when it will be written}) will set the four
+% counters |\l_@@_row_min_int|, |\l_@@_row_max_int|, |\l_@@_col_min_int| and
+% |\l_@@_col_max_int| to the intersections of the sub-matrices which contains
+% the cell of row |#1| and column |#2|.
+% As of now, it's only the whole array (excepted exterior row and columns).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_adjust_to_submatrix:nn #1 #2
+ {
+ \int_set:Nn \l_@@_row_min_int 1
+ \int_set:Nn \l_@@_col_min_int 1
+ \int_set_eq:NN \l_@@_row_max_int \c@iRow
+ \int_set_eq:NN \l_@@_col_max_int \c@jCol
+% \end{macrocode}
+% We do a loop over all the submatrices specified in the |code-before|. We have
+% stored the position of all those submatrices in |\g_@@_submatrix_seq|.
+% \begin{macrocode}
+ \seq_map_inline:Nn \g_@@_submatrix_seq
+ { \@@_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 }
+ }
+% \end{macrocode}
+%
+% \medskip
+% |#1| and |#2| are the numbers of row and columns of the cell where the command
+% of dotted line (ex.: |\Vdots|) has been issued. |#3|, |#4|, |#5| and |#6| are
+% the specification (in $i$ and $j$) of the submatrix where are analysing.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6
+ {
+ \bool_if:nT
+ {
+ \int_compare_p:n { #3 <= #1 }
+ && \int_compare_p:n { #1 <= #5 }
+ && \int_compare_p:n { #4 <= #2 }
+ && \int_compare_p:n { #2 <= #6 }
+ }
+ {
+ \int_set:Nn \l_@@_row_min_int { \int_max:nn \l_@@_row_min_int { #3 } }
+ \int_set:Nn \l_@@_col_min_int { \int_max:nn \l_@@_col_min_int { #4 } }
+ \int_set:Nn \l_@@_row_max_int { \int_min:nn \l_@@_row_max_int { #5 } }
+ \int_set:Nn \l_@@_col_max_int { \int_min:nn \l_@@_col_max_int { #6 } }
+ }
+ }
+% \end{macrocode}
+%
+% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_initial_coords:
{
@@ -9862,12 +10141,74 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_open_x_initial_dim:
+ {
+ \dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim
+ \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int }
+ {
+ \pgfpointanchor
+ { \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int }
+ { west }
+ \dim_set:Nn \l_@@_x_initial_dim
+ { \dim_min:nn \l_@@_x_initial_dim \pgf@x }
+ }
+ }
+% \end{macrocode}
+% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in
+% those cells).
+% \begin{macrocode}
+ \dim_compare:nNnT \l_@@_x_initial_dim = \c_max_dim
+ {
+ \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
+ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \dim_add:Nn \l_@@_x_initial_dim \col@sep
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_open_x_final_dim:
+ {
+ \dim_set:Nn \l_@@_x_final_dim { - \c_max_dim }
+ \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int }
+ {
+ \pgfpointanchor
+ { \@@_env: - ##1 - \int_use:N \l_@@_final_j_int }
+ { east }
+ \dim_set:Nn \l_@@_x_final_dim
+ { \dim_max:nn \l_@@_x_final_dim \pgf@x }
+ }
+ }
+% \end{macrocode}
+% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in
+% those cells).
+% \begin{macrocode}
+ \dim_compare:nNnT \l_@@_x_final_dim = { - \c_max_dim }
+ {
+ \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int }
+ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
+ \dim_sub:Nn \l_@@_x_final_dim \col@sep
+ }
+ }
+% \end{macrocode}
+%
+%
+%
% \interitem
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Ldots:nnn #1 #2 #3
{
+ \@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
@@ -9914,18 +10255,14 @@ version 2005/12/01 or later.
{
\bool_if:NTF \l_@@_initial_open_bool
{
- \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
- \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
- \dim_add:Nn \l_@@_x_initial_dim \col@sep
+ \@@_open_x_initial_dim:
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
}
{ \@@_set_initial_coords_from_anchor:n { base~east } }
\bool_if:NTF \l_@@_final_open_bool
{
- \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int }
- \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
- \dim_sub:Nn \l_@@_x_final_dim \col@sep
+ \@@_open_x_final_dim:
\@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y
}
@@ -9947,6 +10284,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Cdots:nnn #1 #2 #3
{
+ \@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
@@ -9975,6 +10313,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \medskip
% The command |\@@_actually_draw_Cdots:| has the following implicit arguments:
% \begin{itemize}
@@ -9990,18 +10329,10 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_actually_draw_Cdots:
{
\bool_if:NTF \l_@@_initial_open_bool
- {
- \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
- \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
- \dim_add:Nn \l_@@_x_initial_dim \col@sep
- }
+ { \@@_open_x_initial_dim: }
{ \@@_set_initial_coords_from_anchor:n { mid~east } }
\bool_if:NTF \l_@@_final_open_bool
- {
- \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int }
- \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
- \dim_sub:Nn \l_@@_x_final_dim \col@sep
- }
+ { \@@_open_x_final_dim: }
{ \@@_set_final_coords_from_anchor:n { mid~west } }
\bool_lazy_and:nnTF
\l_@@_initial_open_bool
@@ -10023,12 +10354,55 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_open_y_initial_dim:
+ {
+ \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base }
+ \dim_set:Nn \l_@@_y_initial_dim
+ { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
+ \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 }
+ {
+ \pgfpointanchor
+ { \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 }
+ { north }
+ \dim_set:Nn \l_@@_y_initial_dim
+ { \dim_max:nn \l_@@_y_initial_dim \pgf@y }
+ }
+ }
+ }
+% \end{macrocode}
%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_open_y_final_dim:
+ {
+ \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base }
+ \dim_set:Nn \l_@@_y_final_dim
+ { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
+ \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 }
+ {
+ \pgfpointanchor
+ { \@@_env: - \int_use:N \l_@@_final_i_int - ##1 }
+ { south }
+ \dim_set:Nn \l_@@_y_final_dim
+ { \dim_min:nn \l_@@_y_final_dim \pgf@y }
+ }
+ }
+ }
+% \end{macrocode}
+%
% The first and the second arguments are the coordinates of the cell where the
% command has been issued. The third argument is the list of the options.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Vdots:nnn #1 #2 #3
{
+ \@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 0
@@ -10073,6 +10447,9 @@ version 2005/12/01 or later.
% be considered as if.
% \begin{macrocode}
\bool_set_false:N \l_tmpa_bool
+% \end{macrocode}
+% First the case when the line is closed on both ends.
+% \begin{macrocode}
\bool_lazy_or:nnF \l_@@_initial_open_bool \l_@@_final_open_bool
{
\@@_set_initial_coords_from_anchor:n { south~west }
@@ -10085,16 +10462,10 @@ version 2005/12/01 or later.
% considered as if.
% \begin{macrocode}
\bool_if:NTF \l_@@_initial_open_bool
- {
- \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int }
- \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
- }
+ \@@_open_y_initial_dim:
{ \@@_set_initial_coords_from_anchor:n { south } }
\bool_if:NTF \l_@@_final_open_bool
- {
- \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int }
- \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
- }
+ \@@_open_y_final_dim:
{ \@@_set_final_coords_from_anchor:n { north } }
\bool_if:NTF \l_@@_initial_open_bool
{
@@ -10130,8 +10501,7 @@ version 2005/12/01 or later.
{
% \end{macrocode}
% Now the case where both extremities are closed. The first conditional tests
-% whether the column is of type |c| (|C| of |{NiceArray}|) or may be considered
-% as if.
+% whether the column is of type |c| or may be considered as if.
% \begin{macrocode}
\dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim
{
@@ -10158,6 +10528,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Ddots:nnn #1 #2 #3
{
+ \@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 1
@@ -10191,17 +10562,17 @@ version 2005/12/01 or later.
{
\bool_if:NTF \l_@@_initial_open_bool
{
- \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int }
- \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
- \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
- \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \@@_open_y_initial_dim:
+ % \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int }
+ % \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \@@_open_x_initial_dim:
}
{ \@@_set_initial_coords_from_anchor:n { south~east } }
\bool_if:NTF \l_@@_final_open_bool
{
- \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int }
- \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
- \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int }
+ % \@@_open_y_final_dim:
+ % \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int }
+ \@@_open_x_final_dim:
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x
}
{ \@@_set_final_coords_from_anchor:n { north~west } }
@@ -10255,6 +10626,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_Iddots:nnn #1 #2 #3
{
+ \@@_adjust_to_submatrix:nn { #1 } { #2 }
\cs_if_free:cT { @@ _ dotted _ #1 - #2 }
{
\@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 }
@@ -10288,18 +10660,22 @@ version 2005/12/01 or later.
{
\bool_if:NTF \l_@@_initial_open_bool
{
- \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int }
- \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
- \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int }
- \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ % \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int }
+ % \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y
+ \@@_open_y_initial_dim:
+ % \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int }
+ % \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x
+ \@@_open_x_initial_dim:
}
{ \@@_set_initial_coords_from_anchor:n { south~west } }
\bool_if:NTF \l_@@_final_open_bool
{
- \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int }
- \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
- \@@_qpoint:n { col - \int_use:N \l_@@_final_j_int }
- \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
+ % \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int }
+ % \dim_set_eq:NN \l_@@_y_final_dim \pgf@y
+ \@@_open_y_final_dim:
+ % \@@_qpoint:n { col - \int_use:N \l_@@_final_j_int }
+ % \dim_set_eq:NN \l_@@_x_final_dim \pgf@x
+ \@@_open_x_final_dim:
}
{ \@@_set_final_coords_from_anchor:n { north~east } }
\bool_if:NT \l_@@_parallelize_diags_bool
@@ -10404,8 +10780,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points
-% (which gives a dotted line with real round points).
+% The command |\@@_draw_standard_dotted_line:| draws the line with our system of dots
+% (which gives a dotted line with real round dots).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_standard_dotted_line:
{
@@ -10494,7 +10870,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_draw_standard_dotted_line_i:
{
% \end{macrocode}
-% The integer |\l_tmpa_int| is the number of dots of the dotted line.
+% The number of dots will be |\l_tmpa_int + 1|.
% \begin{macrocode}
\bool_if:NTF \l_@@_initial_open_bool
{
@@ -10532,6 +10908,8 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
+%
+% \medskip
% The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the
% vector between two dots in the dotted line.
% \begin{macrocode}
@@ -10860,7 +11238,7 @@ version 2005/12/01 or later.
\AtBeginDocument
{
\tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
- \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
+ \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
% \end{macrocode}
% We don't put |!| before the last optionnal argument for homogeneity with
% |\Cdots|, etc. which have only one optional argument.
@@ -11177,7 +11555,7 @@ version 2005/12/01 or later.
%
% We want to avoid the thin white lines that are shown in some \textsc{pdf}
% viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to
-% draw rectangles of the same color in the same instruction |\pgfusepathqfill|
+% draw rectangles of the same color in the same instruction |\pgfusepath { fill }|
% (and they will be in the same instruction |fill|---coded |f|--- in the
% resulting \textsc{pdf}).
%
@@ -11246,7 +11624,7 @@ version 2005/12/01 or later.
{
\color ##2
\use:c { l_@@_color _ ##1 _tl }
- \pgfusepathqfill
+ \pgfusepath { fill }
}
\endpgfpicture
}
@@ -11282,7 +11660,7 @@ version 2005/12/01 or later.
\tl_set:Nn \l_@@_cols_tl { - }
% \end{macrocode}
% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
+% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
% \begin{macrocode}
\@@_cartesian_path:
}
@@ -11309,7 +11687,7 @@ version 2005/12/01 or later.
\tl_set:Nn \l_@@_cols_tl { #1 }
% \end{macrocode}
% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
+% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
% \begin{macrocode}
\@@_cartesian_path:
}
@@ -11325,14 +11703,29 @@ version 2005/12/01 or later.
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \@@_rectanglecolor:nn { #3 } { #4 } }
+ { \@@_rectanglecolor:nnn { #3 } { #4 } { 0 pt }}
}
}
% \end{macrocode}
%
% \bigskip
+% The last argument is the radius of the corners of the rectangle.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rectanglecolor:nn #1 #2
+\NewDocumentCommand \@@_roundedrectanglecolor { O { } m m m m }
+ {
+ \tl_if_blank:nF { #2 }
+ {
+ \@@_add_to_colors_seq:xn
+ { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
+ { \@@_rectanglecolor:nnn { #3 } { #4 } { #5 } }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The last argument is the radius of the corners of the rectangle.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3
{
\@@_cut_on_hyphen:w #1 \q_stop
\tl_clear_new:N \l_tmpc_tl
@@ -11343,10 +11736,10 @@ version 2005/12/01 or later.
\tl_set:Nx \l_@@_rows_tl { \l_tmpc_tl - \l_tmpa_tl }
\tl_set:Nx \l_@@_cols_tl { \l_tmpd_tl - \l_tmpb_tl }
% \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
+% The command |\@@_cartesian_path:n| takes in two implicit arguments:
+% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
% \begin{macrocode}
- \@@_cartesian_path:
+ \@@_cartesian_path:n { #3 }
}
% \end{macrocode}
%
@@ -11488,10 +11881,10 @@ version 2005/12/01 or later.
{ #3 }
% \end{macrocode}
% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
+% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
% \begin{macrocode}
\@@_cartesian_path:
- \pgfusepathqfill
+ \pgfusepath { fill }
}
\bool_set_false:N \l_tmpa_bool
}
@@ -11507,7 +11900,7 @@ version 2005/12/01 or later.
% |\l_@@_cols_tl| and |\l_@@_row_tl|.
% \begin{macrocode}
\@@_cartesian_path:
- \pgfusepathqfill
+ \pgfusepath { fill }
}
\bool_set_true:N \l_tmpa_bool
}
@@ -11559,14 +11952,17 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
-%
+% \begin{macrocode}
+\cs_new:Npn \@@_cartesian_path: { \@@_cartesian_path:n { 0 pt } }
+% \end{macrocode}
+%
% \bigskip
% The following command uses two implicit arguments : |\l_@@_rows_tl| and
% |\l_@@_cols_tl| which are specifications for a set of rows and a set of
% columns. It creates a path but does \emph{not} fill it. It must be filled by
-% another command after.
+% another command after. The argument is the radius of the corners.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cartesian_path:
+\cs_new_protected:Npn \@@_cartesian_path:n #1
{
% \end{macrocode}
% We begin the loop over the columns.
@@ -11582,6 +11978,13 @@ version 2005/12/01 or later.
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+% \end{macrocode}
+% If we decide to provide the commands |\cellcolor|, |\rectanglecolor|,
+% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors| available in
+% the |code-before| of a |\SubMatrix|, we will have to modify the following
+% line, by adding a kind of offset. We will have also some other rows below in
+% the same command |\@@_cartesian_path:|.
+% \begin{macrocode}
\@@_qpoint:n { col - \l_tmpa_tl }
\int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl
{ \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
@@ -11589,7 +11992,7 @@ version 2005/12/01 or later.
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
\dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
% \end{macrocode}
-% We begin the loop over the rows
+% We begin the loop over the rows.
% \begin{macrocode}
\clist_map_inline:Nn \l_@@_rows_tl
{
@@ -11609,6 +12012,7 @@ version 2005/12/01 or later.
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \l_tmpa_tl }
\dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \pgfsetcornersarced { \pgfpoint { #1 } { #1 } }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpd_dim }
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim }
@@ -11625,7 +12029,15 @@ version 2005/12/01 or later.
\NewDocumentCommand \@@_cellcolor_tabular { O { } m }
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
- { \cellcolor [ #1 ] { #2 } { \int_use:N \c@iRow - \int_use:N \c@jCol } }
+ {
+% \end{macrocode}
+% We must not expand the color (|#2|) because the color may contain the token
+% |!| which may be activated by some packages (ex.: \pkg{babel} with the option
+% |french| on latex and pdflatex).
+% \begin{macrocode}
+ \cellcolor [ #1 ] { \exp_not:n { #2 } }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ }
}
% \end{macrocode}
%
@@ -11637,7 +12049,7 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
- \exp_not:N \rectanglecolor [ #1 ] { #2 }
+ \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
{ \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } }
}
@@ -11655,7 +12067,10 @@ version 2005/12/01 or later.
% columns drawn before the specifications of color for the rows (and the cells).
% \begin{macrocode}
\tl_gput_left:Nx \g_nicematrix_code_before_tl
- { \exp_not:N \columncolor [ #1 ] { #2 } { \int_use:N \c@jCol } }
+ {
+ \exp_not:N \columncolor [ #1 ]
+ { \exp_not:n { #2 } } { \int_use:N \c@jCol }
+ }
}
}
% \end{macrocode}
@@ -11858,7 +12273,7 @@ version 2005/12/01 or later.
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpb_dim \l_tmpa_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpc_dim }
- \pgfusepathqfill
+ \pgfusepath { fill }
\group_end:
}
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
@@ -11897,7 +12312,11 @@ version 2005/12/01 or later.
\int_step_inline:nnn
{ \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
{ \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@jCol } \c@jCol }
- { \@@_vline:nn { ##1 } 1 }
+ {
+ \tl_if_eq:NnF \l_@@_vlines_clist { all }
+ { \clist_if_in:NnT \l_@@_vlines_clist { ##1 } }
+ { \@@_vline:nn { ##1 } 1 }
+ }
}
% \end{macrocode}
%
@@ -12067,7 +12486,11 @@ version 2005/12/01 or later.
\int_step_inline:nnn
{ \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
{ \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow }
- { \@@_hline:nn { ##1 } 1 }
+ {
+ \tl_if_eq:NnF \l_@@_hlines_clist { all }
+ { \clist_if_in:NnT \l_@@_hlines_clist { ##1 } }
+ { \@@_hline:nn { ##1 } 1 }
+ }
}
% \end{macrocode}
%
@@ -13016,12 +13439,8 @@ version 2005/12/01 or later.
r .value_forbidden:n = true ,
c .code:n = \tl_set:Nn \l_@@_pos_of_block_tl c ,
c .value_forbidden:n = true ,
-% \end{macrocode}
-% The two following lines will be uncommented when we will give to the key
-% |color| its new definition.
-% \begin{macrocode}
- % color .tl_set:N = \l_@@_color_tl ,
- % color .value_required:n = true ,
+ color .tl_set:N = \l_@@_color_tl ,
+ color .value_required:n = true ,
}
% \end{macrocode}
%
@@ -13068,7 +13487,8 @@ version 2005/12/01 or later.
% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is
% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a
% missing value by 100 (it's a convention: when the block will actually be drawn
-% these values will be detected and interpreted as \emph{maximal possible value}).
+% these values will be detected and interpreted as \emph{maximal possible
+% value} according to the actual size of the array).
% \begin{macrocode}
\bool_lazy_or:nnTF
{ \tl_if_blank_p:n { #1 } }
@@ -13096,7 +13516,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
% \end{macrocode}
-%
%
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl
@@ -13332,15 +13751,9 @@ version 2005/12/01 or later.
fill .value_required:n = true ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
-% \end{macrocode}
-% The following definition for the key |color| will be deleted when we will give
-% to the key |color| of the command |\Block| its new definition. It will be
-% replaced by the line which is commented.
-% \begin{macrocode}
- color .code:n =
- \@@_fatal:n { Key~color~for~Block }
- \tl_set:Nn \l_@@_fill_tl { #1 } ,
- % color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
+ rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
+ rounded-corners .default:n = 4 pt ,
+ color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
color .value_required:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
@@ -13453,10 +13866,11 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
- \exp_not:N \rectanglecolor
+ \exp_not:N \roundedrectanglecolor
{ \exp_not:V \l_@@_fill_tl }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
+ { \dim_use:N \l_@@_rounded_corners_dim }
}
}
% \end{macrocode}
@@ -13479,7 +13893,7 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{macrocode}
- \hbox_set:Nn \l_@@_cell_box { #6 }
+ \hbox_set:Nn \l_@@_cell_box { \set@color #6 }
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
% \end{macrocode}
%
@@ -13738,7 +14152,7 @@ version 2005/12/01 or later.
%
% % \bigskip
% The first argument of |\@@_stroke_block:nnn| is a list of options for the
-% rectangle that you will stoke. The second argument is the upper-left cell of
+% rectangle that you will stroke. The second argument is the upper-left cell of
% the block (with, as usual, the syntex $i$|-|$j$) and the third is the last
% cell of the block (with the same syntax).
% \begin{macrocode}
@@ -13759,8 +14173,14 @@ version 2005/12/01 or later.
% \begin{macrocode}
\str_if_eq:VnTF \l_@@_draw_tl { default }
{ \CT@arc@ }
- { \pgfsetstrokecolor { \l_@@_draw_tl } }
+ { \exp_args:NV \pgfsetstrokecolor \l_@@_draw_tl }
}
+ \pgfsetcornersarced
+ {
+ \pgfpoint
+ { \dim_use:N \l_@@_rounded_corners_dim }
+ { \dim_use:N \l_@@_rounded_corners_dim }
+ }
\@@_cut_on_hyphen:w #2 \q_stop
\bool_lazy_and:nnT
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
@@ -13783,7 +14203,10 @@ version 2005/12/01 or later.
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
- \pgfusepathqstroke
+% \end{macrocode}
+% We can't use |\pgfusepathqtroke| because of the key |rounded-corners|.
+% \begin{macrocode}
+ \pgfusepath { stroke }
}
\endpgfpicture
\group_end:
@@ -13798,10 +14221,12 @@ version 2005/12/01 or later.
% We will uncomment the following line when we will give to the key |color| of
% the command |\Block| its new definition.
% \begin{macrocode}
- % color .tl_set:N = \l_@@_draw_tl ,
+ color .tl_set:N = \l_@@_draw_tl ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
line-width .dim_set:N = \l_@@_line_width_dim ,
+ rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
+ rounded-corners .default:n = 4 pt
}
% \end{macrocode}
%
@@ -14228,10 +14653,12 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / SubMatrix }
{
- hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
+ hlines .clist_set:N = \l_@@_hlines_clist ,
hlines .default:n = all ,
- vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
+ vlines .clist_set:N = \l_@@_vlines_clist ,
vlines .default:n = all ,
+ hvlines .meta:n = { hlines, vlines } ,
+ hvlines .value_forbidden:n = true ,
name .code:n =
\tl_if_empty:nTF { #1 }
{ \@@_error:n { Invalid~name~format } }
@@ -14249,14 +14676,33 @@ version 2005/12/01 or later.
} ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
+ code .tl_set:N = \l_@@_code_tl ,
+ code .value_required:n = true ,
name .value_required:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix }
}
% \end{macrocode}
%
% \bigskip
-% In the |code-after|, the following command |\@@_SubMatrix| will be linked to
-% |\SubMatrix|.
+% \begin{macrocode}
+\NewDocumentCommand \@@_SubMatrix_in_code_before { m m m m ! O { } }
+ {
+ \@@_cut_on_hyphen:w #3 \q_stop
+ \tl_clear_new:N \l_tmpc_tl
+ \tl_clear_new:N \l_tmpd_tl
+ \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl
+ \@@_cut_on_hyphen:w #2 \q_stop
+ \seq_gput_right:Nx \g_@@_submatrix_seq
+ { { \l_tmpa_tl } { \l_tmpb_tl } { \l_tmpc_tl } { \l_tmpd_tl } }
+ \tl_gput_right:Nn \g_@@_internal_code_after_tl
+ { \SubMatrix { #1 } { #2 } { #3 } { #4 } [ #5 ] }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% In the internal |code-after| and in the |\CodeAfter| the following command
+% |\@@_SubMatrix| will be linked to |\SubMatrix|.
% \begin{itemize}
% \item |#1| is the left delimiter;
% \item |#2| is the upper-left cell of the matrix with the format $i$-$j$;
@@ -14265,26 +14711,35 @@ version 2005/12/01 or later.
% \item |#5| is the list of options of the command.
% \end{itemize}
% \begin{macrocode}
-\NewDocumentCommand \@@_SubMatrix { m m m m ! O { } }
+\NewDocumentCommand \@@_SubMatrix { m m m m O { } }
{
\group_begin:
% \end{macrocode}
+% The four following token lists correspond to the position of the |\SubMatrix|.
+% \begin{macrocode}
+ \tl_clear_new:N \l_@@_first_i_tl
+ \tl_clear_new:N \l_@@_first_j_tl
+ \tl_clear_new:N \l_@@_last_i_tl
+ \tl_clear_new:N \l_@@_last_j_tl
+% \end{macrocode}
% The command |\@@_cut_on_hyphen:w| cuts on the hyphen an argument of the form
% $i$-$j$. The value of $i$ is stored in |\l_tmpa_tl| and the value of $j$ is
% stored in |\l_tmpb_tl|.
% \begin{macrocode}
- \@@_cut_on_hyphen:w #3 \q_stop
- \tl_clear_new:N \l_tmpc_tl
- \tl_clear_new:N \l_tmpd_tl
- \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
- \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl
\@@_cut_on_hyphen:w #2 \q_stop
+ \tl_set_eq:NN \l_@@_first_i_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_@@_first_j_tl \l_tmpb_tl
+ \@@_cut_on_hyphen:w #3 \q_stop
+ \tl_set_eq:NN \l_@@_last_i_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_@@_last_j_tl \l_tmpb_tl
\bool_lazy_or:nnTF
- { \int_compare_p:nNn \l_tmpc_tl > \g_@@_row_total_int }
- { \int_compare_p:nNn \l_tmpd_tl > \g_@@_col_total_int }
+ { \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int }
+ { \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int }
{ \@@_error:n { SubMatrix~too~large } }
{
\str_clear_new:N \l_@@_submatrix_name_str
+ \clist_clear:N \l_@@_hlines_clist
+ \clist_clear:N \l_@@_vlines_clist
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
@@ -14296,43 +14751,43 @@ version 2005/12/01 or later.
% The last value of |\int_step_inline:nnn| is provided by currifycation.
% \begin{macrocode}
\bool_if:NTF \l_@@_submatrix_slim_bool
- { \int_step_inline:nnn \l_tmpa_tl \l_tmpc_tl }
+ { \int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl }
{ \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int }
{
\cs_if_exist:cT
- { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpb_tl }
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl }
{
- \pgfpointanchor { \@@_env: - ##1 - \l_tmpb_tl } { west }
+ \pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west }
\dim_set:Nn \l_@@_x_initial_dim
{ \dim_min:nn \l_@@_x_initial_dim \pgf@x }
}
\cs_if_exist:cT
- { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpd_tl }
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl }
{
- \pgfpointanchor { \@@_env: - ##1 - \l_tmpd_tl } { east }
+ \pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east }
\dim_set:Nn \l_@@_x_final_dim
{ \dim_max:nn \l_@@_x_final_dim \pgf@x }
}
}
- \@@_qpoint:n { row - \l_tmpa_tl - base }
+ \@@_qpoint:n { row - \l_@@_first_i_tl - base }
\dim_set:Nn \l_@@_y_initial_dim
{ \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
- \@@_qpoint:n { row - \l_tmpc_tl - base }
+ \@@_qpoint:n { row - \l_@@_last_i_tl - base }
\dim_set:Nn \l_@@_y_final_dim
{ \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int
{
\cs_if_exist:cT
- { pgf @ sh @ ns @ \@@_env: - \l_tmpa_tl - ##1 }
+ { pgf @ sh @ ns @ \@@_env: - \l_@@_first_i_tl - ##1 }
{
- \pgfpointanchor { \@@_env: - \l_tmpa_tl - ##1 } { north }
+ \pgfpointanchor { \@@_env: - \l_@@_first_i_tl - ##1 } { north }
\dim_set:Nn \l_@@_y_initial_dim
{ \dim_max:nn \l_@@_y_initial_dim \pgf@y }
}
\cs_if_exist:cT
- { pgf @ sh @ ns @ \@@_env: - \l_tmpc_tl - ##1 }
+ { pgf @ sh @ ns @ \@@_env: - \l_@@_last_i_tl - ##1 }
{
- \pgfpointanchor { \@@_env: - \l_tmpc_tl - ##1 } { south }
+ \pgfpointanchor { \@@_env: - \l_@@_last_i_tl - ##1 } { south }
\dim_set:Nn \l_@@_y_final_dim
{ \dim_min:nn \l_@@_y_final_dim \pgf@y }
}
@@ -14360,9 +14815,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_map_inline:Nn \g_@@_cols_vlism_seq
{
- \int_compare:nNnT \l_tmpb_tl < { ##1 }
+ \int_compare:nNnT \l_@@_first_j_tl < { ##1 }
{
- \int_compare:nNnT { ##1 } < { \int_eval:n { \l_tmpd_tl + 1 } }
+ \int_compare:nNnT
+ { ##1 } < { \int_eval:n { \l_@@_last_j_tl + 1 } }
{
% \end{macrocode}
% First, we extract the value of the abscissa of the rule we have to draw.
@@ -14381,15 +14837,17 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all }
- { \int_step_inline:nn { \l_tmpd_tl - \l_tmpb_tl } }
- { \clist_map_inline:Nn \l_@@_submatrix_vlines_clist }
+ \tl_if_eq:NnTF \l_@@_vlines_clist { all }
+ { \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } }
+ { \clist_map_inline:Nn \l_@@_vlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
- { \int_compare_p:nNn { ##1 } < { \l_tmpd_tl - \l_tmpb_tl + 1 } }
+ {
+ \int_compare_p:nNn
+ { ##1 } < { \l_@@_last_j_tl - \l_@@_first_j_tl + 1 } }
{
- \@@_qpoint:n { col - \int_eval:n { ##1 + \l_tmpb_tl } }
+ \@@_qpoint:n { col - \int_eval:n { ##1 + \l_@@_first_j_tl } }
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim }
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim }
\pgfusepathqstroke
@@ -14404,15 +14862,17 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all }
- { \int_step_inline:nn { \l_tmpc_tl - \l_tmpa_tl } }
- { \clist_map_inline:Nn \l_@@_submatrix_hlines_clist }
+ \tl_if_eq:NnTF \l_@@_hlines_clist { all }
+ { \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } }
+ { \clist_map_inline:Nn \l_@@_hlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
- { \int_compare_p:nNn { ##1 } < { \l_tmpc_tl - \l_tmpa_tl + 1 } }
+ {
+ \int_compare_p:nNn
+ { ##1 } < { \l_@@_last_i_tl - \l_@@_first_i_tl + 1 } }
{
- \@@_qpoint:n { row - \int_eval:n { ##1 + \l_tmpa_tl } }
+ \@@_qpoint:n { row - \int_eval:n { ##1 + \l_@@_first_i_tl } }
% \end{macrocode}
% We use a group to protect |\l_tmpa_dim| and |\l_tmpb_dim|.
% \begin{macrocode}
@@ -14495,11 +14955,121 @@ version 2005/12/01 or later.
\@@_node_right:nn #4 { \@@_env: - \l_@@_submatrix_name_str - right }
}
\endpgfpicture
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \cs_set_eq:NN \pgfpointanchor \@@_pgfpointanchor:n
+ \flag_clear_new:n { nicematrix }
+ \l_@@_code_tl
}
\group_end:
}
% \end{macrocode}
+% The group was a group for the whole |\SubMatrix|.
+%
+% \bigskip
+% In the key |code| of the command |\SubMatrix| there may be Tikz instructions.
+% We want that, in these instructions, the $i$ and $j$ in specifications of
+% nodes of the forms $i$|-|$j$, |row-|$i$, |col-|$j$ and $i$\verb+-|+$j$ refer
+% to the number of row and columm \emph{relative} of the current |\SubMatrix|.
+% That's why we will patch (locally in the |\SubMatrix|) the command
+% |\pgfpointanchor|.
+% \begin{macrocode}
+\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor
+% \end{macrocode}
+%
+% \bigskip
+% The following command will be linked to |\pgfpointanchor| just before the
+% execution of the option |code| of the command |\SubMatrix|. In this command,
+% we catch the argument |#1| of |\pgfpointanchor| and we apply to it the command
+% |\@@_pgfpointanchor_i:nn| before passing it to the original |\pgfpointanchor|.
+% We have to act in an expandable way because the command |\pgfpointanchor| is
+% used in names of Tikz nodes which are computed in an expandable way.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_pgfpointanchor:n #1
+ {
+ \use:e
+ { \exp_not:N \@@_old_pgfpointanchor { \@@_pgfpointanchor_i:nn #1 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% In fact, the argument of |\pgfpointanchor| is always of the form
+% |\a_command { name_of_node }| where ``|name_of_node|'' is the name of the Tikz
+% node without the potential prefix and suffix. That's why we catch two
+% arguments and work only on the second by trying (first) to extract an hyphen |-|.
+% \begin{macrocode}
+\cs_new:Npn \@@_pgfpointanchor_i:nn #1 #2
+ { #1 { \@@_pgfpointanchor_ii:w #2 - \q_stop } }
+% \end{macrocode}
%
+% \bigskip
+% Since |\seq_if_in:NnTF| and |\clist_if_in:NnTF| are not expandable, we will
+% use the following token list and |\str_case:nVTF| to test whether we have an
+% integer or not.
+% \begin{macrocode}
+\tl_const:Nn \c_@@_integers_alist_tl
+ {
+ { 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { }
+ { 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { }
+ { 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { }
+ { 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new:Npn \@@_pgfpointanchor_ii:w #1-#2\q_stop
+ {
+% \end{macrocode}
+% If there is no hyphen, that means that the node is of the form of a single
+% number (ex.: |5| or |11|). In that case, we are in an analysis which result
+% from a specification of node of the form $i$\verb+-|+$j$. In that case, the
+% $i$ of the number of row arrives first (and alone) in a |\pgfpointanchor| and,
+% the, the $j$ arrives (alone) in the following |\pgfpointanchor|. In order to
+% know whether we have a number of row of a number of column, we keep track of
+% the number of such treatments by the expandable flag called |nicematrix|.
+% \begin{macrocode}
+ \tl_if_empty:nTF { #2 }
+ {
+ \str_case:nVTF { #1 } \c_@@_integers_alist_tl
+ {
+ \flag_raise:n { nicematrix }
+ \int_if_even:nTF { \flag_height:n { nicematrix } }
+ { \int_eval:n { #1 + \l_@@_first_i_tl - 1 } }
+ { \int_eval:n { #1 + \l_@@_first_j_tl - 1 } }
+ }
+ { #1 }
+ }
+% \end{macrocode}
+% If there is an hyphen, we have to see whether we have a node of the form
+% $i$|-|$j$, |row-|$i$ or |col-|$j$.
+% \begin{macrocode}
+ { \@@_pgfpointanchor_iii:w { #1 } #2 }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% There was an hyphen in the name of the node and that's why we have to retrieve
+% the extra hyphen we have put (cf. |\@@_pgfpointanchor_i:nn|).
+% \begin{macrocode}
+\cs_new:Npn \@@_pgfpointanchor_iii:w #1 #2 -
+ {
+ \str_case:nnF { #1 }
+ {
+ { row } { row - \int_eval:n { #2 + \l_@@_first_i_tl - 1 } }
+ { col } { col - \int_eval:n { #2 + \l_@@_first_j_tl - 1 } }
+ }
+% \end{macrocode}
+% Now the case of a node of the form $i$|-|$j$.
+% \begin{macrocode}
+ {
+ \int_eval:n { #1 + \l_@@_first_i_tl - 1 }
+ - \int_eval:n { #2 + \l_@@_first_j_tl - 1 }
+ }
+ }
+% \end{macrocode}
+%
% \medskip
% The command |\@@_node_left:nn| puts the left delimiter with the correct size.
% The argument |#1| is the delimiter to put. The argument |#2| is the name we
@@ -14868,15 +15438,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \begin{macrocode}
-\@@_msg_new:nn { Key~color~for~Block }
- {
- The~key~'color'~for~the~command~\token_to_str:N \Block\
- is~deprecated:~you~should~use~'fill'~instead.\\
- This~error~is~fatal.
-
- }
-% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { ampersand~in~light-syntax }
@@ -14988,6 +15549,16 @@ version 2005/12/01 or later.
\seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }.
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { r~or~l~with~preamble }
+ {
+ You~can't~use~the~key~'\l_keys_key_str'~in~your~\@@_full_name_env:.~
+ You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~
+ your~\@@_full_name_env:.\\
+ If~you~go~on,~this~key~will~be~ignored.
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { Hdotsfor~in~col~0 }
@@ -15131,8 +15702,8 @@ version 2005/12/01 or later.
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~keys~are~(in~alphabetic~order):~-,~c,~draw,~fill,~l,~
- line-width~and~r.
+ The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~
+ line-width,~rounded-corners~and~r.
}
% \end{macrocode}
%
@@ -15167,12 +15738,13 @@ version 2005/12/01 or later.
'delimiters/color',~
'extra-height',~
'hlines',~
+ 'hvlines',~
'left-xshift',~
'name',~
'right-xshift',~
'rules'~(with~the~subkeys~'color'~and~'width'),~
'slim',~
- 'vlines'~and~'xshift'~(which~set~both~'left-xshift'~
+ 'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~
and~'right-xshift').\\
}
% \end{macrocode}
@@ -15862,9 +16434,21 @@ version 2005/12/01 or later.
% \subsection*{Changes between versions 5.10 and 5.11}
%
% It's now possible, in the |code-before| and in the |\CodeAfter|, to use the
-% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential)
+% syntax \verb+(i-|j)+ for the Tikz node at the intersection of the (potential)
% horizontal rule number~$i$ and the (potential) vertical rule number~$j$.
%
+% % \subsection*{Changes between versions 5.11 and 5.12}
+%
+% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key
+% |code-before|).
+%
+% New key |delimiters/max-width|.
+%
+% New keys |hlines|, |vlines| and |hvlines| for the command |\SubMatrix| in the
+% |\CodeAfter|.
+%
+% New key |rounded-corners| for the command |\Block|.
+%
% \PrintIndex
%
% \tableofcontents
diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf
index a8e3ae524e..18b9e7af32 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix.pdf
Binary files differ