| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% This file should be compiled with $lualatex$. |
| 4 |
%x |
| 5 |
% Copyright (C) 2018-2026 by F. Pantigny |
| 6 |
% ------------------------------------------ |
| 7 |
% |
| 8 |
% This file may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 10 |
% of this license or (at your option) any later version. |
| 11 |
% The latest version of this license is in: |
| 12 |
% |
| 13 |
% http://www.latex-project.org/lppl.txt |
| 14 |
% |
| 15 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 16 |
% version 2005/12/01 or later. |
| 17 |
% |
| 18 |
% \fi |
| 19 |
% \iffalse |
| 20 |
\def\myfileversion{7.9a} |
| 21 |
\def\myfiledate{2026/05/22} |
| 22 |
% |
| 23 |
% |
| 24 |
%<*batchfile> |
| 25 |
\begingroup |
| 26 |
\input l3docstrip.tex |
| 27 |
\keepsilent |
| 28 |
\usedir{tex/latex/nicematrix} |
| 29 |
\preamble |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
Copyright (C) 2018-2026 by F. Pantigny |
| 34 |
----------------------------------- |
| 35 |
|
| 36 |
This file may be distributed and/or modified under the |
| 37 |
conditions of the LaTeX Project Public License, either version 1.3 |
| 38 |
of this license or (at your option) any later version. |
| 39 |
The latest version of this license is in: |
| 40 |
|
| 41 |
http://www.latex-project.org/lppl.txt |
| 42 |
|
| 43 |
and version 1.3 or later is part of all distributions of LaTeX |
| 44 |
version 2005/12/01 or later. |
| 45 |
|
| 46 |
\endpreamble |
| 47 |
\askforoverwritefalse |
| 48 |
\endgroup |
| 49 |
%</batchfile> |
| 50 |
% |
| 51 |
%<*driver> |
| 52 |
\documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by TikZ) |
| 53 |
\VerbatimFootnotes |
| 54 |
|
| 55 |
\usepackage[luatex]{geometry} |
| 56 |
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} |
| 57 |
|
| 58 |
\usepackage{tikz} |
| 59 |
\usetikzlibrary{fit} |
| 60 |
\usepackage{nicematrix} |
| 61 |
|
| 62 |
\NewDocumentEnvironment {scope} {} {} {} |
| 63 |
\def\interitem{\vspace{7mm plus 2 mm minus 3mm}} |
| 64 |
|
| 65 |
\fvset{formatcom=\color{gray}} |
| 66 |
|
| 67 |
\usepackage{upquote} |
| 68 |
|
| 69 |
\usepackage{titlesec} |
| 70 |
\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} |
| 71 |
\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} |
| 72 |
\parindent = 0pt |
| 73 |
\skip \footins = 2 \bigskipamount |
| 74 |
|
| 75 |
|
| 76 |
\begin{document} |
| 77 |
\DocInput{nicematrix-code.dtx} |
| 78 |
\end{document} |
| 79 |
%</driver> |
| 80 |
% \fi |
| 81 |
% \title{The code of the package \pkg{nicematrix}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{nicematrix}, |
| 82 |
% at the date of~\myfiledate.}} |
| 83 |
% \author{F. Pantigny \\ \texttt{[email protected]}} |
| 84 |
% |
| 85 |
% \hypersetup |
| 86 |
% { |
| 87 |
% pdfinfo = |
| 88 |
% { |
| 89 |
% Title = The code of the package 'nicematrix' , |
| 90 |
% Subject = A LaTeX package , |
| 91 |
% Author = F. Pantigny |
| 92 |
% } |
| 93 |
% } |
| 94 |
% |
| 95 |
% |
| 96 |
% \maketitle |
| 97 |
% |
| 98 |
% \begin{abstract} |
| 99 |
% This document is the documented code of the LaTeX package \pkg{nicematrix}. It |
| 100 |
% is \emph{not} its user's guide. The guide of utilisation is the document |
| 101 |
% |nicematrix.pdf| (with a French translation: |nicematrix-french.pdf|). |
| 102 |
% \end{abstract} |
| 103 |
% |
| 104 |
% |
| 105 |
% \bigskip |
| 106 |
% The development of the extension \pkg{nicematrix} is done on the following GitHub |
| 107 |
% depot: |
| 108 |
% |
| 109 |
% \verb|https://github.com/fpantigny/nicematrix| |
| 110 |
% |
| 111 |
% |
| 112 |
% \bigskip |
| 113 |
% \section{Declaration of the package and packages loaded} |
| 114 |
% |
| 115 |
% |
| 116 |
% The prefix |nicematrix| has been registered for this package. |
| 117 |
% |
| 118 |
% See: |http://mirrors.ctan.org/macros/latex/contrib/l3kernel/l3prefixes.pdf| |
| 119 |
% |
| 120 |
%<@@=nicematrix> |
| 121 |
% |
| 122 |
% \bigskip |
| 123 |
% First, we load \pkg{pgfcore} and the module \pkg{shapes}. We do so because |
| 124 |
% it's not possible to use |\usepgfmodule| in |\ExplSyntaxOn|. |
| 125 |
% \begin{macrocode} |
| 126 |
\RequirePackage{pgfcore} |
| 127 |
\usepgfmodule{shapes} |
| 128 |
% \end{macrocode} |
| 129 |
% |
| 130 |
% |
| 131 |
% We give the traditional declaration of a package written with the L3 |
| 132 |
% programming layer. |
| 133 |
% \begin{macrocode} |
| 134 |
\ProvidesExplPackage |
| 135 |
{nicematrix} |
| 136 |
{\myfiledate} |
| 137 |
{\myfileversion} |
| 138 |
{Enhanced arrays with the help of PGF/TikZ} |
| 139 |
% \end{macrocode} |
| 140 |
% |
| 141 |
% |
| 142 |
% \begin{macrocode} |
| 143 |
\msg_new:nnn { nicematrix } { latex-too-old } |
| 144 |
{ |
| 145 |
Your~LaTeX~release~is~too~old. \\ |
| 146 |
You~need~at~least~the~version~of~2025-06-01. \\ |
| 147 |
If~you~use~Overleaf,~you~need~at~least~"TeXLive~2025".\\ |
| 148 |
The~package~'nicematrix'~won't~be~loaded. |
| 149 |
} |
| 150 |
% \end{macrocode} |
| 151 |
% |
| 152 |
% \begin{macrocode} |
| 153 |
\providecommand { \IfFormatAtLeastTF } { \@ifl@t@r \fmtversion } |
| 154 |
\IfFormatAtLeastTF { 2025-06-01 } |
| 155 |
{ } |
| 156 |
{ \msg_critical:nn { nicematrix } { latex-too-old } } |
| 157 |
% \end{macrocode} |
| 158 |
% |
| 159 |
% |
| 160 |
% |
| 161 |
% \bigskip |
| 162 |
% The command for the treatment of the options of |\usepackage| is at the end of |
| 163 |
% this package for technical reasons. |
| 164 |
% |
| 165 |
% \bigskip |
| 166 |
% \begin{macrocode} |
| 167 |
\RequirePackage { amsmath } |
| 168 |
% \end{macrocode} |
| 169 |
% |
| 170 |
% \bigskip |
| 171 |
% \begin{macrocode} |
| 172 |
\RequirePackage{array} |
| 173 |
% \end{macrocode} |
| 174 |
% |
| 175 |
% |
| 176 |
% \bigskip |
| 177 |
% \begin{macrocode} |
| 178 |
\cs_new_protected:Npn \@@_error:n { \msg_error:nn { nicematrix } } |
| 179 |
\cs_new_protected:Npn \@@_warning:n { \msg_warning:nn { nicematrix } } |
| 180 |
\cs_new_protected:Npn \@@_error:nn { \msg_error:nnn { nicematrix } } |
| 181 |
\cs_generate_variant:Nn \@@_error:nn { n e } |
| 182 |
\cs_new_protected:Npn \@@_error:nnn { \msg_error:nnnn { nicematrix } } |
| 183 |
\cs_new_protected:Npn \@@_fatal:n { \msg_fatal:nn { nicematrix } } |
| 184 |
\cs_new_protected:Npn \@@_fatal:nn { \msg_fatal:nnn { nicematrix } } |
| 185 |
\cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { nicematrix } } |
| 186 |
% \end{macrocode} |
| 187 |
% |
| 188 |
% With Overleaf (and also in TeXPage), by default, a document is compiled in |
| 189 |
% non-stop mode. When there is an error, there is no way to the user to use the |
| 190 |
% key H in order to have more information. That's why we decide to put that |
| 191 |
% piece of information (for the messages with such information) in the main part |
| 192 |
% of the message when the key |messages-for-Overleaf| is used (at load-time). |
| 193 |
% \begin{macrocode} |
| 194 |
\cs_new_protected:Npn \@@_msg_new:nnn #1 #2 #3 |
| 195 |
{ |
| 196 |
\bool_if:NTF \g_@@_messages_for_Overleaf_bool |
| 197 |
{ \msg_new:nnn { nicematrix } { #1 } { #2 \\ #3 } } |
| 198 |
{ |
| 199 |
\msg_new:nnnn { nicematrix } { #1 } { #2 } { #3 } |
| 200 |
% \end{macrocode} |
| 201 |
% We keep also in memory in another message the complement of information |
| 202 |
% (generally the list of the available keys) in order to write it the |log| file |
| 203 |
% in all circunstancies (it will be useful for the AI of some systems such as Prism). |
| 204 |
% \begin{macrocode} |
| 205 |
\msg_new:nnn { nicematrix } { #1~+ } { #3 } |
| 206 |
} |
| 207 |
} |
| 208 |
% \end{macrocode} |
| 209 |
% |
| 210 |
% \bigskip |
| 211 |
% We also create a command which will usually generate an error but only a |
| 212 |
% warning on Overleaf. The argument is given by curryfication. |
| 213 |
% \begin{macrocode} |
| 214 |
\cs_new_protected:Npn \@@_error_or_warning:n |
| 215 |
{ |
| 216 |
\bool_if:NTF \g_@@_messages_for_Overleaf_bool |
| 217 |
\@@_warning:n |
| 218 |
\@@_error:n |
| 219 |
} |
| 220 |
% \end{macrocode} |
| 221 |
% |
| 222 |
% We try to detect whether the compilation is done on Overleaf. We use |
| 223 |
% |\c_sys_jobname_str| because, with Overleaf, the value of |\c_sys_jobname_str| |
| 224 |
% is always ``|output|''. |
| 225 |
% \begin{macrocode} |
| 226 |
\bool_new:N \g_@@_messages_for_Overleaf_bool |
| 227 |
\bool_gset:Nn \g_@@_messages_for_Overleaf_bool |
| 228 |
{ |
| 229 |
\str_if_eq_p:on \c_sys_jobname_str { _region_ } % for Emacs |
| 230 |
|| \str_if_eq_p:ee \c_sys_jobname_str { output } % for Overleaf |
| 231 |
} |
| 232 |
% \end{macrocode} |
| 233 |
% |
| 234 |
% |
| 235 |
% |
| 236 |
% \bigskip |
| 237 |
% \begin{macrocode} |
| 238 |
\@@_msg_new:nn { mdwtab~loaded } |
| 239 |
{ |
| 240 |
The~packages~'mdwtab'~and~'nicematrix'~are~incompatible.~ |
| 241 |
This~error~is~fatal. |
| 242 |
} |
| 243 |
% \end{macrocode} |
| 244 |
% |
| 245 |
% \bigskip |
| 246 |
% \begin{macrocode} |
| 247 |
\hook_gput_code:nnn { begindocument / end } { . } |
| 248 |
{ \IfPackageLoadedT { mdwtab } { \@@_fatal:n { mdwtab~loaded } } } |
| 249 |
% \end{macrocode} |
| 250 |
% |
| 251 |
% |
| 252 |
% We test whether the current class is \cls{revtex4-1} (deprecated) or |
| 253 |
% \cls{revtex4-2} because the version 4.2f of \cls{revtex4-2} is incompatible with |
| 254 |
% \pkg{nicematrix}. |
| 255 |
% |
| 256 |
% \begin{macrocode} |
| 257 |
\IfClassLoadedTF { revtex4-1 } |
| 258 |
{ \bool_const:Nn \c_@@_revtex_bool { \c_true_bool } } |
| 259 |
{ |
| 260 |
\IfClassLoadedTF { revtex4-2 } |
| 261 |
{ \bool_const:Nn \c_@@_revtex_bool { \c_true_bool } } |
| 262 |
{ |
| 263 |
% \end{macrocode} |
| 264 |
% Maybe one of the previous classes will be loaded inside another class... We |
| 265 |
% try to detect that situation. |
| 266 |
% \begin{macrocode} |
| 267 |
\cs_if_exist:NT \rvtx@ifformat@geq |
| 268 |
{ \bool_const:Nn \c_@@_revtex_bool { \c_true_bool } } |
| 269 |
{ \bool_const:Nn \c_@@_revtex_bool { \c_false_bool } } |
| 270 |
} |
| 271 |
} |
| 272 |
% \end{macrocode} |
| 273 |
% |
| 274 |
% \begin{macrocode} |
| 275 |
\@@_msg_new:nn { class~revtex } |
| 276 |
{ |
| 277 |
You~can't~use~this~version~of~'nicematrix'~in~a~class~of~REVTeX~because~ |
| 278 |
REVTeX~is~*not*~compatible~with~recent~versions~of~LaTeX.~Sorry...\\ |
| 279 |
The~package~'nicematrix'~won't~be~loaded. |
| 280 |
} |
| 281 |
% \end{macrocode} |
| 282 |
% |
| 283 |
% \begin{macrocode} |
| 284 |
\bool_if:NT \c_@@_revtex_bool |
| 285 |
{ \msg_critical:nn { nicematrix } { class~revtex } } |
| 286 |
% \end{macrocode} |
| 287 |
% |
| 288 |
% \bigskip |
| 289 |
% \section{Collecting options} |
| 290 |
% |
| 291 |
% The following technique allows to create user commands with the ability to put |
| 292 |
% an arbitrary number of |[|\textsl{list of (key=val)}|]| after the name of the |
| 293 |
% command. |
| 294 |
% |
| 295 |
% \medskip |
| 296 |
% \emph{Example} :\par\nobreak |
| 297 |
% |
| 298 |
% |\@@_collect_options:n { \F } [x=a,y=b] [z=c,t=d] { arg }| |
| 299 |
% |
| 300 |
% will be transformed in :\quad |\F{x=a,y=b,z=c,t=d}{arg}| |
| 301 |
% |
| 302 |
% \smallskip |
| 303 |
% Therefore, by writing : |\def\G{\@@_collect_options:n{\F}}|, |
| 304 |
% |
| 305 |
% the command |\G| takes in an arbitrary number of optional arguments between |
| 306 |
% square brackets. |
| 307 |
% |
| 308 |
% Be careful: that command is \emph{not} ``fully expandable'' (because of |
| 309 |
% |\peek_meaning:NTF|). |
| 310 |
% |
| 311 |
% \bigskip |
| 312 |
% \begin{macrocode} |
| 313 |
\cs_new_protected:Npn \@@_collect_options:n #1 |
| 314 |
{ |
| 315 |
\peek_meaning:NTF [ |
| 316 |
{ \@@_collect_options:nw { #1 } } |
| 317 |
{ #1 { } } |
| 318 |
} |
| 319 |
% \end{macrocode} |
| 320 |
% |
| 321 |
% \bigskip |
| 322 |
% We use |\NewDocumentCommand| in order to be able to allow nested brackets |
| 323 |
% within the argument between |[| and |]|. |
| 324 |
% \begin{macrocode} |
| 325 |
\NewDocumentCommand \@@_collect_options:nw { m r[] } |
| 326 |
{ \@@_collect_options:nn { #1 } { #2 } } |
| 327 |
|
| 328 |
\cs_new_protected:Npn \@@_collect_options:nn #1 #2 |
| 329 |
{ |
| 330 |
\peek_meaning:NTF [ |
| 331 |
{ \@@_collect_options:nnw { #1 } { #2 } } |
| 332 |
{ #1 { #2 } } |
| 333 |
} |
| 334 |
|
| 335 |
\cs_new_protected:Npn \@@_collect_options:nnw #1#2[#3] |
| 336 |
{ \@@_collect_options:nn { #1 } { #2 , #3 } } |
| 337 |
% \end{macrocode} |
| 338 |
% |
| 339 |
% |
| 340 |
% \bigskip |
| 341 |
% \section{Technical definitions} |
| 342 |
% |
| 343 |
% Here are definitions that have been added to the LaTeX kernel in February 2006. |
| 344 |
% |
| 345 |
% |
| 346 |
% The following constants are defined only for efficiency in the tests. |
| 347 |
% \begin{macrocode} |
| 348 |
\tl_const:Nn \c_@@_c_tl { c } |
| 349 |
\tl_const:Nn \c_@@_l_tl { l } |
| 350 |
\tl_const:Nn \c_@@_r_tl { r } |
| 351 |
\tl_const:Nn \c_@@_all_tl { all } |
| 352 |
\tl_const:Nn \c_@@_dot_tl { . } |
| 353 |
\str_const:Nn \c_@@_r_str { r } |
| 354 |
\str_const:Nn \c_@@_c_str { c } |
| 355 |
\str_const:Nn \c_@@_l_str { l } |
| 356 |
% \end{macrocode} |
| 357 |
% |
| 358 |
% \begin{macrocode} |
| 359 |
\tl_const:Nn \c_@@_brace_tl { nicematrix/brace } |
| 360 |
\tl_const:Nn \c_@@_mirrored_brace_tl { nicematrix/mirrored-brace } |
| 361 |
% \end{macrocode} |
| 362 |
% |
| 363 |
% |
| 364 |
% |
| 365 |
% \bigskip |
| 366 |
% The following token list will be used for definitions of user commands (with |
| 367 |
% |\NewDocumentCommand|) with an embellishment using an \emph{underscore} (there |
| 368 |
% may be problems because of the catcode of the underscore). |
| 369 |
% \begin{macrocode} |
| 370 |
\tl_new:N \l_@@_argspec_tl |
| 371 |
% \end{macrocode} |
| 372 |
% |
| 373 |
% \begin{macrocode} |
| 374 |
\cs_generate_variant:Nn \seq_set_split:Nnn { N o } |
| 375 |
\cs_generate_variant:Nn \str_set:Nn { N o } |
| 376 |
\cs_generate_variant:Nn \tl_build_put_right:Nn { N o } |
| 377 |
\prg_generate_conditional_variant:Nnn \clist_if_in:Nn { N e } { T , F, TF } |
| 378 |
\prg_generate_conditional_variant:Nnn \tl_if_empty:n { e } { T } |
| 379 |
\prg_generate_conditional_variant:Nnn \tl_if_head_eq_meaning:nN { o N } { TF } |
| 380 |
\cs_generate_variant:Nn \dim_min:nn { v } |
| 381 |
\cs_generate_variant:Nn \dim_max:nn { v } |
| 382 |
% \end{macrocode} |
| 383 |
% |
| 384 |
% \medskip |
| 385 |
% \begin{macrocode} |
| 386 |
\AtBeginDocument |
| 387 |
{ |
| 388 |
\IfPackageLoadedTF { tikz } |
| 389 |
{ |
| 390 |
% \end{macrocode} |
| 391 |
% In some constructions, we will have to use a |{pgfpicture}| which \emph{must} |
| 392 |
% be replaced by a |{tikzpicture}| if TikZ is loaded. However, this switch |
| 393 |
% between |{pgfpicture}| and |{tikzpicture}| can't be done dynamically with a |
| 394 |
% conditional because, when the TikZ library |external| is loaded by the user, |
| 395 |
% the pair |\tikzpicture|-|\endtikpicture| (or |
| 396 |
% |\begin{tikzpicture}-\end{tikzpicture}|) must be statically ``visible'' (even |
| 397 |
% when externalization is not activated). |
| 398 |
% |
| 399 |
% That's why we create |\c_@@_pgfortikzpicture_tl| and |
| 400 |
% |\c_@@_endpgfortikzpicture_tl| which will be used to construct in a |
| 401 |
% |\AtBeginDocument | the correct version of some |
| 402 |
% commands. The tokens |\exp_not:N| are mandatory. |
| 403 |
% \begin{macrocode} |
| 404 |
\tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \tikzpicture } |
| 405 |
\tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endtikzpicture } |
| 406 |
} |
| 407 |
{ |
| 408 |
\tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \pgfpicture } |
| 409 |
\tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture } |
| 410 |
} |
| 411 |
} |
| 412 |
% \end{macrocode} |
| 413 |
% |
| 414 |
% |
| 415 |
% |
| 416 |
% |
| 417 |
% \bigskip |
| 418 |
% If the final user uses \pkg{nicematrix}, PGF/TikZ will write instruction |
| 419 |
% |\pgfsyspdfmark| in the |aux| file. If he changes its mind and no longer loads |
| 420 |
% \pkg{nicematrix}, an error may occur at the next compilation because of |
| 421 |
% remanent instructions |\pgfsyspdfmark| in the |aux| file. With the following |
| 422 |
% code, we try to avoid that situation. |
| 423 |
% \begin{macrocode} |
| 424 |
\cs_new_protected:Npn \@@_provide_pgfsyspdfmark: |
| 425 |
{ |
| 426 |
\iow_now:Nn \@mainaux |
| 427 |
{ |
| 428 |
\ExplSyntaxOn |
| 429 |
\cs_if_free:NT \pgfsyspdfmark |
| 430 |
{ \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } |
| 431 |
\ExplSyntaxOff |
| 432 |
} |
| 433 |
\cs_gset_eq:NN \@@_provide_pgfsyspdfmark: \prg_do_nothing: |
| 434 |
} |
| 435 |
% \end{macrocode} |
| 436 |
% |
| 437 |
% |
| 438 |
% \bigskip |
| 439 |
% We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots |
| 440 |
% going forward ($\iddots$). We use |\ProvideDocumentCommand| and so, if the |
| 441 |
% command |\iddots| has already been defined (for example by the package |
| 442 |
% \pkg{mathdots}), we don't define it again. |
| 443 |
% |
| 444 |
% \begin{macrocode} |
| 445 |
\ProvideDocumentCommand { \iddots } { } |
| 446 |
{ |
| 447 |
\mathinner |
| 448 |
{ |
| 449 |
\mkern 1 mu |
| 450 |
\box_move_up:nn { 1 pt } { \hbox { . } } |
| 451 |
\mkern 2 mu |
| 452 |
\box_move_up:nn { 4 pt } { \hbox { . } } |
| 453 |
\mkern 2 mu |
| 454 |
\box_move_up:nn { 7 pt } |
| 455 |
{ \vbox:n { \kern 7 pt \hbox { . } } } |
| 456 |
\mkern 1 mu |
| 457 |
} |
| 458 |
} |
| 459 |
% \end{macrocode} |
| 460 |
% |
| 461 |
% This definition is a variant of the standard definition of |\ddots|. |
| 462 |
% |
| 463 |
% |
| 464 |
% \bigskip |
| 465 |
% In the |aux| file, we will have the references of the PGF/TikZ nodes created |
| 466 |
% by \pkg{nicematrix}. However, when \pkg{booktabs} is used, some nodes (more |
| 467 |
% precisely, some |row| nodes) will be defined twice because their position will |
| 468 |
% be modified. In order to avoid an error message in this case, we will redefine |
| 469 |
% |\pgfutil@check@rerun| in the |aux| file. |
| 470 |
% \begin{macrocode} |
| 471 |
\AtBeginDocument |
| 472 |
{ |
| 473 |
\IfPackageLoadedT { booktabs } |
| 474 |
{ |
| 475 |
\iow_now:Nn \@mainaux |
| 476 |
{ |
| 477 |
\ExplSyntaxOn |
| 478 |
\cs_if_exist_use:NT \nicematrix@redefine@check@rerun |
| 479 |
\ExplSyntaxOff |
| 480 |
} |
| 481 |
} |
| 482 |
} |
| 483 |
\cs_set_protected:Npn \nicematrix@redefine@check@rerun |
| 484 |
{ |
| 485 |
\let \@@_old_pgfutil@check@rerun \pgfutil@check@rerun |
| 486 |
% \end{macrocode} |
| 487 |
% The new version of |\pgfutil@check@rerun| will not check the PGF nodes whose |
| 488 |
% names start with |nm-| (which is the prefix for the nodes created by |
| 489 |
% \pkg{nicematrix}). |
| 490 |
% \begin{macrocode} |
| 491 |
\cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2 |
| 492 |
{ |
| 493 |
% \end{macrocode} |
| 494 |
% |\str_if_eq:ee(TF)| is slightly faster than |\str_if_eq:nn(TF)|. |
| 495 |
% \begin{macrocode} |
| 496 |
\str_if_eq:eeF { nm- } { \tl_range:nnn { ##1 } { 1 } { 3 } } |
| 497 |
{ \@@_old_pgfutil@check@rerun { ##1 } { ##2 } } |
| 498 |
} |
| 499 |
} |
| 500 |
% \end{macrocode} |
| 501 |
% |
| 502 |
% \bigskip |
| 503 |
% We have to know whether \pkg{colortbl} is loaded in particular for the |
| 504 |
% redefinition of |\everycr|. The command |\@@_everycr:| will be used only |
| 505 |
% in |\@@_some_initialization:|, itself in |\ar@ialign|. |
| 506 |
% \begin{macrocode} |
| 507 |
\AtBeginDocument |
| 508 |
{ |
| 509 |
\cs_set_protected:Npe \@@_everycr: |
| 510 |
{ |
| 511 |
\IfPackageLoadedTF { colortbl } \CT@everycr \everycr |
| 512 |
{ \noalign { \@@_in_everycr: } } |
| 513 |
} |
| 514 |
\IfPackageLoadedTF { colortbl } |
| 515 |
{ |
| 516 |
\cs_new_eq:NN \@@_old_cellcolor: \cellcolor |
| 517 |
\cs_new_eq:NN \@@_old_rowcolor: \rowcolor |
| 518 |
\cs_new_protected:Npn \@@_revert_colortbl: |
| 519 |
{ |
| 520 |
\hook_gput_code:nnn { env / tabular / begin } { nicematrix } |
| 521 |
{ |
| 522 |
\cs_set_eq:NN \cellcolor \@@_old_cellcolor: |
| 523 |
\cs_set_eq:NN \rowcolor \@@_old_rowcolor: |
| 524 |
} |
| 525 |
} |
| 526 |
% \end{macrocode} |
| 527 |
% When \pkg{colortbl} is used, we have to catch the tokens |\columncolor| in the |
| 528 |
% preamble because, otherwise, \pkg{colortbl} will catch them and the colored |
| 529 |
% panels won't be drawn by \pkg{nicematrix}, but by \pkg{colortbl} (with an |
| 530 |
% output which is not perfect). |
| 531 |
% |
| 532 |
% \begin{macrocode} |
| 533 |
\cs_new_protected:Npn \@@_replace_columncolor: |
| 534 |
{ |
| 535 |
\tl_replace_all:Nnn \g_@@_array_preamble_tl |
| 536 |
\columncolor |
| 537 |
\@@_columncolor_preamble |
| 538 |
% \end{macrocode} |
| 539 |
% |\@@_column_preamble|, despite its name, will be defined with |
| 540 |
% |\NewDocumentCommand| because it takes in an optional argument between square |
| 541 |
% brackets in first position for the colorimetric space. |
| 542 |
% \begin{macrocode} |
| 543 |
} |
| 544 |
} |
| 545 |
{ |
| 546 |
\cs_new_protected:Npn \@@_revert_colortbl: { } |
| 547 |
\cs_new_protected:Npn \@@_replace_columncolor: |
| 548 |
{ \cs_set_eq:NN \columncolor \@@_columncolor_preamble } |
| 549 |
% \end{macrocode} |
| 550 |
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of |
| 551 |
% the rules in the array. We will use it to store the instruction of color for |
| 552 |
% the rules even if \pkg{colortbl} is not loaded. |
| 553 |
% \begin{macrocode} |
| 554 |
\def \CT@arc@ { } |
| 555 |
\def \arrayrulecolor #1 # { \CT@arc { #1 } } |
| 556 |
\def \CT@arc #1 #2 |
| 557 |
{ |
| 558 |
\dim_compare:nNnT \baselineskip = \c_zero_dim { \noalign } |
| 559 |
{ \cs_gset_nopar:Npn \CT@arc@ { \color #1 { #2 } } } |
| 560 |
} |
| 561 |
% \end{macrocode} |
| 562 |
% Idem for |\CT@drs@|. |
| 563 |
% \begin{macrocode} |
| 564 |
\def \doublerulesepcolor #1 # { \CT@drs { #1 } } |
| 565 |
\def \CT@drs #1 #2 |
| 566 |
{ |
| 567 |
\dim_compare:nNnT \baselineskip = \c_zero_dim { \noalign } |
| 568 |
{ \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } } |
| 569 |
} |
| 570 |
\def \hline |
| 571 |
{ |
| 572 |
\noalign { \ifnum 0 = `} \fi |
| 573 |
\cs_set_eq:NN \hskip \vskip |
| 574 |
\cs_set_eq:NN \vrule \hrule |
| 575 |
\cs_set_eq:NN \@width \@height |
| 576 |
{ \CT@arc@ \vline } |
| 577 |
\futurelet \reserved@a |
| 578 |
\@xhline |
| 579 |
} |
| 580 |
} |
| 581 |
} |
| 582 |
% \end{macrocode} |
| 583 |
% |
| 584 |
% \bigskip |
| 585 |
% We have to redefine |\cline| for several reasons. The command |\@@_cline:| will |
| 586 |
% be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The |
| 587 |
% following commands must \emph{not} be protected. |
| 588 |
% \begin{macrocode} |
| 589 |
\cs_set_nopar:Npn \@@_standard_cline: #1 { \@@_standard_cline:w #1 \q_stop } |
| 590 |
\cs_set_nopar:Npn \@@_standard_cline:w #1-#2 \q_stop |
| 591 |
{ |
| 592 |
\int_if_zero:nT \l_@@_first_col_int { \omit & } |
| 593 |
\int_compare:nNnT { #1 } > 1 |
| 594 |
{ \multispan { \int_eval:n { #1 - 1 } } & } |
| 595 |
\multispan { \int_eval:n { #2 - #1 + 1 } } |
| 596 |
{ |
| 597 |
\CT@arc@ |
| 598 |
\leaders \hrule \@height \arrayrulewidth \hfill |
| 599 |
% \end{macrocode} |
| 600 |
% The following |\skip_horizontal:N \c_zero_dim| is to prevent a potential |
| 601 |
% |\unskip| to delete the |\leaders|\footnote{See question 99041 on TeX |
| 602 |
% StackExchange.} |
| 603 |
% \begin{macrocode} |
| 604 |
\skip_horizontal:N \c_zero_dim |
| 605 |
} |
| 606 |
% \end{macrocode} |
| 607 |
% Our |\everycr| has been modified. In particular, the creation of the |row| |
| 608 |
% node is in the |\everycr| (maybe we should put it with the incrementation of |
| 609 |
% |\c@iRow|). Since the following |\cr| correspond to a ``false row'', we have |
| 610 |
% to nullify |\everycr|. |
| 611 |
% \begin{macrocode} |
| 612 |
\everycr { } |
| 613 |
\cr |
| 614 |
\noalign { \skip_vertical:n { - \arrayrulewidth } } |
| 615 |
} |
| 616 |
% \end{macrocode} |
| 617 |
% |
| 618 |
% \bigskip |
| 619 |
% The following version of |\cline| spreads the array of a quantity equal |
| 620 |
% to |\arrayrulewidth| as does |\hline|. It will be loaded excepted if the key |
| 621 |
% |standard-cline| has been used. |
| 622 |
% \begin{macrocode} |
| 623 |
\cs_set:Npn \@@_cline: |
| 624 |
% \end{macrocode} |
| 625 |
% We have to act in a fully expandable way since there may be |\noalign| (in the |
| 626 |
% |\multispan|) to detect. That's why we use |\@@_cline_i:en|. |
| 627 |
% \begin{macrocode} |
| 628 |
{ \@@_cline_i:en { \l_@@_first_col_int } } |
| 629 |
% \end{macrocode} |
| 630 |
% The command |\cline_i:nn| has two arguments. The first is the number of the |
| 631 |
% current column (it \emph{must} be used in that column). The second is a |
| 632 |
% standard argument of |\cline| of the form \textsl{i}-\textsl{j} or the form |
| 633 |
% \textsl{i}. |
| 634 |
% \begin{macrocode} |
| 635 |
\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1|#2- \q_stop } |
| 636 |
\cs_generate_variant:Nn \@@_cline_i:nn { e } |
| 637 |
\cs_set:Npn \@@_cline_i:w #1|#2-#3 \q_stop |
| 638 |
{ |
| 639 |
\tl_if_empty:nTF { #3 } |
| 640 |
{ \@@_cline_iii:w #1|#2-#2 \q_stop } |
| 641 |
{ \@@_cline_ii:w #1|#2-#3 \q_stop } |
| 642 |
} |
| 643 |
\cs_set:Npn \@@_cline_ii:w #1|#2-#3- \q_stop |
| 644 |
{ \@@_cline_iii:w #1|#2-#3 \q_stop } |
| 645 |
\cs_set:Npn \@@_cline_iii:w #1|#2-#3 \q_stop |
| 646 |
{ |
| 647 |
% \end{macrocode} |
| 648 |
% Now, |#1| is the number of the current column and we have to draw a line from |
| 649 |
% the column |#2| to the column |#3| (both included). |
| 650 |
% \begin{macrocode} |
| 651 |
\int_compare:nNnT { #1 } < { #2 } |
| 652 |
{ \multispan { \int_eval:n { #2 - #1 } } & } |
| 653 |
\multispan { \int_eval:n { #3 - #2 + 1 } } |
| 654 |
{ |
| 655 |
\CT@arc@ |
| 656 |
\leaders \hrule \@height \arrayrulewidth \hfill |
| 657 |
\skip_horizontal:N \c_zero_dim |
| 658 |
} |
| 659 |
% \end{macrocode} |
| 660 |
% You look whether there is another |\cline| to draw (the final user may put |
| 661 |
% several |\cline|). |
| 662 |
% \begin{macrocode} |
| 663 |
\peek_meaning_remove_ignore_spaces:NTF \cline |
| 664 |
{ & \@@_cline_i:en { \int_eval:n { #3 + 1 } } } |
| 665 |
{ \everycr { } \cr } |
| 666 |
} |
| 667 |
% \end{macrocode} |
| 668 |
% |
| 669 |
% |
| 670 |
% \bigskip |
| 671 |
% The following command will be nullified in the environment |{NiceTabular}|, |
| 672 |
% |{NiceTabular*}| and |{NiceTabularX}|. |
| 673 |
% \begin{macrocode} |
| 674 |
\cs_set:Nn \@@_math_toggle: { $ } % $ |
| 675 |
% \end{macrocode} |
| 676 |
% |
| 677 |
% \bigskip |
| 678 |
% \begin{macrocode} |
| 679 |
\cs_new_protected:Npn \@@_set_CTarc:n #1 |
| 680 |
{ |
| 681 |
\tl_if_blank:nF { #1 } |
| 682 |
{ |
| 683 |
\tl_if_head_eq_meaning:nNTF { #1 } [ |
| 684 |
{ \def \CT@arc@ { \color #1 } } |
| 685 |
{ \def \CT@arc@ { \color { #1 } } } |
| 686 |
} |
| 687 |
} |
| 688 |
\cs_generate_variant:Nn \@@_set_CTarc:n { o } |
| 689 |
% \end{macrocode} |
| 690 |
% |
| 691 |
% \bigskip |
| 692 |
% \begin{macrocode} |
| 693 |
\cs_new_protected:Npn \@@_set_CTdrsc:n #1 |
| 694 |
{ |
| 695 |
\tl_if_head_eq_meaning:nNTF { #1 } [ |
| 696 |
{ \def \CT@drsc@ { \color #1 } } |
| 697 |
{ \def \CT@drsc@ { \color { #1 } } } |
| 698 |
} |
| 699 |
% \end{macrocode} |
| 700 |
% |
| 701 |
% \bigskip |
| 702 |
% The following command must \emph{not} be protected since it will be used to |
| 703 |
% write instructions in the |\g_@@_pre_code_before_tl|. |
| 704 |
% \begin{macrocode} |
| 705 |
\cs_new:Npn \@@_exp_color_arg:Nn #1 #2 |
| 706 |
{ |
| 707 |
\tl_if_head_eq_meaning:nNTF { #2 } [ |
| 708 |
{ #1 #2 } |
| 709 |
{ #1 { #2 } } |
| 710 |
} |
| 711 |
\cs_generate_variant:Nn \@@_exp_color_arg:Nn { N o } |
| 712 |
% \end{macrocode} |
| 713 |
% |
| 714 |
% The following command must be protected because of its use of the command |\color|. |
| 715 |
% \begin{macrocode} |
| 716 |
\cs_new_protected:Npn \@@_color:n #1 |
| 717 |
{ \tl_if_blank:nF { #1 } { \@@_exp_color_arg:Nn \color { #1 } } } |
| 718 |
\cs_generate_variant:Nn \@@_color:n { o } |
| 719 |
% \end{macrocode} |
| 720 |
% |
| 721 |
% |
| 722 |
% \bigskip |
| 723 |
% \begin{macrocode} |
| 724 |
\cs_new_protected:Npn \@@_rescan_for_spanish:N #1 |
| 725 |
{ |
| 726 |
\tl_set_rescan:Nno |
| 727 |
#1 |
| 728 |
{ |
| 729 |
\char_set_catcode_other:N > |
| 730 |
\char_set_catcode_other:N < |
| 731 |
} |
| 732 |
#1 |
| 733 |
} |
| 734 |
% \end{macrocode} |
| 735 |
% |
| 736 |
% \bigskip |
| 737 |
% \bigskip |
| 738 |
% The L3 programming layer provides scratch dimensions |\l_tmpa_dim| and |
| 739 |
% |\l_tmpb_dim|. We create several more in the same spirit. |
| 740 |
% \begin{macrocode} |
| 741 |
\dim_new:N \l_@@_tmpc_dim |
| 742 |
\dim_new:N \l_@@_tmpd_dim |
| 743 |
% \end{macrocode} |
| 744 |
% |
| 745 |
% \begin{macrocode} |
| 746 |
\tl_new:N \l_@@_tmpc_tl |
| 747 |
\tl_new:N \l_@@_tmpd_tl |
| 748 |
% \end{macrocode} |
| 749 |
% |
| 750 |
% \begin{macrocode} |
| 751 |
\int_new:N \l_@@_tmpc_int |
| 752 |
% \end{macrocode} |
| 753 |
% |
| 754 |
% \bigskip |
| 755 |
% \section{Parameters} |
| 756 |
% |
| 757 |
% \bigskip |
| 758 |
% The following counter will count the environments |{NiceArray}|. The value of |
| 759 |
% this counter will be used to prefix the names of the TikZ nodes created in the |
| 760 |
% array. |
| 761 |
% \begin{macrocode} |
| 762 |
\int_new:N \g_@@_env_int |
| 763 |
% \end{macrocode} |
| 764 |
% |
| 765 |
% \bigskip |
| 766 |
% The following command is only a syntaxic shortcut. It must \emph{not} be |
| 767 |
% protected (it will be used in names of \textsc{pgf} nodes). |
| 768 |
% \begin{macrocode} |
| 769 |
\cs_new:Npn \@@_env: { nm - \int_use:N \g_@@_env_int } |
| 770 |
% \end{macrocode} |
| 771 |
% |
| 772 |
% \bigskip |
| 773 |
% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}. |
| 774 |
% It's only a facility given to the final user. It gives the number of the last |
| 775 |
% environment (in fact the number of the current environment but it's meant to |
| 776 |
% be used after the environment in order to refer to that environment --- and |
| 777 |
% its nodes --- without having to give it a name). This command \emph{must} be |
| 778 |
% expandable since it will be used in \pkg{pgf} nodes. |
| 779 |
% \begin{macrocode} |
| 780 |
\NewExpandableDocumentCommand \NiceMatrixLastEnv { } { \int_use:N \g_@@_env_int } |
| 781 |
% \end{macrocode} |
| 782 |
% |
| 783 |
% \medskip |
| 784 |
% The array will be composed in a box (named |\l_@@_the_array_box|) because we |
| 785 |
% have to do manipulations concerning the potential exterior rows. |
| 786 |
% \begin{macrocode} |
| 787 |
\box_new:N \l_@@_the_array_box |
| 788 |
% \end{macrocode} |
| 789 |
% |
| 790 |
% \bigskip |
| 791 |
% The following command is only a syntaxic shortcut. The |q| in |qpoint| means |
| 792 |
% \emph{quick}. |
| 793 |
% \begin{macrocode} |
| 794 |
\cs_new_protected:Npn \@@_qpoint:n #1 |
| 795 |
{ \pgfpointanchor { \@@_env: - #1 } { center } } |
| 796 |
% \end{macrocode} |
| 797 |
% |
| 798 |
% \bigskip |
| 799 |
% If the user uses |{NiceTabular}|, |{NiceTabular*}| or |{NiceTabularX}|, we |
| 800 |
% will raise the following flag. |
| 801 |
% \begin{macrocode} |
| 802 |
\bool_new:N \l_@@_tabular_bool |
| 803 |
% \end{macrocode} |
| 804 |
% |
| 805 |
% \bigskip |
| 806 |
% |\g_@@_delims_bool| will be true for the environments with delimiters (ex. : |
| 807 |
% |{pNiceMatrix}|, |{pNiceArray}|, |\pAutoNiceMatrix|, etc.). |
| 808 |
% \begin{macrocode} |
| 809 |
\bool_new:N \g_@@_delims_bool |
| 810 |
\bool_gset_true:N \g_@@_delims_bool |
| 811 |
% \end{macrocode} |
| 812 |
% In fact, if there is delimiters in the preamble of |{NiceArray}| (eg: |
| 813 |
% |[cccc]|), this boolean will be set to false. |
| 814 |
% |
| 815 |
% \medskip |
| 816 |
% The following boolean will be equal to |true| in the environments which have |
| 817 |
% a preamble (provided by the final user): |{NiceTabular}|, |{NiceArray}|, |
| 818 |
% |{pNiceArray}|, etc. |
| 819 |
% \begin{macrocode} |
| 820 |
\bool_new:N \l_@@_preamble_bool |
| 821 |
\bool_set_true:N \l_@@_preamble_bool |
| 822 |
% \end{macrocode} |
| 823 |
% |
| 824 |
% \medskip |
| 825 |
% We need a special treatment for |{NiceMatrix}| when |vlines| is not used, in |
| 826 |
% order to retrieve |\arraycolsep| on both sides. |
| 827 |
% \begin{macrocode} |
| 828 |
\bool_new:N \l_@@_NiceMatrix_without_vlines_bool |
| 829 |
% \end{macrocode} |
| 830 |
% |
| 831 |
% \bigskip |
| 832 |
% The following counter will count the environments |{NiceMatrixBlock}|. |
| 833 |
% \begin{macrocode} |
| 834 |
\int_new:N \g_@@_NiceMatrixBlock_int |
| 835 |
% \end{macrocode} |
| 836 |
% |
| 837 |
% \bigskip |
| 838 |
% It's possible to put tabular notes (with |\tabularnote|) in the caption if |
| 839 |
% that caption is composed \emph{above} the tabular. In such case, we will count |
| 840 |
% in |\g_@@_notes_caption_int| the number of uses of the command |
| 841 |
% |\tabularnote| \emph{without optional argument} in that caption. |
| 842 |
% \begin{macrocode} |
| 843 |
\int_new:N \g_@@_notes_caption_int |
| 844 |
% \end{macrocode} |
| 845 |
% |
| 846 |
% \bigskip |
| 847 |
% The dimension |\l_@@_columns_width_dim| will be used when the options specify |
| 848 |
% that all the columns must have the same width (but, if the key |columns-width| |
| 849 |
% is used with the special value |auto|, the boolean |
| 850 |
% |\l_@@_auto_columns_width_bool| also will be raised). |
| 851 |
% \begin{macrocode} |
| 852 |
\dim_new:N \l_@@_columns_width_dim |
| 853 |
% \end{macrocode} |
| 854 |
% |
| 855 |
% \bigskip |
| 856 |
% The dimension |\l_@@_col_width_dim| will be available in each cell which |
| 857 |
% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{...}|, |
| 858 |
% |m{...}|, |b{...}| but also |X| (when the actual width of that column is known, that |
| 859 |
% is to say after the first compilation). It's the width of that column. It will |
| 860 |
% be used by some commands |\Block|. A non positive value means that the column |
| 861 |
% has no fixed width (it's a column of type |c|, |r|, |l|, etc.). |
| 862 |
% \begin{macrocode} |
| 863 |
\dim_new:N \l_@@_col_width_dim |
| 864 |
\dim_set:Nn \l_@@_col_width_dim { -1 cm } |
| 865 |
% \end{macrocode} |
| 866 |
% |
| 867 |
% |
| 868 |
% \bigskip |
| 869 |
% The following counters will be used to count the numbers of rows and columns |
| 870 |
% of the array. |
| 871 |
% \begin{macrocode} |
| 872 |
\int_new:N \g_@@_row_total_int |
| 873 |
\int_new:N \g_@@_col_total_int |
| 874 |
% \end{macrocode} |
| 875 |
% |
| 876 |
% \bigskip |
| 877 |
% The following parameter will be used by |\@@_create_row_node:| to avoid to |
| 878 |
% create the same row-node twice (at the end of the array). |
| 879 |
% \begin{macrocode} |
| 880 |
\int_new:N \g_@@_last_row_node_int |
| 881 |
% \end{macrocode} |
| 882 |
% |
| 883 |
% \bigskip |
| 884 |
% The following counter corresponds to the key |nb-rows| of the command |
| 885 |
% |\RowStyle|. |
| 886 |
% \begin{macrocode} |
| 887 |
\int_new:N \l_@@_key_nb_rows_int |
| 888 |
% \end{macrocode} |
| 889 |
% |
| 890 |
% |
| 891 |
% \bigskip |
| 892 |
% The following token list will contain the type of horizontal alignment of the |
| 893 |
% current cell as provided by the corresponding column. The possible values are |
| 894 |
% |r|, |l|, |c| and |j|. For example, a column |p[l]{3cm}| will provide the |
| 895 |
% value |l| for all the cells of the column. |
| 896 |
% \begin{macrocode} |
| 897 |
\tl_new:N \l_@@_hpos_cell_tl |
| 898 |
\tl_set_eq:NN \l_@@_hpos_cell_tl \c_@@_c_tl |
| 899 |
% \end{macrocode} |
| 900 |
% |
| 901 |
% |
| 902 |
% \bigskip |
| 903 |
% When there is a mono-column block (created by the command |\Block|), we want |
| 904 |
% to take into account the width of that block for the width of the column. |
| 905 |
% That's why we compute the width of that block in the |\g_@@_blocks_wd_dim| |
| 906 |
% and, after the construction of the box |\l_@@_cell_box|, we change the width |
| 907 |
% of that box to take into account the length |\g_@@_blocks_wd_dim|. |
| 908 |
% \begin{macrocode} |
| 909 |
\dim_new:N \g_@@_blocks_wd_dim |
| 910 |
% \end{macrocode} |
| 911 |
% |
| 912 |
% \bigskip |
| 913 |
% Idem for the mono-row blocks. |
| 914 |
% \begin{macrocode} |
| 915 |
\dim_new:N \g_@@_blocks_ht_dim |
| 916 |
\dim_new:N \g_@@_blocks_dp_dim |
| 917 |
% \end{macrocode} |
| 918 |
% |
| 919 |
% \bigskip |
| 920 |
% The following dimension correspond to the key |width| (which may be fixed in |
| 921 |
% |\NiceMatrixOptions| but also in an environment |{NiceTabular}|). |
| 922 |
% \begin{macrocode} |
| 923 |
\dim_new:N \l_@@_width_dim |
| 924 |
% \end{macrocode} |
| 925 |
% |
| 926 |
% \bigskip |
| 927 |
% The clist |\g_@@_names_clist| will be the list of all the names of |
| 928 |
% environments used (via the option |name|) in the document: two environments |
| 929 |
% must not have the same name. However, it's possible to use the option |
| 930 |
% |allow-duplicate-names|. |
| 931 |
% \begin{macrocode} |
| 932 |
\clist_new:N \g_@@_names_clist |
| 933 |
% \end{macrocode} |
| 934 |
% |
| 935 |
% \bigskip |
| 936 |
% We want to know whether we are in an environment of \pkg{nicematrix} because we |
| 937 |
% will raise an error if the user tries to use nested environments. |
| 938 |
% \begin{macrocode} |
| 939 |
\bool_new:N \l_@@_in_env_bool |
| 940 |
% \end{macrocode} |
| 941 |
% |
| 942 |
% \bigskip |
| 943 |
% The following key corresponds to the key |notes/detect_duplicates|. |
| 944 |
% \begin{macrocode} |
| 945 |
\bool_new:N \l_@@_notes_detect_duplicates_bool |
| 946 |
\bool_set_true:N \l_@@_notes_detect_duplicates_bool |
| 947 |
% \end{macrocode} |
| 948 |
% |
| 949 |
% \bigskip |
| 950 |
% \begin{macrocode} |
| 951 |
\bool_new:N \l_@@_initial_open_bool |
| 952 |
\bool_new:N \l_@@_final_open_bool |
| 953 |
% \end{macrocode} |
| 954 |
% |
| 955 |
% |
| 956 |
% \bigskip |
| 957 |
% If the user uses |{NiceTabular*}|, the width of the tabular (in the first |
| 958 |
% argument of the environment |{NiceTabular*}|) will be stored in the following |
| 959 |
% dimension. |
| 960 |
% \begin{macrocode} |
| 961 |
\dim_new:N \l_@@_tabular_width_dim |
| 962 |
% \end{macrocode} |
| 963 |
% |
| 964 |
% \bigskip |
| 965 |
% |\l_@@_rule_width_before_dim| will be used before the construction of the array (that |
| 966 |
% is to say during the definition of new types of rules and during the instructions used |
| 967 |
% by the final user in order to require rules of several types). |
| 968 |
% \begin{macrocode} |
| 969 |
\dim_new:N \l_@@_rule_width_before_dim |
| 970 |
% \end{macrocode} |
| 971 |
% |
| 972 |
% |\l_@@_rule_width_before_dim| will be used \emph{after} the construction of the array |
| 973 |
% (that is to say when we are actually drawing the rules). |
| 974 |
% \begin{macrocode} |
| 975 |
\dim_new:N \l_@@_rule_width_after_dim |
| 976 |
% \end{macrocode} |
| 977 |
% We use two variables only for legibility. We could use the same since we are not at all |
| 978 |
% at the same moment in the compilation. |
| 979 |
% |
| 980 |
% \bigskip |
| 981 |
% The key |color| in a command of rule such as |\Hline| (or the specifier |
| 982 |
% ``\verb+|+'' in the preamble of an environment). |
| 983 |
% \begin{macrocode} |
| 984 |
\tl_new:N \l_@@_rule_color_tl |
| 985 |
% \end{macrocode} |
| 986 |
% |
| 987 |
% \bigskip |
| 988 |
% The following boolean will be raised when the command |\rotate| is used. |
| 989 |
% \begin{macrocode} |
| 990 |
\bool_new:N \g_@@_rotate_bool |
| 991 |
% \end{macrocode} |
| 992 |
% |
| 993 |
% \bigskip |
| 994 |
% The following boolean will be raised when the command |\rotate| is used with |
| 995 |
% the key |c|. |
| 996 |
% \begin{macrocode} |
| 997 |
\bool_new:N \g_@@_rotate_c_bool |
| 998 |
% \end{macrocode} |
| 999 |
% |
| 1000 |
% \bigskip |
| 1001 |
% The following boolean will be raised when the command |\rotate| is used with |
| 1002 |
% the key |-90|. |
| 1003 |
% \begin{macrocode} |
| 1004 |
\bool_new:N \g_@@_rotate_minus_bool |
| 1005 |
% \end{macrocode} |
| 1006 |
% |
| 1007 |
% \bigskip |
| 1008 |
% In a cell, it will be possible to know whether we are in a cell of a column of |
| 1009 |
% type |X| thanks to that flag (the |X| columns of \pkg{nicematrix} are inspired |
| 1010 |
% by those of \pkg{tabularx}). You will use that flag for the blocks. |
| 1011 |
% \begin{macrocode} |
| 1012 |
\bool_new:N \l_@@_X_bool |
| 1013 |
% \end{macrocode} |
| 1014 |
% |
| 1015 |
% \bigskip |
| 1016 |
% |\l_@@_V_of_X_bool| during the construction of the preamble when a column of |
| 1017 |
% type |X| uses the key |V| (whose name is inspired by the columns~|V| of the |
| 1018 |
% extension \pkg{varwidth}). |
| 1019 |
% \begin{macrocode} |
| 1020 |
\bool_new:N \l_@@_V_of_X_bool |
| 1021 |
% \end{macrocode} |
| 1022 |
% |
| 1023 |
% \bigskip |
| 1024 |
% The flag |g_@@_V_of_X_bool| will be raised when there is at least in the tabular |
| 1025 |
% a column of type |X| using the key |V|. |
| 1026 |
% \begin{macrocode} |
| 1027 |
\bool_new:N \g_@@_V_of_X_bool |
| 1028 |
% \end{macrocode} |
| 1029 |
% |
| 1030 |
% \begin{macrocode} |
| 1031 |
\bool_new:N \g_@@_caption_finished_bool |
| 1032 |
% \end{macrocode} |
| 1033 |
% |
| 1034 |
% \bigskip |
| 1035 |
% The following boolean will be raised when the key |no-cell-nodes| is used. |
| 1036 |
% \begin{macrocode} |
| 1037 |
\bool_new:N \l_@@_no_cell_nodes_bool |
| 1038 |
% \end{macrocode} |
| 1039 |
% |
| 1040 |
% \bigskip |
| 1041 |
% We will write in |\g_@@_aux_tl| all the instructions that we have to write on |
| 1042 |
% the |aux| file for the current environment. The contain of that token list |
| 1043 |
% will be written on the |aux| file at the end of the environment (in an |
| 1044 |
% instruction |\tl_gset:cn { g_@@_ \int_use:N \g_@@_env_int _ tl }|). |
| 1045 |
% \begin{macrocode} |
| 1046 |
\tl_new:N \g_@@_aux_tl |
| 1047 |
% \end{macrocode} |
| 1048 |
% |
| 1049 |
% During the second run, if information concerning the current environment has |
| 1050 |
% been found in the |aux| file, the following flag will be raised. It will be |
| 1051 |
% used, for instance to disable several constructions (continuous dotted lines, |
| 1052 |
% and colored backgrounds) during the first compilation (in order to speed it up). |
| 1053 |
% \begin{macrocode} |
| 1054 |
\bool_new:N \g_@@_aux_found_bool |
| 1055 |
% \end{macrocode} |
| 1056 |
% |
| 1057 |
% \bigskip |
| 1058 |
% In particuler, in that |aux| file, there will be, for each environment of |
| 1059 |
% \pkg{nicematrix}, an affectation for the the following sequence that will |
| 1060 |
% contain information about the size of the array. |
| 1061 |
% \begin{macrocode} |
| 1062 |
\seq_new:N \g_@@_size_seq |
| 1063 |
% \end{macrocode} |
| 1064 |
% |
| 1065 |
% \bigskip |
| 1066 |
% \begin{macrocode} |
| 1067 |
\tl_new:N \g_@@_left_delim_tl |
| 1068 |
\tl_new:N \g_@@_right_delim_tl |
| 1069 |
% \end{macrocode} |
| 1070 |
% |
| 1071 |
% \bigskip |
| 1072 |
% The token list |\g_@@_user_preamble_tl| will contain the preamble provided by |
| 1073 |
% the the final user of \pkg{nicematrix} (eg the preamble of an environment |
| 1074 |
% |{NiceTabular}|). |
| 1075 |
% \begin{macrocode} |
| 1076 |
\tl_new:N \g_@@_user_preamble_tl |
| 1077 |
% \end{macrocode} |
| 1078 |
% The token list |\g_@@_array_preamble_tl| will contain the preamble constructed |
| 1079 |
% by \pkg{nicematrix} for the environment |{array}| (of \pkg{array}). |
| 1080 |
% \begin{macrocode} |
| 1081 |
\tl_new:N \g_@@_array_preamble_tl |
| 1082 |
% \end{macrocode} |
| 1083 |
% For |\multicolumn|. |
| 1084 |
% \begin{macrocode} |
| 1085 |
\tl_new:N \g_@@_preamble_tl |
| 1086 |
% \end{macrocode} |
| 1087 |
% |
| 1088 |
% \bigskip |
| 1089 |
% The following parameter corresponds to the key |columns-type| of the |
| 1090 |
% environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. and also the key |
| 1091 |
% |matrix / columns-type| of |\NiceMatrixOptions|. |
| 1092 |
% \begin{macrocode} |
| 1093 |
\tl_new:N \l_@@_columns_type_tl |
| 1094 |
\str_set:Nn \l_@@_columns_type_tl { c } |
| 1095 |
% \end{macrocode} |
| 1096 |
% |
| 1097 |
% \bigskip |
| 1098 |
% The following parameters correspond to the keys |down|, |up| and |middle| of a |
| 1099 |
% command such as |\Cdots|. Usually, the final user doesn't use that keys |
| 1100 |
% directly because he uses the syntax with the embellishments |_|, |^| and |:|. |
| 1101 |
% \begin{macrocode} |
| 1102 |
\tl_new:N \l_@@_xdots_down_tl |
| 1103 |
\tl_new:N \l_@@_xdots_up_tl |
| 1104 |
\tl_new:N \l_@@_xdots_middle_tl |
| 1105 |
% \end{macrocode} |
| 1106 |
% |
| 1107 |
% \bigskip |
| 1108 |
% We will store in the following sequence information provided by the |
| 1109 |
% instructions |\rowlistcolors| in the main array (not in the |\CodeBefore|). |
| 1110 |
% \begin{macrocode} |
| 1111 |
\seq_new:N \g_@@_rowlistcolors_seq |
| 1112 |
% \end{macrocode} |
| 1113 |
% |
| 1114 |
% |
| 1115 |
% \bigskip |
| 1116 |
% \begin{macrocode} |
| 1117 |
\cs_new_protected:Npn \@@_test_if_math_mode: |
| 1118 |
{ |
| 1119 |
\if_mode_math: \else: |
| 1120 |
\@@_fatal:n { Outside~math~mode } |
| 1121 |
\fi: |
| 1122 |
} |
| 1123 |
% \end{macrocode} |
| 1124 |
% |
| 1125 |
% |
| 1126 |
% The list of the columns where vertical lines in sub-matrices (vlism) must be |
| 1127 |
% drawn. Of course, the actual value of this sequence will be known after the |
| 1128 |
% analysis of the preamble of the array. |
| 1129 |
% \begin{macrocode} |
| 1130 |
\seq_new:N \g_@@_cols_vlism_seq |
| 1131 |
% \end{macrocode} |
| 1132 |
% |
| 1133 |
% \bigskip |
| 1134 |
% The following colors will be used to memorize the color of the potential ``first |
| 1135 |
% col'' and the potential ``first row''. |
| 1136 |
% \begin{macrocode} |
| 1137 |
\colorlet { nicematrix-last-col } { . } |
| 1138 |
\colorlet { nicematrix-last-row } { . } |
| 1139 |
% \end{macrocode} |
| 1140 |
% \bigskip |
| 1141 |
% The following string is the name of the current environment or the current |
| 1142 |
% command of \pkg{nicematrix} (despite its name which contains \textsl{env}). |
| 1143 |
% \begin{macrocode} |
| 1144 |
\str_new:N \g_@@_name_env_str |
| 1145 |
% \end{macrocode} |
| 1146 |
% |
| 1147 |
% \bigskip |
| 1148 |
% The following string will contain the word \emph{command} or |
| 1149 |
% \emph{environment} whether we are in a command of \pkg{nicematrix} or in an |
| 1150 |
% environment of \pkg{nicematrix}. The default value is \emph{environment}. |
| 1151 |
% \begin{macrocode} |
| 1152 |
\str_new:N \g_@@_com_or_env_str |
| 1153 |
\str_gset:Nn \g_@@_com_or_env_str { environment } |
| 1154 |
% \end{macrocode} |
| 1155 |
% |
| 1156 |
% \bigskip |
| 1157 |
% \begin{macrocode} |
| 1158 |
\bool_new:N \l_@@_bold_row_style_bool |
| 1159 |
% \end{macrocode} |
| 1160 |
% |
| 1161 |
% |
| 1162 |
% \bigskip |
| 1163 |
% |\g_@@_cbic_clist| is for |create-blocks-in-col| |
| 1164 |
% \begin{macrocode} |
| 1165 |
\clist_new:N \g_@@_cbic_clist |
| 1166 |
% \end{macrocode} |
| 1167 |
% |
| 1168 |
% \bigskip |
| 1169 |
% |\g_@@_col_with_trees_clist| is for |draw-trees-in-col| |
| 1170 |
% \begin{macrocode} |
| 1171 |
\clist_new:N \g_@@_col_with_trees_clist |
| 1172 |
% \end{macrocode} |
| 1173 |
% |
| 1174 |
% |
| 1175 |
% \bigskip |
| 1176 |
% The following command will be able to reconstruct the full name of the current |
| 1177 |
% command or environment (despite its name which contains \textsl{env}). This |
| 1178 |
% command must \emph{not} be protected since it will be used in error messages |
| 1179 |
% and we have to use |\str_if_eq:eeTF| and not |\tl_if_eq:eeTF| because we need |
| 1180 |
% to be fully expandable). |\str_if_eq:ee(TF)| is faster than |\str_if_eq:nn(TF)|. |
| 1181 |
% \begin{macrocode} |
| 1182 |
\cs_new:Npn \@@_full_name_env: |
| 1183 |
{ |
| 1184 |
\str_if_eq:eeTF \g_@@_com_or_env_str { command } |
| 1185 |
{ command \space \c_backslash_str \g_@@_name_env_str } |
| 1186 |
{ environment \space \{ \g_@@_name_env_str \} } |
| 1187 |
} |
| 1188 |
% \end{macrocode} |
| 1189 |
% |
| 1190 |
% \bigskip |
| 1191 |
% \begin{macrocode} |
| 1192 |
\tl_new:N \g_@@_cell_after_hook_tl |
| 1193 |
% \end{macrocode} |
| 1194 |
% |
| 1195 |
% The argument is given by curryfication. |
| 1196 |
% \begin{macrocode} |
| 1197 |
\cs_new_protected:Npn \@@_put_in_cell_after_hook:n |
| 1198 |
{ \tl_gput_right:Nn \g_@@_cell_after_hook_tl } |
| 1199 |
% \end{macrocode} |
| 1200 |
% |
| 1201 |
% |
| 1202 |
% |
| 1203 |
% \bigskip |
| 1204 |
% The so-called |\CodeBefore| is split in two parts because we want to control |
| 1205 |
% the order of execution of some instructions. |
| 1206 |
% \begin{macrocode} |
| 1207 |
\tl_new:N \g_@@_pre_code_before_tl |
| 1208 |
\tl_new:N \g_nicematrix_code_before_tl |
| 1209 |
% \end{macrocode} |
| 1210 |
% The value of the key |code-before| will be added to the left of |
| 1211 |
% |\g_@@_pre_code_before_tl|. Idem for the code between |\CodeBefore| and |
| 1212 |
% |\Body|. |
| 1213 |
% |
| 1214 |
% \bigskip |
| 1215 |
% |\g_@@_rules_tl| will contain instructions to draw rules specified by: |
| 1216 |
% |
| 1217 |
% \begin{itemize} |
| 1218 |
% \item the keys |hlines| and |vlines| (and |hvlines|, |hvlines-except-borders|); |
| 1219 |
% \item the specifier \verb+|+ in the preamble of the argument; |
| 1220 |
% \item the commands |\Hline|; |
| 1221 |
% \item the key |hlines|, |vlines| and |hvlines| of a block; |
| 1222 |
% \item the key |draw| of a block; |
| 1223 |
% \item the command |\diagbox|. |
| 1224 |
% \end{itemize} |
| 1225 |
% \begin{macrocode} |
| 1226 |
\tl_new:N \g_@@_rules_tl |
| 1227 |
% \end{macrocode} |
| 1228 |
% |
| 1229 |
% The so-called |\CodeAfter| is split in two parts because we want to control |
| 1230 |
% the order of execution of some instructions. |
| 1231 |
% \begin{macrocode} |
| 1232 |
\tl_new:N \g_@@_pre_code_after_tl |
| 1233 |
\tl_new:N \g_nicematrix_code_after_tl |
| 1234 |
% \end{macrocode} |
| 1235 |
% The |\CodeAfter| provided by the final user (with the key |code-after| or the |
| 1236 |
% keyword |\CodeAfter|) will be stored in the second token list. |
| 1237 |
% |
| 1238 |
% \bigskip |
| 1239 |
% \begin{macrocode} |
| 1240 |
\bool_new:N \l_@@_in_code_after_bool |
| 1241 |
% \end{macrocode} |
| 1242 |
% |
| 1243 |
% |
| 1244 |
% \bigskip |
| 1245 |
% The following parameter will be raised when a block contains an ampersand |
| 1246 |
% (|&|) in its content (=label). |
| 1247 |
% \begin{macrocode} |
| 1248 |
\bool_new:N \l_@@_ampersand_bool |
| 1249 |
% \end{macrocode} |
| 1250 |
% |
| 1251 |
% \bigskip |
| 1252 |
% The counters |\l_@@_old_iRow_int| and |\l_@@_old_jCol_int| will be used to |
| 1253 |
% save the values of the potential LaTeX counters |iRow| and |jCol|. These LaTeX |
| 1254 |
% counters will be restored at the end of the environment. |
| 1255 |
% \begin{macrocode} |
| 1256 |
\int_new:N \l_@@_old_iRow_int |
| 1257 |
\int_new:N \l_@@_old_jCol_int |
| 1258 |
% \end{macrocode} |
| 1259 |
% The TeX counters |\c@iRow| and |\c@jCol| will be created in the beginning of |
| 1260 |
% |{NiceArrayWithDelims}| (if they don't exist previously). |
| 1261 |
% |
| 1262 |
% \bigskip |
| 1263 |
% The following sequence will contain the names (without backslash) of the |
| 1264 |
% commands created by |custom-line| by the key |command| or |ccommand| (commands |
| 1265 |
% used by the final user in order to draw horizontal rules). |
| 1266 |
% \begin{macrocode} |
| 1267 |
\seq_new:N \l_@@_custom_line_commands_seq |
| 1268 |
% \end{macrocode} |
| 1269 |
% |
| 1270 |
% |
| 1271 |
% \bigskip |
| 1272 |
% The sum of the weights of all the |X|-columns in the preamble. |
| 1273 |
% \begin{macrocode} |
| 1274 |
\fp_new:N \g_@@_total_X_weight_fp |
| 1275 |
% \end{macrocode} |
| 1276 |
% |
| 1277 |
% \bigskip |
| 1278 |
% If there is at least one |X|-column in the preamble of the array, the |
| 1279 |
% following flag will be raised via the |aux| file. The length |
| 1280 |
% |l_@@_x_columns_dim| will be the width of |X|-columns of weight $1.0$ (the |
| 1281 |
% width of a column of weight $x$ will be that dimension multiplied by~$x$). |
| 1282 |
% That value is computed after the construction of the array during the first |
| 1283 |
% compilation in order to be used in the following run. |
| 1284 |
% \begin{macrocode} |
| 1285 |
\bool_new:N \l_@@_X_columns_aux_bool |
| 1286 |
\dim_new:N \l_@@_X_columns_dim |
| 1287 |
% \end{macrocode} |
| 1288 |
% |
| 1289 |
% \bigskip |
| 1290 |
% This boolean will be used only to detect in an expandable way whether we are |
| 1291 |
% at the beginning of the (potential) column zero, in order to raise an error if |
| 1292 |
% |\Hdotsfor| is used in that column. |
| 1293 |
% \begin{macrocode} |
| 1294 |
\bool_new:N \g_@@_after_col_zero_bool |
| 1295 |
% \end{macrocode} |
| 1296 |
% |
| 1297 |
% \bigskip |
| 1298 |
% A kind of false row will be inserted at the end of the array for the |
| 1299 |
% construction of the |col| nodes (and also to fix the width of the columns when |
| 1300 |
% |columns-width| is used). When this special row will be created, we will raise |
| 1301 |
% the flag |\g_@@_row_of_col_done_bool| in order to avoid some actions set in |
| 1302 |
% the redefinition of |\everycr| when the last |\cr| of the |\halign| will occur |
| 1303 |
% (after that row of |col| nodes). |
| 1304 |
% \begin{macrocode} |
| 1305 |
\bool_new:N \g_@@_row_of_col_done_bool |
| 1306 |
% \end{macrocode} |
| 1307 |
% |
| 1308 |
% |
| 1309 |
% \bigskip |
| 1310 |
% It's possible to use the command |\NotEmpty| to specify explicitly that a |
| 1311 |
% cell must be considered as non empty by \pkg{nicematrix} (the TikZ nodes are |
| 1312 |
% constructed only in the non empty cells). |
| 1313 |
% \begin{macrocode} |
| 1314 |
\bool_new:N \g_@@_not_empty_cell_bool |
| 1315 |
% \end{macrocode} |
| 1316 |
% |
| 1317 |
% \bigskip |
| 1318 |
% \begin{macrocode} |
| 1319 |
\tl_new:N \l_@@_code_before_tl |
| 1320 |
\bool_new:N \l_@@_code_before_bool |
| 1321 |
% \end{macrocode} |
| 1322 |
% |
| 1323 |
% |
| 1324 |
% \bigskip |
| 1325 |
% The following token list will contain the code inserted in each cell of the |
| 1326 |
% current row (this token list will be cleared at the beginning of each row). |
| 1327 |
% \begin{macrocode} |
| 1328 |
\tl_new:N \g_@@_row_style_tl |
| 1329 |
% \end{macrocode} |
| 1330 |
% |
| 1331 |
% \bigskip |
| 1332 |
% The following dimensions will be used when drawing the dotted lines but also |
| 1333 |
% for the rules. |
| 1334 |
% \begin{macrocode} |
| 1335 |
\dim_new:N \l_@@_x_initial_dim |
| 1336 |
\dim_new:N \l_@@_y_initial_dim |
| 1337 |
\dim_new:N \l_@@_x_final_dim |
| 1338 |
\dim_new:N \l_@@_y_final_dim |
| 1339 |
% \end{macrocode} |
| 1340 |
% |
| 1341 |
% |
| 1342 |
% \bigskip |
| 1343 |
% \begin{macrocode} |
| 1344 |
\dim_new:N \g_@@_dp_row_zero_dim |
| 1345 |
\dim_new:N \g_@@_ht_row_zero_dim |
| 1346 |
\dim_new:N \g_@@_ht_row_one_dim |
| 1347 |
\dim_new:N \g_@@_dp_ante_last_row_dim |
| 1348 |
\dim_new:N \g_@@_ht_last_row_dim |
| 1349 |
\dim_new:N \g_@@_dp_last_row_dim |
| 1350 |
% \end{macrocode} |
| 1351 |
% |
| 1352 |
% \bigskip |
| 1353 |
% Some cells will be declared as ``empty'' (for example a cell with an |
| 1354 |
% instruction |\Cdots|). |
| 1355 |
% \begin{macrocode} |
| 1356 |
\bool_new:N \g_@@_empty_cell_bool |
| 1357 |
% \end{macrocode} |
| 1358 |
% |
| 1359 |
% |
| 1360 |
% \bigskip |
| 1361 |
% The following dimensions will be used internally to compute the width of the |
| 1362 |
% potential ``first column'' and ``last column''. |
| 1363 |
% \begin{macrocode} |
| 1364 |
\dim_new:N \g_@@_width_last_col_dim |
| 1365 |
\dim_new:N \g_@@_width_first_col_dim |
| 1366 |
% \end{macrocode} |
| 1367 |
% |
| 1368 |
% \bigskip |
| 1369 |
% The following sequence will contain the characteristics of the blocks of the |
| 1370 |
% array, specified by the command |\Block|. Each block is represented by 6 |
| 1371 |
% components surrounded by curly braces: |
| 1372 |
% |
| 1373 |
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|. |
| 1374 |
% |
| 1375 |
% The variable is global because it will be modified in the cells of the array. |
| 1376 |
% \begin{macrocode} |
| 1377 |
\seq_new:N \g_@@_blocks_seq |
| 1378 |
% \end{macrocode} |
| 1379 |
% We also manage a sequence of the \emph{positions} of the blocks. In that |
| 1380 |
% sequence, each block is represented by only five components: |
| 1381 |
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{name}|}|. |
| 1382 |
% A block with the key |hvlines| won't appear in that |
| 1383 |
% sequence (otherwise, the lines in that block would not be drawn!). |
| 1384 |
% \begin{macrocode} |
| 1385 |
\seq_new:N \g_@@_pos_of_blocks_seq |
| 1386 |
% \end{macrocode} |
| 1387 |
% In fact, this sequence will also contain the positions of the cells with a |
| 1388 |
% |\diagbox|. The sequence |\g_@@_pos_of_blocks_seq| will be used when we will |
| 1389 |
% draw the rules (which respect the blocks). |
| 1390 |
% |
| 1391 |
% \bigskip |
| 1392 |
% In the |\CodeBefore|, the value of |\g_@@_pos_of_blocks_seq| will be the value |
| 1393 |
% read in the |aux| file from a previous run. However, in the |\CodeBefore|, the |
| 1394 |
% commands |\EmptyColumn| and |\EmptyRow| will write virtual positions of blocks |
| 1395 |
% in the following sequence. |
| 1396 |
% \begin{macrocode} |
| 1397 |
\seq_new:N \g_@@_future_pos_of_blocks_seq |
| 1398 |
% \end{macrocode} |
| 1399 |
% They will be added to |\g_@@_pos_of_blocks_seq| after the computation of the |
| 1400 |
% ``empty corners''. |
| 1401 |
% |
| 1402 |
% \bigskip |
| 1403 |
% We will also manage a sequence for the positions of the dotted lines. These |
| 1404 |
% dotted lines are created in the array by |\Cdots|, |\Vdots|, |\Ddots|, etc. |
| 1405 |
% However, their positions, that is to say, their extremities, will be |
| 1406 |
% determined only after the construction of the array. In this sequence, each |
| 1407 |
% item contains five components: |
| 1408 |
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|% |
| 1409 |
% \textsl{name}|}|. |
| 1410 |
% \begin{macrocode} |
| 1411 |
\seq_new:N \g_@@_pos_of_xdots_seq |
| 1412 |
% \end{macrocode} |
| 1413 |
% The sequence |\g_@@_pos_of_xdots_seq| will be used when we will draw the rules |
| 1414 |
% required by the key |hvlines| (these rules won't be drawn within the virtual |
| 1415 |
% blocks corresponding to the dotted lines). |
| 1416 |
% |
| 1417 |
% \medskip |
| 1418 |
% The final user may decide to ``stroke'' a block (using, for example, the key |
| 1419 |
% |draw=red!15| when using the command |\Block|). In that case, the rules |
| 1420 |
% specified, for instance, by |hvlines| must not be drawn around the block. |
| 1421 |
% That's why we keep the information of all that stroken blocks in the following |
| 1422 |
% sequence. |
| 1423 |
% \begin{macrocode} |
| 1424 |
\seq_new:N \g_@@_pos_of_stroken_blocks_seq |
| 1425 |
% \end{macrocode} |
| 1426 |
% |
| 1427 |
% \medskip |
| 1428 |
% If the user has used the key |corners|, all the cells which are in an (empty) |
| 1429 |
% corner will be stored in the following list. We use a |clist| instead of a |
| 1430 |
% |seq| because we will frequently search in that list (and searching in a |
| 1431 |
% |clist| is faster than searching in a |seq|). |
| 1432 |
% \begin{macrocode} |
| 1433 |
\clist_new:N \l_@@_corners_cells_clist |
| 1434 |
% \end{macrocode} |
| 1435 |
% |
| 1436 |
% \medskip |
| 1437 |
% The list of the names of the potential |\SubMatrix| in the |\CodeAfter| of an |
| 1438 |
% environment. Unfortunately, that list has to be global (we have to use it |
| 1439 |
% inside the group for the options of a given |\SubMatrix|). |
| 1440 |
% \begin{macrocode} |
| 1441 |
\seq_new:N \g_@@_submatrix_names_seq |
| 1442 |
% \end{macrocode} |
| 1443 |
% |
| 1444 |
% \medskip |
| 1445 |
% The following flag will be raised if the key |width| is used in an environment |
| 1446 |
% |{NiceTabular}| (not in a command |\NiceMatrixOptions|). You use it to raise |
| 1447 |
% an error when this key is used while no column |X| is used. |
| 1448 |
% \begin{macrocode} |
| 1449 |
\bool_new:N \l_@@_width_used_bool |
| 1450 |
% \end{macrocode} |
| 1451 |
% |
| 1452 |
% \medskip |
| 1453 |
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells |
| 1454 |
% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is |
| 1455 |
% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the |
| 1456 |
% values of $n$) correspondent will be stored. These lists will be used for the |
| 1457 |
% creation of the ``medium nodes'' (if they are created). |
| 1458 |
% \begin{macrocode} |
| 1459 |
\seq_new:N \g_@@_multicolumn_cells_seq |
| 1460 |
\seq_new:N \g_@@_multicolumn_sizes_seq |
| 1461 |
% \end{macrocode} |
| 1462 |
% |
| 1463 |
% \medskip |
| 1464 |
% The following counter will be used for structures such as |\Hline\Hline|. |
| 1465 |
% \begin{macrocode} |
| 1466 |
\int_new:N \l_@@_multiplicity_int |
| 1467 |
\int_set:Nn \l_@@_multiplicity_int { 1 } |
| 1468 |
% \end{macrocode} |
| 1469 |
% |
| 1470 |
% \medskip |
| 1471 |
% By default, the diagonal lines will be parallelized\footnote{It's possible to |
| 1472 |
% use the option |parallelize-diags| to disable this parallelization.}. There |
| 1473 |
% are two types of diagonals lines: the $|\Ddots|$ diagonals and the |\Iddots| |
| 1474 |
% diagonals. We have to count both types in order to know whether a diagonal is |
| 1475 |
% the first of its type in the current |{NiceArray}| environment. |
| 1476 |
% \begin{macrocode} |
| 1477 |
\int_new:N \g_@@_ddots_int |
| 1478 |
\int_new:N \g_@@_iddots_int |
| 1479 |
% \end{macrocode} |
| 1480 |
% |
| 1481 |
% The dimensions |\g_@@_delta_x_one_dim| and |\g_@@_delta_y_one_dim| will |
| 1482 |
% contain the $\Delta_x$ and $\Delta_y$ of the first |\Ddots| diagonal. We have |
| 1483 |
% to store these values in order to draw the others |\Ddots| diagonals parallel |
| 1484 |
% to the first one. Similarly |\g_@@_delta_x_two_dim| and |
| 1485 |
% |\g_@@_delta_y_two_dim| are the $\Delta_x$ and $\Delta_y$ of the first |
| 1486 |
% |\Iddots| diagonal. |
| 1487 |
% \begin{macrocode} |
| 1488 |
\dim_new:N \g_@@_delta_x_one_dim |
| 1489 |
\dim_new:N \g_@@_delta_y_one_dim |
| 1490 |
\dim_new:N \g_@@_delta_x_two_dim |
| 1491 |
\dim_new:N \g_@@_delta_y_two_dim |
| 1492 |
% \end{macrocode} |
| 1493 |
% |
| 1494 |
% \medskip |
| 1495 |
% The following counters will be used when searching the extremities of a dotted |
| 1496 |
% line (we need these counters because of the potential ``open'' lines in the |
| 1497 |
% |\SubMatrix|---the |\SubMatrix| in the |code-before|). |
| 1498 |
% \begin{macrocode} |
| 1499 |
\int_new:N \l_@@_row_min_int |
| 1500 |
\int_new:N \l_@@_row_max_int |
| 1501 |
\int_new:N \l_@@_col_min_int |
| 1502 |
\int_new:N \l_@@_col_max_int |
| 1503 |
% \end{macrocode} |
| 1504 |
% |
| 1505 |
% \medskip |
| 1506 |
% \begin{macrocode} |
| 1507 |
\int_new:N \l_@@_initial_i_int |
| 1508 |
\int_new:N \l_@@_initial_j_int |
| 1509 |
\int_new:N \l_@@_final_i_int |
| 1510 |
\int_new:N \l_@@_final_j_int |
| 1511 |
% \end{macrocode} |
| 1512 |
% |
| 1513 |
% \medskip |
| 1514 |
% The following counters will be used when drawing the rules. |
| 1515 |
% \begin{macrocode} |
| 1516 |
\int_new:N \l_@@_segment_start_int |
| 1517 |
\int_new:N \l_@@_segment_end_int |
| 1518 |
% \end{macrocode} |
| 1519 |
% |
| 1520 |
% \medskip |
| 1521 |
% The following sequence will be used when the command |\SubMatrix| is used in |
| 1522 |
% the |\CodeBefore| (and not in the |\CodeAfter|). It will contain the position of |
| 1523 |
% all the sub-matrices specified in the |\CodeBefore|. Each sub-matrix is |
| 1524 |
% represented by an ``object'' of the form |{|$i$|}{|$j$|}{|$k$|}{|$l$|}| |
| 1525 |
% where $i$ and $j$ are the number of row and column of the upper-left cell and |
| 1526 |
% $k$ and $l$ the number of row and column of the lower-right cell. |
| 1527 |
% \begin{macrocode} |
| 1528 |
\seq_new:N \g_@@_submatrix_seq |
| 1529 |
% \end{macrocode} |
| 1530 |
% |
| 1531 |
% \medskip |
| 1532 |
% We are able to determine the number of columns specified in the preamble (for |
| 1533 |
% the environments with explicit preamble of course and without the potential |
| 1534 |
% exterior columns). |
| 1535 |
% \begin{macrocode} |
| 1536 |
\int_new:N \g_@@_static_num_of_col_int |
| 1537 |
% \end{macrocode} |
| 1538 |
% |
| 1539 |
% \medskip |
| 1540 |
% The following parameters correspond to the keys |fill|, |opacity|, |draw|, |
| 1541 |
% |tikz|, |borders|, and |rounded-corners| of the command |\Block|. |
| 1542 |
% \begin{macrocode} |
| 1543 |
\tl_new:N \l_@@_draw_tl |
| 1544 |
\seq_new:N \l_@@_tikz_seq |
| 1545 |
\tl_new:N \l_@@_tikz_rule_tl |
| 1546 |
% \end{macrocode} |
| 1547 |
% The last parameter has no direct link with the [empty] corners of the array |
| 1548 |
% (which are computed and taken into account by \pkg{nicematrix} when the key |
| 1549 |
% |corners| is used). |
| 1550 |
% |
| 1551 |
% |
| 1552 |
% \medskip |
| 1553 |
% The parameters of the horizontal position of the label of a block. If the user |
| 1554 |
% uses the key |c| or |C|, the value is |c|. If the user uses the key |l| or |
| 1555 |
% |L|, the value is |l|. If the user uses the key |r| or |R|, the value is |r|. |
| 1556 |
% If the user has used a capital letter, the boolean |
| 1557 |
% |\l_@@_hpos_of_block_cap_bool| will be raised (in the second pass of the |
| 1558 |
% analyze of the keys of the command |\Block|). |
| 1559 |
% \begin{macrocode} |
| 1560 |
\str_new:N \l_@@_hpos_block_str |
| 1561 |
\str_set:Nn \l_@@_hpos_block_str { c } |
| 1562 |
\bool_new:N \l_@@_hpos_of_block_cap_bool |
| 1563 |
\bool_new:N \l_@@_p_block_bool |
| 1564 |
% \end{macrocode} |
| 1565 |
% |
| 1566 |
% \medskip |
| 1567 |
% \begin{macrocode} |
| 1568 |
\bool_new:N \l_@@_fix_vertex_bool |
| 1569 |
% \end{macrocode} |
| 1570 |
% |
| 1571 |
% \medskip |
| 1572 |
% If the final user has used the special color ``|nocolor|'', the following flag |
| 1573 |
% will be raised. |
| 1574 |
% \begin{macrocode} |
| 1575 |
\bool_new:N \l_@@_nocolor_used_bool |
| 1576 |
% \end{macrocode} |
| 1577 |
% |
| 1578 |
% \medskip |
| 1579 |
% For the vertical position, the possible values are |c|, |t|, |b|, |T| and |B| |
| 1580 |
% (but |\l_@@_vpos_block_str| will remain empty if the user doesn't use a key |
| 1581 |
% for the vertical position). |
| 1582 |
% \begin{macrocode} |
| 1583 |
\str_new:N \l_@@_vpos_block_str |
| 1584 |
% \end{macrocode} |
| 1585 |
% |
| 1586 |
% |
| 1587 |
% |
| 1588 |
% \medskip |
| 1589 |
% The blocks which use the key |-| will store their content in a box. These |
| 1590 |
% boxes are numbered with the following counter. |
| 1591 |
% \begin{macrocode} |
| 1592 |
\int_new:N \g_@@_block_box_int |
| 1593 |
% \end{macrocode} |
| 1594 |
% |
| 1595 |
% |
| 1596 |
% \medskip |
| 1597 |
% The following key is set when the keys |hvlines| and |hvlines-except-borders| |
| 1598 |
% are used. It's used only to change slightly the clipping path set by the key |
| 1599 |
% |rounded-corners| (for a |{tabular}|). |
| 1600 |
% \begin{macrocode} |
| 1601 |
\bool_new:N \l_@@_hvlines_bool |
| 1602 |
% \end{macrocode} |
| 1603 |
% |
| 1604 |
% |
| 1605 |
% \bigskip |
| 1606 |
% When |\l_@@_dotted_bool| is |true|, a dotted line (with our system) will be drawn. |
| 1607 |
% \begin{macrocode} |
| 1608 |
\bool_new:N \l_@@_dotted_bool |
| 1609 |
% \end{macrocode} |
| 1610 |
% |
| 1611 |
% \bigskip |
| 1612 |
% The following flag will be set to true during the composition of a caption |
| 1613 |
% specified (by the key |caption|). |
| 1614 |
% \begin{macrocode} |
| 1615 |
\bool_new:N \l_@@_in_caption_bool |
| 1616 |
% \end{macrocode} |
| 1617 |
% |
| 1618 |
% |
| 1619 |
% \bigskip |
| 1620 |
% \textbf{Variables for the exterior rows and columns} |
| 1621 |
% |
| 1622 |
% \nobreak |
| 1623 |
% \medskip |
| 1624 |
% The keys for the exterior rows and columns are |first-row|, |first-col|, |
| 1625 |
% |last-row| and |last-col|. However, internally, these keys are not coded in a |
| 1626 |
% similar way. |
| 1627 |
% |
| 1628 |
% \bigskip |
| 1629 |
% \begin{itemize} |
| 1630 |
% \item \textbf{First row}\par\nobreak |
| 1631 |
% The integer |\l_@@_first_row_int| is the number of the first row of the |
| 1632 |
% array. The default value is $1$, but, if the option |first-row| is used, |
| 1633 |
% the value will be~$0$. |
| 1634 |
% \begin{macrocode} |
| 1635 |
\int_new:N \l_@@_first_row_int |
| 1636 |
\int_set:Nn \l_@@_first_row_int 1 |
| 1637 |
% \end{macrocode} |
| 1638 |
% |
| 1639 |
% \medskip |
| 1640 |
% \item \textbf{First column}\par\nobreak |
| 1641 |
% The integer |\l_@@_first_col_int| is the number of the first column of the |
| 1642 |
% array. The default value is $1$, but, if the option |first-col| is used, |
| 1643 |
% the value will be~$0$. |
| 1644 |
% \begin{macrocode} |
| 1645 |
\int_new:N \l_@@_first_col_int |
| 1646 |
\int_set:Nn \l_@@_first_col_int 1 |
| 1647 |
% \end{macrocode} |
| 1648 |
% |
| 1649 |
% \medskip |
| 1650 |
% \item \textbf{Last row}\par\nobreak |
| 1651 |
% The counter |\l_@@_last_row_int| is the number of the potential ``last row'', |
| 1652 |
% as specified by the key |last-row|. A value of $-2$ means that there is no |
| 1653 |
% ``last row''. A value of $-1$ means that there is a ``last row'' but we don't |
| 1654 |
% know the number of that row (the key |last-row| has been used without value |
| 1655 |
% and the actual value has not still been read in the |aux| file). |
| 1656 |
% \begin{macrocode} |
| 1657 |
\int_new:N \l_@@_last_row_int |
| 1658 |
\int_set:Nn \l_@@_last_row_int { -2 } |
| 1659 |
% \end{macrocode} |
| 1660 |
% |
| 1661 |
% \smallskip |
| 1662 |
% If, in an environment like |{pNiceArray}|, the option |last-row| is used |
| 1663 |
% without value, we will globally raise the following flag. It will be used to |
| 1664 |
% know if we have, after the construction of the array, to write in the |aux| |
| 1665 |
% file the number of the ``last row''.\footnote{We can't use |
| 1666 |
% |\l_@@_last_row_int| for this usage because, if \pkg{nicematrix} has read its |
| 1667 |
% value from the |aux| file, the value of the counter won't be $-1$ any longer.} |
| 1668 |
% \begin{macrocode} |
| 1669 |
\bool_new:N \l_@@_last_row_without_value_bool |
| 1670 |
% \end{macrocode} |
| 1671 |
% |
| 1672 |
% \smallskip |
| 1673 |
% Idem for |\l_@@_last_col_without_value_bool| |
| 1674 |
% \begin{macrocode} |
| 1675 |
\bool_new:N \l_@@_last_col_without_value_bool |
| 1676 |
% \end{macrocode} |
| 1677 |
% |
| 1678 |
% \medskip |
| 1679 |
% \item \textbf{Last column}\par\nobreak |
| 1680 |
% |
| 1681 |
% For the potential ``last column'', we use an integer. A value of $-2$ means |
| 1682 |
% that there is no last column. A value of $-1$ means that we are in an |
| 1683 |
% environment without preamble (e.g. |{bNiceMatrix}|) and there is a last column |
| 1684 |
% but we don't know its value because the user has used the option |last-col| |
| 1685 |
% without value. A value of $0$ means that the option |last-col| has been used |
| 1686 |
% in an environment with preamble (like |{pNiceArray}|): in this case, the key |
| 1687 |
% was necessary without argument. The command |\NiceMatrixOptions| also sets |
| 1688 |
% |\l_@@_last_col_int| to~$0$. |
| 1689 |
% \begin{macrocode} |
| 1690 |
\int_new:N \l_@@_last_col_int |
| 1691 |
\int_set:Nn \l_@@_last_col_int { -2 } |
| 1692 |
% \end{macrocode} |
| 1693 |
% |
| 1694 |
% However, we have also a boolean. Consider the following code: |
| 1695 |
% \begin{center} |
| 1696 |
% \begin{BVerbatim} |
| 1697 |
% \begin{pNiceArray}{cc}[last-col] |
| 1698 |
% 1 & 2 \\ |
| 1699 |
% 3 & 4 |
| 1700 |
% \end{pNiceArray} |
| 1701 |
% \end{BVerbatim} |
| 1702 |
% \end{center} |
| 1703 |
% In such a code, the ``last column'' specified by the key |last-col| is not |
| 1704 |
% used. We want to be able to detect such a situation and we create a boolean |
| 1705 |
% for that job. |
| 1706 |
% \begin{macrocode} |
| 1707 |
\bool_new:N \g_@@_last_col_found_bool |
| 1708 |
% \end{macrocode} |
| 1709 |
% This boolean is set to |false| at the end of |\@@_pre_array_after_CodeBefore:|. |
| 1710 |
% |
| 1711 |
% \medskip |
| 1712 |
% In the last column, we will raise the following flag (it will be used by |
| 1713 |
% |\OnlyMainNiceMatrix|). |
| 1714 |
% \begin{macrocode} |
| 1715 |
\bool_new:N \l_@@_in_last_col_bool |
| 1716 |
% \end{macrocode} |
| 1717 |
% \end{itemize} |
| 1718 |
% |
| 1719 |
% \bigskip |
| 1720 |
% \textbf{Some utilities} |
| 1721 |
% |
| 1722 |
% \medskip |
| 1723 |
% \begin{macrocode} |
| 1724 |
\cs_new_protected:Npn \@@_cut_on_hyphen:w #1-#2 \q_stop |
| 1725 |
{ |
| 1726 |
% \end{macrocode} |
| 1727 |
% Here, we use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 1728 |
% \begin{macrocode} |
| 1729 |
\def \l_tmpa_tl { #1 } |
| 1730 |
\def \l_tmpb_tl { #2 } |
| 1731 |
} |
| 1732 |
% \end{macrocode} |
| 1733 |
% |
| 1734 |
% |
| 1735 |
% The following takes as argument the name of a |clist| and which should be a |
| 1736 |
% list of intervals of integers. It \emph{expands} that list, that is to say, |
| 1737 |
% it replaces (by a sort of |mapcan| or |flat_map|) the interval by the explicit |
| 1738 |
% list of the integers. The second argument is |\c@iRow| or |\c@jCol|. |
| 1739 |
% \begin{macrocode} |
| 1740 |
\cs_new_protected:Npn \@@_expand_clist_hvlines:NN #1 #2 |
| 1741 |
{ |
| 1742 |
\clist_if_in:NnF #1 { all } |
| 1743 |
{ |
| 1744 |
\clist_clear:N \l_tmpa_clist |
| 1745 |
\clist_map_inline:Nn #1 |
| 1746 |
{ |
| 1747 |
\tl_if_head_eq_meaning:nNTF { ##1 } - |
| 1748 |
{ |
| 1749 |
% \end{macrocode} |
| 1750 |
% If we have yet the number of columns or the number of columns (because |
| 1751 |
% they have been computed during a previous run and written on the |aux| file), |
| 1752 |
% we can compute the actual position of the rule with a negative position. |
| 1753 |
% \begin{macrocode} |
| 1754 |
\int_if_zero:nF { #2 } |
| 1755 |
{ |
| 1756 |
\clist_put_right:Ne \l_tmpa_clist |
| 1757 |
{ \int_eval:n { #2 + (##1) + 1 } } |
| 1758 |
} |
| 1759 |
} |
| 1760 |
{ |
| 1761 |
% \end{macrocode} |
| 1762 |
% We recall than |\tl_if_in:nnTF| is slightly faster than |\str_if_in:nnTF|. |
| 1763 |
% \begin{macrocode} |
| 1764 |
\tl_if_in:nnTF { ##1 } { - } |
| 1765 |
{ \@@_cut_on_hyphen:w ##1 \q_stop } |
| 1766 |
{ |
| 1767 |
% \end{macrocode} |
| 1768 |
% Here, we use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 1769 |
% \begin{macrocode} |
| 1770 |
\def \l_tmpa_tl { ##1 } |
| 1771 |
\def \l_tmpb_tl { ##1 } |
| 1772 |
} |
| 1773 |
\int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl |
| 1774 |
{ \clist_put_right:Nn \l_tmpa_clist { ####1 } } |
| 1775 |
} |
| 1776 |
} |
| 1777 |
\tl_set_eq:NN #1 \l_tmpa_clist |
| 1778 |
} |
| 1779 |
} |
| 1780 |
% \end{macrocode} |
| 1781 |
% |
| 1782 |
% \bigskip |
| 1783 |
% The following internal parameters are for: |
| 1784 |
% \begin{itemize} |
| 1785 |
% \item |\Ldots| \emph{with both extremities open} (and hence also |\Hdotsfor| in an |
| 1786 |
% exterior row; |
| 1787 |
% \item when the special character ``|:|'' is used in order to put the label of |
| 1788 |
% a so-called ``dotted line'' \emph{on the line}, a margin of |
| 1789 |
% |\c_@@_innersep_middle_dim| will be added around the label. |
| 1790 |
% \end{itemize} |
| 1791 |
% |
| 1792 |
% \begin{macrocode} |
| 1793 |
\AtBeginDocument |
| 1794 |
{ |
| 1795 |
\dim_const:Nn \c_@@_shift_Ldots_last_row_dim { 0.5 em } |
| 1796 |
\dim_const:Nn \c_@@_innersep_middle_dim { 0.17 em } |
| 1797 |
} |
| 1798 |
% \end{macrocode} |
| 1799 |
% |
| 1800 |
% |
| 1801 |
% \bigskip |
| 1802 |
% \section{The command \textbackslash tabularnote} |
| 1803 |
% |
| 1804 |
% \bigskip |
| 1805 |
% Of course, it's possible to use |\tabularnote| in the main tabular. But there |
| 1806 |
% is also the possibility to use that command in the caption of the tabular. And |
| 1807 |
% the caption may be specified by two means: |
| 1808 |
% |
| 1809 |
% \begin{itemize} |
| 1810 |
% \item The caption may of course be provided by the command |\caption| in a |
| 1811 |
% floating environment. Of course, a command |\tabularnote| in that |\caption| |
| 1812 |
% makes sens only if the |\caption| is \emph{before} the |{tabular}|. |
| 1813 |
% \item It's also possible to use |\tabularnote| in the value of the key |
| 1814 |
% |caption| of the |{NiceTabular}| when the key |caption-above| is in force. |
| 1815 |
% However, in that case, one must remind that the caption is composed |
| 1816 |
% \emph{after} the composition of the box which contains the main tabular |
| 1817 |
% (that's mandatory since that caption must be wrapped with a line width equal |
| 1818 |
% to the width of the tabular). However, we want the labels of the successive |
| 1819 |
% tabular notes in the logical order. That's why: |
| 1820 |
% \begin{itemize} |
| 1821 |
% \item The number of tabular notes present in the caption will be written on |
| 1822 |
% the |aux| file and available in |\g_@@_notes_caption_int|.\footnote{More |
| 1823 |
% precisely, it's the number of tabular notes which do not use the optional |
| 1824 |
% argument of |\tabularnote|.} |
| 1825 |
% \item During the composition of the main tabular, the tabular notes will be |
| 1826 |
% numbered from |\g_@@_notes_caption_int|+1 and the notes will be stored in |
| 1827 |
% |\g_@@_notes_seq|. Each component of |\g_@@_notes_seq| will be a kind of |
| 1828 |
% couple of the form : \texttt{\{\textsl{label}\}\{\textsl{text of the |
| 1829 |
% tabularnote}\}}. The first component is the optional argument (between square |
| 1830 |
% brackets) of the command |\tabularnote| (if the optional argument is not used, |
| 1831 |
% the value will be the special marker expressed by |\NoValue|). |
| 1832 |
% \item During the composition of the caption (value of |\l_@@_caption_tl|), the |
| 1833 |
% tabular notes will be numbered from $1$ to |\g_@@_notes_caption_int| and the |
| 1834 |
% notes themselves will be stored in |\g_@@_notes_in_caption_seq|. The structure |
| 1835 |
% of the components of that sequence will be the same as for |\g_@@_notes_seq|. |
| 1836 |
% \item After the composition of the main tabular and after the composition of |
| 1837 |
% the caption, the sequences |\g_@@_notes_in_caption_seq| and |\g_@@_notes_seq| |
| 1838 |
% will be merged (in that order) and the notes will be composed. |
| 1839 |
% \end{itemize} |
| 1840 |
% \end{itemize} |
| 1841 |
% |
| 1842 |
% |
| 1843 |
% \bigskip |
| 1844 |
% The LaTeX counter |tabularnote| will be used to count the tabular notes during |
| 1845 |
% the construction of the array (this counter won't be used during the |
| 1846 |
% composition of the notes at the end of the array). You use a LaTeX counter |
| 1847 |
% because we will use |\refstepcounter| in order to have the tabular notes |
| 1848 |
% referenceable. |
| 1849 |
% \begin{macrocode} |
| 1850 |
\newcounter { tabularnote } |
| 1851 |
% \end{macrocode} |
| 1852 |
% |
| 1853 |
% We want to avoid error messages for duplicate labels when the package |
| 1854 |
% \pkg{hyperref} is used. That's why we will count all the tabular notes of the |
| 1855 |
% whole document with |\g_@@_tabularnote_int|. |
| 1856 |
% \begin{macrocode} |
| 1857 |
\int_new:N \g_@@_tabularnote_int |
| 1858 |
\cs_set:Npn \theHtabularnote { \int_use:N \g_@@_tabularnote_int } |
| 1859 |
% \end{macrocode} |
| 1860 |
% |
| 1861 |
% \begin{macrocode} |
| 1862 |
\seq_new:N \g_@@_notes_seq |
| 1863 |
\seq_new:N \g_@@_notes_in_caption_seq |
| 1864 |
% \end{macrocode} |
| 1865 |
% |
| 1866 |
% \bigskip |
| 1867 |
% Before the actual tabular notes, it's possible to put a text |
| 1868 |
% specified by the key |tabularnote| of the environment. The token list |
| 1869 |
% |\g_@@_tabularnote_tl| corresponds to the value of that key. |
| 1870 |
% \begin{macrocode} |
| 1871 |
\tl_new:N \g_@@_tabularnote_tl |
| 1872 |
% \end{macrocode} |
| 1873 |
% |
| 1874 |
% \bigskip |
| 1875 |
% We prepare the tools for the formatting of the references of the footnotes (in |
| 1876 |
% the tabular itself). There may have several references of footnote at the same |
| 1877 |
% point and we have to take into account that point. |
| 1878 |
% \begin{macrocode} |
| 1879 |
\seq_new:N \l_@@_notes_labels_seq |
| 1880 |
\newcounter { nicematrix_draft } |
| 1881 |
\cs_new_protected:Npn \@@_notes_format:n #1 |
| 1882 |
{ |
| 1883 |
\setcounter { nicematrix_draft } { #1 } |
| 1884 |
\@@_notes_style:n { nicematrix_draft } |
| 1885 |
} |
| 1886 |
% \end{macrocode} |
| 1887 |
% |
| 1888 |
% \bigskip |
| 1889 |
% The following function can be redefined by using the key |notes/style|. |
| 1890 |
% \begin{macrocode} |
| 1891 |
\cs_new:Npn \@@_notes_style:n #1 { \textit { \alph { #1 } } } |
| 1892 |
% \end{macrocode} |
| 1893 |
% |
| 1894 |
% \bigskip |
| 1895 |
% The following function can be redefined by using the key |
| 1896 |
% |notes/label-in-tabular|. |
| 1897 |
% \begin{macrocode} |
| 1898 |
\cs_new:Npn \@@_notes_label_in_tabular:n #1 { \textsuperscript { #1 } } |
| 1899 |
% \end{macrocode} |
| 1900 |
% |
| 1901 |
% \bigskip |
| 1902 |
% The following function can be redefined by using the key |notes/label-in-list|. |
| 1903 |
% \begin{macrocode} |
| 1904 |
\cs_new:Npn \@@_notes_label_in_list:n #1 { \textsuperscript { #1 } } |
| 1905 |
% \end{macrocode} |
| 1906 |
% |
| 1907 |
% \bigskip |
| 1908 |
% We define |\thetabularnote| because it will be used by LaTeX if the user want |
| 1909 |
% to reference a tabular which has been marked by a |\label|. The TeX group is |
| 1910 |
% for the case where the user has put an instruction such as |\color{red}| in |
| 1911 |
% |\@@_notes_style:n|. |
| 1912 |
% \begin{macrocode} |
| 1913 |
\cs_set:Npn \thetabularnote { { \@@_notes_style:n { tabularnote } } } |
| 1914 |
% \end{macrocode} |
| 1915 |
% |
| 1916 |
% \bigskip |
| 1917 |
% The tabular notes will be available for the final user only when |
| 1918 |
% \pkg{enumitem} is loaded. Indeed, the tabular notes will be composed at the end |
| 1919 |
% of the array with a list customized by \pkg{enumitem} (a list |tabularnotes| |
| 1920 |
% in the general case and a list |tabularnotes*| if the key |para| is in force). |
| 1921 |
% However, we can test whether \pkg{enumitem} has been loaded only at the |
| 1922 |
% beginning of the document (we want to allow the user to load \pkg{enumitem} |
| 1923 |
% after \pkg{nicematrix}). |
| 1924 |
% \begin{macrocode} |
| 1925 |
\AtBeginDocument |
| 1926 |
{ |
| 1927 |
\IfPackageLoadedTF { enumitem } |
| 1928 |
{ |
| 1929 |
% \end{macrocode} |
| 1930 |
% The type of list |tabularnotes| will be used to format the tabular notes at |
| 1931 |
% the end of the array in the general case and |tabularnotes*| will be used if |
| 1932 |
% the key |para| is in force. |
| 1933 |
% \begin{macrocode} |
| 1934 |
\newlist { tabularnotes } { enumerate } { 1 } |
| 1935 |
\setlist [ tabularnotes ] |
| 1936 |
{ |
| 1937 |
topsep = \c_zero_dim , |
| 1938 |
noitemsep , |
| 1939 |
leftmargin = * , |
| 1940 |
align = left , |
| 1941 |
labelsep = \c_zero_dim , |
| 1942 |
label = |
| 1943 |
\@@_notes_label_in_list:n { \@@_notes_style:n { tabularnotesi } } , |
| 1944 |
} |
| 1945 |
\newlist { tabularnotes* } { enumerate* } { 1 } |
| 1946 |
\setlist [ tabularnotes* ] |
| 1947 |
{ |
| 1948 |
afterlabel = \nobreak , |
| 1949 |
itemjoin = \quad , |
| 1950 |
label = |
| 1951 |
\@@_notes_label_in_list:n { \@@_notes_style:n { tabularnotes*i } } |
| 1952 |
} |
| 1953 |
% \end{macrocode} |
| 1954 |
% |
| 1955 |
% \bigskip |
| 1956 |
% One must remind that we have allowed a |\tabular| in the caption and |
| 1957 |
% that caption may also be found in the list of tables (|\listoftables|). We |
| 1958 |
% want the command |\tabularnote| be no-op during the composition of that list. |
| 1959 |
% That's why we program |\tabularnote| to be no-op excepted in a floating |
| 1960 |
% environment or in an environment of \pkg{nicematrix}. |
| 1961 |
% \begin{macrocode} |
| 1962 |
\NewDocumentCommand { \tabularnote } { o m } |
| 1963 |
{ |
| 1964 |
\bool_lazy_or:nnT \l_@@_in_env_bool { \cs_if_exist_p:N \@captype } |
| 1965 |
{ |
| 1966 |
\bool_lazy_and:nnTF \l_@@_in_env_bool { ! \l_@@_tabular_bool } |
| 1967 |
{ \@@_error:n { tabularnote~forbidden } } |
| 1968 |
{ |
| 1969 |
% \end{macrocode} |
| 1970 |
% The second argument of |\@@_tabularnote_caption:nn| ou |\@@_tabularnote:nn| is provided |
| 1971 |
% by curryfication. |
| 1972 |
% \begin{macrocode} |
| 1973 |
\bool_if:NTF \l_@@_in_caption_bool |
| 1974 |
{ |
| 1975 |
\tl_if_novalue:nTF { #1 } |
| 1976 |
{ \@@_tabularnote_caption:nn { #1 } } |
| 1977 |
{ \@@_tabularnote_caption:nn { \exp_not:n { #1 } } } |
| 1978 |
} |
| 1979 |
{ |
| 1980 |
\tl_if_novalue:nTF { #1 } |
| 1981 |
{ \@@_tabularnote:nn { #1 } } |
| 1982 |
{ \@@_tabularnote:nn { \exp_not:n { #1 } } } |
| 1983 |
} |
| 1984 |
{ #2 } |
| 1985 |
} |
| 1986 |
} |
| 1987 |
} |
| 1988 |
} |
| 1989 |
{ |
| 1990 |
\NewDocumentCommand \tabularnote { o m } |
| 1991 |
{ \@@_err_enumitem_not_loaded: } |
| 1992 |
} |
| 1993 |
} |
| 1994 |
% \end{macrocode} |
| 1995 |
% |
| 1996 |
% |
| 1997 |
% \begin{macrocode} |
| 1998 |
\cs_new_protected:Npn \@@_err_enumitem_not_loaded: |
| 1999 |
{ |
| 2000 |
\@@_error_or_warning:n { enumitem~not~loaded } |
| 2001 |
\cs_gset:Npn \@@_err_enumitem_not_loaded: { } |
| 2002 |
} |
| 2003 |
% \end{macrocode} |
| 2004 |
% |
| 2005 |
% \begin{macrocode} |
| 2006 |
\cs_new_protected:Npn \@@_test_first_novalue:nnn #1 #2 #3 |
| 2007 |
{ \tl_if_novalue:nT { #1 } { #3 } } |
| 2008 |
% \end{macrocode} |
| 2009 |
% |
| 2010 |
% \bigskip |
| 2011 |
% For the version in normal conditions, that is to say not in the |caption|. |
| 2012 |
% |#1| is the optional argument of |\tabularnote| (maybe equal to the special |
| 2013 |
% marker expressed by |\NoValue|) and |#2| is the mandatory argument of |
| 2014 |
% |\tabularnote|. |
| 2015 |
% \begin{macrocode} |
| 2016 |
\cs_new_protected:Npn \@@_tabularnote:nn #1 #2 |
| 2017 |
{ |
| 2018 |
% \end{macrocode} |
| 2019 |
% You have to see whether the argument of |\tabularnote| has yet been used as |
| 2020 |
% argument of another |\tabularnote| in the same tabular. In that case, there |
| 2021 |
% will be only one note (for both commands |\tabularnote|) at the end of the |
| 2022 |
% tabular. We search the argument of our command |\tabularnote| in |
| 2023 |
% |\g_@@_notes_seq|. The position in the sequence will be stored in |
| 2024 |
% |\l_tmpa_int| (0 if the text is not in the sequence yet). |
| 2025 |
% \begin{macrocode} |
| 2026 |
\int_zero:N \l_tmpa_int |
| 2027 |
\bool_if:NT \l_@@_notes_detect_duplicates_bool |
| 2028 |
{ |
| 2029 |
% \end{macrocode} |
| 2030 |
% We recall that each component of |\g_@@_notes_seq| is a kind of couple of the form |
| 2031 |
% \begin{center} |
| 2032 |
% \texttt{\{\textsl{label}\}\{\textsl{text of the tabularnote}\}}. |
| 2033 |
% \end{center} |
| 2034 |
% If the user have used |\tabularnote| without the optional argument, the |
| 2035 |
% \texttt{\textsl{label}} will be the special marker expressed by |\NoValue|. |
| 2036 |
% |
| 2037 |
% When we will go through the sequence |\g_@@_notes_seq|, we will count in |
| 2038 |
% |\l_tmpb_int| the notes without explicit label in order to have the |
| 2039 |
% ``current'' value of the counter |\c@tabularnote|. |
| 2040 |
% \begin{macrocode} |
| 2041 |
\int_zero:N \l_tmpb_int |
| 2042 |
\seq_map_indexed_inline:Nn \g_@@_notes_seq |
| 2043 |
{ |
| 2044 |
\@@_test_first_novalue:nnn ##2 { \int_incr:N \l_tmpb_int } |
| 2045 |
\tl_if_eq:nnT { { #1 } { #2 } } { ##2 } |
| 2046 |
{ |
| 2047 |
\tl_if_novalue:nTF { #1 } |
| 2048 |
{ \int_set_eq:NN \l_tmpa_int \l_tmpb_int } |
| 2049 |
{ \int_set:Nn \l_tmpa_int { ##1 } } |
| 2050 |
\seq_map_break: |
| 2051 |
} |
| 2052 |
} |
| 2053 |
\int_if_zero:nF \l_tmpa_int |
| 2054 |
{ \int_add:Nn \l_tmpa_int { \g_@@_notes_caption_int } } |
| 2055 |
} |
| 2056 |
\int_if_zero:nT \l_tmpa_int |
| 2057 |
{ |
| 2058 |
\seq_gput_right:Nn \g_@@_notes_seq { { #1 } { #2 } } |
| 2059 |
\tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } |
| 2060 |
} |
| 2061 |
\seq_put_right:Ne \l_@@_notes_labels_seq |
| 2062 |
{ |
| 2063 |
\tl_if_novalue:nTF { #1 } |
| 2064 |
{ |
| 2065 |
\@@_notes_format:n |
| 2066 |
{ |
| 2067 |
\int_eval:n |
| 2068 |
{ |
| 2069 |
\int_if_zero:nTF \l_tmpa_int |
| 2070 |
\c@tabularnote |
| 2071 |
\l_tmpa_int |
| 2072 |
} |
| 2073 |
} |
| 2074 |
} |
| 2075 |
{ #1 } |
| 2076 |
} |
| 2077 |
\peek_meaning:NF \tabularnote |
| 2078 |
{ |
| 2079 |
% \end{macrocode} |
| 2080 |
% If the following token is \emph{not} a |\tabularnote|, we have finished the |
| 2081 |
% sequence of successive commands |\tabularnote| and we have to format the |
| 2082 |
% labels of these tabular notes (in the array). We compose those labels in a box |
| 2083 |
% |\l_tmpa_box| because we will do a special construction in order to have this |
| 2084 |
% box in an overlapping position if we are at the end of a cell when |
| 2085 |
% |\l_@@_hpos_cell_tl| is equal to |c| or |r|. |
| 2086 |
% \begin{macrocode} |
| 2087 |
\hbox_set:Nn \l_tmpa_box |
| 2088 |
{ |
| 2089 |
% \end{macrocode} |
| 2090 |
% We remind that it is the command |\@@_notes_label_in_tabular:n| that will |
| 2091 |
% put the labels in a |\textsuperscript|. |
| 2092 |
% \begin{macrocode} |
| 2093 |
\@@_notes_label_in_tabular:n |
| 2094 |
{ \seq_use:Nn \l_@@_notes_labels_seq { , } } |
| 2095 |
} |
| 2096 |
% \end{macrocode} |
| 2097 |
% We want the (last) tabular note referenceable (with the standard command |\label|). |
| 2098 |
% \begin{macrocode} |
| 2099 |
\int_gdecr:N \c@tabularnote |
| 2100 |
\int_set_eq:NN \l_tmpa_int \c@tabularnote |
| 2101 |
% \end{macrocode} |
| 2102 |
% The following line is only to avoid error messages for multiply defined labels |
| 2103 |
% when the package \pkg{hyperref} is used. |
| 2104 |
% \begin{macrocode} |
| 2105 |
\int_gincr:N \g_@@_tabularnote_int |
| 2106 |
\refstepcounter { tabularnote } |
| 2107 |
\int_compare:nNnT \l_tmpa_int = \c@tabularnote |
| 2108 |
{ \int_gincr:N \c@tabularnote } |
| 2109 |
\seq_clear:N \l_@@_notes_labels_seq |
| 2110 |
\bool_lazy_or:nnTF |
| 2111 |
{ \str_if_eq_p:ee c \l_@@_hpos_cell_tl } |
| 2112 |
{ \str_if_eq_p:ee r \l_@@_hpos_cell_tl } |
| 2113 |
{ |
| 2114 |
\hbox_overlap_right:n { \box_use:N \l_tmpa_box } |
| 2115 |
% \end{macrocode} |
| 2116 |
% If the command |\tabularnote| is used exactly at the end of the cell, the |
| 2117 |
% |\unskip| (inserted by \pkg{array}?) will delete the skip we insert now |
| 2118 |
% and the label of the footnote will be composed in an overlapping position (by |
| 2119 |
% design). |
| 2120 |
% \begin{macrocode} |
| 2121 |
\skip_horizontal:n { \box_wd:N \l_tmpa_box } |
| 2122 |
} |
| 2123 |
{ \box_use:N \l_tmpa_box } |
| 2124 |
} |
| 2125 |
} |
| 2126 |
% \end{macrocode} |
| 2127 |
% |
| 2128 |
% \bigskip |
| 2129 |
% Now the version when the command is used in the key |caption|. The main |
| 2130 |
% difficulty is that the argument of the command |\caption| is composed several |
| 2131 |
% times. In order to know the number of commands |\tabularnote| in the caption, |
| 2132 |
% we will consider that there should not be the same tabular note twice in the |
| 2133 |
% caption (in the main tabular, it's possible). Once we have found a tabular |
| 2134 |
% note which has yet been encountered, we consider that you are in a new |
| 2135 |
% composition of the argument of |\caption|. |
| 2136 |
% \begin{macrocode} |
| 2137 |
\cs_new_protected:Npn \@@_tabularnote_caption:nn #1 #2 |
| 2138 |
{ |
| 2139 |
\bool_if:NTF \g_@@_caption_finished_bool |
| 2140 |
{ |
| 2141 |
\int_compare:nNnT \c@tabularnote = \g_@@_notes_caption_int |
| 2142 |
{ \int_gzero:N \c@tabularnote } |
| 2143 |
% \end{macrocode} |
| 2144 |
% Now, we try to detect duplicate notes in the caption. |
| 2145 |
% Be careful! We must put |\tl_if_in:NnF| and not |\tl_if_in:NnT|! |
| 2146 |
% \begin{macrocode} |
| 2147 |
\seq_if_in:NnF \g_@@_notes_in_caption_seq { { #1 } { #2 } } |
| 2148 |
{ \@@_error:n { Identical~notes~in~caption } } |
| 2149 |
} |
| 2150 |
{ |
| 2151 |
% \end{macrocode} |
| 2152 |
% In the following code, we are in the first composition of the caption or at |
| 2153 |
% the first |\tabularnote| of the second composition. |
| 2154 |
% \begin{macrocode} |
| 2155 |
\seq_if_in:NnTF \g_@@_notes_in_caption_seq { { #1 } { #2 } } |
| 2156 |
{ |
| 2157 |
% \end{macrocode} |
| 2158 |
% Now, we know that are in the second composition of the caption since we are |
| 2159 |
% reading a tabular note which has yet been read. Now, the value of |
| 2160 |
% |\g_@@_notes_caption_int| won't change anymore: it's the number of uses |
| 2161 |
% \emph{without optional argument} of the command |\tabularnote| in the caption. |
| 2162 |
% \begin{macrocode} |
| 2163 |
\bool_gset_true:N \g_@@_caption_finished_bool |
| 2164 |
\int_gset_eq:NN \g_@@_notes_caption_int \c@tabularnote |
| 2165 |
\int_gzero:N \c@tabularnote |
| 2166 |
} |
| 2167 |
{ \seq_gput_right:Nn \g_@@_notes_in_caption_seq { { #1 } { #2 } } } |
| 2168 |
} |
| 2169 |
% \end{macrocode} |
| 2170 |
% Now, we will compose the label of the footnote (in the caption). Even if we |
| 2171 |
% are not in the first composition, we have to compose that label! |
| 2172 |
% \begin{macrocode} |
| 2173 |
\tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } |
| 2174 |
\seq_put_right:Ne \l_@@_notes_labels_seq |
| 2175 |
{ |
| 2176 |
\tl_if_novalue:nTF { #1 } |
| 2177 |
{ \@@_notes_format:n { \int_use:N \c@tabularnote } } |
| 2178 |
{ #1 } |
| 2179 |
} |
| 2180 |
\peek_meaning:NF \tabularnote |
| 2181 |
{ |
| 2182 |
\@@_notes_label_in_tabular:n { \seq_use:Nn \l_@@_notes_labels_seq { , } } |
| 2183 |
\seq_clear:N \l_@@_notes_labels_seq |
| 2184 |
} |
| 2185 |
} |
| 2186 |
% \end{macrocode} |
| 2187 |
% |
| 2188 |
% |
| 2189 |
% \begin{macrocode} |
| 2190 |
\cs_new_protected:Npn \@@_count_novalue_first:nn #1 #2 |
| 2191 |
{ \tl_if_novalue:nT { #1 } { \int_gincr:N \g_@@_notes_caption_int } } |
| 2192 |
% \end{macrocode} |
| 2193 |
% |
| 2194 |
% |
| 2195 |
% \section{Command for creation of rectangle nodes} |
| 2196 |
% |
| 2197 |
% The following command should be used in a |{pgfpicture}|. It creates a |
| 2198 |
% rectangle (empty but with a name). |
| 2199 |
% |
| 2200 |
% |#1| is the name of the node which will be created; |
| 2201 |
% |#2| and |#3| are the coordinates of one of the corner of the rectangle; |
| 2202 |
% |#4| and |#5| are the coordinates of the opposite corner. |
| 2203 |
% \begin{macrocode} |
| 2204 |
\cs_new_protected:Npn \@@_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 |
| 2205 |
{ |
| 2206 |
\begin { pgfscope } |
| 2207 |
\pgfset |
| 2208 |
{ |
| 2209 |
inner~sep = \c_zero_dim , |
| 2210 |
minimum~size = \c_zero_dim |
| 2211 |
} |
| 2212 |
\pgftransformshift { \pgfpoint { 0.5 * ( #2 + #4 ) } { 0.5 * ( #3 + #5 ) } } |
| 2213 |
\pgfnode |
| 2214 |
{ rectangle } |
| 2215 |
{ center } |
| 2216 |
{ |
| 2217 |
\vbox_to_ht:nn |
| 2218 |
{ \dim_abs:n { #5 - #3 } } |
| 2219 |
{ |
| 2220 |
\vfill |
| 2221 |
\hbox_to_wd:nn { \dim_abs:n { #4 - #2 } } { } |
| 2222 |
} |
| 2223 |
} |
| 2224 |
{ #1 } |
| 2225 |
{ } |
| 2226 |
\end { pgfscope } |
| 2227 |
} |
| 2228 |
% \end{macrocode} |
| 2229 |
% |
| 2230 |
% \medskip |
| 2231 |
% The command |\@@_pgf_rect_node:nnn| is a variant of |\@@_pgf_rect_node:nnnnn|: |
| 2232 |
% it takes two \textsc{pgf} points as arguments instead of the four dimensions |
| 2233 |
% which are the coordinates. |
| 2234 |
% \begin{macrocode} |
| 2235 |
\cs_new_protected:Npn \@@_pgf_rect_node:nnn #1 #2 #3 |
| 2236 |
{ |
| 2237 |
\begin { pgfscope } |
| 2238 |
\pgfset |
| 2239 |
{ |
| 2240 |
inner~sep = \c_zero_dim , |
| 2241 |
minimum~size = \c_zero_dim |
| 2242 |
} |
| 2243 |
\pgftransformshift { \pgfpointscale { 0.5 } { \pgfpointadd { #2 } { #3 } } } |
| 2244 |
\pgfpointdiff { #3 } { #2 } |
| 2245 |
\pgfgetlastxy \l_tmpa_dim \l_tmpb_dim |
| 2246 |
\pgfnode |
| 2247 |
{ rectangle } |
| 2248 |
{ center } |
| 2249 |
{ |
| 2250 |
\vbox_to_ht:nn |
| 2251 |
{ \dim_abs:n \l_tmpb_dim } |
| 2252 |
{ \vfill \hbox_to_wd:nn { \dim_abs:n \l_tmpa_dim } { } } |
| 2253 |
} |
| 2254 |
{ #1 } |
| 2255 |
{ } |
| 2256 |
\end { pgfscope } |
| 2257 |
} |
| 2258 |
% \end{macrocode} |
| 2259 |
% |
| 2260 |
% |
| 2261 |
% \bigskip |
| 2262 |
% \section{The options} |
| 2263 |
% |
| 2264 |
% |
| 2265 |
% \bigskip |
| 2266 |
% The following parameter corresponds to the key |caption-above| of |
| 2267 |
% |\NiceMatrixOptions|. When this paremeter is |true|, the captions of the |
| 2268 |
% environments |{NiceTabular}|, specified with the key |caption| are put above |
| 2269 |
% the tabular (and below elsewhere). |
| 2270 |
% \begin{macrocode} |
| 2271 |
\bool_new:N \l_@@_caption_above_bool |
| 2272 |
% \end{macrocode} |
| 2273 |
% |
| 2274 |
% |
| 2275 |
% \bigskip |
| 2276 |
% The following dimension is the distance between two dots for the dotted lines |
| 2277 |
% (when |line-style| is equal to |standard|, which is the initial value). The |
| 2278 |
% initial value is 0.45~em but it will be changed if the option |small| is used. |
| 2279 |
% \begin{macrocode} |
| 2280 |
\dim_new:N \l_@@_xdots_inter_dim |
| 2281 |
\AtBeginDocument |
| 2282 |
{ \dim_set:Nn \l_@@_xdots_inter_dim { 0.45 em } } |
| 2283 |
% \end{macrocode} |
| 2284 |
% The unit is |em| and that's why we fix the dimension after the preamble. |
| 2285 |
% |
| 2286 |
% \bigskip |
| 2287 |
% The following dimension is the distance between a node (in fact an |
| 2288 |
% anchor of that node) and a dotted line (for real dotted lines, the actual |
| 2289 |
% distance may, of course, be a bit larger, depending of the exact position of |
| 2290 |
% the dots). |
| 2291 |
% \begin{macrocode} |
| 2292 |
\dim_new:N \l_@@_xdots_shorten_start_dim |
| 2293 |
\dim_new:N \l_@@_xdots_shorten_end_dim |
| 2294 |
\AtBeginDocument |
| 2295 |
{ |
| 2296 |
\dim_set:Nn \l_@@_xdots_shorten_start_dim { 0.3 em } |
| 2297 |
\dim_set:Nn \l_@@_xdots_shorten_end_dim { 0.3 em } |
| 2298 |
} |
| 2299 |
% \end{macrocode} |
| 2300 |
% The unit is |em| and that's why we fix the dimension after the preamble. |
| 2301 |
% |
| 2302 |
% \bigskip |
| 2303 |
% The following dimension is the radius of the dots for the dotted lines (when |
| 2304 |
% |line-style| is equal to |standard|, which is the initial value). The initial |
| 2305 |
% value is 0.53~pt but it will be changed if the option |small| is used. |
| 2306 |
% \begin{macrocode} |
| 2307 |
\dim_new:N \l_@@_xdots_radius_dim |
| 2308 |
\AtBeginDocument |
| 2309 |
{ \dim_set:Nn \l_@@_xdots_radius_dim { 0.53 pt } } |
| 2310 |
% \end{macrocode} |
| 2311 |
% The unit is |em| and that's why we fix the dimension after the preamble. |
| 2312 |
% |
| 2313 |
% |
| 2314 |
% \bigskip |
| 2315 |
% The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the |
| 2316 |
% commands |\Cdots|, |\Ldots|, etc. and of the options |line-style| for the |
| 2317 |
% environments and |\NiceMatrixOptions|. The constant |\c_@@_standard_tl| will |
| 2318 |
% be used in some tests. |
| 2319 |
% \begin{macrocode} |
| 2320 |
\tl_new:N \l_@@_xdots_line_style_tl |
| 2321 |
\tl_const:Nn \c_@@_standard_tl { standard } |
| 2322 |
\tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl |
| 2323 |
% \end{macrocode} |
| 2324 |
% |
| 2325 |
% \bigskip |
| 2326 |
% The boolean |\l_@@_light_syntax_bool| corresponds to the option |light-syntax| |
| 2327 |
% and the boolean |\l_@@_light_syntax_expanded_bool| correspond to the the |
| 2328 |
% option |light-syntax-expanded|. |
| 2329 |
% \begin{macrocode} |
| 2330 |
\bool_new:N \l_@@_light_syntax_bool |
| 2331 |
\bool_new:N \l_@@_light_syntax_expanded_bool |
| 2332 |
% \end{macrocode} |
| 2333 |
% |
| 2334 |
% |
| 2335 |
% \medskip |
| 2336 |
% When the key |respect-arraystretch| is used, the following command will be nullified. |
| 2337 |
% \begin{macrocode} |
| 2338 |
\cs_new_protected:Npn \@@_reset_arraystretch: { \def \arraystretch { 1 } } |
| 2339 |
% \end{macrocode} |
| 2340 |
% |
| 2341 |
% |
| 2342 |
% \bigskip |
| 2343 |
% The following flag will be used when the current options specify that all the |
| 2344 |
% columns of the array must have the same width equal to the largest width of a |
| 2345 |
% cell of the array (except the cells of the potential exterior columns). |
| 2346 |
% \begin{macrocode} |
| 2347 |
\bool_new:N \l_@@_auto_columns_width_bool |
| 2348 |
% \end{macrocode} |
| 2349 |
% |
| 2350 |
% \bigskip |
| 2351 |
% The following boolean corresponds to the key |create-cell-nodes| of the |
| 2352 |
% keyword |\CodeBefore|. When that key is used the ``cell nodes'' will be created |
| 2353 |
% before the |\CodeBefore| but, of course, they are \emph{always} available in |
| 2354 |
% the main tabular and after! |
| 2355 |
% \begin{macrocode} |
| 2356 |
\bool_new:N \g_@@_create_cell_nodes_bool |
| 2357 |
% \end{macrocode} |
| 2358 |
% |
| 2359 |
% \bigskip |
| 2360 |
% The string |\l_@@_name_str| will contain the optional name of the |
| 2361 |
% environment: this name can be used to access to the TikZ nodes created in the |
| 2362 |
% array from outside the environment. |
| 2363 |
% \begin{macrocode} |
| 2364 |
\str_new:N \l_@@_name_str |
| 2365 |
% \end{macrocode} |
| 2366 |
% |
| 2367 |
% |
| 2368 |
% \bigskip |
| 2369 |
% The boolean |\l_@@_medium_nodes_bool| will be used to indicate whether the |
| 2370 |
% ``medium nodes'' are created in the array. Idem for the ``large nodes''. |
| 2371 |
% \begin{macrocode} |
| 2372 |
\bool_new:N \l_@@_medium_nodes_bool |
| 2373 |
\bool_new:N \l_@@_large_nodes_bool |
| 2374 |
% \end{macrocode} |
| 2375 |
% |
| 2376 |
% \bigskip |
| 2377 |
% The boolean |\l_@@_except_borders_bool| will be raised when the key |
| 2378 |
% |hvlines-except-borders| will be used (but that key has also other effects). |
| 2379 |
% \begin{macrocode} |
| 2380 |
\bool_new:N \l_@@_except_borders_bool |
| 2381 |
% \end{macrocode} |
| 2382 |
% |
| 2383 |
% |
| 2384 |
% |
| 2385 |
% \bigskip |
| 2386 |
% \begin{macrocode} |
| 2387 |
\keys_define:nn { nicematrix / xdots } |
| 2388 |
{ |
| 2389 |
% \end{macrocode} |
| 2390 |
% When the key |xdots/nullify| is used, the instructions like |\vdots| are |
| 2391 |
% inserted within a |\hphantom| (and so the constructed matrix has exactly the |
| 2392 |
% same size as a matrix constructed with the classical |{matrix}| and |\ldots|, |
| 2393 |
% |\vdots|, etc.). |
| 2394 |
% \begin{macrocode} |
| 2395 |
nullify .bool_set:N = \l_@@_nullify_dots_bool , |
| 2396 |
brace-shift .dim_set:N = \l_@@_brace_shift_dim , |
| 2397 |
brace-shift+ .code:n = |
| 2398 |
\dim_add:Nn \l_@@_brace_shift_dim { #1 } , |
| 2399 |
brace-shift+ .value_required:n = true , |
| 2400 |
brace-shift~+ .meta:n = { brace-shift+ = #1 } , |
| 2401 |
Vbrace .bool_set:N = \l_@@_Vbrace_bool , |
| 2402 |
shorten-start .code:n = |
| 2403 |
\AtBeginDocument { \dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 } } , |
| 2404 |
shorten-start .value_required:n = true , |
| 2405 |
shorten-start+ .code:n = |
| 2406 |
\AtBeginDocument { \dim_add:Nn \l_@@_xdots_shorten_start_dim { #1 } } , |
| 2407 |
shorten-start~+ .meta:n = { shorten-start += #1 } , |
| 2408 |
shorten-start+ .value_required:n = true , |
| 2409 |
shorten-end .code:n = |
| 2410 |
\AtBeginDocument { \dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 } } , |
| 2411 |
shorten-end .value_required:n = true , |
| 2412 |
shorten-end+ .code:n = |
| 2413 |
\AtBeginDocument { \dim_add:Nn \l_@@_xdots_shorten_end_dim { #1 } } , |
| 2414 |
shorten-end+ .value_required:n = true , |
| 2415 |
shorten-end~+ .meta:n = { shorten-end += #1 } , |
| 2416 |
shorten .code:n = |
| 2417 |
\AtBeginDocument |
| 2418 |
{ |
| 2419 |
\dim_set:Nn \l_@@_xdots_shorten_start_dim { #1 } |
| 2420 |
\dim_set:Nn \l_@@_xdots_shorten_end_dim { #1 } |
| 2421 |
} , |
| 2422 |
shorten .value_required:n = true , |
| 2423 |
shorten+ .code:n = |
| 2424 |
\AtBeginDocument |
| 2425 |
{ |
| 2426 |
\dim_add:Nn \l_@@_xdots_shorten_start_dim { #1 } |
| 2427 |
\dim_add:Nn \l_@@_xdots_shorten_end_dim { #1 } |
| 2428 |
} , |
| 2429 |
shorten~+ .meta:n = { shorten+ = #1 } , |
| 2430 |
horizontal-labels .bool_set:N = \l_@@_xdots_h_labels_bool , |
| 2431 |
horizontal-label .bool_set:N = \l_@@_xdots_h_labels_bool , |
| 2432 |
line-style .code:n = |
| 2433 |
{ |
| 2434 |
\bool_lazy_or:nnTF |
| 2435 |
{ \cs_if_exist_p:N \tikzpicture } |
| 2436 |
{ \str_if_eq_p:nn { #1 } { standard } } |
| 2437 |
{ \tl_set:Nn \l_@@_xdots_line_style_tl { #1 } } |
| 2438 |
{ \@@_error:n { bad~option~for~line-style } } |
| 2439 |
} , |
| 2440 |
line-style .value_required:n = true , |
| 2441 |
color .tl_set:N = \l_@@_xdots_color_tl , |
| 2442 |
color .value_required:n = true , |
| 2443 |
radius .code:n = |
| 2444 |
\AtBeginDocument { \dim_set:Nn \l_@@_xdots_radius_dim { #1 } } , |
| 2445 |
radius .value_required:n = true , |
| 2446 |
inter .code:n = |
| 2447 |
\AtBeginDocument { \dim_set:Nn \l_@@_xdots_inter_dim { #1 } } , |
| 2448 |
radius .value_required:n = true , |
| 2449 |
% \end{macrocode} |
| 2450 |
% The options |down|, |up| and |middle| are not documented for the final user |
| 2451 |
% because he should use the syntax with |^|, |_| and |:|. We use |
| 2452 |
% |\tl_put_right:Nn| and not |\tl_set:Nn| (or |.tl_set:N|) because we don't want |
| 2453 |
% a direct use of |up=...| erased by an absent |^{...}|. |
| 2454 |
% \begin{macrocode} |
| 2455 |
down .code:n = \tl_put_right:Nn \l_@@_xdots_down_tl { #1 } , |
| 2456 |
up .code:n = \tl_put_right:Nn \l_@@_xdots_up_tl { #1 } , |
| 2457 |
middle .code:n = \tl_put_right:Nn \l_@@_xdots_middle_tl { #1 } , |
| 2458 |
% \end{macrocode} |
| 2459 |
% The key |draw-first|, which is meant to be used only with |\Ddots| and |
| 2460 |
% |\Iddots|, will be caught when |\Ddots| or |\Iddots| is used (during the |
| 2461 |
% construction of the array and not when we draw the dotted lines). |
| 2462 |
% \begin{macrocode} |
| 2463 |
draw-first .code:n = \prg_do_nothing: , |
| 2464 |
unknown .code:n = |
| 2465 |
\@@_unknown_key:nn { nicematrix / xdots } { Unknown~key~for~xdots } |
| 2466 |
} |
| 2467 |
% \end{macrocode} |
| 2468 |
% |
| 2469 |
% |
| 2470 |
% \bigskip |
| 2471 |
% \begin{macrocode} |
| 2472 |
\keys_define:nn { nicematrix / trees } |
| 2473 |
{ |
| 2474 |
color.tl_set:N = \l_@@_trees_color_tl , |
| 2475 |
color .value_required:n = true , |
| 2476 |
line-width .dim_set:N = \l_@@_trees_line_width_dim , |
| 2477 |
rounded-corners .dim_set:N = \l_@@_trees_rounded_corners_dim , |
| 2478 |
rounded-corners .default:n = 2 pt , |
| 2479 |
unknown .code:n = |
| 2480 |
\@@_unknown_key:nn { nicematrix / trees } { Unknown~key~for~trees } |
| 2481 |
} |
| 2482 |
% \end{macrocode} |
| 2483 |
% |
| 2484 |
% \bigskip |
| 2485 |
% \begin{macrocode} |
| 2486 |
\keys_define:nn { nicematrix / rules } |
| 2487 |
{ |
| 2488 |
fix-vertex .code:n = |
| 2489 |
\bool_set_true:N \l_@@_fix_vertex_bool |
| 2490 |
\socket_assign_plug:nn { nicematrix / draw-at-odd-vertex-h } { active } |
| 2491 |
\socket_assign_plug:nn { nicematrix / draw-at-odd-vertex-v } { active } , |
| 2492 |
color .tl_set:N = \l_@@_rules_color_tl , |
| 2493 |
color .value_required:n = true , |
| 2494 |
width .dim_set:N = \arrayrulewidth , |
| 2495 |
unknown .code:n = \@@_error:n { Unknown~key~for~rules } |
| 2496 |
} |
| 2497 |
% \end{macrocode} |
| 2498 |
% |
| 2499 |
% \bigskip |
| 2500 |
% First, we define a set of keys ``|nicematrix / Global|'' which will be used |
| 2501 |
% (with the mechanism of |.inherit:n|) by other sets of keys. |
| 2502 |
% |
| 2503 |
% \begin{macrocode} |
| 2504 |
\keys_define:nn { nicematrix / Global } |
| 2505 |
{ |
| 2506 |
fix-vertex .value_forbidden:n = true , |
| 2507 |
brace-shift .dim_set:N = \l_@@_brace_shift_dim , |
| 2508 |
brace-shift+ .code:n = |
| 2509 |
\dim_add:Nn \l_@@_brace_shift_dim { #1 } , |
| 2510 |
brace-shift+ .value_required:n = true , |
| 2511 |
brace-shift~+ .meta:n = { brace-shift+ = #1 } , |
| 2512 |
caption-above .code:n = \@@_error_or_warning:n { caption-above~in~env } , |
| 2513 |
show-cell-names .code = \@@_error_or_warning:n { show-cell-names } , |
| 2514 |
color-inside .code:n = \@@_fatal:n { key~color-inside } , |
| 2515 |
colortbl-like .code:n = \@@_fatal:n { key~color-inside } , |
| 2516 |
ampersand-in-blocks .bool_set:N = \l_@@_amp_in_blocks_bool , |
| 2517 |
&-in-blocks .meta:n = ampersand-in-blocks , |
| 2518 |
no-cell-nodes .code:n = |
| 2519 |
\bool_set_true:N \l_@@_no_cell_nodes_bool |
| 2520 |
\cs_set_protected:Npn \@@_node_cell: |
| 2521 |
{ \set@color \box_use_drop:N \l_@@_cell_box } , |
| 2522 |
no-cell-nodes .value_forbidden:n = true , |
| 2523 |
% \end{macrocode} |
| 2524 |
% When the key |rounded-corners| is used, a clipping is applied in the |
| 2525 |
% |\CodeBefore| of the environment in order to have rounded corners for the |
| 2526 |
% potential colored panels. |
| 2527 |
% \begin{macrocode} |
| 2528 |
rounded-corners .dim_set:N = \l_@@_tab_rounded_corners_dim , |
| 2529 |
rounded-corners .default:n = 4 pt , |
| 2530 |
custom-line .code:n = \@@_custom_line:n { #1 } , |
| 2531 |
default-line .code:n = \@@_default_line:n { #1 } , |
| 2532 |
rules .code:n = \keys_set:nn { nicematrix / rules } { #1 } , |
| 2533 |
rules .value_required:n = true , |
| 2534 |
trees .code:n = \keys_set:nn { nicematrix / trees } { #1 } , |
| 2535 |
trees .value_required:n = true , |
| 2536 |
% \end{macrocode} |
| 2537 |
% By default, the behaviour of |\cline| is changed in the environments of |
| 2538 |
% \pkg{nicematrix}: a |\cline| spreads the array by an amount equal to |
| 2539 |
% |\arrayrulewidth|. It's possible to disable this feature with the key |
| 2540 |
% |standard-cline|. |
| 2541 |
% \begin{macrocode} |
| 2542 |
standard-cline .bool_set:N = \l_@@_standard_cline_bool , |
| 2543 |
cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim , |
| 2544 |
cell-space-top-limit+ .code:n = |
| 2545 |
\dim_add:Nn \l_@@_cell_space_top_limit_dim { #1 } , |
| 2546 |
cell-space-top-limit+ .value_required:n = true , |
| 2547 |
cell-space-top-limit~+ .meta:n = { cell-space-top-limit+ = #1 } , |
| 2548 |
cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim , |
| 2549 |
cell-space-bottom-limit+ .code:n = |
| 2550 |
\dim_add:Nn \l_@@_cell_space_bottom_limit_dim { #1 } , |
| 2551 |
cell-space-bottom-limit+ .value_required:n = true , |
| 2552 |
cell-space-bottom-limit~+ .meta:n = { cell-space-bottom-limit+ = #1 } , |
| 2553 |
cell-space-limits .meta:n = |
| 2554 |
{ |
| 2555 |
cell-space-top-limit = #1 , |
| 2556 |
cell-space-bottom-limit = #1 , |
| 2557 |
} , |
| 2558 |
cell-space-limits .value_required:n = true , |
| 2559 |
cell-space-limits+ .meta:n = |
| 2560 |
{ |
| 2561 |
cell-space-top-limit += #1 , |
| 2562 |
cell-space-bottom-limit += #1 , |
| 2563 |
} , |
| 2564 |
cell-space-limits+ .value_required:n = true , |
| 2565 |
cell-space-limits~+ .meta:n = { cell-space-limits+ = #1 } , |
| 2566 |
xdots .code:n = \keys_set:nn { nicematrix / xdots } { #1 } , |
| 2567 |
light-syntax .code:n = |
| 2568 |
\bool_set_true:N \l_@@_light_syntax_bool |
| 2569 |
\bool_set_false:N \l_@@_light_syntax_expanded_bool , |
| 2570 |
light-syntax .value_forbidden:n = true , |
| 2571 |
light-syntax-expanded .code:n = |
| 2572 |
\bool_set_true:N \l_@@_light_syntax_bool |
| 2573 |
\bool_set_true:N \l_@@_light_syntax_expanded_bool , |
| 2574 |
light-syntax-expanded .value_forbidden:n = true , |
| 2575 |
% \end{macrocode} |
| 2576 |
% |
| 2577 |
% The key |end-of-row| specifies the symbol used to mark the ends of rows when |
| 2578 |
% the light syntax is used. |
| 2579 |
% \begin{macrocode} |
| 2580 |
end-of-row .tl_set:N = \l_@@_end_of_row_tl , |
| 2581 |
end-of-row .value_required:n = true , |
| 2582 |
end-of-row .initial:n = ; , |
| 2583 |
|
| 2584 |
first-col .code:n = \int_zero:N \l_@@_first_col_int , |
| 2585 |
first-row .code:n = \int_zero:N \l_@@_first_row_int , |
| 2586 |
last-row .int_set:N = \l_@@_last_row_int , |
| 2587 |
last-row .default:n = -1 , |
| 2588 |
|
| 2589 |
code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , |
| 2590 |
code-for-first-col .value_required:n = true , |
| 2591 |
code-for-first-col+ .code:n = |
| 2592 |
{ \tl_put_right:Nn \l_@@_code_for_first_col_tl { #1 } } , |
| 2593 |
code-for-first-col+ .value_required:n = true , |
| 2594 |
code-for-first-col~+ .meta:n = { code-for-first-col+ = #1 } , |
| 2595 |
|
| 2596 |
code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , |
| 2597 |
code-for-last-col .value_required:n = true , |
| 2598 |
code-for-last-col+ .code:n = |
| 2599 |
{ \tl_put_right:Nn \l_@@_code_for_last_col_tl { #1 } } , |
| 2600 |
code-for-last-col+ .value_required:n = true , |
| 2601 |
code-for-last-col~+ .meta:n = { code-for-last-col+ = #1 } , |
| 2602 |
|
| 2603 |
code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , |
| 2604 |
code-for-first-row .value_required:n = true , |
| 2605 |
code-for-first-row+ .code:n = |
| 2606 |
{ \tl_put_right:Nn \l_@@_code_for_first_row_tl { #1 } } , |
| 2607 |
code-for-first-row+ .value_required:n = true , |
| 2608 |
code-for-first-row~+ .meta:n = { code-for-first-row+ = #1 } , |
| 2609 |
|
| 2610 |
code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , |
| 2611 |
code-for-last-row .value_required:n = true , |
| 2612 |
code-for-last-row+ .code:n = |
| 2613 |
{ \tl_put_right:Nn \l_@@_code_for_first_col_tl { #1 } } , |
| 2614 |
code-for-last-row+ .value_required:n = true , |
| 2615 |
code-for-last-row~+ .meta:n = { code-for-last-row+ = #1 } , |
| 2616 |
|
| 2617 |
hlines .clist_set:N = \l_@@_hlines_clist , |
| 2618 |
hlines .default:n = all , |
| 2619 |
vlines .clist_set:N = \l_@@_vlines_clist , |
| 2620 |
vlines .default:n = all , |
| 2621 |
|
| 2622 |
vlines-in-sub-matrix .code:n = |
| 2623 |
{ |
| 2624 |
\tl_if_single_token:nTF { #1 } |
| 2625 |
{ |
| 2626 |
\tl_if_in:NnTF \c_@@_forbidden_letters_tl { #1 } |
| 2627 |
{ \@@_error:nn { Forbidden~letter } { #1 } } |
| 2628 |
% \end{macrocode} |
| 2629 |
% We write directly a command for the automata which reads the preamble provided |
| 2630 |
% by the final user. |
| 2631 |
% \begin{macrocode} |
| 2632 |
{ \cs_set_eq:cN { @@ _ #1 : } \@@_make_preamble_vlism:n } |
| 2633 |
} |
| 2634 |
{ \@@_error:n { One~letter~allowed } } |
| 2635 |
} , |
| 2636 |
vlines-in-sub-matrix .value_required:n = true , |
| 2637 |
hvlines .code:n = |
| 2638 |
{ |
| 2639 |
\bool_set_true:N \l_@@_hvlines_bool |
| 2640 |
\tl_set_eq:NN \l_@@_vlines_clist \c_@@_all_tl |
| 2641 |
\tl_set_eq:NN \l_@@_hlines_clist \c_@@_all_tl |
| 2642 |
} , |
| 2643 |
hvlines .value_forbidden:n = true , |
| 2644 |
hvlines-except-borders .code:n = |
| 2645 |
{ |
| 2646 |
\tl_set_eq:NN \l_@@_vlines_clist \c_@@_all_tl |
| 2647 |
\tl_set_eq:NN \l_@@_hlines_clist \c_@@_all_tl |
| 2648 |
\bool_set_true:N \l_@@_hvlines_bool |
| 2649 |
\bool_set_true:N \l_@@_except_borders_bool |
| 2650 |
} , |
| 2651 |
hlines-except-borders .value_forbidden:n = true , |
| 2652 |
hlines-except-borders .code:n = |
| 2653 |
{ |
| 2654 |
\tl_set_eq:NN \l_@@_hlines_clist \c_@@_all_tl |
| 2655 |
\bool_set_true:N \l_@@_hlines_bool |
| 2656 |
\bool_set_true:N \l_@@_except_borders_bool |
| 2657 |
} , |
| 2658 |
hlines-except-borders .value_forbidden:n = true , |
| 2659 |
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , |
| 2660 |
parallelize-diags .initial:n = true , |
| 2661 |
% \end{macrocode} |
| 2662 |
% |
| 2663 |
% \bigskip |
| 2664 |
% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots|, |
| 2665 |
% |\ddots|, etc. are redefined and behave like the commands |\Cdots|, |\Ldots|, |
| 2666 |
% |\Vdots|, |\Ddots|, etc. |
| 2667 |
% \begin{macrocode} |
| 2668 |
renew-dots .bool_set:N = \l_@@_renew_dots_bool , |
| 2669 |
renew-dots .value_forbidden:n = true , |
| 2670 |
nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , |
| 2671 |
create-medium-nodes .bool_set:N = \l_@@_medium_nodes_bool , |
| 2672 |
create-large-nodes .bool_set:N = \l_@@_large_nodes_bool , |
| 2673 |
create-extra-nodes .meta:n = |
| 2674 |
{ create-medium-nodes , create-large-nodes } , |
| 2675 |
left-margin .dim_set:N = \l_@@_left_margin_dim , |
| 2676 |
left-margin .default:n = \arraycolsep , |
| 2677 |
right-margin .dim_set:N = \l_@@_right_margin_dim , |
| 2678 |
right-margin .default:n = \arraycolsep , |
| 2679 |
margin .meta:n = { left-margin = #1 , right-margin = #1 } , |
| 2680 |
margin .default:n = \arraycolsep , |
| 2681 |
extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim , |
| 2682 |
extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim , |
| 2683 |
extra-margin .meta:n = |
| 2684 |
{ extra-left-margin = #1 , extra-right-margin = #1 } , |
| 2685 |
extra-margin .value_required:n = true , |
| 2686 |
respect-arraystretch .code:n = |
| 2687 |
\cs_set_eq:NN \@@_reset_arraystretch: \prg_do_nothing: , |
| 2688 |
respect-arraystretch .value_forbidden:n = true , |
| 2689 |
% \end{macrocode} |
| 2690 |
% The code of the key |pgf-node-code| will be used when the nodes of the cells |
| 2691 |
% (that is to say the nodes of the form |i-j|) will be created. |
| 2692 |
% \begin{macrocode} |
| 2693 |
pgf-node-code .tl_set:N = \l_@@_pgf_node_code_tl , |
| 2694 |
pgf-node-code .value_required:n = true , |
| 2695 |
} |
| 2696 |
% \end{macrocode} |
| 2697 |
% |
| 2698 |
% \bigskip |
| 2699 |
% We define a set of keys used by the environments of \pkg{nicematrix} (but not |
| 2700 |
% by the command |\NiceMatrixOptions|). |
| 2701 |
% \begin{macrocode} |
| 2702 |
\keys_define:nn { nicematrix / environments } |
| 2703 |
{ |
| 2704 |
draw-trees-in-col .code:n = |
| 2705 |
\clist_gput_right:Nn \g_@@_col_with_trees_clist { #1 } , |
| 2706 |
draw-trees-in-col .value_required:n = true , |
| 2707 |
create-blocks-in-col .code:n = |
| 2708 |
\clist_gput_right:Nn \g_@@_cbic_clist { #1 } , |
| 2709 |
create-blocks-in-col .value_required:n = true , |
| 2710 |
corners .clist_set:N = \l_@@_corners_clist , |
| 2711 |
corners .default:n = { NW , SW , NE , SE } , |
| 2712 |
code-before .code:n = |
| 2713 |
{ |
| 2714 |
\tl_if_empty:nF { #1 } |
| 2715 |
{ |
| 2716 |
\tl_gput_left:Nn \g_@@_pre_code_before_tl { #1 } |
| 2717 |
\bool_set_true:N \l_@@_code_before_bool |
| 2718 |
} |
| 2719 |
} , |
| 2720 |
code-before .value_required:n = true , |
| 2721 |
% \end{macrocode} |
| 2722 |
% \bigskip |
| 2723 |
% The options |c|, |t| and |b| of the environment |{NiceArray}| have the same |
| 2724 |
% meaning as the option of the classical environment |{array}|. |
| 2725 |
% \begin{macrocode} |
| 2726 |
c .code:n = \tl_set:Nn \l_@@_baseline_tl c , |
| 2727 |
t .code:n = \tl_set:Nn \l_@@_baseline_tl t , |
| 2728 |
b .code:n = \tl_set:Nn \l_@@_baseline_tl b , |
| 2729 |
% \end{macrocode} |
| 2730 |
% The string |\l_@@_baseline_tl| may contain one of the three values |t|, |
| 2731 |
% |c| or |b| as in the option of the environment |{array}|. However, it may also |
| 2732 |
% contain \textbf{an integer} (which represents the number of the row to which |
| 2733 |
% align the array). |
| 2734 |
% \begin{macrocode} |
| 2735 |
baseline .tl_set:N = \l_@@_baseline_tl , |
| 2736 |
baseline .value_required:n = true , |
| 2737 |
baseline .initial:n = c , |
| 2738 |
columns-width .code:n = |
| 2739 |
% \end{macrocode} |
| 2740 |
% We use |\str_if_eq:nnTF| which is slightly faster than |\tl_if_eq:nnTF| (and |
| 2741 |
% is expandable). |\str_if_eq:ee(TF)| is faster than |\str_if_eq:nn(TF)|. |
| 2742 |
% \begin{macrocode} |
| 2743 |
\str_if_eq:eeTF { #1 } { auto } |
| 2744 |
{ \bool_set_true:N \l_@@_auto_columns_width_bool } |
| 2745 |
{ \dim_set:Nn \l_@@_columns_width_dim { #1 } } , |
| 2746 |
columns-width .value_required:n = true , |
| 2747 |
name .code:n = |
| 2748 |
% \end{macrocode} |
| 2749 |
% We test whether we are in the measuring phase of an environment of |
| 2750 |
% \pkg{amsmath} (always loaded by \pkg{nicematrix}) because we want to avoid a |
| 2751 |
% fallacious message of duplicate name in this case. |
| 2752 |
% \begin{macrocode} |
| 2753 |
\legacy_if:nF { measuring@ } |
| 2754 |
{ |
| 2755 |
\str_set:Ne \l_@@_name_str { #1 } |
| 2756 |
\clist_if_in:NoTF \g_@@_names_clist \l_@@_name_str |
| 2757 |
{ \@@_err_duplicate_names:n { #1 } } |
| 2758 |
{ \clist_gpush:No \g_@@_names_clist \l_@@_name_str } |
| 2759 |
} , |
| 2760 |
name .value_required:n = true , |
| 2761 |
code-after .tl_gset:N = \g_nicematrix_code_after_tl , |
| 2762 |
code-after .value_required:n = true , |
| 2763 |
} |
| 2764 |
% \end{macrocode} |
| 2765 |
% |
| 2766 |
% \begin{macrocode} |
| 2767 |
\cs_set:Npn \@@_err_duplicate_names:n #1 |
| 2768 |
{ \@@_error:nn { Duplicate~name } { #1 } } |
| 2769 |
% \end{macrocode} |
| 2770 |
% |
| 2771 |
% \begin{macrocode} |
| 2772 |
\keys_define:nn { nicematrix / notes } |
| 2773 |
{ |
| 2774 |
no-print .bool_set:N = \l_@@_notes_no_print_bool , |
| 2775 |
para .bool_set:N = \l_@@_notes_para_bool , |
| 2776 |
code-before .tl_set:N = \l_@@_notes_code_before_tl , |
| 2777 |
code-before .value_required:n = true , |
| 2778 |
code-before+ .code:n = |
| 2779 |
\tl_put_right:Nn \l_@@_note_code_before_tl { #1 } , |
| 2780 |
code-before+ .value_required:n = true , |
| 2781 |
code-before~+ .code:n = |
| 2782 |
\tl_put_right:Nn \l_@@_note_code_before_tl { #1 } , |
| 2783 |
code-before~+ .value_required:n = true , |
| 2784 |
code-after .tl_set:N = \l_@@_notes_code_after_tl , |
| 2785 |
code-after .value_required:n = true , |
| 2786 |
bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool , |
| 2787 |
style .cs_set:Np = \@@_notes_style:n #1 , |
| 2788 |
style .value_required:n = true , |
| 2789 |
label-in-tabular .cs_set:Np = \@@_notes_label_in_tabular:n #1 , |
| 2790 |
label-in-tabular .value_required:n = true , |
| 2791 |
label-in-list .cs_set:Np = \@@_notes_label_in_list:n #1 , |
| 2792 |
label-in-list .value_required:n = true , |
| 2793 |
enumitem-keys .code:n = |
| 2794 |
{ |
| 2795 |
\AtBeginDocument |
| 2796 |
{ |
| 2797 |
\IfPackageLoadedT { enumitem } |
| 2798 |
{ \setlist* [ tabularnotes ] { #1 } } |
| 2799 |
} |
| 2800 |
} , |
| 2801 |
enumitem-keys .value_required:n = true , |
| 2802 |
enumitem-keys-para .code:n = |
| 2803 |
{ |
| 2804 |
\AtBeginDocument |
| 2805 |
{ |
| 2806 |
\IfPackageLoadedT { enumitem } |
| 2807 |
{ \setlist* [ tabularnotes* ] { #1 } } |
| 2808 |
} |
| 2809 |
} , |
| 2810 |
enumitem-keys-para .value_required:n = true , |
| 2811 |
detect-duplicates .bool_set:N = \l_@@_notes_detect_duplicates_bool , |
| 2812 |
unknown .code:n = |
| 2813 |
\@@_unknown_key:nn { nicematrix / notes } { Unknown~key~for~notes } |
| 2814 |
} |
| 2815 |
% \end{macrocode} |
| 2816 |
% |
| 2817 |
% \bigskip |
| 2818 |
% Sometimes, we want to have several arrays vertically juxtaposed in order to |
| 2819 |
% have an alignment of the columns of these arrays. To acheive this goal, one |
| 2820 |
% may wish to use the same width for all the columns (for example with the |
| 2821 |
% option |columns-width| or the option |auto-columns-width| of the environment |
| 2822 |
% |{NiceMatrixBlock}|). However, even if we use the same type of delimiters, the |
| 2823 |
% width of the delimiters may be different from an array to another because the |
| 2824 |
% width of the delimiter is fonction of its size. That's why we create an option |
| 2825 |
% called |delimiters/max-width| which will give to the delimiters the width of |
| 2826 |
% a delimiter (of the same type) of big size. |
| 2827 |
% \begin{macrocode} |
| 2828 |
\keys_define:nn { nicematrix / delimiters } |
| 2829 |
{ |
| 2830 |
max-width .bool_set:N = \l_@@_delimiters_max_width_bool , |
| 2831 |
color .tl_set:N = \l_@@_delimiters_color_tl , |
| 2832 |
color .value_required:n = true , |
| 2833 |
} |
| 2834 |
% \end{macrocode} |
| 2835 |
% |
| 2836 |
% \bigskip |
| 2837 |
% We begin the construction of the major sets of keys (used by the different |
| 2838 |
% user commands and environments). |
| 2839 |
% \begin{macrocode} |
| 2840 |
\keys_define:nn { nicematrix } |
| 2841 |
{ |
| 2842 |
NiceMatrixOptions .inherit:n = |
| 2843 |
{ nicematrix / Global } , |
| 2844 |
NiceMatrixOptions / xdots .inherit:n = nicematrix / xdots , |
| 2845 |
NiceMatrixOptions / rules .inherit:n = nicematrix / rules , |
| 2846 |
NiceMatrixOptions / notes .inherit:n = nicematrix / notes , |
| 2847 |
NiceMatrixOptions / trees .inherit:n = nicematrix / trees , |
| 2848 |
NiceMatrixOptions / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 2849 |
SubMatrix / rules .inherit:n = nicematrix / rules , |
| 2850 |
CodeAfter / xdots .inherit:n = nicematrix / xdots , |
| 2851 |
CodeBefore / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 2852 |
CodeAfter / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 2853 |
NiceMatrix .inherit:n = |
| 2854 |
{ |
| 2855 |
nicematrix / Global , |
| 2856 |
nicematrix / environments , |
| 2857 |
} , |
| 2858 |
NiceMatrix / xdots .inherit:n = nicematrix / xdots , |
| 2859 |
NiceMatrix / rules .inherit:n = nicematrix / rules , |
| 2860 |
NiceMatrix / trees .inherit:n = nicematrix / trees , |
| 2861 |
NiceTabular .inherit:n = |
| 2862 |
{ |
| 2863 |
nicematrix / Global , |
| 2864 |
nicematrix / environments |
| 2865 |
} , |
| 2866 |
NiceTabular / xdots .inherit:n = nicematrix / xdots , |
| 2867 |
NiceTabular / rules .inherit:n = nicematrix / rules , |
| 2868 |
NiceTabular / notes .inherit:n = nicematrix / notes , |
| 2869 |
NiceTabular / trees .inherit:n = nicematrix / trees , |
| 2870 |
NiceArray .inherit:n = |
| 2871 |
{ |
| 2872 |
nicematrix / Global , |
| 2873 |
nicematrix / environments , |
| 2874 |
} , |
| 2875 |
NiceArray / xdots .inherit:n = nicematrix / xdots , |
| 2876 |
NiceArray / rules .inherit:n = nicematrix / rules , |
| 2877 |
NiceArray / trees .inherit:n = nicematrix / trees , |
| 2878 |
pNiceArray .inherit:n = |
| 2879 |
{ |
| 2880 |
nicematrix / Global , |
| 2881 |
nicematrix / environments , |
| 2882 |
} , |
| 2883 |
pNiceArray / xdots .inherit:n = nicematrix / xdots , |
| 2884 |
pNiceArray / rules .inherit:n = nicematrix / rules , |
| 2885 |
pNiceArray / trees .inherit:n = nicematrix / trees |
| 2886 |
} |
| 2887 |
% \end{macrocode} |
| 2888 |
% |
| 2889 |
% |
| 2890 |
% \bigskip |
| 2891 |
% We finalise the definition of the set of keys |
| 2892 |
% ``|nicematrix / NiceMatrixOptions|'' with the options specific to |
| 2893 |
% |\NiceMatrixOptions|. |
| 2894 |
% \begin{macrocode} |
| 2895 |
\keys_define:nn { nicematrix / NiceMatrixOptions } |
| 2896 |
{ |
| 2897 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 2898 |
delimiters / color .value_required:n = true , |
| 2899 |
delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool , |
| 2900 |
delimiters .code:n = \keys_set:nn { nicematrix / delimiters } { #1 } , |
| 2901 |
delimiters .value_required:n = true , |
| 2902 |
width .dim_set:N = \l_@@_width_dim , |
| 2903 |
last-col .code:n = |
| 2904 |
\tl_if_empty:nF { #1 } |
| 2905 |
{ \@@_error:n { last-col~non~empty~for~NiceMatrixOptions } } |
| 2906 |
\int_zero:N \l_@@_last_col_int , |
| 2907 |
small .bool_set:N = \l_@@_small_bool , |
| 2908 |
small .value_forbidden:n = true , |
| 2909 |
% \end{macrocode} |
| 2910 |
% |
| 2911 |
% With the option |renew-matrix|, the environment |{matrix}| of \pkg{amsmath} |
| 2912 |
% and its variants are redefined to behave like the environment |{NiceMatrix}| |
| 2913 |
% and its variants. |
| 2914 |
% \begin{macrocode} |
| 2915 |
renew-matrix .code:n = \@@_renew_matrix: , |
| 2916 |
renew-matrix .value_forbidden:n = true , |
| 2917 |
% \end{macrocode} |
| 2918 |
% |
| 2919 |
% \bigskip |
| 2920 |
% The option |exterior-arraycolsep| will have effect only in |{NiceArray}| for |
| 2921 |
% those who want to have for |{NiceArray}| the same behaviour as |{array}|. |
| 2922 |
% \begin{macrocode} |
| 2923 |
exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool , |
| 2924 |
% \end{macrocode} |
| 2925 |
% |
| 2926 |
% \bigskip |
| 2927 |
% If the option |columns-width| is used, all the columns will have the same |
| 2928 |
% width. |
| 2929 |
% |
| 2930 |
% In |\NiceMatrixOptions|, the special value |auto| is not available. |
| 2931 |
% \begin{macrocode} |
| 2932 |
columns-width .code:n = |
| 2933 |
% \end{macrocode} |
| 2934 |
% We use |\str_if_eq:nnTF| which is slightly faster than |\tl_if_eq:nnTF|. |
| 2935 |
% |\str_if_eq:ee(TF)| is faster than |\str_if_eq:nn(TF)|. |
| 2936 |
% \begin{macrocode} |
| 2937 |
\str_if_eq:eeTF { #1 } { auto } |
| 2938 |
{ \@@_error:n { Option~auto~for~columns-width } } |
| 2939 |
{ \dim_set:Nn \l_@@_columns_width_dim { #1 } } , |
| 2940 |
% \end{macrocode} |
| 2941 |
% |
| 2942 |
% \bigskip |
| 2943 |
% Usually, an error is raised when the user tries to give the same name to two |
| 2944 |
% distincts environments of \pkg{nicematrix} (these names are global and not |
| 2945 |
% local to the current TeX scope). However, the option |allow-duplicate-names| |
| 2946 |
% disables this feature. |
| 2947 |
% \begin{macrocode} |
| 2948 |
allow-duplicate-names .code:n = |
| 2949 |
\cs_set:Nn \@@_err_duplicate_names:n { } , |
| 2950 |
allow-duplicate-names .value_forbidden:n = true , |
| 2951 |
notes .code:n = \keys_set:nn { nicematrix / notes } { #1 } , |
| 2952 |
notes .value_required:n = true , |
| 2953 |
sub-matrix .code:n = \keys_set:nn { nicematrix / sub-matrix } { #1 } , |
| 2954 |
sub-matrix .value_required:n = true , |
| 2955 |
matrix / columns-type .tl_set:N = \l_@@_columns_type_tl , |
| 2956 |
matrix / columns-type .value_required:n = true , |
| 2957 |
caption-above .bool_set:N = \l_@@_caption_above_bool , |
| 2958 |
unknown .code:n = |
| 2959 |
\@@_unknown_key:nn |
| 2960 |
{ nicematrix / Global , nicematrix / NiceMatrixOptions } |
| 2961 |
{ Unknown~key~for~NiceMatrixOptions } |
| 2962 |
} |
| 2963 |
% \end{macrocode} |
| 2964 |
% |
| 2965 |
% |
| 2966 |
% \bigskip |
| 2967 |
% |\NiceMatrixOptions| is the command of the package \pkg{nicematrix} to fix |
| 2968 |
% options at the document level. The scope of these specifications is the |
| 2969 |
% current TeX group. |
| 2970 |
% \begin{macrocode} |
| 2971 |
\NewDocumentCommand \NiceMatrixOptions { m } |
| 2972 |
{ \keys_set:nn { nicematrix / NiceMatrixOptions } { #1 } } |
| 2973 |
% \end{macrocode} |
| 2974 |
% |
| 2975 |
% |
| 2976 |
% \bigskip |
| 2977 |
% We finalise the definition of the set of keys ``|nicematrix / NiceMatrix|''. |
| 2978 |
% That set of keys will be used by |{NiceMatrix}|, |{pNiceMatrix}|, |
| 2979 |
% |{bNiceMatrix}|, etc. |
| 2980 |
% |
| 2981 |
% \begin{macrocode} |
| 2982 |
\keys_define:nn { nicematrix / NiceMatrix } |
| 2983 |
{ |
| 2984 |
last-col .code:n = \tl_if_empty:nTF { #1 } |
| 2985 |
{ |
| 2986 |
\bool_set_true:N \l_@@_last_col_without_value_bool |
| 2987 |
\int_set:Nn \l_@@_last_col_int { -1 } |
| 2988 |
} |
| 2989 |
{ \int_set:Nn \l_@@_last_col_int { #1 } } , |
| 2990 |
columns-type .tl_set:N = \l_@@_columns_type_tl , |
| 2991 |
columns-type .value_required:n = true , |
| 2992 |
l .meta:n = { columns-type = l } , |
| 2993 |
r .meta:n = { columns-type = r } , |
| 2994 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 2995 |
delimiters / color .value_required:n = true , |
| 2996 |
delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool , |
| 2997 |
delimiters .code:n = \keys_set:nn { nicematrix / delimiters } { #1 } , |
| 2998 |
delimiters .value_required:n = true , |
| 2999 |
small .bool_set:N = \l_@@_small_bool , |
| 3000 |
small .value_forbidden:n = true , |
| 3001 |
unknown .code:n = |
| 3002 |
\@@_unknown_key:nn |
| 3003 |
{ nicematrix / Global , nicematrix / environments , nicematrix / NiceMatrix } |
| 3004 |
{ Unknown~key~for~NiceMatrix } |
| 3005 |
} |
| 3006 |
% \end{macrocode} |
| 3007 |
% |
| 3008 |
% |
| 3009 |
% |
| 3010 |
% \bigskip |
| 3011 |
% We finalise the definition of the set of keys ``|nicematrix / NiceArray|'' |
| 3012 |
% with the options specific to |{NiceArray}|. |
| 3013 |
% |
| 3014 |
% \begin{macrocode} |
| 3015 |
\keys_define:nn { nicematrix / NiceArray } |
| 3016 |
{ |
| 3017 |
% \end{macrocode} |
| 3018 |
% |
| 3019 |
% In the environments |{NiceArray}| and its variants, the option |last-col| must |
| 3020 |
% be used without value because the number of columns of the array is read |
| 3021 |
% from the preamble of the array. |
| 3022 |
% \begin{macrocode} |
| 3023 |
small .bool_set:N = \l_@@_small_bool , |
| 3024 |
small .value_forbidden:n = true , |
| 3025 |
last-col .code:n = \tl_if_empty:nF { #1 } |
| 3026 |
{ \@@_error:n { last-col~non~empty~for~NiceArray } } |
| 3027 |
\int_zero:N \l_@@_last_col_int , |
| 3028 |
r .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3029 |
l .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3030 |
unknown .code:n = |
| 3031 |
\@@_unknown_key:nn |
| 3032 |
{ nicematrix / NiceArray , nicematrix / Global , nicematrix / environments} |
| 3033 |
{ Unknown~key~for~NiceArray } |
| 3034 |
} |
| 3035 |
% \end{macrocode} |
| 3036 |
% |
| 3037 |
% |
| 3038 |
% |
| 3039 |
% \begin{macrocode} |
| 3040 |
\keys_define:nn { nicematrix / pNiceArray } |
| 3041 |
{ |
| 3042 |
first-col .code:n = \int_zero:N \l_@@_first_col_int , |
| 3043 |
last-col .code:n = \tl_if_empty:nF { #1 } |
| 3044 |
{ \@@_error:n { last-col~non~empty~for~NiceArray } } |
| 3045 |
\int_zero:N \l_@@_last_col_int , |
| 3046 |
first-row .code:n = \int_zero:N \l_@@_first_row_int , |
| 3047 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 3048 |
delimiters / color .value_required:n = true , |
| 3049 |
delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool , |
| 3050 |
delimiters .code:n = \keys_set:nn { nicematrix / delimiters } { #1 } , |
| 3051 |
delimiters .value_required:n = true , |
| 3052 |
small .bool_set:N = \l_@@_small_bool , |
| 3053 |
small .value_forbidden:n = true , |
| 3054 |
r .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3055 |
l .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3056 |
unknown .code:n = |
| 3057 |
\@@_unknown_key:nn |
| 3058 |
{ nicematrix / pNiceArray , nicematrix / Global , nicematrix / environments } |
| 3059 |
{ Unknown~key~for~NiceMatrix } |
| 3060 |
} |
| 3061 |
% \end{macrocode} |
| 3062 |
% |
| 3063 |
% \bigskip |
| 3064 |
% We finalise the definition of the set of keys ``|nicematrix / NiceTabular|'' |
| 3065 |
% with the options specific to |{NiceTabular}|. |
| 3066 |
% |
| 3067 |
% \begin{macrocode} |
| 3068 |
\keys_define:nn { nicematrix / NiceTabular } |
| 3069 |
{ |
| 3070 |
% \end{macrocode} |
| 3071 |
% The dimension |width| will be used if at least a column of type |X| is used. |
| 3072 |
% If there is no column of type |X|, an error will be raised. |
| 3073 |
% \begin{macrocode} |
| 3074 |
width .code:n = \dim_set:Nn \l_@@_width_dim { #1 } |
| 3075 |
\bool_set_true:N \l_@@_width_used_bool , |
| 3076 |
width .value_required:n = true , |
| 3077 |
notes .code:n = \keys_set:nn { nicematrix / notes } { #1 } , |
| 3078 |
tabularnote .tl_gset:N = \g_@@_tabularnote_tl , |
| 3079 |
tabularnote .value_required:n = true , |
| 3080 |
caption .tl_set:N = \l_@@_caption_tl , |
| 3081 |
caption .value_required:n = true , |
| 3082 |
short-caption .tl_set:N = \l_@@_short_caption_tl , |
| 3083 |
short-caption .value_required:n = true , |
| 3084 |
label .tl_set:N = \l_@@_label_tl , |
| 3085 |
label .value_required:n = true , |
| 3086 |
last-col .code:n = \tl_if_empty:nF { #1 } |
| 3087 |
{ \@@_error:n { last-col~non~empty~for~NiceArray } } |
| 3088 |
\int_zero:N \l_@@_last_col_int , |
| 3089 |
r .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3090 |
l .code:n = \@@_error:n { r~or~l~with~preamble } , |
| 3091 |
unknown .code:n = |
| 3092 |
\@@_unknown_key:nn |
| 3093 |
{ nicematrix / NiceTabular , nicematrix / Global , nicematrix / environments } |
| 3094 |
{ Unknown~key~for~NiceTabular } |
| 3095 |
} |
| 3096 |
% \end{macrocode} |
| 3097 |
% |
| 3098 |
% |
| 3099 |
% \bigskip |
| 3100 |
% The |\CodeAfter| (inserted with the key |code-after| or after the keyword |
| 3101 |
% |\CodeAfter|) may always begin with a list of pairs \textsl{key=value} between |
| 3102 |
% square brackets. Here is the corresponding set of keys. |
| 3103 |
% |
| 3104 |
% We \emph{must} put the following instructions \emph{after} the : |
| 3105 |
% |
| 3106 |
% \begin{verbatim} |
| 3107 |
% CodeAfter / sub-matrix .inherit:n = nicematrix / sub-matrix |
| 3108 |
% \end{verbatim} |
| 3109 |
% |
| 3110 |
% \begin{macrocode} |
| 3111 |
\keys_define:nn { nicematrix / CodeAfter } |
| 3112 |
{ |
| 3113 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 3114 |
delimiters / color .value_required:n = true , |
| 3115 |
rules .code:n = \keys_set:nn { nicematrix / rules } { #1 } , |
| 3116 |
rules .value_required:n = true , |
| 3117 |
xdots .code:n = \keys_set:nn { nicematrix / xdots } { #1 } , |
| 3118 |
sub-matrix .code:n = \keys_set:nn { nicematrix / sub-matrix } { #1 } , |
| 3119 |
sub-matrix .value_required:n = true , |
| 3120 |
unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter } |
| 3121 |
} |
| 3122 |
% \end{macrocode} |
| 3123 |
% |
| 3124 |
% \bigskip |
| 3125 |
% \section{Important code used by \{NiceArrayWithDelims\} } |
| 3126 |
% |
| 3127 |
% The pseudo-environment |\@@_cell_begin:|--|\@@_cell_end:| will be used to format the |
| 3128 |
% cells of the array. In the code, the affectations are global because this |
| 3129 |
% pseudo-environment will be used in the cells of a |\halign| (via an |
| 3130 |
% environment |{array}|). |
| 3131 |
% |
| 3132 |
% \begin{macrocode} |
| 3133 |
\cs_new_protected:Npn \@@_cell_begin: |
| 3134 |
{ |
| 3135 |
% \end{macrocode} |
| 3136 |
% |\g_@@_cell_after_hook_tl| will be set during the composition of the box |
| 3137 |
% |\l_@@_cell_box| and will be used \emph{after} the composition in order to |
| 3138 |
% modify that box. |
| 3139 |
% \begin{macrocode} |
| 3140 |
\tl_gclear:N \g_@@_cell_after_hook_tl |
| 3141 |
% \end{macrocode} |
| 3142 |
% At the beginning of the cell, we link |\CodeAfter| to a command which do |
| 3143 |
% begin with |\\| (whereas the standard version of |\CodeAfter| does |
| 3144 |
% not). |
| 3145 |
% \begin{macrocode} |
| 3146 |
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i: |
| 3147 |
% \end{macrocode} |
| 3148 |
% The following link is done only to have a better error message when |\Hline| |
| 3149 |
% is used in another place than the beginning of a line. |
| 3150 |
% \begin{macrocode} |
| 3151 |
\cs_set_eq:NN \Hline \@@_Hline_in_cell: |
| 3152 |
% \end{macrocode} |
| 3153 |
% We increment the LaTeX counter |jCol|, which is the counter of the columns. |
| 3154 |
% \begin{macrocode} |
| 3155 |
\int_gincr:N \c@jCol |
| 3156 |
% \end{macrocode} |
| 3157 |
% Now, we increment the counter of the rows. We don't do this incrementation in |
| 3158 |
% the |\everycr| because some packages, like \pkg{arydshln}, create special rows |
| 3159 |
% in the |\halign| that we don't want to take into account. |
| 3160 |
% |
| 3161 |
% Here is a version with the standard syntax of L3. |
| 3162 |
% \begin{Verbatim}[formatcom=\small] |
| 3163 |
% \int_compare:nNnT { \c@jCol } = { 1 } |
| 3164 |
% { \int_compare:nNnT \l_@@_first_col_int = { 1 } { \@@_begin_of_row: } } |
| 3165 |
% \end{Verbatim} |
| 3166 |
% |
| 3167 |
% We will use a version a little more efficient. |
| 3168 |
% \begin{macrocode} |
| 3169 |
\if_int_compare:w \c@jCol = \c_one_int |
| 3170 |
\if_int_compare:w \l_@@_first_col_int = \c_one_int |
| 3171 |
\@@_begin_of_row: |
| 3172 |
\fi: |
| 3173 |
\fi: |
| 3174 |
% \end{macrocode} |
| 3175 |
% The content of the cell is composed in the box |\l_@@_cell_box|. The |
| 3176 |
% |\hbox_set_end:| corresponding to this |\hbox_set:Nw| is in the |
| 3177 |
% |\@@_cell_end:|. |
| 3178 |
% \begin{macrocode} |
| 3179 |
\hbox_set:Nw \l_@@_cell_box |
| 3180 |
% \end{macrocode} |
| 3181 |
% The following command is nullified in the tabulars. |
| 3182 |
% \begin{macrocode} |
| 3183 |
\@@_tuning_not_tabular_begin: |
| 3184 |
% \end{macrocode} |
| 3185 |
% |
| 3186 |
% \begin{macrocode} |
| 3187 |
\@@_tuning_exterior_rows: |
| 3188 |
\g_@@_row_style_tl |
| 3189 |
} |
| 3190 |
% \end{macrocode} |
| 3191 |
% |
| 3192 |
% \begin{macrocode} |
| 3193 |
\cs_new_protected:Npn \@@_tuning_exterior_rows: { } |
| 3194 |
% \end{macrocode} |
| 3195 |
% |
| 3196 |
% Here is a version with the standard syntax of L3. |
| 3197 |
% \begin{Verbatim}[formatcom=\small] |
| 3198 |
% \cs_new_protected:Npn \@@_tuning_first_last_row: |
| 3199 |
% { |
| 3200 |
% \int_if_zero:nTF { \c@iRow } |
| 3201 |
% { |
| 3202 |
% \int_if_zero:nF { \c@jCol } |
| 3203 |
% { |
| 3204 |
% \l_@@_code_for_first_row_tl |
| 3205 |
% \xglobal \colorlet { nicematrix-first-row } { . } |
| 3206 |
% } |
| 3207 |
% } |
| 3208 |
% { \cs_gset_eq:NN \@@_tuning_exterior_rows: \@@_tuning_last_row: } |
| 3209 |
% } |
| 3210 |
% \end{Verbatim} |
| 3211 |
% |
| 3212 |
% We will use a version a little more efficient. |
| 3213 |
% \begin{macrocode} |
| 3214 |
\cs_new_protected:Npn \@@_tuning_first_last_row: |
| 3215 |
{ |
| 3216 |
\if_int_compare:w \c@iRow = \c_zero_int |
| 3217 |
\if_int_compare:w \c@jCol > \c_zero_int |
| 3218 |
\l_@@_code_for_first_row_tl |
| 3219 |
\@@_tuning_key_small: % 2026/04/06 |
| 3220 |
\xglobal \colorlet { nicematrix-first-row } { . } |
| 3221 |
\fi: |
| 3222 |
\else: |
| 3223 |
\cs_gset_eq:NN \@@_tuning_exterior_rows: \@@_tuning_last_row: |
| 3224 |
\fi: |
| 3225 |
} |
| 3226 |
% \end{macrocode} |
| 3227 |
% |
| 3228 |
% |
| 3229 |
% The following command will be nullified unless there is a last row and we |
| 3230 |
% know its value (\emph{ie}: |\l_@@_lat_row_int > 0|). |
| 3231 |
% \begin{Verbatim}[formatcom=\small] |
| 3232 |
% \cs_new_protected:Npn \@@_tuning_last_row: |
| 3233 |
% { |
| 3234 |
% \int_compare:nNnT { \c@iRow } = { \l_@@_last_row_int } |
| 3235 |
% { |
| 3236 |
% \l_@@_code_for_last_row_tl |
| 3237 |
% \xglobal \colorlet { nicematrix-last-row } { . } |
| 3238 |
% } |
| 3239 |
% } |
| 3240 |
% \end{Verbatim} |
| 3241 |
% |
| 3242 |
% We will use a version a little more efficient. |
| 3243 |
% \begin{macrocode} |
| 3244 |
\cs_new_protected:Npn \@@_tuning_last_row: |
| 3245 |
{ |
| 3246 |
\if_int_compare:w \c@iRow = \l_@@_last_row_int |
| 3247 |
\l_@@_code_for_last_row_tl |
| 3248 |
\@@_tuning_key_small: % 2026/04/06 |
| 3249 |
\xglobal \colorlet { nicematrix-last-row } { . } |
| 3250 |
\fi: |
| 3251 |
} |
| 3252 |
% \end{macrocode} |
| 3253 |
% |
| 3254 |
% A different value will be provided to the following commands when the key |
| 3255 |
% |small| is in force. |
| 3256 |
% \begin{macrocode} |
| 3257 |
\cs_set_eq:NN \@@_tuning_key_small: \prg_do_nothing: |
| 3258 |
% \end{macrocode} |
| 3259 |
% |
| 3260 |
% The following commands are nullified in the tabulars. |
| 3261 |
% \begin{macrocode} |
| 3262 |
\cs_set_nopar:Npn \@@_tuning_not_tabular_begin: |
| 3263 |
{ |
| 3264 |
\m@th |
| 3265 |
$ % $ |
| 3266 |
% \end{macrocode} |
| 3267 |
% A special value is provided by the following control sequence when the key |
| 3268 |
% |small| is in force. |
| 3269 |
% \begin{macrocode} |
| 3270 |
\@@_tuning_key_small: |
| 3271 |
} |
| 3272 |
\cs_set:Nn \@@_tuning_not_tabular_end: { $ } % $ |
| 3273 |
% \end{macrocode} |
| 3274 |
% |
| 3275 |
% \interitem |
| 3276 |
% The following macro |\@@_begin_of_row| is usually used in the cell |
| 3277 |
% number~$1$ of the row. However, when the key |first-col| is used, |
| 3278 |
% |\@@_begin_of_row| is executed in the cell number~$0$ of the row. |
| 3279 |
% \begin{macrocode} |
| 3280 |
\cs_new_protected:Npn \@@_begin_of_row: |
| 3281 |
{ |
| 3282 |
\int_gincr:N \c@iRow |
| 3283 |
\dim_gset_eq:NN \g_@@_dp_ante_last_row_dim \g_@@_dp_last_row_dim |
| 3284 |
\dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox } |
| 3285 |
\dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox } |
| 3286 |
\pgfpicture |
| 3287 |
\pgfrememberpicturepositiononpagetrue |
| 3288 |
\pgfcoordinate |
| 3289 |
{ \@@_env: - row - \int_use:N \c@iRow - base } |
| 3290 |
{ \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } } |
| 3291 |
\str_if_empty:NF \l_@@_name_str |
| 3292 |
{ |
| 3293 |
\pgfnodealias |
| 3294 |
{ \l_@@_name_str - row - \int_use:N \c@iRow - base } |
| 3295 |
{ \@@_env: - row - \int_use:N \c@iRow - base } |
| 3296 |
} |
| 3297 |
\endpgfpicture |
| 3298 |
} |
| 3299 |
% \end{macrocode} |
| 3300 |
% Remark: If the key |create-cell-nodes| of the |\CodeBefore| is used, then we |
| 3301 |
% will add some lines to that command. |
| 3302 |
% |
| 3303 |
% |
| 3304 |
% \interitem |
| 3305 |
% The following code is used in each cell of the array. It actualises quantities |
| 3306 |
% that, at the end of the array, will give information about the vertical |
| 3307 |
% dimension of the two first rows and the two last rows. If the user uses the |
| 3308 |
% |last-row|, some lines of code will be dynamically added to this command. |
| 3309 |
% |
| 3310 |
% |
| 3311 |
% Here is a version with the standard syntax of L3. |
| 3312 |
% \begin{Verbatim}[formatcom = \small] |
| 3313 |
% \cs_new_protected:Npn \@@_update_for_first_and_last_row: |
| 3314 |
% { |
| 3315 |
% \int_if_zero:nTF { \c@iRow } |
| 3316 |
% { |
| 3317 |
% \dim_compare:nNnT |
| 3318 |
% { \box_dp:N \l_@@_cell_box } > { \g_@@_dp_row_zero_dim } |
| 3319 |
% { \dim_gset:Nn \g_@@_dp_row_zero_dim { \box_dp:N \l_@@_cell_box } } |
| 3320 |
% \dim_compare:nNnT |
| 3321 |
% { \box_ht:N \l_@@_cell_box } > { \g_@@_ht_row_zero_dim } |
| 3322 |
% { \dim_gset:Nn \g_@@_ht_row_zero_dim { \box_ht:N \l_@@_cell_box } } |
| 3323 |
% } |
| 3324 |
% { |
| 3325 |
% \int_compare:nNnT { \c@iRow } = { 1 } |
| 3326 |
% { |
| 3327 |
% \dim_compare:nNnT |
| 3328 |
% { \box_ht:N \l_@@_cell_box } > { \g_@@_ht_row_one_dim } |
| 3329 |
% { \dim_gset:Nn \g_@@_ht_row_one_dim { \box_ht:N \l_@@_cell_box } } |
| 3330 |
% } |
| 3331 |
% } |
| 3332 |
% } |
| 3333 |
% \end{Verbatim} |
| 3334 |
% |
| 3335 |
% We will use a version a little more efficient. |
| 3336 |
% \begin{macrocode} |
| 3337 |
\cs_new_protected:Npn \@@_update_for_first_and_last_row: |
| 3338 |
{ |
| 3339 |
\if_int_compare:w \c@iRow = \c_zero_int |
| 3340 |
\if_dim:w \box_dp:N \l_@@_cell_box > \g_@@_dp_row_zero_dim |
| 3341 |
\global \g_@@_dp_row_zero_dim = \box_dp:N \l_@@_cell_box |
| 3342 |
\fi: |
| 3343 |
\if_dim:w \box_ht:N \l_@@_cell_box > \g_@@_ht_row_zero_dim |
| 3344 |
\global \g_@@_ht_row_zero_dim = \box_ht:N \l_@@_cell_box |
| 3345 |
\fi: |
| 3346 |
\else: |
| 3347 |
\if_int_compare:w \c@iRow = \c_one_int |
| 3348 |
\if_dim:w \box_ht:N \l_@@_cell_box > \g_@@_ht_row_one_dim |
| 3349 |
\global \g_@@_ht_row_one_dim = \box_ht:N \l_@@_cell_box |
| 3350 |
\fi: |
| 3351 |
\fi: |
| 3352 |
\fi: |
| 3353 |
} |
| 3354 |
% \end{macrocode} |
| 3355 |
% |
| 3356 |
% \bigskip |
| 3357 |
% \begin{macrocode} |
| 3358 |
\cs_new_protected:Npn \@@_rotate_cell_box: |
| 3359 |
{ |
| 3360 |
\box_rotate:Nn \l_@@_cell_box |
| 3361 |
{ \bool_if:NTF \g_@@_rotate_minus_bool { -90 } { 90 } } |
| 3362 |
\bool_if:NTF \g_@@_rotate_c_bool |
| 3363 |
{ |
| 3364 |
\hbox_set:Nn \l_@@_cell_box |
| 3365 |
{ |
| 3366 |
\IfFormatAtLeastTF { 2026-04-01 } |
| 3367 |
{ \vbox_center:n { \box_use:N \l_@@_cell_box } } |
| 3368 |
{ |
| 3369 |
\m@th |
| 3370 |
$ % $ |
| 3371 |
\vcenter { \box_use:N \l_@@_cell_box } |
| 3372 |
$ % $ |
| 3373 |
} |
| 3374 |
} |
| 3375 |
} |
| 3376 |
{ |
| 3377 |
\int_compare:nNnT \c@iRow = \l_@@_last_row_int |
| 3378 |
{ |
| 3379 |
\vbox_set_top:Nn \l_@@_cell_box |
| 3380 |
{ |
| 3381 |
\vbox_to_zero:n { } |
| 3382 |
\skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } |
| 3383 |
\box_use:N \l_@@_cell_box |
| 3384 |
} |
| 3385 |
} |
| 3386 |
} |
| 3387 |
\bool_gset_false:N \g_@@_rotate_bool |
| 3388 |
\bool_gset_false:N \g_@@_rotate_c_bool |
| 3389 |
\bool_gset_false:N \g_@@_rotate_minus_bool |
| 3390 |
} |
| 3391 |
% \end{macrocode} |
| 3392 |
% |
| 3393 |
% |
| 3394 |
% \bigskip |
| 3395 |
% Here is a version of the command |\@@_adjust_size_box:| with the syntax |
| 3396 |
% of standard L3. |
| 3397 |
% \begin{Verbatim}[formatcom=\small] |
| 3398 |
% \cs_new_protected:Npn \@@_adjust_size_box: |
| 3399 |
% { |
| 3400 |
% \dim_compare:nNnT { \g_@@_blocks_wd_dim } > { \c_zero_dim } |
| 3401 |
% { |
| 3402 |
% \dim_compare:nNnT \g_@@_blocks_wd_dim > { \box_wd:N \l_@@_cell_box } |
| 3403 |
% { \box_set_wd:Nn \l_@@_cell_box \g_@@_blocks_wd_dim } |
| 3404 |
% \dim_gzero:N \g_@@_blocks_wd_dim |
| 3405 |
% } |
| 3406 |
% \dim_compare:nNnT { \g_@@_blocks_dp_dim } > { \c_zero_dim } |
| 3407 |
% { |
| 3408 |
% \dim_compare:nNnT \g_@@_blocks_dp_dim > { \box_dp:N \l_@@_cell_box } |
| 3409 |
% { \box_set_dp:Nn \l_@@_cell_box \g_@@_blocks_dp_dim } |
| 3410 |
% \dim_gzero:N \g_@@_blocks_dp_dim |
| 3411 |
% } |
| 3412 |
% \dim_compare:nNnT { \g_@@_blocks_ht_dim } > { \c_zero_dim } |
| 3413 |
% { |
| 3414 |
% \dim_compare:nNnT \g_@@_blocks_ht_dim > { \box_ht:N \l_@@_cell_box } |
| 3415 |
% { \box_set_ht:Nn \l_@@_cell_box \g_@@_blocks_ht_dim } |
| 3416 |
% \dim_gzero:N \g_@@_blocks_ht_dim |
| 3417 |
% } |
| 3418 |
% } |
| 3419 |
% \end{Verbatim} |
| 3420 |
% |
| 3421 |
% Here is a version slightly more efficient. |
| 3422 |
% \begin{macrocode} |
| 3423 |
\cs_set_protected:Npn \@@_adjust_size_box: |
| 3424 |
{ |
| 3425 |
\if_dim:w \g_@@_blocks_wd_dim > \c_zero_dim |
| 3426 |
\if_dim:w \g_@@_blocks_wd_dim > \box_wd:N \l_@@_cell_box |
| 3427 |
\box_wd:N \l_@@_cell_box = \g_@@_blocks_wd_dim |
| 3428 |
\fi: |
| 3429 |
\global \g_@@_blocks_wd_dim = \c_zero_dim |
| 3430 |
\fi: |
| 3431 |
\if_dim:w \g_@@_blocks_dp_dim > \c_zero_dim |
| 3432 |
\if_dim:w \g_@@_blocks_dp_dim > \box_dp:N \l_@@_cell_box |
| 3433 |
\box_dp:N \l_@@_cell_box = \g_@@_blocks_dp_dim |
| 3434 |
\fi |
| 3435 |
\global \g_@@_blocks_dp_dim = \c_zero_dim |
| 3436 |
\fi: |
| 3437 |
\if_dim:w \g_@@_blocks_ht_dim > \c_zero_dim |
| 3438 |
\if_dim:w \g_@@_blocks_ht_dim > \box_ht:N \l_@@_cell_box |
| 3439 |
\box_ht:N \l_@@_cell_box = \g_@@_blocks_ht_dim |
| 3440 |
\fi: |
| 3441 |
\global \g_@@_blocks_ht_dim = \c_zero_dim |
| 3442 |
\fi: |
| 3443 |
} |
| 3444 |
% \end{macrocode} |
| 3445 |
% |
| 3446 |
% |
| 3447 |
% \begin{macrocode} |
| 3448 |
\cs_new_protected:Npn \@@_cell_end: |
| 3449 |
{ |
| 3450 |
% \end{macrocode} |
| 3451 |
% The following command is nullified in the tabulars. |
| 3452 |
% \begin{macrocode} |
| 3453 |
\@@_tuning_not_tabular_end: |
| 3454 |
\hbox_set_end: |
| 3455 |
\@@_cell_end_i: |
| 3456 |
} |
| 3457 |
% \end{macrocode} |
| 3458 |
% |
| 3459 |
% |
| 3460 |
% \begin{Verbatim}[formatcom=\small] |
| 3461 |
% \cs_new_protected:Npn \@@_cell_end_i: |
| 3462 |
% { |
| 3463 |
% \g_@@_cell_after_hook_tl |
| 3464 |
% \bool_if:NT \g_@@_rotate_bool { \@@_rotate_cell_box: } |
| 3465 |
% \@@_adjust_size_box: |
| 3466 |
% \box_set_ht:Nn \l_@@_cell_box |
| 3467 |
% { \box_ht:N \l_@@_cell_box + \l_@@_cell_space_top_limit_dim } |
| 3468 |
% \box_set_dp:Nn \l_@@_cell_box |
| 3469 |
% { \box_dp:N \l_@@_cell_box + \l_@@_cell_space_bottom_limit_dim } |
| 3470 |
% \@@_update_max_cell_width: |
| 3471 |
% \@@_update_for_first_and_last_row: |
| 3472 |
% \bool_if:NTF \g_@@_empty_cell_bool |
| 3473 |
% { \box_use_drop:N \l_@@_cell_box } |
| 3474 |
% { |
| 3475 |
% \bool_if:NTF \g_@@_not_empty_cell_bool |
| 3476 |
% { \@@_print_node_cell: } |
| 3477 |
% { |
| 3478 |
% \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > { \c_zero_dim } |
| 3479 |
% { \@@_print_node_cell: } |
| 3480 |
% { \box_use_drop:N \l_@@_cell_box } |
| 3481 |
% } |
| 3482 |
% } |
| 3483 |
% \int_compare:nNnT { \c@jCol } > { \g_@@_col_total_int } |
| 3484 |
% { \int_gset_eq:NN \g_@@_col_total_int \c@jCol } |
| 3485 |
% \bool_gset_false:N \g_@@_empty_cell_bool |
| 3486 |
% \bool_gset_false:N \g_@@_not_empty_cell_bool |
| 3487 |
% } |
| 3488 |
% \end{Verbatim} |
| 3489 |
% |
| 3490 |
% \bigskip |
| 3491 |
% Here is a version slightly more efficient. |
| 3492 |
% \begin{macrocode} |
| 3493 |
\cs_new_protected:Npn \@@_cell_end_i: |
| 3494 |
{ |
| 3495 |
% \end{macrocode} |
| 3496 |
% The token list |\g_@@_cell_after_hook_tl| is (potentially) set during the |
| 3497 |
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the |
| 3498 |
% composition in order to modify that box. |
| 3499 |
% \begin{macrocode} |
| 3500 |
\g_@@_cell_after_hook_tl |
| 3501 |
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: |
| 3502 |
\@@_adjust_size_box: |
| 3503 |
% \end{macrocode} |
| 3504 |
% |
| 3505 |
% \begin{macrocode} |
| 3506 |
\box_set_ht:Nn \l_@@_cell_box |
| 3507 |
{ \box_ht:N \l_@@_cell_box + \l_@@_cell_space_top_limit_dim } |
| 3508 |
\box_set_dp:Nn \l_@@_cell_box |
| 3509 |
{ \box_dp:N \l_@@_cell_box + \l_@@_cell_space_bottom_limit_dim } |
| 3510 |
% \end{macrocode} |
| 3511 |
% |
| 3512 |
% We want to compute in |\g_@@_max_cell_width_dim| the width of the widest cell |
| 3513 |
% of the array (except the cells of the ``first column'' and the ``last |
| 3514 |
% column''). |
| 3515 |
% \begin{macrocode} |
| 3516 |
\@@_update_max_cell_width: |
| 3517 |
% \end{macrocode} |
| 3518 |
% |
| 3519 |
% The following computations are for the ``first row'' and the ``last row''. |
| 3520 |
% \begin{macrocode} |
| 3521 |
\@@_update_for_first_and_last_row: |
| 3522 |
% \end{macrocode} |
| 3523 |
% |
| 3524 |
% \medskip |
| 3525 |
% If the cell is empty, or may be considered as if, we must not create the |
| 3526 |
% \textsc{pgf} node, for two reasons: |
| 3527 |
% \begin{itemize} |
| 3528 |
% \item it's a waste of time since such a node would be rather pointless; |
| 3529 |
% \item we test the existence of these nodes in order to determine whether a |
| 3530 |
% cell is empty when we search the extremities of a dotted line. |
| 3531 |
% \end{itemize} |
| 3532 |
% However, it's difficult to determine whether a cell is empty. Up to now |
| 3533 |
% we use the following technique: |
| 3534 |
% \begin{itemize} |
| 3535 |
% \item for the columns of type |p|, |m|, |b|, |V| (of \pkg{varwidth}) or |X|, |
| 3536 |
% we test whether the cell is syntactically empty with |\@@_test_if_empty:| and |
| 3537 |
% |\@@_test_if_empty_for_S:| |
| 3538 |
% \item if the width of the box |\l_@@_cell_box| (created with the content of |
| 3539 |
% the cell) is equal to zero, we consider the cell as empty (however, |
| 3540 |
% this is not perfect since the user may have used a |\rlap|, |\llap|, |\clap| |
| 3541 |
% or a |\mathclap| of \pkg{mathtools}). |
| 3542 |
% \item the cells with a command |\Ldots| or |\Cdots|, |\Vdots|, etc., |
| 3543 |
% should also be considered as empty; if |nullify-dots| is in force, there would |
| 3544 |
% be nothing to do (in this case the previous commands only write an instruction |
| 3545 |
% in a kind of |\CodeAfter|); however, if |nullify-dots| is not in force, a |
| 3546 |
% phantom of |\ldots|, |\cdots|, |\vdots| is inserted and its width is not equal |
| 3547 |
% to zero; that's why these commands raise a boolean |\g_@@_empty_cell_bool| and |
| 3548 |
% we begin by testing this boolean. |
| 3549 |
% \end{itemize} |
| 3550 |
% \begin{macrocode} |
| 3551 |
\bool_if:NTF \g_@@_empty_cell_bool |
| 3552 |
{ \box_use_drop:N \l_@@_cell_box } |
| 3553 |
{ |
| 3554 |
\bool_if:NTF \g_@@_not_empty_cell_bool |
| 3555 |
\@@_print_node_cell: |
| 3556 |
{ |
| 3557 |
\if_dim:w \box_wd:N \l_@@_cell_box > \c_zero_dim |
| 3558 |
\@@_print_node_cell: |
| 3559 |
\else: |
| 3560 |
\box_use_drop:N \l_@@_cell_box |
| 3561 |
\fi: |
| 3562 |
} |
| 3563 |
} |
| 3564 |
\if_int_compare:w \c@jCol > \g_@@_col_total_int |
| 3565 |
\global \g_@@_col_total_int = \c@jCol |
| 3566 |
\fi: |
| 3567 |
\global \let \g_@@_empty_cell_bool \c_false_bool |
| 3568 |
\global \let \g_@@_not_empty_cell_bool \c_false_bool |
| 3569 |
} |
| 3570 |
% \end{macrocode} |
| 3571 |
% |
| 3572 |
% \bigskip |
| 3573 |
% The following command will be nullified in our redefinition of |\multicolumn|. |
| 3574 |
% \begin{Verbatim}[formatcom=\small] |
| 3575 |
% \cs_new_protected:Npn \@@_update_max_cell_width: |
| 3576 |
% { |
| 3577 |
% \dim_gset:Nn \g_@@_max_cell_width_dim |
| 3578 |
% { \dim_max:nn { \g_@@_max_cell_width_dim } { \box_wd:N \l_@@_cell_box } } |
| 3579 |
% } |
| 3580 |
% \end{Verbatim} |
| 3581 |
% |
| 3582 |
% We will use the following version, slightly more efficient: |
| 3583 |
% \bigskip |
| 3584 |
% \begin{macrocode} |
| 3585 |
\cs_new_protected:Npn \@@_update_max_cell_width: |
| 3586 |
{ |
| 3587 |
\if_dim:w \box_wd:N \l_@@_cell_box > \g_@@_max_cell_width_dim |
| 3588 |
\global \g_@@_max_cell_width_dim = \box_wd:N \l_@@_cell_box |
| 3589 |
\fi: |
| 3590 |
} |
| 3591 |
% \end{macrocode} |
| 3592 |
% |
| 3593 |
% \bigskip |
| 3594 |
% The following variant of |\@@_cell_end:| is only for the columns of type |
| 3595 |
% |w{s}{...}| or |W{s}{...}| (which use the horizontal alignment key |s| of |
| 3596 |
% |\makebox|). |
| 3597 |
% \begin{macrocode} |
| 3598 |
\cs_new_protected:Npn \@@_cell_end_for_w_s: |
| 3599 |
{ |
| 3600 |
\@@_math_toggle: |
| 3601 |
\hbox_set_end: |
| 3602 |
\bool_if:NF \g_@@_rotate_bool |
| 3603 |
{ |
| 3604 |
\hbox_set:Nn \l_@@_cell_box |
| 3605 |
{ |
| 3606 |
\makebox [ \l_@@_col_width_dim ] [ s ] |
| 3607 |
{ \hbox_unpack_drop:N \l_@@_cell_box } |
| 3608 |
} |
| 3609 |
} |
| 3610 |
\@@_cell_end_i: |
| 3611 |
} |
| 3612 |
% \end{macrocode} |
| 3613 |
% |
| 3614 |
% \bigskip |
| 3615 |
% \begin{macrocode} |
| 3616 |
\pgfset |
| 3617 |
{ |
| 3618 |
nicematrix / cell-node /.style = |
| 3619 |
{ |
| 3620 |
inner~sep = \c_zero_dim , |
| 3621 |
minimum~width = \c_zero_dim |
| 3622 |
} |
| 3623 |
} |
| 3624 |
% \end{macrocode} |
| 3625 |
% |
| 3626 |
% \bigskip |
| 3627 |
% In the cells of a column of type |S| (of \pkg{siunitx}), we have to wrap the |
| 3628 |
% command |\@@_node_cell:| inside a command of \pkg{siunitx} to inforce the |
| 3629 |
% correct horizontal alignment. In the cells of the columns with other columns |
| 3630 |
% type, we don't have to do that job. That's why we create a socket with its |
| 3631 |
% default plug (|identity|) and a plug when we have to do the wrapping. |
| 3632 |
% \begin{macrocode} |
| 3633 |
\socket_new:nn { nicematrix / siunitx-wrap } { 1 } |
| 3634 |
\socket_new_plug:nnn { nicematrix / siunitx-wrap } { active } |
| 3635 |
{ |
| 3636 |
\use:c |
| 3637 |
{ |
| 3638 |
__siunitx_table_align_ |
| 3639 |
\bool_if:NTF \l__siunitx_table_text_bool |
| 3640 |
\l__siunitx_table_align_text_tl |
| 3641 |
\l__siunitx_table_align_number_str |
| 3642 |
:n |
| 3643 |
} |
| 3644 |
{ #1 } |
| 3645 |
} |
| 3646 |
% \end{macrocode} |
| 3647 |
% |
| 3648 |
% \bigskip |
| 3649 |
% Now, a socket which deal with |create-cell-nodes| of the keyword |
| 3650 |
% |\CodeBefore|. When that key is used the ``cell nodes'' will be created before |
| 3651 |
% the |\CodeBefore| but, of course, they are \emph{always} available in the main |
| 3652 |
% tabular and after! |
| 3653 |
% \begin{macrocode} |
| 3654 |
\socket_new:nn { nicematrix / create-cell-nodes } { 1 } |
| 3655 |
\socket_new_plug:nnn { nicematrix / create-cell-nodes } { active } |
| 3656 |
{ |
| 3657 |
\box_move_up:nn { \box_ht:N \l_@@_cell_box } |
| 3658 |
\hbox:n |
| 3659 |
{ |
| 3660 |
\pgfsys@markposition |
| 3661 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - NW } |
| 3662 |
} |
| 3663 |
#1 |
| 3664 |
\box_move_down:nn { \box_dp:N \l_@@_cell_box } |
| 3665 |
\hbox:n |
| 3666 |
{ |
| 3667 |
\pgfsys@markposition |
| 3668 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - SE } |
| 3669 |
} |
| 3670 |
} |
| 3671 |
% \end{macrocode} |
| 3672 |
% |
| 3673 |
% \bigskip |
| 3674 |
% \begin{macrocode} |
| 3675 |
\cs_new_protected:Npn \@@_print_node_cell: |
| 3676 |
{ |
| 3677 |
\socket_use:nn { nicematrix / siunitx-wrap } |
| 3678 |
{ \socket_use:nn { nicematrix / create-cell-nodes } { \@@_node_cell: } } |
| 3679 |
} |
| 3680 |
% \end{macrocode} |
| 3681 |
% |
| 3682 |
% \bigskip |
| 3683 |
% The following command creates the \textsc{pgf} name of the node with, of |
| 3684 |
% course, |\l_@@_cell_box| as the content. |
| 3685 |
% \begin{macrocode} |
| 3686 |
\cs_new_protected:Npn \@@_node_cell: |
| 3687 |
{ |
| 3688 |
\pgfpicture |
| 3689 |
\pgfsetbaseline \c_zero_dim |
| 3690 |
\pgfrememberpicturepositiononpagetrue |
| 3691 |
\pgfset { nicematrix / cell-node } |
| 3692 |
\pgfnode |
| 3693 |
{ rectangle } |
| 3694 |
{ base } |
| 3695 |
{ |
| 3696 |
% \end{macrocode} |
| 3697 |
% The following instruction |\set@color| has been added on 2022/10/06. It's |
| 3698 |
% necessary only with XeLaTeX and not with the other engines (we don't know why). |
| 3699 |
% \begin{macrocode} |
| 3700 |
\sys_if_engine_xetex:T { \set@color } |
| 3701 |
\box_use:N \l_@@_cell_box |
| 3702 |
} |
| 3703 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 3704 |
{ \l_@@_pgf_node_code_tl } |
| 3705 |
\str_if_empty:NF \l_@@_name_str |
| 3706 |
{ |
| 3707 |
\pgfnodealias |
| 3708 |
{ \l_@@_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 3709 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 3710 |
} |
| 3711 |
\endpgfpicture |
| 3712 |
} |
| 3713 |
% \end{macrocode} |
| 3714 |
% |
| 3715 |
% |
| 3716 |
% \interitem |
| 3717 |
% The second argument of the following command |\@@_instruction_of_type:nnn| |
| 3718 |
% defined below is the type of the instruction (|Cdots|, |Vdots|, |Ddots|, |
| 3719 |
% etc.). The third argument is the list of options. This command writes in the |
| 3720 |
% corresponding |\g_@@_|\textsl{type}|_lines_tl| the instruction which will |
| 3721 |
% actually draw the line after the construction of the matrix. |
| 3722 |
% |
| 3723 |
% \medskip |
| 3724 |
% For example, for the following matrix, |
| 3725 |
% |
| 3726 |
% \smallskip |
| 3727 |
% \begin{BVerbatim}[baseline=c,boxwidth=11cm] |
| 3728 |
% \begin{pNiceMatrix} |
| 3729 |
% 1 & 2 & 3 & 4 \\ |
| 3730 |
% 5 & \Cdots & & 6 \\ |
| 3731 |
% 7 & \Cdots[color=red] |
| 3732 |
% \end{pNiceMatrix} |
| 3733 |
% \end{BVerbatim} |
| 3734 |
% $\begin{pNiceMatrix} |
| 3735 |
% 1 & 2 & 3 & 4 \\ |
| 3736 |
% 5 & \Cdots & & 6 \\ |
| 3737 |
% 7 & \Cdots[color=red] |
| 3738 |
% \end{pNiceMatrix}$ |
| 3739 |
% |
| 3740 |
% \smallskip |
| 3741 |
% the content of |\g_@@_Cdots_lines_tl| will be: |
| 3742 |
% |
| 3743 |
% \smallskip |
| 3744 |
% \begin{scope} |
| 3745 |
% \color{gray} |
| 3746 |
% |\@@_draw_Cdots:nnn {2}{2}{}| |
| 3747 |
% |
| 3748 |
% |\@@_draw_Cdots:nnn {3}{2}{color=red}| |
| 3749 |
% \end{scope} |
| 3750 |
% |
| 3751 |
% |
| 3752 |
% \bigskip |
| 3753 |
% The first argument is a boolean which indicates whether you must put the |
| 3754 |
% instruction on the left or on the right on the list of instructions (with |
| 3755 |
% consequences for the parallelisation of the diagonal lines). |
| 3756 |
% \begin{macrocode} |
| 3757 |
\cs_new_protected:Npn \@@_instruction_of_type:nnn #1 #2 #3 |
| 3758 |
{ |
| 3759 |
\bool_if:nTF { #1 } \tl_gput_left:ce \tl_gput_right:ce |
| 3760 |
{ g_@@_ #2 _ lines _ tl } |
| 3761 |
{ |
| 3762 |
\use:c { @@ _ draw _ #2 : nnn } |
| 3763 |
{ \int_use:N \c@iRow } |
| 3764 |
{ \int_use:N \c@jCol } |
| 3765 |
{ \exp_not:n { #3 } } |
| 3766 |
} |
| 3767 |
} |
| 3768 |
% \end{macrocode} |
| 3769 |
% |
| 3770 |
% \bigskip |
| 3771 |
% \begin{macrocode} |
| 3772 |
\cs_new_protected:Npn \@@_array:n |
| 3773 |
{ |
| 3774 |
\dim_set:Nn \col@sep |
| 3775 |
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep } |
| 3776 |
\dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim |
| 3777 |
{ \def \@halignto { } } |
| 3778 |
{ \cs_set_nopar:Npe \@halignto { to \dim_use:N \l_@@_tabular_width_dim } } |
| 3779 |
% \end{macrocode} |
| 3780 |
% It \pkg{colortbl} is loaded, |\@tabarray| has been redefined to incorporate |
| 3781 |
% |\CT@start|. |
| 3782 |
% \begin{macrocode} |
| 3783 |
\@tabarray |
| 3784 |
% \end{macrocode} |
| 3785 |
% |\l_@@_baseline_tl| may have the value |t|, |c| or |b|. However, if the value |
| 3786 |
% is |b|, we compose the |\array| (of \pkg{array}) with the option |t| and the |
| 3787 |
% right translation will be done further. Remark that |\str_if_eq:eeTF| is |
| 3788 |
% fully expandable and we need something fully expandable here. |
| 3789 |
% |\str_if_eq:ee(TF)| is faster than |\str_if_eq:nn(TF)|. |
| 3790 |
% \begin{macrocode} |
| 3791 |
[ \str_if_eq:eeTF c \l_@@_baseline_tl c t ] |
| 3792 |
} |
| 3793 |
\cs_generate_variant:Nn \@@_array:n { o } |
| 3794 |
% \end{macrocode} |
| 3795 |
% |
| 3796 |
% \medskip |
| 3797 |
% We keep in memory the standard version of |\ar@ialign| because we will redefine |
| 3798 |
% |\ar@ialign| in the environment |{NiceArrayWithDelims}| but restore the standard |
| 3799 |
% version for use in the cells of the array. |
| 3800 |
% We use here a |\cs_set_eq:cN| instead of a |\cs_set_eq:NN| in order to avoid a |
| 3801 |
% message when |explcheck| is used on |nicematrix.sty|. |
| 3802 |
% \begin{macrocode} |
| 3803 |
\cs_new_eq:cN { @@_old_ar@ialign: } \ar@ialign |
| 3804 |
% \end{macrocode} |
| 3805 |
% |
| 3806 |
% |
| 3807 |
% |
| 3808 |
% The following command creates a |row| node (and not a row of nodes!). |
| 3809 |
% \begin{macrocode} |
| 3810 |
\cs_new_protected:Npn \@@_create_row_node: |
| 3811 |
{ |
| 3812 |
\int_compare:nNnT \c@iRow > \g_@@_last_row_node_int |
| 3813 |
{ |
| 3814 |
\int_gset_eq:NN \g_@@_last_row_node_int \c@iRow |
| 3815 |
\@@_create_row_node_i: |
| 3816 |
} |
| 3817 |
} |
| 3818 |
% \end{macrocode} |
| 3819 |
% |
| 3820 |
% \begin{macrocode} |
| 3821 |
\cs_new_protected:Npn \@@_create_row_node_i: |
| 3822 |
{ |
| 3823 |
% \end{macrocode} |
| 3824 |
% The |\hbox:n| (or |\hbox|) is mandatory. |
| 3825 |
% \begin{macrocode} |
| 3826 |
\hbox |
| 3827 |
{ |
| 3828 |
\bool_if:NT \l_@@_code_before_bool |
| 3829 |
{ |
| 3830 |
\vtop |
| 3831 |
{ |
| 3832 |
\skip_vertical:N 0.5\arrayrulewidth |
| 3833 |
\pgfsys@markposition |
| 3834 |
{ \@@_env: - row - \int_eval:n { \c@iRow + 1 } } |
| 3835 |
\skip_vertical:N -0.5\arrayrulewidth |
| 3836 |
} |
| 3837 |
} |
| 3838 |
\pgfpicture |
| 3839 |
\pgfrememberpicturepositiononpagetrue |
| 3840 |
\pgfcoordinate { \@@_env: - row - \int_eval:n { \c@iRow + 1 } } |
| 3841 |
{ \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } } |
| 3842 |
\str_if_empty:NF \l_@@_name_str |
| 3843 |
{ |
| 3844 |
\pgfnodealias |
| 3845 |
{ \l_@@_name_str - row - \int_eval:n { \c@iRow + 1 } } |
| 3846 |
{ \@@_env: - row - \int_eval:n { \c@iRow + 1 } } |
| 3847 |
} |
| 3848 |
\endpgfpicture |
| 3849 |
} |
| 3850 |
} |
| 3851 |
% \end{macrocode} |
| 3852 |
% |
| 3853 |
% |
| 3854 |
% \bigskip |
| 3855 |
% \begin{macrocode} |
| 3856 |
\cs_new_protected:Npn \@@_in_everycr: |
| 3857 |
{ |
| 3858 |
\tbl_if_row_was_started:T { \UseTaggingSocket { tbl / row / end } } |
| 3859 |
\tbl_update_cell_data_for_next_row: |
| 3860 |
\int_gzero:N \c@jCol |
| 3861 |
\bool_gset_false:N \g_@@_after_col_zero_bool |
| 3862 |
\bool_if:NF \g_@@_row_of_col_done_bool |
| 3863 |
{ |
| 3864 |
\@@_create_row_node: |
| 3865 |
% \end{macrocode} |
| 3866 |
% We don't draw now the rules of the key |hlines| (or |hvlines|) but we reserve the |
| 3867 |
% vertical space for these rules (the rules will be drawn by \textsc{pgf}). |
| 3868 |
% \begin{macrocode} |
| 3869 |
\clist_if_empty:NF \l_@@_hlines_clist |
| 3870 |
{ |
| 3871 |
\str_if_eq:eeF \l_@@_hlines_clist { all } |
| 3872 |
{ |
| 3873 |
\clist_if_in:NeT |
| 3874 |
\l_@@_hlines_clist |
| 3875 |
{ \int_eval:n { \c@iRow + 1 } } |
| 3876 |
} |
| 3877 |
{ |
| 3878 |
% \end{macrocode} |
| 3879 |
% The counter |\c@iRow| has the value $-1$ only if there is a ``first |
| 3880 |
% row'' and that we are before that ``first row'', i.e. just before the |
| 3881 |
% beginning of the array. |
| 3882 |
% \begin{macrocode} |
| 3883 |
\int_compare:nNnT \c@iRow > { -1 } |
| 3884 |
{ |
| 3885 |
\int_compare:nNnF \c@iRow = \l_@@_last_row_int |
| 3886 |
% \end{macrocode} |
| 3887 |
% |
| 3888 |
% \begin{macrocode} |
| 3889 |
{ \hrule height \arrayrulewidth width \c_zero_dim } |
| 3890 |
} |
| 3891 |
} |
| 3892 |
} |
| 3893 |
} |
| 3894 |
} |
| 3895 |
% \end{macrocode} |
| 3896 |
% |
| 3897 |
% |
| 3898 |
% |
| 3899 |
% |
| 3900 |
% \bigskip |
| 3901 |
% When the key |renew-dots| is used, the following code will be executed. |
| 3902 |
% \begin{macrocode} |
| 3903 |
\cs_set_protected:Npn \@@_renew_dots: |
| 3904 |
{ |
| 3905 |
\cs_set_eq:NN \ldots \@@_Ldots: |
| 3906 |
\cs_set_eq:NN \cdots \@@_Cdots: |
| 3907 |
\cs_set_eq:NN \vdots \@@_Vdots: |
| 3908 |
\cs_set_eq:NN \ddots \@@_Ddots: |
| 3909 |
\cs_set_eq:NN \iddots \@@_Iddots: |
| 3910 |
\cs_set_eq:NN \dots \@@_Ldots: |
| 3911 |
\cs_set_eq:NN \hdotsfor \@@_Hdotsfor: |
| 3912 |
} |
| 3913 |
% \end{macrocode} |
| 3914 |
% |
| 3915 |
% |
| 3916 |
% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is |
| 3917 |
% a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but |
| 3918 |
% it occurs after a vertical skip done by a low level TeX command. When this |
| 3919 |
% macro |\@BTnormal| occurs, the |row| node has yet been inserted by |
| 3920 |
% \pkg{nicematrix} \emph{before} the vertical skip (and thus, at a wrong place). |
| 3921 |
% That why we decide to create a new |row| node (for the same row). We patch the |
| 3922 |
% macro |\@BTnormal| to create this |row| node. This new |row| node will |
| 3923 |
% overwrite the previous definition of that |row| node and we have managed to |
| 3924 |
% avoid the error messages of that redefinition |
| 3925 |
% \footnote{cf. |\nicematrix@redefine@check@rerun|}. |
| 3926 |
% \begin{macrocode} |
| 3927 |
\AtBeginDocument |
| 3928 |
{ |
| 3929 |
\IfPackageLoadedTF { booktabs } |
| 3930 |
{ |
| 3931 |
\cs_new_protected:Npn \@@_patch_booktabs: |
| 3932 |
{ \tl_put_left:Nn \@BTnormal \@@_create_row_node_i: } |
| 3933 |
} |
| 3934 |
{ \cs_new_protected:Npn \@@_patch_booktabs: { } } |
| 3935 |
% \end{macrocode} |
| 3936 |
% \begin{macrocode} |
| 3937 |
} |
| 3938 |
% \end{macrocode} |
| 3939 |
% |
| 3940 |
% The box |\@arstrutbox| is a box constructed in the beginning of the |
| 3941 |
% environment |{array}|. The construction of that box takes into account the |
| 3942 |
% current value of |\arraystretch|\footnote{The option |small| of |
| 3943 |
% \pkg{nicematrix} changes (among others) the value of |\arraystretch|. This is |
| 3944 |
% done, of course, before the call of |{array}|.} and |\extrarowheight| (of |
| 3945 |
% \pkg{array}). That box is inserted (via |\@arstrut|) in the beginning of each |
| 3946 |
% row of the array. That's why we use the dimensions of that box to initialize |
| 3947 |
% the variables which will be the dimensions of the potential first and last row |
| 3948 |
% of the environment. This initialization must be done after the creation of |
| 3949 |
% |\@arstrutbox| and that's why we do it in the |\ialign|. |
| 3950 |
% \begin{macrocode} |
| 3951 |
\cs_new_protected:Npn \@@_some_initialization: |
| 3952 |
{ |
| 3953 |
\@@_everycr: |
| 3954 |
\dim_gset:Nn \g_@@_dp_row_zero_dim { \box_dp:N \@arstrutbox } |
| 3955 |
\dim_gset:Nn \g_@@_ht_row_zero_dim { \box_ht:N \@arstrutbox } |
| 3956 |
\dim_gset_eq:NN \g_@@_ht_row_one_dim \g_@@_ht_row_zero_dim |
| 3957 |
\dim_gzero:N \g_@@_dp_ante_last_row_dim |
| 3958 |
\dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox } |
| 3959 |
\dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox } |
| 3960 |
} |
| 3961 |
% \end{macrocode} |
| 3962 |
% |
| 3963 |
% \vspace{1cm} |
| 3964 |
% |
| 3965 |
% \label{prearray} |
| 3966 |
% |
| 3967 |
% |\@@_pre_array_after_CodeBefore:| will be executed in |\@@_pre_array:| |
| 3968 |
% \emph{after} the execution of the |\CodeBefore|. |
| 3969 |
% It contains all the code before the beginning of the construction of |
| 3970 |
% |\l_@@_the_array_box|. |
| 3971 |
% \begin{macrocode} |
| 3972 |
\cs_new_protected:Npn \@@_pre_array_after_CodeBefore: |
| 3973 |
{ |
| 3974 |
% \end{macrocode} |
| 3975 |
% |
| 3976 |
% \medskip |
| 3977 |
% The value of |\g_@@_pos_of_blocks_seq| has been written on the |aux| file and |
| 3978 |
% loaded before the (potential) execution of the |\CodeBefore|. |
| 3979 |
% |
| 3980 |
% Now, we reinitialize that variable with the content of |
| 3981 |
% |\g_@@_future_pos_of_blocks_seq| because the mains blocks will be added |
| 3982 |
% in |\g_@@_pos_of_blocks_seq| during the construction of the array. |
| 3983 |
% \begin{macrocode} |
| 3984 |
\seq_gclear:N \g_@@_pos_of_blocks_seq |
| 3985 |
% \end{macrocode} |
| 3986 |
% |
| 3987 |
% Idem for other sequences written on the |aux| file. |
| 3988 |
% \begin{macrocode} |
| 3989 |
\seq_gclear_new:N \g_@@_multicolumn_cells_seq |
| 3990 |
\seq_gclear_new:N \g_@@_multicolumn_sizes_seq |
| 3991 |
% \end{macrocode} |
| 3992 |
% |
| 3993 |
% \bigskip |
| 3994 |
% The command |\create_row_node:| will create a row-node (and not a row of |
| 3995 |
% nodes!). However, at the end of the array we construct a ``false row'' (for |
| 3996 |
% the col-nodes) and it interferes with the construction of the last row-node |
| 3997 |
% of the array. We don't want to create such row-node twice (to avaid warnings |
| 3998 |
% or, maybe, errors). That's why the command |\@@_create_row_node:| will use the |
| 3999 |
% following counter to avoid such construction. |
| 4000 |
% \begin{macrocode} |
| 4001 |
\int_gset:Nn \g_@@_last_row_node_int { -2 } |
| 4002 |
% \end{macrocode} |
| 4003 |
% The value $-2$ is important. |
| 4004 |
% |
| 4005 |
% \bigskip |
| 4006 |
% The total weight of the letters |X| in the preamble of the array. |
| 4007 |
% \begin{macrocode} |
| 4008 |
\fp_gzero:N \g_@@_total_X_weight_fp |
| 4009 |
\bool_gset_false:N \g_@@_V_of_X_bool |
| 4010 |
% \end{macrocode} |
| 4011 |
% |
| 4012 |
% \begin{macrocode} |
| 4013 |
\@@_expand_clist_hvlines:NN \l_@@_hlines_clist \c@iRow |
| 4014 |
\@@_expand_clist_hvlines:NN \l_@@_vlines_clist \c@jCol |
| 4015 |
% \end{macrocode} |
| 4016 |
% |
| 4017 |
% \begin{macrocode} |
| 4018 |
\@@_patch_booktabs: |
| 4019 |
\box_clear_new:N \l_@@_cell_box |
| 4020 |
\normalbaselines |
| 4021 |
% \end{macrocode} |
| 4022 |
% If the option |small| is used, we have to do some tuning. In particular, we |
| 4023 |
% change the value of |\arraystretch| (this parameter is used in the |
| 4024 |
% construction of |\@arstrutbox| in the beginning of |{array}|). |
| 4025 |
% \begin{macrocode} |
| 4026 |
\bool_if:NT \l_@@_small_bool |
| 4027 |
{ |
| 4028 |
% \end{macrocode} |
| 4029 |
% \begin{macrocode} |
| 4030 |
\def \arraystretch { 0.47 } |
| 4031 |
\dim_set:Nn \arraycolsep { 1.45 pt } |
| 4032 |
% \end{macrocode} |
| 4033 |
% By default, |\@@_tuning_key_small:| is no-op. |
| 4034 |
% \begin{macrocode} |
| 4035 |
\cs_set_eq:NN \@@_tuning_key_small: \scriptstyle |
| 4036 |
} |
| 4037 |
% \end{macrocode} |
| 4038 |
% |
| 4039 |
% \bigskip |
| 4040 |
% The boolean |\g_@@_create_cell_nodes_bool| corresponds to the key |
| 4041 |
% |create-cell-nodes| of the keyword |\CodeBefore|. When that key is used the |
| 4042 |
% ``cell nodes'' will be created before the |\CodeBefore| but, of course, they |
| 4043 |
% are \emph{always} available in the main tabular and after! |
| 4044 |
% \begin{macrocode} |
| 4045 |
\bool_if:NT \g_@@_create_cell_nodes_bool |
| 4046 |
{ |
| 4047 |
\tl_put_right:Nn \@@_begin_of_row: |
| 4048 |
{ |
| 4049 |
\pgfsys@markposition |
| 4050 |
{ \@@_env: - row - \int_use:N \c@iRow - base } |
| 4051 |
} |
| 4052 |
\socket_assign_plug:nn { nicematrix / create-cell-nodes } { active } |
| 4053 |
} |
| 4054 |
% \end{macrocode} |
| 4055 |
% |
| 4056 |
% \bigskip |
| 4057 |
% The environment |{array}| uses internally the command |\ar@ialign|. We change |
| 4058 |
% that command for several reasons. In particular, |\ar@ialign| sets |\everycr| |
| 4059 |
% to |{ }| and we \emph{need} to change the value of |\everycr|. |
| 4060 |
% \begin{macrocode} |
| 4061 |
\def \ar@ialign |
| 4062 |
{ |
| 4063 |
\tbl_init_cell_data_for_table: |
| 4064 |
\@@_some_initialization: |
| 4065 |
\dim_zero:N \tabskip |
| 4066 |
% \end{macrocode} |
| 4067 |
% |
| 4068 |
% After its first use, the definition of |\ar@ialign| will revert |
| 4069 |
% automatically to its default definition. With that programmation, we will |
| 4070 |
% have, in the cells of the array, a clean version of |\ar@ialign|. We use |
| 4071 |
% |\cs_set_eq:Nc| instead of |\cs_set_eq:NN| in order to avoid a message when |
| 4072 |
% |explcheck| is used on |nicematrix.sty|. |
| 4073 |
% \begin{macrocode} |
| 4074 |
\cs_set_eq:Nc \ar@ialign { @@_old_ar@ialign: } |
| 4075 |
\halign |
| 4076 |
} |
| 4077 |
% \end{macrocode} |
| 4078 |
% |
| 4079 |
% |
| 4080 |
% We keep in memory the old versions or |\ldots|, |\cdots|, etc. only because we |
| 4081 |
% use them inside |\phantom| commands in order that the new commands |\Ldots|, |
| 4082 |
% |\Cdots|, etc. give the same spacing (except when the option |nullify-dots| is |
| 4083 |
% used). |
| 4084 |
% \begin{macrocode} |
| 4085 |
\cs_set_eq:NN \@@_old_ldots: \ldots |
| 4086 |
\cs_set_eq:NN \@@_old_cdots: \cdots |
| 4087 |
\cs_set_eq:NN \@@_old_vdots: \vdots |
| 4088 |
\cs_set_eq:NN \@@_old_ddots: \ddots |
| 4089 |
\cs_set_eq:NN \@@_old_iddots: \iddots |
| 4090 |
\bool_if:NTF \l_@@_standard_cline_bool |
| 4091 |
{ \cs_set_eq:NN \cline \@@_standard_cline: } |
| 4092 |
{ \cs_set_eq:NN \cline \@@_cline: } |
| 4093 |
\cs_set_eq:NN \Ldots \@@_Ldots: |
| 4094 |
\cs_set_eq:NN \Cdots \@@_Cdots: |
| 4095 |
\cs_set_eq:NN \Vdots \@@_Vdots: |
| 4096 |
\cs_set_eq:NN \Ddots \@@_Ddots: |
| 4097 |
\cs_set_eq:NN \Iddots \@@_Iddots: |
| 4098 |
\cs_set_eq:NN \Hline \@@_Hline: |
| 4099 |
\cs_set_eq:NN \Hspace \@@_Hspace: |
| 4100 |
\cs_set_eq:NN \Hdotsfor \@@_Hdotsfor: |
| 4101 |
\cs_set_eq:NN \Vdotsfor \@@_Vdotsfor: |
| 4102 |
\cs_set_eq:NN \Block \@@_Block: |
| 4103 |
\cs_set_eq:NN \rotate \@@_rotate: |
| 4104 |
\cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n |
| 4105 |
\cs_set_eq:NN \dotfill \@@_dotfill: |
| 4106 |
\cs_set_eq:NN \CodeAfter \@@_CodeAfter: |
| 4107 |
\cs_if_free:NT \Body { \cs_set_eq:NN \Body \@@_Body: } |
| 4108 |
\cs_if_free:NT \CodeBefore { \cs_set_eq:NN \CodeBefore \@@_CodeBefore: } |
| 4109 |
\cs_set_eq:NN \diagbox \@@_diagbox:nn |
| 4110 |
\cs_set_eq:NN \NotEmpty \@@_NotEmpty: |
| 4111 |
\cs_set_eq:NN \TopRule \@@_TopRule |
| 4112 |
\cs_set_eq:NN \MidRule \@@_MidRule |
| 4113 |
\cs_set_eq:NN \BottomRule \@@_BottomRule |
| 4114 |
\cs_set_eq:NN \RowStyle \@@_RowStyle:n |
| 4115 |
\cs_set_eq:NN \Hbrace \@@_Hbrace |
| 4116 |
\cs_set_eq:NN \Vbrace \@@_Vbrace |
| 4117 |
\seq_map_inline:Nn \l_@@_custom_line_commands_seq |
| 4118 |
{ \cs_set_eq:cc { ##1 } { nicematrix - ##1 } } |
| 4119 |
\cs_set_eq:NN \cellcolor \@@_cellcolor_tabular |
| 4120 |
\cs_set_eq:NN \rowcolor \@@_rowcolor_tabular |
| 4121 |
\cs_set_eq:NN \rowcolors \@@_rowcolors_tabular |
| 4122 |
\cs_set_eq:NN \rowlistcolors \@@_rowlistcolors_tabular |
| 4123 |
\int_if_zero:nTF \l_@@_first_row_int |
| 4124 |
{ \cs_gset_eq:NN \@@_tuning_exterior_rows: \@@_tuning_first_last_row: } |
| 4125 |
{ |
| 4126 |
\int_compare:nNnT \l_@@_last_row_int > \c_zero_int |
| 4127 |
{ \cs_gset_eq:NN \@@_tuning_exterior_rows: \@@_tuning_last_row: } |
| 4128 |
} |
| 4129 |
\bool_if:NT \l_@@_renew_dots_bool { \@@_renew_dots: } |
| 4130 |
% \end{macrocode} |
| 4131 |
% We redefine |\multicolumn| and, since we want |\multicolumn| to be available |
| 4132 |
% in the potential environments |{tabular}| nested in the environments of |
| 4133 |
% \pkg{nicematrix}, we patch |{tabular}| to go back to the original definition. |
| 4134 |
% A |\hook_gremove_code:nn| will be put in |\@@_after_array:|. |
| 4135 |
% \begin{macrocode} |
| 4136 |
\cs_set_eq:NN \multicolumn \@@_multicolumn:nnn |
| 4137 |
\hook_gput_code:nnn { env / tabular / begin } { nicematrix } |
| 4138 |
{ \cs_set_eq:NN \multicolumn \@@_old_multicolumn: } |
| 4139 |
\@@_revert_colortbl: |
| 4140 |
% \end{macrocode} |
| 4141 |
% If there is one or several commands |\tabularnote| in the caption specified |
| 4142 |
% by the key |caption| and if that caption has to be composed above the tabular, |
| 4143 |
% we have now that information because it has been written in the |aux| file at |
| 4144 |
% a previous run. We use that information to start counting the tabular notes in |
| 4145 |
% the main array at the right value (we remember that the caption will be |
| 4146 |
% composed \emph{after} the array!). |
| 4147 |
% \begin{macrocode} |
| 4148 |
\tl_if_exist:NT \l_@@_note_in_caption_tl |
| 4149 |
{ |
| 4150 |
\tl_if_empty:NF \l_@@_note_in_caption_tl |
| 4151 |
{ |
| 4152 |
\int_gset:Nn \g_@@_notes_caption_int \l_@@_note_in_caption_tl |
| 4153 |
\int_gset:Nn \c@tabularnote \l_@@_note_in_caption_tl |
| 4154 |
} |
| 4155 |
} |
| 4156 |
% \end{macrocode} |
| 4157 |
% |
| 4158 |
% |
| 4159 |
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells |
| 4160 |
% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is |
| 4161 |
% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the |
| 4162 |
% values of $n$) correspondent will be stored. These lists will be used for the |
| 4163 |
% creation of the ``medium nodes'' (if they are created). |
| 4164 |
% \begin{macrocode} |
| 4165 |
\seq_gclear:N \g_@@_multicolumn_cells_seq |
| 4166 |
\seq_gclear:N \g_@@_multicolumn_sizes_seq |
| 4167 |
% \end{macrocode} |
| 4168 |
% |
| 4169 |
% |
| 4170 |
% When we compose a cell which belongs to a column which contains a instruction |
| 4171 |
% |\columncolor| (in the preamble of the environment), we add the number of that |
| 4172 |
% column in the following sequence (in order to recall that we have written |
| 4173 |
% the following instruction of the |\g_@@_pre_code_before_tl|). |
| 4174 |
% \begin{macrocode} |
| 4175 |
\seq_gclear_new:N \g_@@_columncolor_seq |
| 4176 |
% \end{macrocode} |
| 4177 |
% |
| 4178 |
% The counter |\c@iRow| will be used to count the rows of the array (its |
| 4179 |
% incrementation will be in the first cell of the row). |
| 4180 |
% \begin{macrocode} |
| 4181 |
\int_gset:Nn \c@iRow { \l_@@_first_row_int - 1 } |
| 4182 |
% \end{macrocode} |
| 4183 |
% |
| 4184 |
% At the end of the environment |{array}|, |\c@iRow| will be the total |
| 4185 |
% number de rows. |
| 4186 |
% |
| 4187 |
% |\g_@@_row_total_int| will be the number of rows excepted the last row (if |
| 4188 |
% |\l_@@_last_row_bool| has been raised with the option |last-row|). |
| 4189 |
% \begin{macrocode} |
| 4190 |
\int_gzero:N \g_@@_row_total_int |
| 4191 |
% \end{macrocode} |
| 4192 |
% |
| 4193 |
% The counter |\c@jCol| will be used to count the columns of the array. |
| 4194 |
% Since we want to know the total number of columns of the matrix, we also |
| 4195 |
% create a counter |\g_@@_col_total_int|. These counters are updated in the |
| 4196 |
% command |\@@_cell_begin:| executed at the beginning of each cell. |
| 4197 |
% \begin{macrocode} |
| 4198 |
\int_gzero:N \g_@@_col_total_int |
| 4199 |
% \end{macrocode} |
| 4200 |
% |
| 4201 |
% \begin{macrocode} |
| 4202 |
\cs_set_eq:NN \@ifnextchar \new@ifnextchar |
| 4203 |
% \end{macrocode} |
| 4204 |
% |
| 4205 |
% \begin{macrocode} |
| 4206 |
\bool_gset_false:N \g_@@_last_col_found_bool |
| 4207 |
% \end{macrocode} |
| 4208 |
% |
| 4209 |
% \medskip |
| 4210 |
% During the construction of the array, the instructions |\Cdots|, |\Ldots|, |
| 4211 |
% etc. will be written in token lists |\g_@@_Cdots_lines_tl|, etc. which will be |
| 4212 |
% executed after the construction of the array. |
| 4213 |
% \begin{macrocode} |
| 4214 |
\tl_gclear_new:N \g_@@_Cdots_lines_tl |
| 4215 |
\tl_gclear_new:N \g_@@_Ldots_lines_tl |
| 4216 |
\tl_gclear_new:N \g_@@_Vdots_lines_tl |
| 4217 |
\tl_gclear_new:N \g_@@_Ddots_lines_tl |
| 4218 |
\tl_gclear_new:N \g_@@_Iddots_lines_tl |
| 4219 |
\tl_gclear_new:N \g_@@_HVdotsfor_lines_tl |
| 4220 |
% \end{macrocode} |
| 4221 |
% |
| 4222 |
% \medskip |
| 4223 |
% \begin{macrocode} |
| 4224 |
\tl_gclear:N \g_nicematrix_code_before_tl |
| 4225 |
\tl_gclear:N \g_@@_pre_code_before_tl |
| 4226 |
% \end{macrocode} |
| 4227 |
% |
| 4228 |
% \medskip |
| 4229 |
% We compute the width of both delimiters. We remind that, when the |
| 4230 |
% environment |{NiceArray}| is used, it's possible to specify the delimiters in |
| 4231 |
% the preamble (eg |[ccc]|). |
| 4232 |
% \begin{macrocode} |
| 4233 |
\dim_zero_new:N \l_@@_left_delim_dim |
| 4234 |
\dim_zero_new:N \l_@@_right_delim_dim |
| 4235 |
\bool_if:NTF \g_@@_delims_bool |
| 4236 |
{ |
| 4237 |
% \end{macrocode} |
| 4238 |
% The command |\bBigg@| is a command of \pkg{amsmath}. |
| 4239 |
% \begin{macrocode} |
| 4240 |
\hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g_@@_left_delim_tl $ } |
| 4241 |
\dim_set:Nn \l_@@_left_delim_dim { \box_wd:N \l_tmpa_box } |
| 4242 |
\hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g_@@_right_delim_tl $ } |
| 4243 |
\dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box } |
| 4244 |
} |
| 4245 |
{ |
| 4246 |
\dim_gset:Nn \l_@@_left_delim_dim |
| 4247 |
{ 2 \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep } |
| 4248 |
\dim_gset_eq:NN \l_@@_right_delim_dim \l_@@_left_delim_dim |
| 4249 |
} |
| 4250 |
} |
| 4251 |
% \end{macrocode} |
| 4252 |
% This is the end of |\@@_pre_array_after_CodeBefore:|. |
| 4253 |
% |
| 4254 |
% |
| 4255 |
% \bigskip |
| 4256 |
% The command |\@@_pre_array:| will be executed after analysis of the keys of the |
| 4257 |
% environment. If will, in particular, read the potential informations written on |
| 4258 |
% the |aux| file. |
| 4259 |
% \begin{macrocode} |
| 4260 |
\cs_new_protected:Npn \@@_pre_array: |
| 4261 |
{ |
| 4262 |
\cs_if_exist:NT \theiRow { \int_set_eq:NN \l_@@_old_iRow_int \c@iRow } |
| 4263 |
\int_gzero_new:N \c@iRow |
| 4264 |
\cs_if_exist:NT \thejCol { \int_set_eq:NN \l_@@_old_jCol_int \c@jCol } |
| 4265 |
\int_gzero_new:N \c@jCol |
| 4266 |
% \end{macrocode} |
| 4267 |
% |
| 4268 |
% We give values to the LaTeX counters |iRow| and |jCol|. We remind that before |
| 4269 |
% and after the main array (in particular in the |\CodeBefore| and the |
| 4270 |
% |\CodeAfter|, they represent the numbers of rows and columns of the array |
| 4271 |
% (without the potential last row and last column). The value of |
| 4272 |
% |\g_@@_row_total_int| is the number of the last row (with potentially a last |
| 4273 |
% exterior row) and |\g_@@_col_total_int| is the number of the last column (with |
| 4274 |
% potentially a last exterior column). |
| 4275 |
% \begin{macrocode} |
| 4276 |
\int_compare:nNnT \l_@@_last_row_int > \c_zero_int |
| 4277 |
{ \int_set:Nn \c@iRow { \l_@@_last_row_int - 1 } } |
| 4278 |
\int_compare:nNnT \l_@@_last_col_int > \c_zero_int |
| 4279 |
{ \int_set:Nn \c@jCol { \l_@@_last_col_int - 1 } } |
| 4280 |
\bool_if:NT \g_@@_aux_found_bool |
| 4281 |
{ |
| 4282 |
\int_set:Nn \c@iRow { \seq_item:Nn \g_@@_size_seq { 2 } } |
| 4283 |
\int_set:Nn \c@jCol { \seq_item:Nn \g_@@_size_seq { 5 } } |
| 4284 |
\int_gset:Nn \g_@@_row_total_int { \seq_item:Nn \g_@@_size_seq { 3 } } |
| 4285 |
\int_gset:Nn \g_@@_col_total_int { \seq_item:Nn \g_@@_size_seq { 6 } } |
| 4286 |
} |
| 4287 |
% \end{macrocode} |
| 4288 |
% |
| 4289 |
% \bigskip |
| 4290 |
% We recall that |\l_@@_last_row_int| and |\l_@@_last_col_int| are \emph{not} |
| 4291 |
% the numbers of the last row and last column of the array. There are only the |
| 4292 |
% values of the keys |last-row| and |last-col| (maybe the user has provided |
| 4293 |
% erroneous values). The meaning of that counters does not change during the |
| 4294 |
% environment of \pkg{nicematrix}. There is only a slight adjustment: if the |
| 4295 |
% user have used one of those keys without value, we provide now the right value |
| 4296 |
% as read on the |aux| file (of course, it's possible only after the first compilation). |
| 4297 |
% \begin{macrocode} |
| 4298 |
\int_compare:nNnT \l_@@_last_row_int = { -1 } |
| 4299 |
{ |
| 4300 |
\bool_set_true:N \l_@@_last_row_without_value_bool |
| 4301 |
\bool_if:NT \g_@@_aux_found_bool |
| 4302 |
{ \int_set:Nn \l_@@_last_row_int { \seq_item:Nn \g_@@_size_seq { 3 } } } |
| 4303 |
} |
| 4304 |
\int_compare:nNnT \l_@@_last_col_int = { -1 } |
| 4305 |
{ |
| 4306 |
\bool_if:NT \g_@@_aux_found_bool |
| 4307 |
{ \int_set:Nn \l_@@_last_col_int { \seq_item:Nn \g_@@_size_seq { 6 } } } |
| 4308 |
} |
| 4309 |
% \end{macrocode} |
| 4310 |
% |
| 4311 |
% \bigskip |
| 4312 |
% If there is an exterior row, we patch a command used in |\@@_cell_begin:| in order to |
| 4313 |
% keep track of some dimensions needed to the construction of that ``last row''. |
| 4314 |
% \begin{macrocode} |
| 4315 |
\int_compare:nNnT \l_@@_last_row_int > { -2 } |
| 4316 |
{ |
| 4317 |
\tl_put_right:Nn \@@_update_for_first_and_last_row: |
| 4318 |
{ |
| 4319 |
\dim_compare:nNnT \g_@@_ht_last_row_dim < { \box_ht:N \l_@@_cell_box } |
| 4320 |
{ \dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \l_@@_cell_box } } |
| 4321 |
\dim_compare:nNnT \g_@@_dp_last_row_dim < { \box_dp:N \l_@@_cell_box } |
| 4322 |
{ \dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \l_@@_cell_box } } |
| 4323 |
} |
| 4324 |
} |
| 4325 |
% \end{macrocode} |
| 4326 |
% |
| 4327 |
% \bigskip |
| 4328 |
% \begin{macrocode} |
| 4329 |
\seq_gclear:N \g_@@_cols_vlism_seq |
| 4330 |
\seq_gclear:N \g_@@_submatrix_seq |
| 4331 |
% \end{macrocode} |
| 4332 |
% |
| 4333 |
% \bigskip |
| 4334 |
% Now the |\CodeBefore|. |
| 4335 |
% \begin{macrocode} |
| 4336 |
\bool_if:NT \l_@@_code_before_bool \@@_exec_code_before: |
| 4337 |
% \end{macrocode} |
| 4338 |
% |
| 4339 |
% \interitem |
| 4340 |
% The code in |\@@_pre_array_after_CodeBefore:| is used only here. |
| 4341 |
% \begin{macrocode} |
| 4342 |
\@@_pre_array_after_CodeBefore: |
| 4343 |
% \end{macrocode} |
| 4344 |
% |
| 4345 |
% \bigskip |
| 4346 |
% Here is the beginning of the box which will contain the array. The |
| 4347 |
% |\hbox_set_end:| corresponding to this |\hbox_set:Nw| will be in the second |
| 4348 |
% part of the environment (and the closing |$| also). |
| 4349 |
% \begin{macrocode} |
| 4350 |
\hbox_set:Nw \l_@@_the_array_box |
| 4351 |
% \end{macrocode} |
| 4352 |
% |
| 4353 |
% \begin{macrocode} |
| 4354 |
\skip_horizontal:N \l_@@_left_margin_dim % \skip_horizontal:N ? |
| 4355 |
\skip_horizontal:N \l_@@_extra_left_margin_dim |
| 4356 |
\UseTaggingSocket { tbl / hmode / begin } |
| 4357 |
% \end{macrocode} |
| 4358 |
% |
| 4359 |
% The following code is a workaround to specify to the tagging system that the |
| 4360 |
% following code is \emph{fake math} (it raises |\l__math_fakemath_bool| in |
| 4361 |
% recent versions of LaTeX). |
| 4362 |
% \begin{macrocode} |
| 4363 |
\m@th |
| 4364 |
$ % $ |
| 4365 |
\bool_if:NTF \l_@@_light_syntax_bool |
| 4366 |
{ \use:c { @@-light-syntax } } |
| 4367 |
{ \use:c { @@-normal-syntax } } |
| 4368 |
} |
| 4369 |
% \end{macrocode} |
| 4370 |
% |
| 4371 |
% \bigskip |
| 4372 |
% The following command |\@@_CodeBefore_Body:w| will be used when the keyword |
| 4373 |
% |\CodeBefore| is present at the beginning of the environment. |
| 4374 |
% \begin{macrocode} |
| 4375 |
\cs_new_protected_nopar:Npn \@@_CodeBefore_Body:w #1 \Body |
| 4376 |
{ |
| 4377 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 4378 |
\int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } |
| 4379 |
{ \@@_rescan_for_spanish:N \l_tmpa_tl } |
| 4380 |
\tl_gput_left:No \g_@@_pre_code_before_tl \l_tmpa_tl |
| 4381 |
\bool_set_true:N \l_@@_code_before_bool |
| 4382 |
% \end{macrocode} |
| 4383 |
% We go on with |\@@_pre_array:| which will (among other) execute the |
| 4384 |
% |\CodeBefore| (specified in the key |code-before| or after the keyword |
| 4385 |
% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the |
| 4386 |
% body of the array... |
| 4387 |
% \begin{macrocode} |
| 4388 |
\@@_pre_array: |
| 4389 |
} |
| 4390 |
% \end{macrocode} |
| 4391 |
% |
| 4392 |
% |
| 4393 |
% |
| 4394 |
% \bigskip |
| 4395 |
% \section{The \textbackslash CodeBefore} |
| 4396 |
% |
| 4397 |
% |
| 4398 |
% \begin{macrocode} |
| 4399 |
\cs_new_protected_nopar:Npn \@@_Body: { \@@_fatal:n { Body~alone } } |
| 4400 |
\cs_new_protected_nopar:Npn \@@_CodeBefore: { \@@_fatal:n { Bad~use~of~CodeBefore } } |
| 4401 |
% \end{macrocode} |
| 4402 |
% |
| 4403 |
% The following command will be executed if the |\CodeBefore| has to be actually |
| 4404 |
% executed (that command will be used only once and is present alone only for legibility). |
| 4405 |
% \begin{macrocode} |
| 4406 |
\cs_new_protected:Npn \@@_pre_code_before: |
| 4407 |
{ |
| 4408 |
% \end{macrocode} |
| 4409 |
% We will create all the |col| nodes and |row| nodes with the information |
| 4410 |
% written in the |aux| file. You use the technique described in the page~1247 of |
| 4411 |
% |pgfmanual.pdf|, version~3.1.10. |
| 4412 |
% \begin{macrocode} |
| 4413 |
\pgfsys@markposition { \@@_env: - position } |
| 4414 |
\pgfsys@getposition { \@@_env: - position } \@@_picture_position: |
| 4415 |
\pgfpicture |
| 4416 |
\pgf@relevantforpicturesizefalse |
| 4417 |
% \end{macrocode} |
| 4418 |
% First, the recreation of the |row| nodes. |
| 4419 |
% \begin{macrocode} |
| 4420 |
\int_step_inline:nnn \l_@@_first_row_int { \g_@@_row_total_int + 1 } |
| 4421 |
{ |
| 4422 |
\pgfsys@getposition { \@@_env: - row - ##1 } \@@_node_position: |
| 4423 |
\pgfcoordinate { \@@_env: - row - ##1 } |
| 4424 |
{ \pgfpointdiff \@@_picture_position: \@@_node_position: } |
| 4425 |
} |
| 4426 |
% \end{macrocode} |
| 4427 |
% Now, the recreation of the |col| nodes. |
| 4428 |
% \begin{macrocode} |
| 4429 |
\int_step_inline:nnn \l_@@_first_col_int { \g_@@_col_total_int + 1 } |
| 4430 |
{ |
| 4431 |
\pgfsys@getposition { \@@_env: - col - ##1 } \@@_node_position: |
| 4432 |
\pgfcoordinate { \@@_env: - col - ##1 } |
| 4433 |
{ \pgfpointdiff \@@_picture_position: \@@_node_position: } |
| 4434 |
} |
| 4435 |
% \end{macrocode} |
| 4436 |
% |
| 4437 |
% \medskip |
| 4438 |
% Now, the creation of the cell nodes |(i-j)|, and, maybe also the ``medium |
| 4439 |
% nodes'' and the ``large nodes''. |
| 4440 |
% \begin{macrocode} |
| 4441 |
\bool_if:NT \g_@@_create_cell_nodes_bool \@@_recreate_cell_nodes: |
| 4442 |
\endpgfpicture |
| 4443 |
% \end{macrocode} |
| 4444 |
% |
| 4445 |
% Now, you recreate the diagonal nodes by using the |row| nodes and the |col| |
| 4446 |
% nodes. |
| 4447 |
% \begin{macrocode} |
| 4448 |
\@@_create_diag_nodes: |
| 4449 |
% \end{macrocode} |
| 4450 |
% |
| 4451 |
% \medskip |
| 4452 |
% Now, the recreation of the nodes of the blocks \emph{which have a name}. |
| 4453 |
% \begin{macrocode} |
| 4454 |
\@@_create_blocks_nodes: |
| 4455 |
% \end{macrocode} |
| 4456 |
% |
| 4457 |
% \begin{macrocode} |
| 4458 |
\IfPackageLoadedT { tikz } |
| 4459 |
{ |
| 4460 |
\tikzset |
| 4461 |
{ |
| 4462 |
every~picture / .style = |
| 4463 |
{ overlay , name~prefix = \@@_env: - } |
| 4464 |
} |
| 4465 |
} |
| 4466 |
\cs_set_eq:NN \cellcolor \@@_cellcolor |
| 4467 |
\cs_set_eq:NN \rectanglecolor \@@_rectanglecolor |
| 4468 |
\cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor |
| 4469 |
\cs_set_eq:NN \rowcolor \@@_rowcolor |
| 4470 |
\cs_set_eq:NN \rowcolors \@@_rowcolors |
| 4471 |
\cs_set_eq:NN \rowlistcolors \@@_rowlistcolors |
| 4472 |
\cs_set_eq:NN \arraycolor \@@_arraycolor |
| 4473 |
\cs_set_eq:NN \columncolor \@@_columncolor |
| 4474 |
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors |
| 4475 |
\cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before |
| 4476 |
\cs_set_eq:NN \ShowCellNames \@@_ShowCellNames |
| 4477 |
\cs_set_eq:NN \ShowCellNames \@@_ShowCellNamesCodeBefore |
| 4478 |
\cs_set_eq:NN \TikzEveryCell \@@_TikzEveryCell |
| 4479 |
\cs_set_eq:NN \EmptyColumn \@@_EmptyColumn:n |
| 4480 |
\cs_set_eq:NN \EmptyRow \@@_EmptyRow:n |
| 4481 |
} |
| 4482 |
% \end{macrocode} |
| 4483 |
% |
| 4484 |
% |
| 4485 |
% |
| 4486 |
% \bigskip |
| 4487 |
% \begin{macrocode} |
| 4488 |
\cs_new_protected:Npn \@@_exec_code_before: |
| 4489 |
{ |
| 4490 |
% \end{macrocode} |
| 4491 |
% We mark the cells which are in the (empty) corners because those cells must |
| 4492 |
% not be colored. We should try to find a way to detect whether we actually |
| 4493 |
% have coloring instructions to execute... |
| 4494 |
% \begin{macrocode} |
| 4495 |
\clist_map_inline:Nn \l_@@_corners_cells_clist |
| 4496 |
{ \cs_set_nopar:cpn { @@ _ corner _ ##1 } { } } |
| 4497 |
% \end{macrocode} |
| 4498 |
% |
| 4499 |
% \begin{macrocode} |
| 4500 |
\seq_gclear_new:N \g_@@_colors_seq |
| 4501 |
% \end{macrocode} |
| 4502 |
% The sequence |\g_@@_colors_seq| will always contain as first element the |
| 4503 |
% special color |nocolor|: when that color is used, no color will be applied in |
| 4504 |
% the corresponding cells by the other coloring commands of \pkg{nicematrix}. |
| 4505 |
% \begin{macrocode} |
| 4506 |
\@@_add_to_colors_seq:nn { { nocolor } } { } |
| 4507 |
\bool_gset_false:N \g_@@_create_cell_nodes_bool |
| 4508 |
\group_begin: |
| 4509 |
% \end{macrocode} |
| 4510 |
% We compose the |\CodeBefore| in math mode in order to nullify the spaces put |
| 4511 |
% by the user between instructions in the |\CodeBefore|. |
| 4512 |
% \begin{macrocode} |
| 4513 |
\if_mode_math: |
| 4514 |
\@@_exec_code_before_i: |
| 4515 |
\else: |
| 4516 |
$ % $ |
| 4517 |
\@@_exec_code_before_i: |
| 4518 |
$ % $ |
| 4519 |
\fi: |
| 4520 |
\group_end: |
| 4521 |
} |
| 4522 |
% \end{macrocode} |
| 4523 |
% |
| 4524 |
% |
| 4525 |
% \bigskip |
| 4526 |
% The following code is a security for the case the user has used \pkg{babel} |
| 4527 |
% with the option \pkg{spanish}: in that case, the characters |<| (de code |
| 4528 |
% \textsc{ascci} 60) and |>| are activated and TikZ is not able to solve the |
| 4529 |
% problem (even with the TikZ library \pkg{babel}). |
| 4530 |
% \begin{macrocode} |
| 4531 |
\cs_new_protected:Npn \@@_exec_code_before_i: |
| 4532 |
{ |
| 4533 |
\int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } |
| 4534 |
{ \@@_rescan_for_spanish:N \l_@@_code_before_tl } |
| 4535 |
% \end{macrocode} |
| 4536 |
% |
| 4537 |
% Here is the |\CodeBefore|. The construction is a bit complicated because |
| 4538 |
% |\g_@@_pre_code_before_tl| may begin with keys between square brackets. Moreover, |
| 4539 |
% after the analyze of those keys, we sometimes have to decide to do \emph{not} |
| 4540 |
% execute the rest of |\g_@@_pre_code_before_tl| (when it is asked for the creation |
| 4541 |
% of cell nodes in the |\CodeBefore|). That's why we use a |\q_stop|: it |
| 4542 |
% will be used to discard the rest of |\g_@@_pre_code_before_tl|. |
| 4543 |
% \begin{macrocode} |
| 4544 |
\exp_last_unbraced:No \@@_CodeBefore_keys: |
| 4545 |
\g_@@_pre_code_before_tl |
| 4546 |
% \end{macrocode} |
| 4547 |
% Now, all the cells which are specified to be colored by instructions in the |
| 4548 |
% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we |
| 4549 |
% want to draw all the cells with the same color at the same time to absolutely |
| 4550 |
% avoid thin white lines in some \textsc{pdf} viewers. |
| 4551 |
% \begin{macrocode} |
| 4552 |
\@@_actually_color: |
| 4553 |
\l_@@_code_before_tl |
| 4554 |
\q_stop |
| 4555 |
} |
| 4556 |
% \end{macrocode} |
| 4557 |
% |
| 4558 |
% \bigskip |
| 4559 |
% \begin{macrocode} |
| 4560 |
\keys_define:nn { nicematrix / CodeBefore } |
| 4561 |
{ |
| 4562 |
create-cell-nodes .bool_gset:N = \g_@@_create_cell_nodes_bool , |
| 4563 |
sub-matrix .code:n = \keys_set:nn { nicematrix / sub-matrix } { #1 } , |
| 4564 |
sub-matrix .value_required:n = true , |
| 4565 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 4566 |
delimiters / color .value_required:n = true , |
| 4567 |
unknown .code:n = \@@_error:n { Unknown~key~for~CodeBefore } |
| 4568 |
} |
| 4569 |
% \end{macrocode} |
| 4570 |
% |
| 4571 |
% |
| 4572 |
% \begin{macrocode} |
| 4573 |
\NewDocumentCommand \@@_CodeBefore_keys: { O { } } |
| 4574 |
{ |
| 4575 |
\keys_set:nn { nicematrix / CodeBefore } { #1 } |
| 4576 |
\@@_CodeBefore:w |
| 4577 |
} |
| 4578 |
% \end{macrocode} |
| 4579 |
% |
| 4580 |
% We have extracted the options of the keyword |\CodeBefore| in order to see |
| 4581 |
% whether the key |create-cell-nodes| has been used. Now, you can execute the |
| 4582 |
% rest of the |\CodeBefore|, excepted, of course, if we are in the first |
| 4583 |
% compilation. |
| 4584 |
% |
| 4585 |
% \begin{macrocode} |
| 4586 |
\cs_new_protected:Npn \@@_CodeBefore:w #1 \q_stop |
| 4587 |
{ |
| 4588 |
\bool_if:NTF \g_@@_aux_found_bool |
| 4589 |
{ |
| 4590 |
\@@_pre_code_before: |
| 4591 |
\legacy_if:nF { measuring@ } { #1 } |
| 4592 |
} |
| 4593 |
% \end{macrocode} |
| 4594 |
% If we are in the first compilation, you won't really execute the |\CodeBefore| but |
| 4595 |
% we have to execute some instructions of creation of PGF/TikZ pictures in order |
| 4596 |
% to have the correct |aux| file in the next run (hence, we avoid to ``lose'' a run). |
| 4597 |
% \begin{macrocode} |
| 4598 |
{ |
| 4599 |
\pgfsys@markposition { \@@_env: - position } |
| 4600 |
\pgfsys@getposition { \@@_env: - position } \@@_picture_position: |
| 4601 |
\pgfpicture |
| 4602 |
\pgf@relevantforpicturesizefalse |
| 4603 |
\endpgfpicture |
| 4604 |
% \end{macrocode} |
| 4605 |
% The following picture corresponds to |\@@_create_diag_nodes:| |
| 4606 |
% \begin{macrocode} |
| 4607 |
\pgfpicture |
| 4608 |
\pgfrememberpicturepositiononpagetrue |
| 4609 |
\endpgfpicture |
| 4610 |
% \end{macrocode} |
| 4611 |
% The following picture corresponds to |\@@_create_blocks_nodes:|. |
| 4612 |
% \begin{macrocode} |
| 4613 |
\pgfpicture |
| 4614 |
\pgf@relevantforpicturesizefalse |
| 4615 |
\pgfrememberpicturepositiononpagetrue |
| 4616 |
\endpgfpicture |
| 4617 |
% \end{macrocode} |
| 4618 |
% The following picture corresponds |\@@_actually_color:| |
| 4619 |
% \begin{macrocode} |
| 4620 |
\pgfpicture |
| 4621 |
\pgf@relevantforpicturesizefalse |
| 4622 |
\endpgfpicture |
| 4623 |
} |
| 4624 |
} |
| 4625 |
% \end{macrocode} |
| 4626 |
% |
| 4627 |
% |
| 4628 |
% \bigskip |
| 4629 |
% By default, if the user uses the |\CodeBefore|, only the |col| nodes, |row| |
| 4630 |
% nodes and |diag| nodes are available in that |\CodeBefore|. With the key |
| 4631 |
% |create-cell-nodes|, the cell nodes, that is to say the nodes of the form |
| 4632 |
% |(i-j)| (but not the extra nodes) are also available because those nodes also |
| 4633 |
% are recreated and that recreation is done by the following command. |
| 4634 |
% \begin{macrocode} |
| 4635 |
\cs_new_protected:Npn \@@_recreate_cell_nodes: |
| 4636 |
{ |
| 4637 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 4638 |
{ |
| 4639 |
\pgfsys@getposition { \@@_env: - ##1 - base } \@@_node_position: |
| 4640 |
\pgfcoordinate { \@@_env: - row - ##1 - base } |
| 4641 |
{ \pgfpointdiff \@@_picture_position: \@@_node_position: } |
| 4642 |
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int |
| 4643 |
{ |
| 4644 |
\cs_if_exist:cT |
| 4645 |
{ pgf @ sys @ pdf @ mark @ pos @ \@@_env: - ##1 - ####1 - NW } |
| 4646 |
{ |
| 4647 |
\pgfsys@getposition |
| 4648 |
{ \@@_env: - ##1 - ####1 - NW } |
| 4649 |
\@@_node_position: |
| 4650 |
\pgfsys@getposition |
| 4651 |
{ \@@_env: - ##1 - ####1 - SE } |
| 4652 |
\@@_node_position_i: |
| 4653 |
\@@_pgf_rect_node:nnn |
| 4654 |
{ \@@_env: - ##1 - ####1 } |
| 4655 |
{ \pgfpointdiff \@@_picture_position: \@@_node_position: } |
| 4656 |
{ \pgfpointdiff \@@_picture_position: \@@_node_position_i: } |
| 4657 |
} |
| 4658 |
} |
| 4659 |
} |
| 4660 |
\@@_create_extra_nodes: |
| 4661 |
\@@_create_aliases_last: |
| 4662 |
} |
| 4663 |
% \end{macrocode} |
| 4664 |
% |
| 4665 |
% \bigskip |
| 4666 |
% \begin{macrocode} |
| 4667 |
\cs_new_protected:Npn \@@_create_aliases_last: |
| 4668 |
{ |
| 4669 |
\int_step_inline:nn \c@iRow |
| 4670 |
{ |
| 4671 |
\pgfnodealias |
| 4672 |
{ \@@_env: - ##1 - last } |
| 4673 |
{ \@@_env: - ##1 - \int_use:N \c@jCol } |
| 4674 |
} |
| 4675 |
\int_step_inline:nn \c@jCol |
| 4676 |
{ |
| 4677 |
\pgfnodealias |
| 4678 |
{ \@@_env: - last - ##1 } |
| 4679 |
{ \@@_env: - \int_use:N \c@iRow - ##1 } |
| 4680 |
} |
| 4681 |
\pgfnodealias |
| 4682 |
{ \@@_env: - last - last } |
| 4683 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 4684 |
} |
| 4685 |
% \end{macrocode} |
| 4686 |
% |
| 4687 |
% \bigskip |
| 4688 |
% \begin{macrocode} |
| 4689 |
\cs_new_protected:Npn \@@_create_blocks_nodes: |
| 4690 |
{ |
| 4691 |
\pgfpicture |
| 4692 |
\pgf@relevantforpicturesizefalse |
| 4693 |
\pgfrememberpicturepositiononpagetrue |
| 4694 |
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq |
| 4695 |
{ \@@_create_one_block_node:nnnnn ##1 } |
| 4696 |
\endpgfpicture |
| 4697 |
} |
| 4698 |
% \end{macrocode} |
| 4699 |
% |
| 4700 |
% The following command is called |\@@_create_one_block_node:nnnnn| but, in |
| 4701 |
% fact, it creates a node only if the last argument (|#5|) which is the name of |
| 4702 |
% the block, is not empty.\footnote{Moreover, there is also in the list |
| 4703 |
% |\g_@@_pos_of_blocks_seq| the positions of the dotted lines (created by |
| 4704 |
% |\Cdots|, etc.) and, for these entries, there is, of course, no name (the |
| 4705 |
% fifth component is empty).} |
| 4706 |
% \begin{macrocode} |
| 4707 |
\cs_new_protected:Npn \@@_create_one_block_node:nnnnn #1 #2 #3 #4 #5 |
| 4708 |
{ |
| 4709 |
\tl_if_empty:nF { #5 } |
| 4710 |
{ |
| 4711 |
\@@_qpoint:n { col - #2 } |
| 4712 |
\dim_set_eq:NN \l_tmpa_dim \pgf@x |
| 4713 |
\@@_qpoint:n { #1 } |
| 4714 |
\dim_set_eq:NN \l_tmpb_dim \pgf@y |
| 4715 |
\@@_qpoint:n { col - \int_eval:n { #4 + 1 } } |
| 4716 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x |
| 4717 |
\@@_qpoint:n { \int_eval:n { #3 + 1 } } |
| 4718 |
\@@_pgf_rect_node:nnnnn |
| 4719 |
{ \@@_env: - #5 } |
| 4720 |
{ \dim_use:N \l_tmpa_dim } |
| 4721 |
{ \dim_use:N \l_tmpb_dim } |
| 4722 |
{ \dim_use:N \l_@@_tmpc_dim } |
| 4723 |
{ \dim_use:N \pgf@y } |
| 4724 |
} |
| 4725 |
} |
| 4726 |
% \end{macrocode} |
| 4727 |
% |
| 4728 |
% |
| 4729 |
% |
| 4730 |
% |
| 4731 |
% \bigskip |
| 4732 |
% \section{The environment \{NiceArrayWithDelims\}} |
| 4733 |
% |
| 4734 |
% \begin{macrocode} |
| 4735 |
\NewDocumentEnvironment { NiceArrayWithDelims } |
| 4736 |
{ m m O { } m ! O { } t \CodeBefore } |
| 4737 |
{ |
| 4738 |
% \end{macrocode} |
| 4739 |
% |
| 4740 |
% \begin{macrocode} |
| 4741 |
\@@_provide_pgfsyspdfmark: |
| 4742 |
\bool_if:NT \g_@@_footnote_bool \savenotes |
| 4743 |
% \end{macrocode} |
| 4744 |
% |
| 4745 |
% The aim of the following |\bgroup| (the corresponding |\egroup| is, of course, |
| 4746 |
% at the end of the environment) is to be able to put an exposant to a matrix in |
| 4747 |
% a mathematical formula. |
| 4748 |
% \begin{macrocode} |
| 4749 |
\bgroup |
| 4750 |
% \end{macrocode} |
| 4751 |
% |
| 4752 |
% \bigskip |
| 4753 |
% \begin{macrocode} |
| 4754 |
\tl_gset:Nn \g_@@_left_delim_tl { #1 } |
| 4755 |
\tl_gset:Nn \g_@@_right_delim_tl { #2 } |
| 4756 |
\tl_gset:Nn \g_@@_user_preamble_tl { #4 } |
| 4757 |
\tl_if_empty:NT \g_@@_user_preamble_tl { \@@_fatal:n { empty~preamble } } |
| 4758 |
% \end{macrocode} |
| 4759 |
% |
| 4760 |
% |
| 4761 |
% \bigskip |
| 4762 |
% \begin{macrocode} |
| 4763 |
\int_gzero:N \g_@@_block_box_int |
| 4764 |
\dim_gzero:N \g_@@_width_last_col_dim |
| 4765 |
\dim_gzero:N \g_@@_width_first_col_dim |
| 4766 |
\bool_gset_false:N \g_@@_row_of_col_done_bool |
| 4767 |
\str_if_empty:NT \g_@@_name_env_str |
| 4768 |
{ \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } } |
| 4769 |
\bool_if:NTF \l_@@_tabular_bool |
| 4770 |
\mode_leave_vertical: |
| 4771 |
\@@_test_if_math_mode: |
| 4772 |
\bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } |
| 4773 |
\bool_set_true:N \l_@@_in_env_bool |
| 4774 |
% \end{macrocode} |
| 4775 |
% The command |\CT@arc@| contains the instruction of color for the rules of the |
| 4776 |
% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but |
| 4777 |
% we use it also for compatibility with \pkg{colortbl}. But we want also to be |
| 4778 |
% able to use color for the rules of the array when \pkg{colortbl} is \emph{not} |
| 4779 |
% loaded. That's why we do the following instruction which is in the patch of |
| 4780 |
% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the |
| 4781 |
% value of |\CT@arc@| at the end of our environment. |
| 4782 |
% \begin{macrocode} |
| 4783 |
\cs_gset_eq:cN { @@_old_CT@arc@ } \CT@arc@ |
| 4784 |
% \end{macrocode} |
| 4785 |
% |
| 4786 |
% We deactivate TikZ externalization because we will use \textsc{pgf} pictures |
| 4787 |
% with the options |overlay| and |remember picture| (or equivalent forms). We |
| 4788 |
% deactivate with |\tikzexternaldisable| and not with |
| 4789 |
% |\tikzset{external/export=false}| which is \emph{not} equivalent. |
| 4790 |
% \begin{macrocode} |
| 4791 |
\cs_if_exist:NT \tikz@library@external@loaded |
| 4792 |
{ |
| 4793 |
\tikzexternaldisable |
| 4794 |
\cs_if_exist:NT \ifstandalone |
| 4795 |
{ \tikzset { external / optimize = false } } |
| 4796 |
} |
| 4797 |
% \end{macrocode} |
| 4798 |
% |
| 4799 |
% We increment the counter |\g_@@_env_int| which counts the environments |
| 4800 |
% of the package. |
| 4801 |
% \begin{macrocode} |
| 4802 |
\int_gincr:N \g_@@_env_int |
| 4803 |
\bool_if:NF \l_@@_block_auto_columns_width_bool |
| 4804 |
{ \dim_gzero_new:N \g_@@_max_cell_width_dim } |
| 4805 |
% \end{macrocode} |
| 4806 |
% |
| 4807 |
% |
| 4808 |
% The sequence |\g_@@_blocks_seq| will contain the characteristics of the blocks |
| 4809 |
% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq| |
| 4810 |
% will contain only the position of the blocks. |
| 4811 |
% \begin{macrocode} |
| 4812 |
\seq_gclear:N \g_@@_blocks_seq |
| 4813 |
\seq_gclear:N \g_@@_pos_of_blocks_seq |
| 4814 |
% \end{macrocode} |
| 4815 |
% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the |
| 4816 |
% positions of the cells with a |\diagbox| and the |\multicolumn|. |
| 4817 |
% |
| 4818 |
% \begin{macrocode} |
| 4819 |
\seq_gclear:N \g_@@_pos_of_stroken_blocks_seq |
| 4820 |
\seq_gclear:N \g_@@_pos_of_xdots_seq |
| 4821 |
\tl_gclear_new:N \g_@@_code_before_tl |
| 4822 |
\tl_gclear:N \g_@@_row_style_tl |
| 4823 |
% \end{macrocode} |
| 4824 |
% |
| 4825 |
% \bigskip |
| 4826 |
% We load all the information written in the |aux| file during previous |
| 4827 |
% compilations corresponding to the current environment. |
| 4828 |
% \begin{macrocode} |
| 4829 |
\tl_if_exist:cTF { g_@@ _ \int_use:N \g_@@_env_int _ tl } |
| 4830 |
{ |
| 4831 |
\bool_gset_true:N \g_@@_aux_found_bool |
| 4832 |
\use:c { g_@@ _ \int_use:N \g_@@_env_int _ tl } |
| 4833 |
} |
| 4834 |
{ \bool_gset_false:N \g_@@_aux_found_bool } |
| 4835 |
% \end{macrocode} |
| 4836 |
% Now, we prepare the token list for the instructions that we will have to write |
| 4837 |
% on the |aux| file at the end of the environment. |
| 4838 |
% \begin{macrocode} |
| 4839 |
\tl_gclear:N \g_@@_aux_tl |
| 4840 |
% \end{macrocode} |
| 4841 |
% |
| 4842 |
% \begin{macrocode} |
| 4843 |
\tl_if_empty:NF \g_@@_code_before_tl |
| 4844 |
{ |
| 4845 |
\bool_set_true:N \l_@@_code_before_bool |
| 4846 |
\tl_put_right:No \l_@@_code_before_tl \g_@@_code_before_tl |
| 4847 |
} |
| 4848 |
\tl_if_empty:NF \g_@@_pre_code_before_tl |
| 4849 |
{ \bool_set_true:N \l_@@_code_before_bool } |
| 4850 |
% \end{macrocode} |
| 4851 |
% |
| 4852 |
% The set of keys is not exactly the same for |{NiceArray}| and for the variants |
| 4853 |
% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for |
| 4854 |
% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|. |
| 4855 |
% \begin{macrocode} |
| 4856 |
\bool_if:NTF \g_@@_delims_bool |
| 4857 |
{ \keys_set:nn { nicematrix / pNiceArray } } |
| 4858 |
{ \keys_set:nn { nicematrix / NiceArray } } |
| 4859 |
{ #3 , #5 } |
| 4860 |
% \end{macrocode} |
| 4861 |
% |
| 4862 |
% \bigskip |
| 4863 |
% \begin{macrocode} |
| 4864 |
\@@_set_CTarc:o \l_@@_rules_color_tl % noqa: w302 |
| 4865 |
% \end{macrocode} |
| 4866 |
% |
| 4867 |
% \bigskip |
| 4868 |
% The argument |#6| is the last argument of |{NiceArrayWithDelims}|. With that |
| 4869 |
% argument of type ``|t \CodeBefore|'', we test whether there is the keyword |
| 4870 |
% |\CodeBefore| at the beginning of the body of the environment. If that keyword |
| 4871 |
% is present, we have now to extract all the content between that keyword |
| 4872 |
% |\CodeBefore| and the (other) keyword |\Body|. It's the job that will do the |
| 4873 |
% command |\@@_CodeBefore_Body:w|. After that job, the command |\@@_CodeBefore_Body:w| |
| 4874 |
% will go on with |\@@_pre_array:|. |
| 4875 |
% \begin{macrocode} |
| 4876 |
\bool_if:nTF { #6 } \@@_CodeBefore_Body:w \@@_pre_array: |
| 4877 |
} |
| 4878 |
% \end{macrocode} |
| 4879 |
% |
| 4880 |
% Now, the second part of the environment |{NiceArrayWithDelims}|. |
| 4881 |
% \begin{macrocode} |
| 4882 |
{ |
| 4883 |
\bool_if:NTF \l_@@_light_syntax_bool |
| 4884 |
{ \use:c { end @@-light-syntax } } |
| 4885 |
{ \use:c { end @@-normal-syntax } } |
| 4886 |
$ % $ |
| 4887 |
\skip_horizontal:N \l_@@_right_margin_dim |
| 4888 |
\skip_horizontal:N \l_@@_extra_right_margin_dim |
| 4889 |
\hbox_set_end: |
| 4890 |
\UseTaggingSocket { tbl / hmode / end } |
| 4891 |
% \end{macrocode} |
| 4892 |
% End of the construction of the array (in the box |\l_@@_the_array_box|). |
| 4893 |
% |
| 4894 |
% \bigskip |
| 4895 |
% If the user has used the key |width| without any column |X|, we raise an error. |
| 4896 |
% \begin{macrocode} |
| 4897 |
\bool_if:NT \l_@@_width_used_bool |
| 4898 |
{ |
| 4899 |
\fp_compare:nNnT { \g_@@_total_X_weight_fp } = { \c_zero_fp } |
| 4900 |
{ \@@_error_or_warning:n { width~without~X~columns } } |
| 4901 |
} |
| 4902 |
% \end{macrocode} |
| 4903 |
% |
| 4904 |
% \bigskip |
| 4905 |
% Now, if there is at least one |X|-column in the environment, we compute the |
| 4906 |
% width that those columns will have (in the next compilation). In fact, |
| 4907 |
% |l_@@_X_columns_dim| will be the width of a column of weight $1.0$. For a |
| 4908 |
% |X|-column of weight~$x$, the width will be |\l_@@_X_columns_dim| multiplied |
| 4909 |
% by~$x$. |
| 4910 |
% \begin{macrocode} |
| 4911 |
\fp_compare:nNnT \g_@@_total_X_weight_fp > \c_zero_fp |
| 4912 |
\@@_compute_width_X: |
| 4913 |
% \end{macrocode} |
| 4914 |
% |
| 4915 |
% \bigskip |
| 4916 |
% It the user has used the key |last-row| with a value, we control that the |
| 4917 |
% given value is correct (since we have just constructed the array, we know the |
| 4918 |
% actual number of rows of the array). |
| 4919 |
% \begin{macrocode} |
| 4920 |
\int_compare:nNnT \l_@@_last_row_int > { -2 } |
| 4921 |
{ |
| 4922 |
\bool_if:NF \l_@@_last_row_without_value_bool |
| 4923 |
{ |
| 4924 |
\int_compare:nNnF \l_@@_last_row_int = \c@iRow |
| 4925 |
{ |
| 4926 |
\@@_error:n { Wrong~last~row } |
| 4927 |
\int_set_eq:NN \l_@@_last_row_int \c@iRow |
| 4928 |
} |
| 4929 |
} |
| 4930 |
} |
| 4931 |
% \end{macrocode} |
| 4932 |
% |
| 4933 |
% Now, the definition of |\c@jCol| and |\g_@@_col_total_int| changes: |\c@jCol| |
| 4934 |
% will be the number of columns without the ``last column''; |
| 4935 |
% |\g_@@_col_total_int| will be the number of columns with this ``last |
| 4936 |
% column''.\footnote{We remind that the potential ``first column'' (exterior) |
| 4937 |
% has the number~$0$.} |
| 4938 |
% \begin{macrocode} |
| 4939 |
\int_gset_eq:NN \c@jCol \g_@@_col_total_int |
| 4940 |
\bool_if:NTF \g_@@_last_col_found_bool |
| 4941 |
{ \int_gdecr:N \c@jCol } |
| 4942 |
{ |
| 4943 |
\int_compare:nNnT \l_@@_last_col_int > { -1 } |
| 4944 |
{ \@@_error:n { last~col~not~used } } |
| 4945 |
} |
| 4946 |
% \end{macrocode} |
| 4947 |
% |
| 4948 |
% We fix also the value of |\c@iRow| and |\g_@@_row_total_int| with the |
| 4949 |
% same principle. |
| 4950 |
% \begin{macrocode} |
| 4951 |
\int_gset_eq:NN \g_@@_row_total_int \c@iRow |
| 4952 |
\int_compare:nNnT \l_@@_last_row_int > { -1 } |
| 4953 |
{ \int_gdecr:N \c@iRow } |
| 4954 |
% \end{macrocode} |
| 4955 |
% |
| 4956 |
% |
| 4957 |
% \bigskip |
| 4958 |
% \textbf{Now, we begin the real construction in the output flow of TeX}. First, we take |
| 4959 |
% into account a potential ``first column'' (we remind that this ``first |
| 4960 |
% column'' has been constructed in an overlapping position and that we have |
| 4961 |
% computed its width in |\g_@@_width_first_col_dim|: see p.~\pageref{overlap-left}). |
| 4962 |
% \begin{macrocode} |
| 4963 |
\int_if_zero:nT \l_@@_first_col_int |
| 4964 |
{ \skip_horizontal:N \g_@@_width_first_col_dim } |
| 4965 |
% \end{macrocode} |
| 4966 |
% |
| 4967 |
% The construction of the real box is different whether we have delimiters to |
| 4968 |
% put. |
| 4969 |
% \begin{macrocode} |
| 4970 |
\bool_if:nTF { ! \g_@@_delims_bool } |
| 4971 |
{ |
| 4972 |
\str_if_eq:eeTF c \l_@@_baseline_tl |
| 4973 |
\@@_use_arraybox_with_notes_c: |
| 4974 |
{ |
| 4975 |
\str_if_eq:eeTF b \l_@@_baseline_tl |
| 4976 |
\@@_use_arraybox_with_notes_b: |
| 4977 |
\@@_use_arraybox_with_notes: |
| 4978 |
} |
| 4979 |
} |
| 4980 |
% \end{macrocode} |
| 4981 |
% |
| 4982 |
% Now, in the case of an environment with delimiters. We compute |\l_tmpa_dim| |
| 4983 |
% which is the total height of the ``first row'' above the array (when the key |
| 4984 |
% |first-row| is used). |
| 4985 |
% \begin{macrocode} |
| 4986 |
{ |
| 4987 |
\int_if_zero:nTF \l_@@_first_row_int |
| 4988 |
{ |
| 4989 |
\dim_set_eq:NN \l_tmpa_dim \g_@@_dp_row_zero_dim |
| 4990 |
\dim_add:Nn \l_tmpa_dim \g_@@_ht_row_zero_dim |
| 4991 |
} |
| 4992 |
{ \dim_zero:N \l_tmpa_dim } |
| 4993 |
% \end{macrocode} |
| 4994 |
% |
| 4995 |
% We compute |\l_tmpb_dim| which is the total height of the ``last row'' |
| 4996 |
% below the array (when the key |last-row| is used). A value of $-2$ for |
| 4997 |
% |\l_@@_last_row_int| means that there is no ``last row''.\footnote{A value of |
| 4998 |
% $-1$ for |\l_@@_last_row_int| means that there is a ``last row'' but the |
| 4999 |
% the user have not set the value with the option |last row| (and we are in the |
| 5000 |
% first compilation).} |
| 5001 |
% \begin{macrocode} |
| 5002 |
\int_compare:nNnTF \l_@@_last_row_int > { -2 } |
| 5003 |
{ |
| 5004 |
\dim_set_eq:NN \l_tmpb_dim \g_@@_ht_last_row_dim |
| 5005 |
\dim_add:Nn \l_tmpb_dim \g_@@_dp_last_row_dim |
| 5006 |
} |
| 5007 |
{ \dim_zero:N \l_tmpb_dim } |
| 5008 |
% \end{macrocode} |
| 5009 |
% |
| 5010 |
% \begin{macrocode} |
| 5011 |
\hbox_set:Nn \l_tmpa_box |
| 5012 |
{ |
| 5013 |
\m@th |
| 5014 |
$ % $ |
| 5015 |
\@@_color:o \l_@@_delimiters_color_tl |
| 5016 |
\exp_after:wN \left \g_@@_left_delim_tl |
| 5017 |
\vcenter |
| 5018 |
{ |
| 5019 |
% \end{macrocode} |
| 5020 |
% We take into account the ``first row'' (we have previously computed its total |
| 5021 |
% height in |\l_tmpa_dim|). The |\hbox:n| (or |\hbox|) is necessary here. |
| 5022 |
% \begin{macrocode} |
| 5023 |
\skip_vertical:n { - \l_tmpa_dim - \arrayrulewidth } |
| 5024 |
\hbox |
| 5025 |
{ |
| 5026 |
\bool_if:NTF \l_@@_tabular_bool |
| 5027 |
{ \skip_horizontal:n { - \tabcolsep } } |
| 5028 |
{ \skip_horizontal:n { - \arraycolsep } } |
| 5029 |
\@@_use_arraybox_with_notes_c: |
| 5030 |
\bool_if:NTF \l_@@_tabular_bool |
| 5031 |
{ \skip_horizontal:n { - \tabcolsep } } |
| 5032 |
{ \skip_horizontal:n { - \arraycolsep } } |
| 5033 |
} |
| 5034 |
% \end{macrocode} |
| 5035 |
% We take into account the ``last row'' (we have previously computed its total |
| 5036 |
% height in |\l_tmpb_dim|). |
| 5037 |
% \begin{macrocode} |
| 5038 |
\skip_vertical:n { - \l_tmpb_dim + \arrayrulewidth } |
| 5039 |
} |
| 5040 |
\exp_after:wN \right \g_@@_right_delim_tl |
| 5041 |
$ % $ |
| 5042 |
} |
| 5043 |
% \end{macrocode} |
| 5044 |
% Now, the box |\l_tmpa_box| is created with the correct delimiters. |
| 5045 |
% |
| 5046 |
% \smallskip |
| 5047 |
% We will put the box in the TeX flow. However, we have a small work to do |
| 5048 |
% when the option |delimiters/max-width| is used. |
| 5049 |
% \begin{macrocode} |
| 5050 |
\bool_if:NTF \l_@@_delimiters_max_width_bool |
| 5051 |
{ \@@_put_box_in_flow_bis:nn \g_@@_left_delim_tl \g_@@_right_delim_tl } |
| 5052 |
\@@_put_box_in_flow: |
| 5053 |
} |
| 5054 |
% \end{macrocode} |
| 5055 |
% |
| 5056 |
% We take into account a potential ``last column'' (this ``last column'' has |
| 5057 |
% been constructed in an overlapping position and we have computed its width in |
| 5058 |
% |\g_@@_width_last_col_dim|: see p.~\pageref{overlap-right}). |
| 5059 |
% \begin{macrocode} |
| 5060 |
\bool_if:NT \g_@@_last_col_found_bool |
| 5061 |
{ \skip_horizontal:N \g_@@_width_last_col_dim } |
| 5062 |
\bool_if:NT \l_@@_preamble_bool |
| 5063 |
{ |
| 5064 |
\int_compare:nNnT \c@jCol < \g_@@_static_num_of_col_int |
| 5065 |
{ \@@_err_columns_not_used: } |
| 5066 |
} |
| 5067 |
\@@_after_array: |
| 5068 |
% \end{macrocode} |
| 5069 |
% The aim of the following |\egroup| (the corresponding |\bgroup| is, of course, |
| 5070 |
% at the beginning of the environment) is to be able to put an exposant to a matrix in |
| 5071 |
% a mathematical formula. |
| 5072 |
% \begin{macrocode} |
| 5073 |
\egroup |
| 5074 |
% \end{macrocode} |
| 5075 |
% |
| 5076 |
% \bigskip |
| 5077 |
% We write on the |aux| file all the information corresponding to the |
| 5078 |
% current environment. |
| 5079 |
% \begin{macrocode} |
| 5080 |
\iow_now:Nn \@mainaux { \ExplSyntaxOn } |
| 5081 |
\iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } } |
| 5082 |
\iow_now:Ne \@mainaux |
| 5083 |
{ |
| 5084 |
\tl_gclear_new:c { g_@@_ \int_use:N \g_@@_env_int _ tl } |
| 5085 |
\tl_gset:cn { g_@@_ \int_use:N \g_@@_env_int _ tl } |
| 5086 |
{ \exp_not:o \g_@@_aux_tl } |
| 5087 |
} |
| 5088 |
\iow_now:Nn \@mainaux { \ExplSyntaxOff } |
| 5089 |
% \end{macrocode} |
| 5090 |
% |
| 5091 |
% \bigskip |
| 5092 |
% \begin{macrocode} |
| 5093 |
\bool_if:NT \g_@@_footnote_bool { \endsavenotes } |
| 5094 |
} |
| 5095 |
% \end{macrocode} |
| 5096 |
% This is the end of the environment |{NiceArrayWithDelims}|. |
| 5097 |
% |
| 5098 |
% |
| 5099 |
% \bigskip |
| 5100 |
% \begin{macrocode} |
| 5101 |
\cs_new_protected:Npn \@@_err_columns_not_used: |
| 5102 |
{ |
| 5103 |
\@@_warning:n { columns~not~used } |
| 5104 |
\cs_gset:Npn \@@_err_columns_not_used: { } |
| 5105 |
} |
| 5106 |
% \end{macrocode} |
| 5107 |
% |
| 5108 |
% \bigskip |
| 5109 |
% The following command will be used only once. We have written that command for |
| 5110 |
% legibility. If there is at least one |X|-column in the environment, we compute |
| 5111 |
% the width that those columns will have (in the next compilation). In fact, |
| 5112 |
% |l_@@_X_columns_dim| will be the width of a column of weight $1.0$. For a |
| 5113 |
% |X|-column of weight~$x$, the width will be |\l_@@_X_columns_dim| multiplied |
| 5114 |
% by~$x$. |
| 5115 |
% \begin{macrocode} |
| 5116 |
\cs_new_protected:Npn \@@_compute_width_X: |
| 5117 |
{ |
| 5118 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 5119 |
{ |
| 5120 |
\bool_set_true:N \l_@@_X_columns_aux_bool |
| 5121 |
\dim_set:Nn \l_@@_X_columns_dim |
| 5122 |
{ |
| 5123 |
% \end{macrocode} |
| 5124 |
% The flag |g_@@_V_of_X_bool| is raised when there is at least in the tabular |
| 5125 |
% a column of type |X| using the key |V|. In that case, the width of the |X| column may |
| 5126 |
% be considered as correct even though the tabular has not (of course) a width equal |
| 5127 |
% to |\l_@@_width_dim| |
| 5128 |
% \begin{macrocode} |
| 5129 |
\bool_lazy_and:nnTF \g_@@_V_of_X_bool \l_@@_X_columns_aux_bool |
| 5130 |
{ \dim_use:N \l_@@_X_columns_dim } |
| 5131 |
{ |
| 5132 |
\dim_compare:nNnTF |
| 5133 |
{ |
| 5134 |
\dim_abs:n |
| 5135 |
{ \l_@@_width_dim - \box_wd:N \l_@@_the_array_box } |
| 5136 |
} |
| 5137 |
< |
| 5138 |
{ 0.001 pt } |
| 5139 |
{ \dim_use:N \l_@@_X_columns_dim } |
| 5140 |
{ |
| 5141 |
\dim_eval:n |
| 5142 |
{ |
| 5143 |
\l_@@_X_columns_dim |
| 5144 |
+ |
| 5145 |
\fp_to_dim:n |
| 5146 |
{ |
| 5147 |
( |
| 5148 |
\dim_eval:n |
| 5149 |
{ \l_@@_width_dim - \box_wd:N \l_@@_the_array_box } |
| 5150 |
) |
| 5151 |
/ \fp_use:N \g_@@_total_X_weight_fp |
| 5152 |
} |
| 5153 |
} |
| 5154 |
} |
| 5155 |
} |
| 5156 |
} |
| 5157 |
} |
| 5158 |
} |
| 5159 |
% \end{macrocode} |
| 5160 |
% |
| 5161 |
% \vspace{1cm} |
| 5162 |
% \section{Construction of the preamble of the array} |
| 5163 |
% |
| 5164 |
% \bigskip |
| 5165 |
% The final user provides a preamble, but we must convert that preamble into a |
| 5166 |
% preamble which will be given to |{array}| (of the package \pkg{array}). |
| 5167 |
% |
| 5168 |
% \bigskip |
| 5169 |
% The preamble given by the final user is stored in |\g_@@_user_preamble_tl|. |
| 5170 |
% The modified version will be stored in |\g_@@_array_preamble_tl|. |
| 5171 |
% \begin{macrocode} |
| 5172 |
\cs_new_protected:Npn \@@_transform_preamble: |
| 5173 |
{ |
| 5174 |
\@@_transform_preamble_i: |
| 5175 |
\@@_transform_preamble_ii: |
| 5176 |
} |
| 5177 |
% \end{macrocode} |
| 5178 |
% |
| 5179 |
% \begin{macrocode} |
| 5180 |
\cs_new_protected:Npn \@@_transform_preamble_i: |
| 5181 |
{ |
| 5182 |
\int_gzero:N \c@jCol |
| 5183 |
% \end{macrocode} |
| 5184 |
% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns |
| 5185 |
% where you will to have to draw vertical lines in the potential sub-matrices |
| 5186 |
% (hence the name |vlism|). |
| 5187 |
% \begin{macrocode} |
| 5188 |
\seq_gclear:N \g_@@_cols_vlism_seq |
| 5189 |
% \end{macrocode} |
| 5190 |
% |\g_tmpb_bool| will be raised if you have a \verb+|+ at the end of the |
| 5191 |
% preamble provided by the final user. |
| 5192 |
% \begin{macrocode} |
| 5193 |
\bool_gset_false:N \g_tmpb_bool |
| 5194 |
% \end{macrocode} |
| 5195 |
% |
| 5196 |
% The following sequence will store the arguments of the successive |>| in the |
| 5197 |
% preamble. |
| 5198 |
% \begin{macrocode} |
| 5199 |
\tl_gclear_new:N \g_@@_pre_cell_tl |
| 5200 |
% \end{macrocode} |
| 5201 |
% The counter |\l_tmpa_int| will count the number of consecutive occurrences |
| 5202 |
% of the symbol \verb+|+. |
| 5203 |
% \begin{macrocode} |
| 5204 |
\int_zero:N \l_tmpa_int |
| 5205 |
\tl_gclear:N \g_@@_array_preamble_tl |
| 5206 |
\str_if_eq:eeTF \l_@@_vlines_clist { all } |
| 5207 |
{ |
| 5208 |
\tl_gset:Nn \g_@@_array_preamble_tl |
| 5209 |
{ ! { \skip_horizontal:N \arrayrulewidth } } |
| 5210 |
} |
| 5211 |
{ |
| 5212 |
\clist_if_in:NnT \l_@@_vlines_clist 1 |
| 5213 |
{ |
| 5214 |
\tl_gset:Nn \g_@@_array_preamble_tl |
| 5215 |
{ ! { \skip_horizontal:N \arrayrulewidth } } |
| 5216 |
} |
| 5217 |
} |
| 5218 |
% \end{macrocode} |
| 5219 |
% |
| 5220 |
% \bigskip |
| 5221 |
% Now, we actually make the preamble (which will be given to |{array}|). It will |
| 5222 |
% be stored in |\g_@@_array_preamble_tl|. |
| 5223 |
% \begin{macrocode} |
| 5224 |
\exp_last_unbraced:No \@@_rec_preamble:n \g_@@_user_preamble_tl \s_stop |
| 5225 |
\int_gset_eq:NN \g_@@_static_num_of_col_int \c@jCol |
| 5226 |
% \end{macrocode} |
| 5227 |
% |
| 5228 |
% \medskip |
| 5229 |
% \begin{macrocode} |
| 5230 |
\@@_replace_columncolor: |
| 5231 |
} |
| 5232 |
% \end{macrocode} |
| 5233 |
% |
| 5234 |
% |
| 5235 |
% \bigskip |
| 5236 |
% \begin{macrocode} |
| 5237 |
\cs_new_protected:Npn \@@_transform_preamble_ii: |
| 5238 |
{ |
| 5239 |
% \end{macrocode} |
| 5240 |
% |
| 5241 |
% \medskip |
| 5242 |
% If there were delimiters at the beginning or at the end of the preamble, the |
| 5243 |
% environment |{NiceArray}| is transformed into an environment |{xNiceMatrix}|. |
| 5244 |
% \begin{macrocode} |
| 5245 |
\tl_if_eq:NNTF \g_@@_left_delim_tl \c_@@_dot_tl |
| 5246 |
{ |
| 5247 |
\tl_if_eq:NNF \g_@@_right_delim_tl \c_@@_dot_tl |
| 5248 |
{ \bool_gset_true:N \g_@@_delims_bool } |
| 5249 |
} |
| 5250 |
{ \bool_gset_true:N \g_@@_delims_bool } |
| 5251 |
% \end{macrocode} |
| 5252 |
% |
| 5253 |
% \medskip |
| 5254 |
% We want to remind whether there is a specifier \verb+|+ at the end of the preamble. |
| 5255 |
% \begin{macrocode} |
| 5256 |
\bool_if:NT \g_tmpb_bool { \bool_set_true:N \l_@@_bar_at_end_of_pream_bool } |
| 5257 |
% \end{macrocode} |
| 5258 |
% |
| 5259 |
% \bigskip |
| 5260 |
% We complete the preamble with the potential ``exterior columns'' (on both sides). |
| 5261 |
% \begin{macrocode} |
| 5262 |
\int_if_zero:nTF \l_@@_first_col_int |
| 5263 |
{ \tl_gput_left:No \g_@@_array_preamble_tl \c_@@_preamble_first_col_tl } |
| 5264 |
{ |
| 5265 |
\bool_if:NF \g_@@_delims_bool |
| 5266 |
{ |
| 5267 |
\bool_if:NF \l_@@_tabular_bool |
| 5268 |
{ |
| 5269 |
\clist_if_empty:NT \l_@@_vlines_clist |
| 5270 |
{ |
| 5271 |
\bool_if:NF \l_@@_exterior_arraycolsep_bool |
| 5272 |
{ \tl_gput_left:Nn \g_@@_array_preamble_tl { @ { } } } |
| 5273 |
} |
| 5274 |
} |
| 5275 |
} |
| 5276 |
} |
| 5277 |
\int_compare:nNnTF \l_@@_last_col_int > { -1 } |
| 5278 |
{ \tl_gput_right:No \g_@@_array_preamble_tl \c_@@_preamble_last_col_tl } |
| 5279 |
{ |
| 5280 |
\bool_if:NF \g_@@_delims_bool |
| 5281 |
{ |
| 5282 |
\bool_if:NF \l_@@_tabular_bool |
| 5283 |
{ |
| 5284 |
\clist_if_empty:NT \l_@@_vlines_clist |
| 5285 |
{ |
| 5286 |
\bool_if:NF \l_@@_exterior_arraycolsep_bool |
| 5287 |
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { @ { } } } |
| 5288 |
} |
| 5289 |
} |
| 5290 |
} |
| 5291 |
} |
| 5292 |
% \end{macrocode} |
| 5293 |
% We try to give a good error message when the final user puts more columns |
| 5294 |
% than allowed by the preamble of the array. The mechanism consists of an extra column. |
| 5295 |
% However, if tagging is in force, that dummy extra column will be tagged (with |<TD>| |
| 5296 |
% tags) and that's why we disable that mechanism when tagging is in force. |
| 5297 |
% \begin{macrocode} |
| 5298 |
\tag_if_active:F |
| 5299 |
{ |
| 5300 |
% \end{macrocode} |
| 5301 |
% Moreover, when |{NiceTabular*}| is used, the mechanism can't be used for technical reasons. |
| 5302 |
% We test that situation with |\l_@@_tabular_width_dim|. |
| 5303 |
% \begin{macrocode} |
| 5304 |
\dim_compare:nNnT \l_@@_tabular_width_dim = \c_zero_dim |
| 5305 |
{ |
| 5306 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5307 |
{ > { \@@_err_too_many_cols: } l } |
| 5308 |
} |
| 5309 |
} |
| 5310 |
} |
| 5311 |
% \end{macrocode} |
| 5312 |
% We have used to add a last column to raise a good error message when the user |
| 5313 |
% puts more columns than allowed by its preamble. For technical reasons, it was |
| 5314 |
% not possible to do that in |{NiceTabular*}| and that's why we used to control that with |
| 5315 |
% the value of |\l_@@_tabular_width_dim|). |
| 5316 |
% |
| 5317 |
% |
| 5318 |
% \bigskip |
| 5319 |
% The preamble provided by the final user will be read by a finite |
| 5320 |
% automata. The following function |\@@_rec_preamble:n| will read that preamble |
| 5321 |
% (usually letter by letter) in a recursive way (hence the name of that function). |
| 5322 |
% in the preamble. |
| 5323 |
% \begin{macrocode} |
| 5324 |
\cs_new_protected:Npn \@@_rec_preamble:n #1 |
| 5325 |
{ |
| 5326 |
% \end{macrocode} |
| 5327 |
% For the majority of the letters, we will trigger the corresponding action by |
| 5328 |
% calling directly a function in the main hashtable of TeX (thanks to the |
| 5329 |
% mechanism |\csname...\endcsname|. Be careful: all these functions take in as |
| 5330 |
% first argument the letter (or token) itself.\footnote{We do that because it's |
| 5331 |
% an easy way to insert the letter at some places in the code that we will add to |
| 5332 |
% |\g_@@_array_preamble_tl|.} |
| 5333 |
% \begin{macrocode} |
| 5334 |
\cs_if_exist:cTF { @@ _ \token_to_str:N #1 : } |
| 5335 |
{ \use:c { @@ _ \token_to_str:N #1 : } { #1 } } |
| 5336 |
{ |
| 5337 |
% \end{macrocode} |
| 5338 |
% Now, the columns defined by |\newcolumntype| of \pkg{array}. |
| 5339 |
% \begin{macrocode} |
| 5340 |
\cs_if_exist:cTF { NC @ find @ #1 } |
| 5341 |
{ |
| 5342 |
\tl_set_eq:Nc \l_tmpb_tl { NC @ rewrite @ #1 } |
| 5343 |
\exp_last_unbraced:No \@@_rec_preamble:n \l_tmpb_tl |
| 5344 |
} |
| 5345 |
{ |
| 5346 |
\str_if_eq:nnTF { #1 } { S } |
| 5347 |
{ \@@_fatal:n { unknown~column~type~S } } |
| 5348 |
{ \@@_fatal:nn { unknown~column~type } { #1 } } |
| 5349 |
} |
| 5350 |
} |
| 5351 |
} |
| 5352 |
% \end{macrocode} |
| 5353 |
% |
| 5354 |
% |
| 5355 |
% \bigskip |
| 5356 |
% For |c|, |l| and |r| |
| 5357 |
% \begin{macrocode} |
| 5358 |
\cs_new_protected:Npn \@@_c: #1 |
| 5359 |
{ |
| 5360 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 5361 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 5362 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5363 |
{ > \@@_cell_begin: c < \@@_cell_end: } |
| 5364 |
% \end{macrocode} |
| 5365 |
% |
| 5366 |
% We increment the counter of columns and then we test for the presence of a |<|. |
| 5367 |
% \begin{macrocode} |
| 5368 |
\int_gincr:N \c@jCol |
| 5369 |
\@@_rec_preamble_after_col:n |
| 5370 |
} |
| 5371 |
% \end{macrocode} |
| 5372 |
% \begin{macrocode} |
| 5373 |
\cs_new_protected:Npn \@@_l: #1 |
| 5374 |
{ |
| 5375 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 5376 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 5377 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5378 |
{ |
| 5379 |
> { \@@_cell_begin: \tl_set_eq:NN \l_@@_hpos_cell_tl \c_@@_l_tl } |
| 5380 |
l |
| 5381 |
< \@@_cell_end: |
| 5382 |
} |
| 5383 |
\int_gincr:N \c@jCol |
| 5384 |
\@@_rec_preamble_after_col:n |
| 5385 |
} |
| 5386 |
% \end{macrocode} |
| 5387 |
% \begin{macrocode} |
| 5388 |
\cs_new_protected:Npn \@@_r: #1 |
| 5389 |
{ |
| 5390 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 5391 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 5392 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5393 |
{ |
| 5394 |
> { \@@_cell_begin: \tl_set_eq:NN \l_@@_hpos_cell_tl \c_@@_r_tl } |
| 5395 |
r |
| 5396 |
< \@@_cell_end: |
| 5397 |
} |
| 5398 |
\int_gincr:N \c@jCol |
| 5399 |
\@@_rec_preamble_after_col:n |
| 5400 |
} |
| 5401 |
% \end{macrocode} |
| 5402 |
% |
| 5403 |
% \medskip |
| 5404 |
% For |!| and |@| |
| 5405 |
% \begin{macrocode} |
| 5406 |
\cs_new_protected:cpn { @@ _ \token_to_str:N ! : } #1 #2 |
| 5407 |
{ |
| 5408 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { #1 { #2 } } |
| 5409 |
\@@_rec_preamble:n |
| 5410 |
} |
| 5411 |
\cs_set_eq:cc { @@ _ \token_to_str:N @ : } { @@ _ \token_to_str:N ! : } |
| 5412 |
% \end{macrocode} |
| 5413 |
% |
| 5414 |
% |
| 5415 |
% \medskip |
| 5416 |
% For \verb+|+ |
| 5417 |
% \begin{macrocode} |
| 5418 |
\cs_new_protected:cpn { @@ _ | : } #1 |
| 5419 |
{ |
| 5420 |
% \end{macrocode} |
| 5421 |
% |\l_tmpa_int| is the number of successive occurrences of \verb+|+ |
| 5422 |
% \begin{macrocode} |
| 5423 |
\int_incr:N \l_tmpa_int |
| 5424 |
\@@_make_preamble_i_i:n |
| 5425 |
} |
| 5426 |
% \end{macrocode} |
| 5427 |
% |
| 5428 |
% \begin{macrocode} |
| 5429 |
\cs_new_protected:Npn \@@_make_preamble_i_i:n #1 |
| 5430 |
{ |
| 5431 |
% \end{macrocode} |
| 5432 |
% Here, we can't use |\str_if_eq:eeTF|. |
| 5433 |
% \begin{macrocode} |
| 5434 |
\str_if_eq:nnTF { #1 } { | } |
| 5435 |
{ \use:c { @@ _ | : } | } |
| 5436 |
{ \@@_make_preamble_i_ii:nn { } #1 } |
| 5437 |
} |
| 5438 |
% \end{macrocode} |
| 5439 |
% |
| 5440 |
% The following constructions aims to allow cumulative blocks of options between |
| 5441 |
% square brackets such as in \verb+|[color=blue][tikz=dashed]+. |
| 5442 |
% \begin{macrocode} |
| 5443 |
\cs_new_protected:Npn \@@_make_preamble_i_ii:nn #1 #2 |
| 5444 |
{ |
| 5445 |
\str_if_eq:nnTF { #2 } { [ } |
| 5446 |
{ \@@_make_preamble_i_ii:nw { #1 } [ } |
| 5447 |
{ \@@_make_preamble_i_iii:nn { #2 } { #1 } } |
| 5448 |
} |
| 5449 |
\cs_new_protected:Npn \@@_make_preamble_i_ii:nw #1 [ #2 ] |
| 5450 |
{ \@@_make_preamble_i_ii:nn { #1 , #2 } } |
| 5451 |
% \end{macrocode} |
| 5452 |
% |
| 5453 |
% \begin{macrocode} |
| 5454 |
\cs_new_protected:Npn \@@_make_preamble_i_iii:nn #1 #2 |
| 5455 |
{ |
| 5456 |
\@@_compute_rule_width:n { multiplicity = \l_tmpa_int , #2 } |
| 5457 |
\tl_gput_right:Ne \g_@@_array_preamble_tl |
| 5458 |
{ |
| 5459 |
% \end{macrocode} |
| 5460 |
% Here, the command |\dim_use:N| is mandatory. |
| 5461 |
% \begin{macrocode} |
| 5462 |
\exp_not:N ! { \skip_horizontal:N \dim_use:N \l_@@_rule_width_before_dim } |
| 5463 |
} |
| 5464 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 5465 |
{ |
| 5466 |
% \end{macrocode} |
| 5467 |
% |
| 5468 |
% \bigskip |
| 5469 |
% With the keys of |nicematrix / rules-after| we would write: |
| 5470 |
% \begin{Verbatim} |
| 5471 |
% \@@_draw_vrule:n |
| 5472 |
% { |
| 5473 |
% multiplicity = \int_use:N \l_tmpa_int , |
| 5474 |
% position = \int_eval:n { \c@jCol + 1 } , |
| 5475 |
% total-width = \dim_use:N \l_@@_rule_width_before_dim , |
| 5476 |
% #2 |
| 5477 |
% } |
| 5478 |
% \end{Verbatim} |
| 5479 |
% |
| 5480 |
% We will use a version slightly more efficient: |
| 5481 |
% \begin{macrocode} |
| 5482 |
{ |
| 5483 |
\int_compare:nNnT \l_tmpa_int > 1 |
| 5484 |
{ \@@_set_multiplicity:n { \int_use:N \l_tmpa_int } } |
| 5485 |
\int_set:Nn \l_@@_position_int { \int_eval:n { \c@jCol + 1 } } |
| 5486 |
\dim_set:Nn \l_@@_rule_width_after_dim |
| 5487 |
{ \dim_use:N \l_@@_rule_width_before_dim } |
| 5488 |
\@@_draw_vrule:n { #2 } |
| 5489 |
} |
| 5490 |
% \end{macrocode} |
| 5491 |
% We don't have provided value for |start| nor for |end|, which means that the |
| 5492 |
% rule will cover (potentially) all the rows of the array. |
| 5493 |
% |
| 5494 |
% \begin{macrocode} |
| 5495 |
} |
| 5496 |
\int_zero:N \l_tmpa_int |
| 5497 |
\str_if_eq:nnT { #1 } { \s_stop } { \bool_gset_true:N \g_tmpb_bool } |
| 5498 |
\@@_rec_preamble:n #1 |
| 5499 |
} |
| 5500 |
% \end{macrocode} |
| 5501 |
% |
| 5502 |
% \bigskip |
| 5503 |
% \begin{macrocode} |
| 5504 |
\cs_new_protected:cpn { @@ _ > : } #1 #2 |
| 5505 |
{ |
| 5506 |
\tl_gput_right:Nn \g_@@_pre_cell_tl { > { #2 } } |
| 5507 |
\@@_rec_preamble:n |
| 5508 |
} |
| 5509 |
% \end{macrocode} |
| 5510 |
% |
| 5511 |
% \begin{macrocode} |
| 5512 |
\bool_new:N \l_@@_bar_at_end_of_pream_bool |
| 5513 |
% \end{macrocode} |
| 5514 |
% |
| 5515 |
% \bigskip |
| 5516 |
% The specifier |p| (and also the specifiers |m|, |b|, |V| and |X|) have an |
| 5517 |
% optional argument between square brackets for a list of |
| 5518 |
% \emph{key}-\emph{value} pairs. Here are the corresponding keys. |
| 5519 |
% \begin{macrocode} |
| 5520 |
\keys_define:nn { nicematrix / p-column } |
| 5521 |
{ |
| 5522 |
r .code:n = \str_set_eq:NN \l_@@_hpos_col_str \c_@@_r_str , |
| 5523 |
r .value_forbidden:n = true , |
| 5524 |
c .code:n = \str_set_eq:NN \l_@@_hpos_col_str \c_@@_c_str , |
| 5525 |
c .value_forbidden:n = true , |
| 5526 |
l .code:n = \str_set_eq:NN \l_@@_hpos_col_str \c_@@_l_str , |
| 5527 |
l .value_forbidden:n = true , |
| 5528 |
S .code:n = \str_set:Nn \l_@@_hpos_col_str { si } , |
| 5529 |
S .value_forbidden:n = true , |
| 5530 |
p .code:n = \str_set:Nn \l_@@_vpos_col_str { p } , |
| 5531 |
p .value_forbidden:n = true , |
| 5532 |
t .meta:n = p , |
| 5533 |
m .code:n = \str_set:Nn \l_@@_vpos_col_str { m } , |
| 5534 |
m .value_forbidden:n = true , |
| 5535 |
b .code:n = \str_set:Nn \l_@@_vpos_col_str { b } , |
| 5536 |
b .value_forbidden:n = true |
| 5537 |
} |
| 5538 |
% \end{macrocode} |
| 5539 |
% |
| 5540 |
% |
| 5541 |
% \medskip |
| 5542 |
% For |p| but also |b| and |m|. |
| 5543 |
% \begin{macrocode} |
| 5544 |
\cs_new_protected:Npn \@@_p: #1 |
| 5545 |
{ |
| 5546 |
\str_set:Nn \l_@@_vpos_col_str { #1 } |
| 5547 |
% \end{macrocode} |
| 5548 |
% Now, you look for a potential character |[| after the letter of the specifier |
| 5549 |
% (for the options). |
| 5550 |
% \begin{macrocode} |
| 5551 |
\@@_make_preamble_ii_i:n |
| 5552 |
} |
| 5553 |
\cs_new_eq:NN \@@_b: \@@_p: |
| 5554 |
\cs_new_eq:NN \@@_m: \@@_p: |
| 5555 |
% \end{macrocode} |
| 5556 |
% |
| 5557 |
% \begin{macrocode} |
| 5558 |
\cs_new_protected:Npn \@@_make_preamble_ii_i:n #1 |
| 5559 |
{ |
| 5560 |
\str_if_eq:nnTF { #1 } { [ } |
| 5561 |
{ \@@_make_preamble_ii_ii:w [ } |
| 5562 |
{ \@@_make_preamble_ii_ii:w [ ] { #1 } } |
| 5563 |
} |
| 5564 |
% \end{macrocode} |
| 5565 |
% |
| 5566 |
% \begin{macrocode} |
| 5567 |
\cs_new_protected:Npn \@@_make_preamble_ii_ii:w [ #1 ] |
| 5568 |
{ \@@_make_preamble_ii_iii:nn { #1 } } |
| 5569 |
% \end{macrocode} |
| 5570 |
% |
| 5571 |
% \medskip |
| 5572 |
% |#1| is the optional argument of the specifier (a list of |
| 5573 |
% \emph{key}-\emph{value} pairs). |
| 5574 |
% |
| 5575 |
% |#2| is the mandatory argument of the specifier: the width of the column. |
| 5576 |
% \begin{macrocode} |
| 5577 |
\cs_new_protected:Npn \@@_make_preamble_ii_iii:nn #1 #2 |
| 5578 |
{ |
| 5579 |
% \end{macrocode} |
| 5580 |
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is |
| 5581 |
% the initial value), |l|, |c|, |r|, |L|, |C| and |R| (when the user has used |
| 5582 |
% the corresponding key in the optional argument of the specifier). |
| 5583 |
% \begin{macrocode} |
| 5584 |
\str_set:Nn \l_@@_hpos_col_str { j } |
| 5585 |
\@@_keys_p_column:n { #1 } |
| 5586 |
% \end{macrocode} |
| 5587 |
% We apply |setlength| in order to allow a width of column of the |
| 5588 |
% form |\widthof{Some words}|. |\widthof| is a command of the package \pkg{calc} |
| 5589 |
% (not loaded by \pkg{nicematrix}) which redefines the command |\setlength|. |
| 5590 |
% Of course, even if \pkg{calc} is not loaded, the following code will work with |
| 5591 |
% the standard version of |\setlength|. |
| 5592 |
% \begin{macrocode} |
| 5593 |
\setlength { \l_tmpa_dim } { #2 } |
| 5594 |
\@@_make_preamble_ii_iv:nnn { \dim_use:N \l_tmpa_dim } { minipage } { } |
| 5595 |
} |
| 5596 |
% \end{macrocode} |
| 5597 |
% |
| 5598 |
% \begin{macrocode} |
| 5599 |
\cs_new_protected:Npn \@@_keys_p_column:n #1 |
| 5600 |
{ \keys_set_known:nnN { nicematrix / p-column } { #1 } \l_tmpa_tl } |
| 5601 |
% \end{macrocode} |
| 5602 |
% |
| 5603 |
% \medskip |
| 5604 |
% |
| 5605 |
% |
| 5606 |
% \bigskip |
| 5607 |
% The first argument is the width of the column. The second is the type of |
| 5608 |
% environment: |minipage| or |varwidth|. The third is some code added at the |
| 5609 |
% beginning of the cell. |
| 5610 |
% |
| 5611 |
% \begin{macrocode} |
| 5612 |
\cs_new_protected:Npn \@@_make_preamble_ii_iv:nnn #1 #2 #3 |
| 5613 |
{ |
| 5614 |
% \end{macrocode} |
| 5615 |
% Here, |\expanded| would probably be slightly faster than |\use:e| |
| 5616 |
% \begin{macrocode} |
| 5617 |
\use:e |
| 5618 |
{ |
| 5619 |
\@@_make_preamble_ii_vi:nnnnnnnn |
| 5620 |
{ \str_if_eq:eeTF p \l_@@_vpos_col_str { t } { b } } |
| 5621 |
{ #1 } |
| 5622 |
{ |
| 5623 |
\cs_set_eq:NN \rotate \@@_rotate_p_col: |
| 5624 |
% \end{macrocode} |
| 5625 |
% The parameter |\l_@@_hpos_col_str| (as |\l_@@_vpos_col_str|) exists only |
| 5626 |
% during the construction of the preamble. During the composition of the array |
| 5627 |
% itself, you will have, in each cell, the parameter |\l_@@_hpos_cell_tl| which |
| 5628 |
% will provide the horizontal alignment of the column to which belongs the cell. |
| 5629 |
% \begin{macrocode} |
| 5630 |
\str_if_eq:eeTF \l_@@_hpos_col_str { j } |
| 5631 |
{ \tl_clear:N \exp_not:N \l_@@_hpos_cell_tl } |
| 5632 |
{ |
| 5633 |
% \end{macrocode} |
| 5634 |
% Here, we use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 5635 |
% \begin{macrocode} |
| 5636 |
\def \exp_not:N \l_@@_hpos_cell_tl |
| 5637 |
{ \str_lowercase:f { \l_@@_hpos_col_str } } |
| 5638 |
} |
| 5639 |
\IfPackageLoadedTF { ragged2e } |
| 5640 |
{ |
| 5641 |
\str_case:on \l_@@_hpos_col_str |
| 5642 |
{ |
| 5643 |
% \end{macrocode} |
| 5644 |
% The following |\exp_not:N| are mandatory. |
| 5645 |
% \begin{macrocode} |
| 5646 |
c { \exp_not:N \Centering } |
| 5647 |
l { \exp_not:N \RaggedRight } |
| 5648 |
r { \exp_not:N \RaggedLeft } |
| 5649 |
} |
| 5650 |
} |
| 5651 |
{ |
| 5652 |
\str_case:on \l_@@_hpos_col_str |
| 5653 |
{ |
| 5654 |
c { \exp_not:N \centering } |
| 5655 |
l { \exp_not:N \raggedright } |
| 5656 |
r { \exp_not:N \raggedleft } |
| 5657 |
} |
| 5658 |
} |
| 5659 |
#3 |
| 5660 |
} |
| 5661 |
{ \str_if_eq:eeT \l_@@_vpos_col_str { m } \@@_center_cell_box: } |
| 5662 |
{ \str_if_eq:eeT \l_@@_hpos_col_str { si } \siunitx_cell_begin:w } |
| 5663 |
{ \str_if_eq:eeT \l_@@_hpos_col_str { si } \siunitx_cell_end: } |
| 5664 |
{ #2 } |
| 5665 |
{ |
| 5666 |
\str_case:onF \l_@@_hpos_col_str |
| 5667 |
{ |
| 5668 |
{ j } { c } |
| 5669 |
{ si } { c } |
| 5670 |
} |
| 5671 |
% \end{macrocode} |
| 5672 |
% We use |\str_lowercase:n| to convert |R| to |r|, etc. |
| 5673 |
% \begin{macrocode} |
| 5674 |
{ \str_lowercase:f \l_@@_hpos_col_str } |
| 5675 |
} |
| 5676 |
} |
| 5677 |
% \end{macrocode} |
| 5678 |
% |
| 5679 |
% We increment the counter of columns, and then we test for the presence of a |<|. |
| 5680 |
% \begin{macrocode} |
| 5681 |
\int_gincr:N \c@jCol |
| 5682 |
\@@_rec_preamble_after_col:n |
| 5683 |
} |
| 5684 |
% \end{macrocode} |
| 5685 |
% |
| 5686 |
% |
| 5687 |
% |
| 5688 |
% \bigskip |
| 5689 |
% |#1| is the optional argument of |{minipage}| (or |{varwidth}|): |t| or |b|. |
| 5690 |
% Indeed, for the columns of type |m|, we use the value |b| here because there |
| 5691 |
% is a special post-action in order to center vertically the box (see |#4|). |
| 5692 |
% |
| 5693 |
% |#2| is the width of the |{minipage}| (or |{varwidth}|), that is to say also |
| 5694 |
% the width of the column. |
| 5695 |
% |
| 5696 |
% |#3| is the coding for the horizontal position of the content of the cell |
| 5697 |
% (|\centering|, |\raggedright|, |\raggedleft| or nothing). It's also possible |
| 5698 |
% to put in that |#3| some code to fix the value of |\l_@@_hpos_cell_tl| which |
| 5699 |
% will be available in each cell of the column. |
| 5700 |
% |
| 5701 |
% |#4| is an extra-code which contains |\@@_center_cell_box:| (when the column |
| 5702 |
% is a |m| column) or nothing (in the other cases). |
| 5703 |
% |
| 5704 |
% |#5| is a code put just before the |c| (or |r| or |l|: see |#8|). |
| 5705 |
% |
| 5706 |
% |#6| is a code put just after the |c| (or |r| or |l|: see |#8|). |
| 5707 |
% |
| 5708 |
% |#7| is the type of environment: |minipage| or |varwidth|. |
| 5709 |
% |
| 5710 |
% |#8| is the letter |c| or |r| or |l| which is the basic specifier of column |
| 5711 |
% which is used \emph{in fine}. |
| 5712 |
% \begin{macrocode} |
| 5713 |
\cs_new_protected:Npn \@@_make_preamble_ii_vi:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 |
| 5714 |
{ |
| 5715 |
\str_if_eq:eeTF \l_@@_hpos_col_str { si } |
| 5716 |
{ |
| 5717 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5718 |
{ > \@@_test_if_empty_for_S: } |
| 5719 |
} |
| 5720 |
{ |
| 5721 |
\str_if_eq:eeTF { #7 } { varwidth } |
| 5722 |
{ |
| 5723 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5724 |
{ > \@@_test_if_empty_varwidth: } |
| 5725 |
} |
| 5726 |
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { > \@@_test_if_empty: } } |
| 5727 |
} |
| 5728 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 5729 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 5730 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5731 |
{ |
| 5732 |
> { |
| 5733 |
% \end{macrocode} |
| 5734 |
% The parameter |\l_@@_col_width_dim|, which is the width of the current column, |
| 5735 |
% will be available in each cell of the column. It will be used by the |
| 5736 |
% mono-column blocks. |
| 5737 |
% \begin{macrocode} |
| 5738 |
\dim_set:Nn \l_@@_col_width_dim { #2 } |
| 5739 |
\@@_cell_begin: |
| 5740 |
% \end{macrocode} |
| 5741 |
% We use the form |\minipage|--|\endminipage| (|\varwidth|--|\endvarwidth|) for |
| 5742 |
% compatibility with \pkg{collcell} (2023-10-31). |
| 5743 |
% \begin{macrocode} |
| 5744 |
\use:c { #7 } [ #1 ] { #2 } |
| 5745 |
% \end{macrocode} |
| 5746 |
% The following lines have been taken from |array.sty|. |
| 5747 |
% \begin{macrocode} |
| 5748 |
\everypar |
| 5749 |
{ |
| 5750 |
\vrule height \box_ht:N \@arstrutbox width \c_zero_dim |
| 5751 |
\everypar { } |
| 5752 |
} |
| 5753 |
% \end{macrocode} |
| 5754 |
% Now, the potential code for the horizontal position of the content of the cell |
| 5755 |
% (|\centering|, |\raggedright|, |\RaggedRight|, etc.). |
| 5756 |
% \begin{macrocode} |
| 5757 |
#3 |
| 5758 |
% \end{macrocode} |
| 5759 |
% The following code is to allow something like |\centering| in |\RowStyle|. |
| 5760 |
% \begin{macrocode} |
| 5761 |
\g_@@_row_style_tl |
| 5762 |
\arraybackslash |
| 5763 |
#5 |
| 5764 |
} |
| 5765 |
#8 |
| 5766 |
< { |
| 5767 |
#6 |
| 5768 |
% \end{macrocode} |
| 5769 |
% The following line has been taken from |array.sty|. |
| 5770 |
% \begin{macrocode} |
| 5771 |
\@finalstrut \@arstrutbox |
| 5772 |
\use:c { end #7 } |
| 5773 |
% \end{macrocode} |
| 5774 |
% If the letter in the preamble is |m|, |#4| will be equal to |
| 5775 |
% |\@@_center_cell_box:| (see just below). |
| 5776 |
% \begin{macrocode} |
| 5777 |
#4 |
| 5778 |
\@@_cell_end: |
| 5779 |
} |
| 5780 |
} |
| 5781 |
} |
| 5782 |
% \end{macrocode} |
| 5783 |
% |
| 5784 |
% \bigskip |
| 5785 |
% The cell always begins with |\ignorespaces| with \pkg{array} and that's why we |
| 5786 |
% retrieve that token. |
| 5787 |
% \begin{macrocode} |
| 5788 |
\cs_new_protected:Npn \@@_test_if_empty: \ignorespaces |
| 5789 |
{ |
| 5790 |
% \end{macrocode} |
| 5791 |
% We open a special group with |\group_align_safe_begin:|. Thus, when |
| 5792 |
% |\peek_meaning:NTF| will read the |&| (when the cell is empty), that lecture |
| 5793 |
% won't trigger the end of the cell (since we are in a lower group...). If the |
| 5794 |
% end of cell was trigerred, we would have other tokens in the TeX flow (and not |
| 5795 |
% |&|). |
| 5796 |
% \begin{macrocode} |
| 5797 |
\group_align_safe_begin: |
| 5798 |
\peek_meaning:NTF & |
| 5799 |
\@@_the_cell_is_empty: |
| 5800 |
{ |
| 5801 |
\peek_meaning:NTF \\ |
| 5802 |
\@@_the_cell_is_empty: |
| 5803 |
{ |
| 5804 |
\peek_meaning:NTF \crcr |
| 5805 |
\@@_the_cell_is_empty: |
| 5806 |
\group_align_safe_end: |
| 5807 |
} |
| 5808 |
} |
| 5809 |
} |
| 5810 |
% \end{macrocode} |
| 5811 |
% |
| 5812 |
% \bigskip |
| 5813 |
% A special version of the previous function for the columns of type |V| (of |
| 5814 |
% \pkg{varwidth}). |
| 5815 |
% \begin{macrocode} |
| 5816 |
\cs_new_protected:Npn \@@_test_if_empty_varwidth: \ignorespaces |
| 5817 |
{ |
| 5818 |
\group_align_safe_begin: |
| 5819 |
\peek_meaning:NTF & |
| 5820 |
\@@_the_cell_is_empty_varwidth: |
| 5821 |
{ |
| 5822 |
\peek_meaning:NTF \\ |
| 5823 |
\@@_the_cell_is_empty_varwidth: |
| 5824 |
{ |
| 5825 |
\peek_meaning:NTF \crcr |
| 5826 |
\@@_the_cell_is_empty_varwidth: |
| 5827 |
\group_align_safe_end: |
| 5828 |
} |
| 5829 |
} |
| 5830 |
} |
| 5831 |
% \end{macrocode} |
| 5832 |
% |
| 5833 |
% \begin{macrocode} |
| 5834 |
\cs_new_protected:Npn \@@_the_cell_is_empty: |
| 5835 |
{ |
| 5836 |
\group_align_safe_end: |
| 5837 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl |
| 5838 |
{ |
| 5839 |
% \end{macrocode} |
| 5840 |
% Be careful: here, we can't merely use |
| 5841 |
% |\bool_gset_true: \g_@@_empty_cell_bool|, |
| 5842 |
% in particular because of the columns of type~|X|. |
| 5843 |
% \begin{macrocode} |
| 5844 |
\box_set_wd:Nn \l_@@_cell_box \c_zero_dim |
| 5845 |
% \end{macrocode} |
| 5846 |
% If all the cells of the column are empty, we still must have a column with |
| 5847 |
% the width required by the column of type |p| (or |b|, or |m|). |
| 5848 |
% \begin{macrocode} |
| 5849 |
\skip_horizontal:N \l_@@_col_width_dim |
| 5850 |
} |
| 5851 |
} |
| 5852 |
% \end{macrocode} |
| 5853 |
% |
| 5854 |
% \begin{macrocode} |
| 5855 |
\cs_new_protected:Npn \@@_the_cell_is_empty_varwidth: |
| 5856 |
{ |
| 5857 |
\group_align_safe_end: |
| 5858 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl |
| 5859 |
{ \box_set_wd:Nn \l_@@_cell_box \c_zero_dim } |
| 5860 |
} |
| 5861 |
% \end{macrocode} |
| 5862 |
% |
| 5863 |
% \begin{macrocode} |
| 5864 |
\cs_new_protected:Npn \@@_test_if_empty_for_S: |
| 5865 |
{ |
| 5866 |
\peek_meaning:NT \__siunitx_table_skip:n |
| 5867 |
{ \bool_gset_true:N \g_@@_empty_cell_bool } |
| 5868 |
} |
| 5869 |
% \end{macrocode} |
| 5870 |
% |
| 5871 |
% |
| 5872 |
% \bigskip |
| 5873 |
% The following command will be used in |m|-columns in order to center |
| 5874 |
% vertically the box. In fact, despite its name, the command does not always |
| 5875 |
% center the cell. Indeed, if there is only one row in the cell, it should not |
| 5876 |
% be centered vertically. It's not possible to know the number of rows of the |
| 5877 |
% cell. However, we consider (as in \pkg{array}) that if the height of the cell |
| 5878 |
% is no more that the height of |\strutbox|, there is only one row. |
| 5879 |
% \begin{macrocode} |
| 5880 |
\cs_new_protected:Npn \@@_center_cell_box: |
| 5881 |
{ |
| 5882 |
% \end{macrocode} |
| 5883 |
% By putting instructions in |\g_@@_cell_after_hook_tl|, we require a |
| 5884 |
% post-action of the box |\l_@@_cell_box|. |
| 5885 |
% \begin{macrocode} |
| 5886 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl |
| 5887 |
{ |
| 5888 |
\dim_compare:nNnT |
| 5889 |
{ \box_ht:N \l_@@_cell_box } |
| 5890 |
> |
| 5891 |
% \end{macrocode} |
| 5892 |
% Previously, we had |\@arstrutbox| and not |\strutbox| in the following line |
| 5893 |
% but the code in \pkg{array} has changed in v 2.5g and we follow the change |
| 5894 |
% (see \emph{array: Correctly identify single-line m-cells} in LaTeX~News~36). |
| 5895 |
% \begin{macrocode} |
| 5896 |
{ \box_ht:N \strutbox } |
| 5897 |
{ |
| 5898 |
\hbox_set:Nn \l_@@_cell_box |
| 5899 |
{ |
| 5900 |
\box_move_down:nn |
| 5901 |
{ |
| 5902 |
( \box_ht:N \l_@@_cell_box - \box_ht:N \@arstrutbox |
| 5903 |
+ \baselineskip ) / 2 |
| 5904 |
} |
| 5905 |
{ \box_use:N \l_@@_cell_box } |
| 5906 |
} |
| 5907 |
} |
| 5908 |
} |
| 5909 |
} |
| 5910 |
% \end{macrocode} |
| 5911 |
% |
| 5912 |
% \medskip |
| 5913 |
% For |V| (similar to the |V| of \pkg{varwidth}). |
| 5914 |
% \begin{macrocode} |
| 5915 |
\cs_new_protected:Npn \@@_V: #1 #2 |
| 5916 |
{ |
| 5917 |
\str_if_eq:nnTF { #2 } { [ } |
| 5918 |
{ \@@_make_preamble_V_i:w [ } |
| 5919 |
{ \@@_make_preamble_V_i:w [ ] { #2 } } |
| 5920 |
} |
| 5921 |
\cs_new_protected:Npn \@@_make_preamble_V_i:w [ #1 ] |
| 5922 |
{ \@@_make_preamble_V_ii:nn { #1 } } |
| 5923 |
\cs_new_protected:Npn \@@_make_preamble_V_ii:nn #1 #2 |
| 5924 |
{ |
| 5925 |
\str_set:Nn \l_@@_vpos_col_str { p } |
| 5926 |
\str_set:Nn \l_@@_hpos_col_str { j } |
| 5927 |
\@@_keys_p_column:n { #1 } |
| 5928 |
% \end{macrocode} |
| 5929 |
% We apply |setlength| in order to allow a width of column of the |
| 5930 |
% form |\widthof{Some words}|. |\widthof| is a command of the package \pkg{calc} |
| 5931 |
% (not loaded by \pkg{nicematrix}) which redefines the command |\setlength|. |
| 5932 |
% Of course, even if \pkg{calc} is not loaded, the following code will work with |
| 5933 |
% the standard version of |\setlength|. |
| 5934 |
% \begin{macrocode} |
| 5935 |
\setlength { \l_tmpa_dim } { #2 } |
| 5936 |
\IfPackageLoadedTF { varwidth } |
| 5937 |
{ \@@_make_preamble_ii_iv:nnn { \dim_use:N \l_tmpa_dim } { varwidth } { } } |
| 5938 |
{ |
| 5939 |
\@@_error_or_warning:n { varwidth~not~loaded } |
| 5940 |
\@@_make_preamble_ii_iv:nnn { \dim_use:N \l_tmpa_dim } { minipage } { } |
| 5941 |
} |
| 5942 |
} |
| 5943 |
% \end{macrocod} |
| 5944 |
% |
| 5945 |
% \medskip |
| 5946 |
% For |w| and |W| |
| 5947 |
% \begin{macrocode} |
| 5948 |
\cs_new_protected:Npn \@@_w: { \@@_make_preamble_w:nnnn { } } |
| 5949 |
\cs_new_protected:Npn \@@_W: { \@@_make_preamble_w:nnnn { \@@_special_W: } } |
| 5950 |
% \end{macrocode} |
| 5951 |
% |
| 5952 |
% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for |W|; |
| 5953 |
% |
| 5954 |
% |#2| is the type of column (|w| or |W|); |
| 5955 |
% |
| 5956 |
% |#3| is the type of horizontal alignment (|c|, |l|, |r| or |s|); |
| 5957 |
% |
| 5958 |
% |#4| is the width of the column. It is provided by curryfication. |
| 5959 |
% |
| 5960 |
% \begin{macrocode} |
| 5961 |
\cs_new_protected:Npn \@@_make_preamble_w:nnnn #1 #2 #3 |
| 5962 |
{ |
| 5963 |
\tl_if_in:nnTF { clrs } { #3 } |
| 5964 |
{ \@@_make_preamble_w_i:nnnn { #1 } { #2 } { #3 } } |
| 5965 |
{ |
| 5966 |
\@@_error:nn { Invalid~argument~for~w } { #3 } |
| 5967 |
\@@_make_preamble_w_i:nnnn { #1 } { #2 } { c } |
| 5968 |
} |
| 5969 |
} |
| 5970 |
% \end{macrocode} |
| 5971 |
% |
| 5972 |
% \begin{macrocode} |
| 5973 |
\cs_new_protected:Npn \@@_make_preamble_w_i:nnnn #1 #2 #3 #4 |
| 5974 |
{ |
| 5975 |
\str_if_eq:nnTF { #3 } { s } |
| 5976 |
{ \@@_make_preamble_w_ii:nnnn { #1 } { #4 } } |
| 5977 |
{ \@@_make_preamble_w_iii:nnnn { #1 } { #2 } { #3 } { #4 } } |
| 5978 |
} |
| 5979 |
% \end{macrocode} |
| 5980 |
% |
| 5981 |
% \bigskip |
| 5982 |
% First, the case of an horizontal alignment equal to |s| (for \emph{stretch}). |
| 5983 |
% |
| 5984 |
% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for |
| 5985 |
% |W|; |
| 5986 |
% |
| 5987 |
% |#2| is the width of the column. |
| 5988 |
% \begin{macrocode} |
| 5989 |
\cs_new_protected:Npn \@@_make_preamble_w_ii:nnnn #1 #2 |
| 5990 |
{ |
| 5991 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 5992 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 5993 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 5994 |
{ |
| 5995 |
> { |
| 5996 |
% \end{macrocode} |
| 5997 |
% We use |\setlength| in order to allow |\widthof| which is a command of \pkg{calc} |
| 5998 |
% (when loaded \pkg{calc} redefines |\setlength|). |
| 5999 |
% Of course, even if \pkg{calc} is not loaded, the following code will work with |
| 6000 |
% the standard version of |\setlength|. |
| 6001 |
% \begin{macrocode} |
| 6002 |
\setlength { \l_@@_col_width_dim } { #2 } |
| 6003 |
\@@_cell_begin: |
| 6004 |
\tl_set_eq:NN \l_@@_hpos_cell_tl \c_@@_c_tl |
| 6005 |
} |
| 6006 |
c |
| 6007 |
< { |
| 6008 |
\@@_cell_end_for_w_s: |
| 6009 |
#1 |
| 6010 |
\@@_adjust_size_box: |
| 6011 |
\box_use_drop:N \l_@@_cell_box |
| 6012 |
} |
| 6013 |
} |
| 6014 |
\int_gincr:N \c@jCol |
| 6015 |
\@@_rec_preamble_after_col:n |
| 6016 |
} |
| 6017 |
% \end{macrocode} |
| 6018 |
% |
| 6019 |
% \bigskip |
| 6020 |
% Then, the most important version, for the horizontal alignments types of |c|, |
| 6021 |
% |l| and |r| (and not |s|). |
| 6022 |
% \begin{macrocode} |
| 6023 |
\cs_new_protected:Npn \@@_make_preamble_w_iii:nnnn #1 #2 #3 #4 |
| 6024 |
{ |
| 6025 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 6026 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 6027 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6028 |
{ |
| 6029 |
> { |
| 6030 |
% \end{macrocode} |
| 6031 |
% The parameter |\l_@@_col_width_dim|, which is the width of the current column, |
| 6032 |
% will be available in each cell of the column. It will be used by the |
| 6033 |
% mono-column blocks. |
| 6034 |
% |
| 6035 |
% We use |\setlength| in order to allow |\widthof| which is a command of \pkg{calc} |
| 6036 |
% (when loaded \pkg{calc} redefines |\setlength|). |
| 6037 |
% Of course, even if \pkg{calc} is not loaded, the following code will work with |
| 6038 |
% the standard version of |\setlength|. |
| 6039 |
% \begin{macrocode} |
| 6040 |
\setlength { \l_@@_col_width_dim } { #4 } |
| 6041 |
\hbox_set:Nw \l_@@_cell_box |
| 6042 |
\@@_cell_begin: |
| 6043 |
\tl_set:Nn \l_@@_hpos_cell_tl { #3 } |
| 6044 |
} |
| 6045 |
c |
| 6046 |
< { |
| 6047 |
\@@_cell_end: |
| 6048 |
\hbox_set_end: |
| 6049 |
#1 |
| 6050 |
\@@_adjust_size_box: |
| 6051 |
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box } |
| 6052 |
} |
| 6053 |
} |
| 6054 |
% \end{macrocode} |
| 6055 |
% We increment the counter of columns and then we test for the presence of a |<|. |
| 6056 |
% \begin{macrocode} |
| 6057 |
\int_gincr:N \c@jCol |
| 6058 |
\@@_rec_preamble_after_col:n |
| 6059 |
} |
| 6060 |
% \end{macrocode} |
| 6061 |
% |
| 6062 |
% \bigskip |
| 6063 |
% \begin{macrocode} |
| 6064 |
\cs_new_protected:Npn \@@_special_W: |
| 6065 |
{ |
| 6066 |
\dim_compare:nNnT { \box_wd:N \l_@@_cell_box } > \l_@@_col_width_dim |
| 6067 |
{ \@@_warning:n { W~warning } } |
| 6068 |
} |
| 6069 |
% \end{macrocode} |
| 6070 |
% |
| 6071 |
% \medskip |
| 6072 |
% For |S| (of \pkg{siunitx}). |
| 6073 |
% \begin{macrocode} |
| 6074 |
\AtBeginDocument |
| 6075 |
{ |
| 6076 |
\IfPackageLoadedT { siunitx } |
| 6077 |
{ |
| 6078 |
\cs_new_protected:Npn \@@_S: #1 #2 |
| 6079 |
{ |
| 6080 |
\str_if_eq:nnTF { #2 } { [ } |
| 6081 |
{ \@@_make_preamble_S:w [ } |
| 6082 |
{ \@@_make_preamble_S:w [ ] { #2 } } |
| 6083 |
} |
| 6084 |
} |
| 6085 |
} |
| 6086 |
% \end{macrocode} |
| 6087 |
% |
| 6088 |
% \begin{macrocode} |
| 6089 |
\cs_new_protected:Npn \@@_make_preamble_S:w [ #1 ] |
| 6090 |
{ \@@_make_preamble_S_i:n { #1 } } |
| 6091 |
% \end{macrocode} |
| 6092 |
% |
| 6093 |
% |
| 6094 |
% \begin{macrocode} |
| 6095 |
\cs_new_protected:Npn \@@_test_siunitx: |
| 6096 |
{ |
| 6097 |
\IfPackageAtLeastF { siunitx } { 2026/03/26 } |
| 6098 |
{ \@@_fatal:n { siunitx~too~old } } |
| 6099 |
\cs_gset_eq:NN \@@_test_siunitx: \prg_do_nothing: |
| 6100 |
} |
| 6101 |
% \end{maacrocode} |
| 6102 |
% |
| 6103 |
% \begin{macrocode} |
| 6104 |
\cs_new_protected:Npn \@@_make_preamble_S_i:n #1 |
| 6105 |
{ |
| 6106 |
\@@_test_siunitx: |
| 6107 |
\tl_gput_right:No \g_@@_array_preamble_tl \g_@@_pre_cell_tl |
| 6108 |
\tl_gclear:N \g_@@_pre_cell_tl |
| 6109 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6110 |
{ |
| 6111 |
> { |
| 6112 |
% \end{macrocode} |
| 6113 |
% In the cells of a column of type |S|, we have to wrap the command |
| 6114 |
% |\@@_node_cell:| for the horizontal alignment of the content of the cell |
| 6115 |
% (\pkg{siunitx} has done a job but it's without effect since we have to put the |
| 6116 |
% content in a box for the PGF/TikZ node and that's why we have to do the job of |
| 6117 |
% horizontal alignement once again). |
| 6118 |
% \begin{macrocode} |
| 6119 |
\socket_assign_plug:nn { nicematrix / siunitx-wrap } { active } |
| 6120 |
\keys_set:nn { siunitx } { #1 } |
| 6121 |
\@@_cell_begin: |
| 6122 |
\siunitx_cell_begin:w |
| 6123 |
} |
| 6124 |
c |
| 6125 |
< |
| 6126 |
{ |
| 6127 |
\siunitx_cell_end: |
| 6128 |
% \end{macrocode} |
| 6129 |
% We want the value of |\l__siunitx_table_text_bool| available \emph{after} |
| 6130 |
% |\@@_cell_end:| because we need it to know how to align our box after the |
| 6131 |
% construction of the PGF/TikZ node. That's why we use |
| 6132 |
% |\g_@@_cell_after_hook_tl| to reset the correct value of |
| 6133 |
% |\l__siunitx_table_text_bool| (of course, if will stay local within the cell |
| 6134 |
% of the underlying |\halign|). |
| 6135 |
% \begin{macrocode} |
| 6136 |
\tl_gput_right:Ne \g_@@_cell_after_hook_tl |
| 6137 |
{ |
| 6138 |
\bool_if:NTF \l__siunitx_table_text_bool |
| 6139 |
\bool_set_true:N |
| 6140 |
\bool_set_false:N |
| 6141 |
\l__siunitx_table_text_bool |
| 6142 |
} |
| 6143 |
\@@_cell_end: |
| 6144 |
} |
| 6145 |
} |
| 6146 |
% \end{macrocode} |
| 6147 |
% We increment the counter of columns and then we test for the presence of a |<|. |
| 6148 |
% \begin{macrocode} |
| 6149 |
\int_gincr:N \c@jCol |
| 6150 |
\@@_rec_preamble_after_col:n |
| 6151 |
} |
| 6152 |
% \end{macrocode} |
| 6153 |
% |
| 6154 |
% |
| 6155 |
% \medskip |
| 6156 |
% For |(|, |[| and |\{|. |
| 6157 |
% \begin{macrocode} |
| 6158 |
\cs_new_protected:cpn { @@ _ \token_to_str:N ( : } #1 #2 |
| 6159 |
{ |
| 6160 |
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } } |
| 6161 |
% \end{macrocode} |
| 6162 |
% If we are before the column 1 and not in |{NiceArray}|, we reserve space for |
| 6163 |
% the left delimiter. |
| 6164 |
% \begin{macrocode} |
| 6165 |
\int_if_zero:nTF \c@jCol |
| 6166 |
{ |
| 6167 |
\tl_if_eq:NNTF \g_@@_left_delim_tl \c_@@_dot_tl |
| 6168 |
{ |
| 6169 |
% \end{macrocode} |
| 6170 |
% In that case, in fact, the first letter of the preamble must be considered as |
| 6171 |
% the left delimiter of the array. |
| 6172 |
% \begin{macrocode} |
| 6173 |
\tl_gset:Nn \g_@@_left_delim_tl { #1 } |
| 6174 |
\tl_gset_eq:NN \g_@@_right_delim_tl \c_@@_dot_tl |
| 6175 |
\@@_rec_preamble:n #2 |
| 6176 |
} |
| 6177 |
{ |
| 6178 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } |
| 6179 |
\@@_make_preamble_iv:nn { #1 } { #2 } |
| 6180 |
} |
| 6181 |
} |
| 6182 |
{ \@@_make_preamble_iv:nn { #1 } { #2 } } |
| 6183 |
} |
| 6184 |
\cs_set_eq:cc { @@ _ \token_to_str:N [ : } { @@ _ \token_to_str:N ( : } |
| 6185 |
\cs_set_eq:cc { @@ _ \token_to_str:N \{ : } { @@ _ \token_to_str:N ( : } |
| 6186 |
% \end{macrocode} |
| 6187 |
% |
| 6188 |
% \begin{macrocode} |
| 6189 |
\cs_new_protected:Npn \@@_make_preamble_iv:nn #1 #2 |
| 6190 |
{ |
| 6191 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6192 |
{ \@@_delimiter:nnn #1 { \int_eval:n { \c@jCol + 1 } } \c_true_bool } |
| 6193 |
\tl_if_in:nnTF { ( [ \{ ) ] \} \left \right } { #2 } |
| 6194 |
{ |
| 6195 |
\@@_error:nn { delimiter~after~opening } { #2 } |
| 6196 |
\@@_rec_preamble:n |
| 6197 |
} |
| 6198 |
{ \@@_rec_preamble:n #2 } |
| 6199 |
} |
| 6200 |
% \end{macrocode} |
| 6201 |
% |
| 6202 |
% In fact, if would be possible to define |\left| and |\right| as no-op. |
| 6203 |
% \begin{macrocode} |
| 6204 |
\cs_new_protected:cpn { @@ _ \token_to_str:N \left : } #1 |
| 6205 |
{ \use:c { @@ _ \token_to_str:N ( : } } |
| 6206 |
% \end{macrocode} |
| 6207 |
% |
| 6208 |
% \bigskip |
| 6209 |
% For the closing delimiters. We have two arguments for the following command because |
| 6210 |
% we directly read the following letter in the preamble (we have to see whether |
| 6211 |
% we have a opening delimiter following and we also have to see whether we are |
| 6212 |
% at the end of the preamble because, in that case, our letter must be |
| 6213 |
% considered as the right delimiter of the environment if the environment is |
| 6214 |
% |{NiceArray}|). |
| 6215 |
% \begin{macrocode} |
| 6216 |
\cs_new_protected:cpn { @@ _ \token_to_str:N ) : } #1 #2 |
| 6217 |
{ |
| 6218 |
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } } |
| 6219 |
\tl_if_in:nnTF { ) ] \} } { #2 } |
| 6220 |
{ \@@_make_preamble_v:nnn #1 #2 } |
| 6221 |
{ |
| 6222 |
\str_if_eq:nnTF \s_stop { #2 } |
| 6223 |
{ |
| 6224 |
\tl_if_eq:NNTF \g_@@_right_delim_tl \c_@@_dot_tl |
| 6225 |
{ \tl_gset:Nn \g_@@_right_delim_tl { #1 } } |
| 6226 |
{ |
| 6227 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } |
| 6228 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6229 |
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } |
| 6230 |
\@@_rec_preamble:n #2 |
| 6231 |
} |
| 6232 |
} |
| 6233 |
{ |
| 6234 |
\tl_if_in:nnT { ( [ \{ \left } { #2 } |
| 6235 |
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } } |
| 6236 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6237 |
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } |
| 6238 |
\@@_rec_preamble:n #2 |
| 6239 |
} |
| 6240 |
} |
| 6241 |
} |
| 6242 |
\cs_set_eq:cc { @@ _ \token_to_str:N ] : } { @@ _ \token_to_str:N ) : } |
| 6243 |
\cs_set_eq:cc { @@ _ \token_to_str:N \} : } { @@ _ \token_to_str:N ) : } |
| 6244 |
% \end{macrocode} |
| 6245 |
% |
| 6246 |
% \begin{macrocode} |
| 6247 |
\cs_new_protected:Npn \@@_make_preamble_v:nnn #1 #2 #3 |
| 6248 |
{ |
| 6249 |
\str_if_eq:nnTF \s_stop { #3 } |
| 6250 |
{ |
| 6251 |
\tl_if_eq:NNTF \g_@@_right_delim_tl \c_@@_dot_tl |
| 6252 |
{ |
| 6253 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } |
| 6254 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6255 |
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } |
| 6256 |
\tl_gset:Nn \g_@@_right_delim_tl { #2 } |
| 6257 |
} |
| 6258 |
{ |
| 6259 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } |
| 6260 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6261 |
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } |
| 6262 |
\@@_error:nn { double~closing~delimiter } { #2 } |
| 6263 |
} |
| 6264 |
} |
| 6265 |
{ |
| 6266 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 6267 |
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } |
| 6268 |
\@@_error:nn { double~closing~delimiter } { #2 } |
| 6269 |
\@@_rec_preamble:n #3 |
| 6270 |
} |
| 6271 |
} |
| 6272 |
% \end{macrocode} |
| 6273 |
% |
| 6274 |
% \medskip |
| 6275 |
% \begin{macrocode} |
| 6276 |
\cs_new_protected:cpn { @@ _ \token_to_str:N \right : } #1 |
| 6277 |
{ \use:c { @@ _ \token_to_str:N ) : } } |
| 6278 |
% \end{macrocode} |
| 6279 |
% |
| 6280 |
% |
| 6281 |
% \bigskip |
| 6282 |
% After a specifier of column, we have to test whether there is one or several |
| 6283 |
% |<{..}| because, after those potential |<{...}|, we have to insert |
| 6284 |
% |!{\skip_horizontal:N ...}| when the key |vlines| is used. In fact, we have |
| 6285 |
% also to test whether there is, after the |<{...}|, a |@{...}|. |
| 6286 |
% \begin{macrocode} |
| 6287 |
\cs_new_protected:Npn \@@_rec_preamble_after_col:n #1 |
| 6288 |
{ |
| 6289 |
\str_if_eq:nnTF { #1 } { < } |
| 6290 |
{ \@@_rec_preamble_after_col_i:n } |
| 6291 |
{ |
| 6292 |
\str_if_eq:nnTF { #1 } { @ } |
| 6293 |
{ \@@_rec_preamble_after_col_ii:n } |
| 6294 |
{ |
| 6295 |
\str_if_eq:eeTF \l_@@_vlines_clist { all } |
| 6296 |
{ |
| 6297 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6298 |
{ ! { \skip_horizontal:N \arrayrulewidth } } |
| 6299 |
} |
| 6300 |
{ |
| 6301 |
\clist_if_in:NeT \l_@@_vlines_clist |
| 6302 |
{ \int_eval:n { \c@jCol + 1 } } |
| 6303 |
{ |
| 6304 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6305 |
{ ! { \skip_horizontal:N \arrayrulewidth } } |
| 6306 |
} |
| 6307 |
} |
| 6308 |
\@@_rec_preamble:n { #1 } |
| 6309 |
} |
| 6310 |
} |
| 6311 |
} |
| 6312 |
% \end{macrocode} |
| 6313 |
% |
| 6314 |
% \begin{macrocode} |
| 6315 |
\cs_new_protected:Npn \@@_rec_preamble_after_col_i:n #1 |
| 6316 |
{ |
| 6317 |
\tl_gput_right:Nn \g_@@_array_preamble_tl { < { #1 } } |
| 6318 |
\@@_rec_preamble_after_col:n |
| 6319 |
} |
| 6320 |
% \end{macrocode} |
| 6321 |
% |
| 6322 |
% We have to catch a |@{...}| after a specifier of column because, if we have to |
| 6323 |
% draw a vertical rule, we have to add in that |@{...}| a |\hskip| corresponding |
| 6324 |
% to the width of the vertical rule. |
| 6325 |
% \begin{macrocode} |
| 6326 |
\cs_new_protected:Npn \@@_rec_preamble_after_col_ii:n #1 |
| 6327 |
{ |
| 6328 |
\str_if_eq:eeTF \l_@@_vlines_clist { all } |
| 6329 |
{ |
| 6330 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6331 |
{ @ { #1 \skip_horizontal:N \arrayrulewidth } } |
| 6332 |
} |
| 6333 |
{ |
| 6334 |
\clist_if_in:NeTF \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } } |
| 6335 |
{ |
| 6336 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6337 |
{ @ { #1 \skip_horizontal:N \arrayrulewidth } } |
| 6338 |
} |
| 6339 |
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { @ { #1 } } } |
| 6340 |
} |
| 6341 |
\@@_rec_preamble:n |
| 6342 |
} |
| 6343 |
% \end{macrocode} |
| 6344 |
% |
| 6345 |
% \bigskip |
| 6346 |
% \begin{macrocode} |
| 6347 |
\cs_new_protected:cpn { @@ _ * : } #1 #2 #3 |
| 6348 |
{ |
| 6349 |
\tl_clear:N \l_tmpa_tl |
| 6350 |
\int_step_inline:nn { #2 } { \tl_put_right:Nn \l_tmpa_tl { #3 } } |
| 6351 |
\exp_last_unbraced:No \@@_rec_preamble:n \l_tmpa_tl |
| 6352 |
} |
| 6353 |
% \end{macrocode} |
| 6354 |
% |
| 6355 |
% \bigskip |
| 6356 |
% The token |\NC@find| is at the head of the definition of the columns type done |
| 6357 |
% by |\newcolumntype|. We want that token to be no-op here. |
| 6358 |
% \begin{macrocode} |
| 6359 |
\cs_new_protected:cpn { @@ _ \token_to_str:N \NC@find : } #1 |
| 6360 |
{ \@@_rec_preamble:n } |
| 6361 |
% \end{macrocode} |
| 6362 |
% |
| 6363 |
% \bigskip |
| 6364 |
% For the case of a letter |X|. This specifier may take in an optional argument |
| 6365 |
% (between square brackets). That's why we test whether there is a |[| after the |
| 6366 |
% letter |X|. |
| 6367 |
% \begin{macrocode} |
| 6368 |
\cs_new_protected:Npn \@@_X: #1 #2 |
| 6369 |
{ |
| 6370 |
\str_if_eq:nnTF { #2 } { [ } |
| 6371 |
{ \@@_make_preamble_X:w [ } |
| 6372 |
{ \@@_make_preamble_X:w [ ] #2 } |
| 6373 |
} |
| 6374 |
% \end{macrocode} |
| 6375 |
% |
| 6376 |
% \begin{macrocode} |
| 6377 |
\cs_new_protected:Npn \@@_make_preamble_X:w [ #1 ] |
| 6378 |
{ \@@_make_preamble_X_i:n { #1 } } |
| 6379 |
% \end{macrocode} |
| 6380 |
% |#1| is the optional argument of the |X| specifier (a list of |
| 6381 |
% \emph{key}-\emph{value} pairs). |
| 6382 |
% |
| 6383 |
% \medskip |
| 6384 |
% The following set of keys is for the specifier |X| in the preamble of the |
| 6385 |
% array. Such specifier may have as keys all the keys of |
| 6386 |
% |{ nicematrix / p-column }| but also a key |V| and also a key which corresponds |
| 6387 |
% to a positive number (1, 2, 0.5, etc.) which is the \emph{weight} of the columns. The |
| 6388 |
% following set of keys will be used to retrieve that value and store it in |\l_tmpa_fp|. |
| 6389 |
% \begin{macrocode} |
| 6390 |
\keys_define:nn { nicematrix / X-column } |
| 6391 |
{ |
| 6392 |
V .code:n = |
| 6393 |
\IfPackageLoadedTF { varwidth } |
| 6394 |
{ |
| 6395 |
\bool_set_true:N \l_@@_V_of_X_bool |
| 6396 |
\bool_gset_true:N \g_@@_V_of_X_bool |
| 6397 |
} |
| 6398 |
{ \@@_error_or_warning:n { varwidth~not~loaded~in~X } } , |
| 6399 |
unknown .code:n = |
| 6400 |
\regex_if_match:nVTF { \A[0-9]*\.?[0-9]*\Z } \l_keys_key_str |
| 6401 |
{ \fp_set:Nn \l_tmpa_fp { \l_keys_key_str } } |
| 6402 |
{ \@@_error_or_warning:n { invalid~weight } } |
| 6403 |
} |
| 6404 |
% \end{macrocode} |
| 6405 |
% |
| 6406 |
% |
| 6407 |
% \medskip |
| 6408 |
% In the following command, |#1| is the list of the options of the specifier |X|. |
| 6409 |
% \begin{macrocode} |
| 6410 |
\cs_new_protected:Npn \@@_make_preamble_X_i:n #1 |
| 6411 |
{ |
| 6412 |
% \end{macrocode} |
| 6413 |
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is |
| 6414 |
% the initial value), |l|, |c| and |r| (when the user has used the corresponding |
| 6415 |
% key in the optional argument of the specifier |X|). |
| 6416 |
% \begin{macrocode} |
| 6417 |
\str_set:Nn \l_@@_hpos_col_str { j } |
| 6418 |
% \end{macrocode} |
| 6419 |
% The possible values of |\l_@@_vpos_col_str| are |p| (the initial value), |m| and |b| |
| 6420 |
% (when the user has used the corresponding key in the optional argument of the |
| 6421 |
% specifier |X|). |
| 6422 |
% \begin{macrocode} |
| 6423 |
\str_set:Nn \l_@@_vpos_col_str { p } |
| 6424 |
% \end{macrocode} |
| 6425 |
% |
| 6426 |
% We will store in |\l_tmpa_fp| the weight of the column (|\l_tmpa_fp| also |
| 6427 |
% appears in |{nicematrix/X-column}| and the error message |invalid~weight|. |
| 6428 |
% \begin{macrocode} |
| 6429 |
\fp_set:Nn \l_tmpa_fp { 1.0 } |
| 6430 |
% \end{macrocode} |
| 6431 |
% |
| 6432 |
% \begin{macrocode} |
| 6433 |
\@@_keys_p_column:n { #1 } |
| 6434 |
% \end{macrocode} |
| 6435 |
% The unknown keys have been stored by |\@@_keys_p_column:n| in |\l_tmpa_tl| and |
| 6436 |
% we use them right away in the set of keys |nicematrix/X-column| in order to |
| 6437 |
% retrieve the potential weight explicitely provided by the final user. |
| 6438 |
% |
| 6439 |
% \begin{macrocode} |
| 6440 |
\bool_set_false:N \l_@@_V_of_X_bool |
| 6441 |
\keys_set:no { nicematrix / X-column } \l_tmpa_tl |
| 6442 |
% \end{macrocode} |
| 6443 |
% Now, the weight of the column is stored in |\l_tmpa_tl|. |
| 6444 |
% \begin{macrocode} |
| 6445 |
\fp_gadd:Nn \g_@@_total_X_weight_fp \l_tmpa_fp |
| 6446 |
% \end{macrocode} |
| 6447 |
% |
| 6448 |
% We test whether we know the actual width of the |X|-columns by reading the |
| 6449 |
% |aux| file (after the first compilation, the width of the |X|-columns is |
| 6450 |
% computed and written in the |aux| file). |
| 6451 |
% \begin{macrocode} |
| 6452 |
\bool_if:NTF \l_@@_X_columns_aux_bool |
| 6453 |
{ |
| 6454 |
\@@_make_preamble_ii_iv:nnn |
| 6455 |
% \end{macrocode} |
| 6456 |
% Of course, the weight of a column depends of its weight (in |\l_tmpa_fp|). |
| 6457 |
% \begin{macrocode} |
| 6458 |
{ \fp_use:N \l_tmpa_fp \l_@@_X_columns_dim } |
| 6459 |
{ \bool_if:NTF \l_@@_V_of_X_bool { varwidth } { minipage } } |
| 6460 |
{ \@@_no_update_width: } |
| 6461 |
} |
| 6462 |
% \end{macrocode} |
| 6463 |
% In the current compilation, we don't known the actual width of the X column. |
| 6464 |
% However, you have to construct the cells of that column! By convention, we |
| 6465 |
% have decided to compose in a |{minipage}| of width 5~cm even though we will |
| 6466 |
% nullify |\l_@@_cell_box| after its composition. |
| 6467 |
% \begin{macrocode} |
| 6468 |
{ |
| 6469 |
\tl_gput_right:Nn \g_@@_array_preamble_tl |
| 6470 |
{ |
| 6471 |
> { |
| 6472 |
\@@_cell_begin: |
| 6473 |
\bool_set_true:N \l_@@_X_bool |
| 6474 |
% \end{macrocode} |
| 6475 |
% You encounter a problem on 2023-03-04: for an environment with |X| columns, |
| 6476 |
% during the first compilations (which are not the definitive one), sometimes, |
| 6477 |
% some cells are declared empty even if they should not. That's a problem |
| 6478 |
% because user's instructions may use these nodes. That's why we have added the |
| 6479 |
% following |\NotEmpty|. |
| 6480 |
% \begin{macrocode} |
| 6481 |
\NotEmpty |
| 6482 |
% \end{macrocode} |
| 6483 |
% The following code will nullify the box of the cell. |
| 6484 |
% \begin{macrocode} |
| 6485 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl |
| 6486 |
{ \hbox_set:Nn \l_@@_cell_box { } } |
| 6487 |
% \end{macrocode} |
| 6488 |
% We put a |{minipage}| to give to the user the ability to put a command such as |
| 6489 |
% |\centering| in the |\RowStyle|. |
| 6490 |
% \begin{macrocode} |
| 6491 |
\begin { minipage } { 5 cm } \arraybackslash |
| 6492 |
} |
| 6493 |
c |
| 6494 |
< { |
| 6495 |
\end { minipage } |
| 6496 |
\@@_cell_end: |
| 6497 |
} |
| 6498 |
} |
| 6499 |
\int_gincr:N \c@jCol |
| 6500 |
\@@_rec_preamble_after_col:n |
| 6501 |
} |
| 6502 |
} |
| 6503 |
% \end{macrocode} |
| 6504 |
% |
| 6505 |
% \medskip |
| 6506 |
% \begin{macrocode} |
| 6507 |
\cs_new_protected:Npn \@@_no_update_width: |
| 6508 |
{ |
| 6509 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl |
| 6510 |
{ \cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: } |
| 6511 |
} |
| 6512 |
% \end{macrocode} |
| 6513 |
% |
| 6514 |
% \medskip |
| 6515 |
% For the letter set by the user with |vlines-in-sub-matrix| (vlism). |
| 6516 |
% \begin{macrocode} |
| 6517 |
\cs_new_protected:Npn \@@_make_preamble_vlism:n #1 |
| 6518 |
{ |
| 6519 |
\seq_gput_right:Ne \g_@@_cols_vlism_seq |
| 6520 |
{ \int_eval:n { \c@jCol + 1 } } |
| 6521 |
\tl_gput_right:Ne \g_@@_array_preamble_tl |
| 6522 |
{ \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } } |
| 6523 |
\@@_rec_preamble:n |
| 6524 |
} |
| 6525 |
% \end{macrocode} |
| 6526 |
% |
| 6527 |
% \medskip |
| 6528 |
% The token |\s_stop| is a marker that we have inserted to mark the end of the |
| 6529 |
% preamble (as provided by the final user) that we have inserted in the TeX flow. |
| 6530 |
% \begin{macrocode} |
| 6531 |
\cs_set_eq:cN { @@ _ \token_to_str:N \s_stop : } \use_none:n |
| 6532 |
% \end{macrocode} |
| 6533 |
% |
| 6534 |
% \medskip |
| 6535 |
% The following lines try to catch some errors (when the final user has, for example, |
| 6536 |
% forgotten the preamble of its environment). |
| 6537 |
% \begin{macrocode} |
| 6538 |
\cs_new_protected:cpn { @@ _ \token_to_str:N \hline : } |
| 6539 |
{ \@@_fatal:n { Preamble~forgotten } } |
| 6540 |
\cs_set_eq:cc { @@ _ \token_to_str:N \Hline : } { @@ _ \token_to_str:N \hline : } |
| 6541 |
\cs_set_eq:cc { @@ _ \token_to_str:N \toprule : } |
| 6542 |
{ @@ _ \token_to_str:N \hline : } |
| 6543 |
\cs_set_eq:cc { @@ _ \token_to_str:N \Block : } { @@ _ \token_to_str:N \hline : } |
| 6544 |
\cs_set_eq:cc { @@ _ \token_to_str:N \CodeBefore : } |
| 6545 |
{ @@ _ \token_to_str:N \hline : } |
| 6546 |
\cs_set_eq:cc { @@ _ \token_to_str:N \RowStyle : } |
| 6547 |
{ @@ _ \token_to_str:N \hline : } |
| 6548 |
\cs_set_eq:cc { @@ _ \token_to_str:N \diagbox : } |
| 6549 |
{ @@ _ \token_to_str:N \hline : } |
| 6550 |
\cs_set_eq:cc { @@ _ \token_to_str:N & : } |
| 6551 |
{ @@ _ \token_to_str:N \hline : } |
| 6552 |
\cs_new_protected:cpn { @@ _ \token_to_str:N \linewidth : } |
| 6553 |
{ \@@_fatal:n { NiceTabularX~probably~required } } |
| 6554 |
\cs_set_eq:cc { @@ _ \token_to_str:N \textwidth : } |
| 6555 |
{ @@ _ \token_to_str:N \linewidth : } |
| 6556 |
% \end{macrocode} |
| 6557 |
% |
| 6558 |
% \bigskip |
| 6559 |
% \section{The redefinition of \textbackslash multicolumn} |
| 6560 |
% |
| 6561 |
% \medskip |
| 6562 |
% The following command must \emph{not} be protected since it begins with |
| 6563 |
% |\multispan| (a TeX primitive). |
| 6564 |
% \begin{macrocode} |
| 6565 |
\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3 |
| 6566 |
{ |
| 6567 |
% \end{macrocode} |
| 6568 |
% The following lines are from the definition of |\multicolumn| in \pkg{array} |
| 6569 |
% (and \emph{not} in standard LaTeX). The first line aims to raise an error if |
| 6570 |
% the user has put more that one column specifier in the preamble of |
| 6571 |
% |\multicolumn|. |
| 6572 |
% \begin{macrocode} |
| 6573 |
\multispan { #1 } |
| 6574 |
\cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: |
| 6575 |
\begingroup |
| 6576 |
\tbl_update_multicolumn_cell_data:n { #1 } |
| 6577 |
% \end{macrocode} |
| 6578 |
% |
| 6579 |
% \medskip |
| 6580 |
% Now, we patch the (small) preamble as we have done with the main preamble of |
| 6581 |
% the array. |
| 6582 |
% \begin{macrocode} |
| 6583 |
\tl_gclear:N \g_@@_preamble_tl |
| 6584 |
\@@_make_m_preamble:n #2 \q_stop |
| 6585 |
% \end{macrocode} |
| 6586 |
% |
| 6587 |
% \medskip |
| 6588 |
% The following lines are an adaptation of the definition of |\multicolumn| in |
| 6589 |
% \pkg{array}. |
| 6590 |
% \begin{macrocode} |
| 6591 |
\def \@addamp |
| 6592 |
{ |
| 6593 |
\legacy_if:nTF { @firstamp } |
| 6594 |
{ \legacy_if_set_false:n { @firstamp } } |
| 6595 |
{ \@preamerr 5 } |
| 6596 |
} |
| 6597 |
\exp_args:No \@mkpream \g_@@_preamble_tl |
| 6598 |
\@addtopreamble \@empty |
| 6599 |
\endgroup |
| 6600 |
\UseTaggingSocket { tbl / colspan } { #1 } |
| 6601 |
% \end{macrocode} |
| 6602 |
% |
| 6603 |
% \medskip |
| 6604 |
% Now, we do a treatment specific to \pkg{nicematrix} which has no equivalent |
| 6605 |
% in the original definition of |\multicolumn|. |
| 6606 |
% \begin{macrocode} |
| 6607 |
\int_compare:nNnT { #1 } > 1 |
| 6608 |
{ |
| 6609 |
\seq_gput_right:Ne \g_@@_multicolumn_cells_seq |
| 6610 |
{ \int_use:N \c@iRow - \int_eval:n { \c@jCol + 1 } } |
| 6611 |
\seq_gput_right:Nn \g_@@_multicolumn_sizes_seq { #1 } |
| 6612 |
\seq_gput_right:Ne \g_@@_pos_of_blocks_seq |
| 6613 |
{ |
| 6614 |
{ |
| 6615 |
\int_if_zero:nTF \c@jCol |
| 6616 |
{ \int_eval:n { \c@iRow + 1 } } |
| 6617 |
{ \int_use:N \c@iRow } |
| 6618 |
} |
| 6619 |
{ \int_eval:n { \c@jCol + 1 } } |
| 6620 |
{ |
| 6621 |
\int_if_zero:nTF \c@jCol |
| 6622 |
{ \int_eval:n { \c@iRow + 1 } } |
| 6623 |
{ \int_use:N \c@iRow } |
| 6624 |
} |
| 6625 |
{ \int_eval:n { \c@jCol + #1 } } |
| 6626 |
% \end{macrocode} |
| 6627 |
% The last argument is for the name of the block. |
| 6628 |
% \begin{macrocode} |
| 6629 |
{ } |
| 6630 |
} |
| 6631 |
} |
| 6632 |
% \end{macrocode} |
| 6633 |
% |
| 6634 |
% \bigskip |
| 6635 |
% We want |\cellcolor| to be available in |\multicolumn| because |\cellcolor| of |
| 6636 |
% \pkg{colortbl} is available in |\multicolumn|. |
| 6637 |
% \begin{macrocode} |
| 6638 |
\RenewDocumentCommand { \cellcolor } { O { } m } |
| 6639 |
{ |
| 6640 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 6641 |
{ |
| 6642 |
\@@_rectanglecolor [ ##1 ] |
| 6643 |
{ \exp_not:n { ##2 } } |
| 6644 |
{ \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 6645 |
{ \int_use:N \c@iRow - \int_eval:n { \c@jCol + #1 } } |
| 6646 |
} |
| 6647 |
\ignorespaces |
| 6648 |
} |
| 6649 |
% \end{macrocode} |
| 6650 |
% |
| 6651 |
% \medskip |
| 6652 |
% The following lines were in the original definition of |\multicolumn|. |
| 6653 |
% \begin{macrocode} |
| 6654 |
\def \@sharp { #3 } |
| 6655 |
\@arstrut |
| 6656 |
\@preamble |
| 6657 |
\null |
| 6658 |
% \end{macrocode} |
| 6659 |
% |
| 6660 |
% \medskip |
| 6661 |
% We add some lines. |
| 6662 |
% \begin{macrocode} |
| 6663 |
\int_gadd:Nn \c@jCol { #1 - 1 } |
| 6664 |
\int_compare:nNnT \c@jCol > \g_@@_col_total_int |
| 6665 |
{ \int_gset_eq:NN \g_@@_col_total_int \c@jCol } |
| 6666 |
\ignorespaces |
| 6667 |
} |
| 6668 |
% \end{macrocode} |
| 6669 |
% |
| 6670 |
% |
| 6671 |
% \bigskip |
| 6672 |
% The following commands will patch the (small) preamble of the |\multicolumn|. |
| 6673 |
% All those commands have a |m| in their name to recall that they deal with the |
| 6674 |
% redefinition of |\multicolumn|. |
| 6675 |
% \begin{macrocode} |
| 6676 |
\cs_new_protected:Npn \@@_make_m_preamble:n #1 |
| 6677 |
{ |
| 6678 |
\str_case:nnF { #1 } |
| 6679 |
{ |
| 6680 |
c { \@@_make_m_preamble_i:n #1 } |
| 6681 |
l { \@@_make_m_preamble_i:n #1 } |
| 6682 |
r { \@@_make_m_preamble_i:n #1 } |
| 6683 |
> { \@@_make_m_preamble_ii:nn #1 } |
| 6684 |
! { \@@_make_m_preamble_ii:nn #1 } |
| 6685 |
@ { \@@_make_m_preamble_ii:nn #1 } |
| 6686 |
| { \@@_make_m_preamble_iii:n #1 } |
| 6687 |
p { \@@_make_m_preamble_iv:nnn t #1 } |
| 6688 |
m { \@@_make_m_preamble_iv:nnn c #1 } |
| 6689 |
b { \@@_make_m_preamble_iv:nnn b #1 } |
| 6690 |
w { \@@_make_m_preamble_v:nnnn { } #1 } |
| 6691 |
W { \@@_make_m_preamble_v:nnnn { \@@_special_W: } #1 } |
| 6692 |
\q_stop { } |
| 6693 |
} |
| 6694 |
{ |
| 6695 |
\cs_if_exist:cTF { NC @ find @ #1 } |
| 6696 |
{ |
| 6697 |
\tl_set_eq:Nc \l_tmpa_tl { NC @ rewrite @ #1 } |
| 6698 |
\exp_last_unbraced:No \@@_make_m_preamble:n \l_tmpa_tl |
| 6699 |
} |
| 6700 |
{ |
| 6701 |
% \end{macrocode} |
| 6702 |
% |
| 6703 |
% \begin{macrocode} |
| 6704 |
\str_if_eq:nnTF { #1 } { S } |
| 6705 |
{ \@@_fatal:n { unknown~column~type~S~multicolumn } } |
| 6706 |
{ \@@_fatal:nn { unknown~column~type~multicolumn } { #1 } } |
| 6707 |
} |
| 6708 |
} |
| 6709 |
} |
| 6710 |
% \end{macrocode} |
| 6711 |
% |
| 6712 |
% \medskip |
| 6713 |
% For |c|, |l| and |r| |
| 6714 |
% \begin{macrocode} |
| 6715 |
\cs_new_protected:Npn \@@_make_m_preamble_i:n #1 |
| 6716 |
{ |
| 6717 |
\tl_gput_right:Nn \g_@@_preamble_tl |
| 6718 |
{ |
| 6719 |
> { \@@_cell_begin: \tl_set:Nn \l_@@_hpos_cell_tl { #1 } } |
| 6720 |
#1 |
| 6721 |
< \@@_cell_end: |
| 6722 |
} |
| 6723 |
% \end{macrocode} |
| 6724 |
% |
| 6725 |
% We test for the presence of a |<|. |
| 6726 |
% \begin{macrocode} |
| 6727 |
\@@_make_m_preamble_x:n |
| 6728 |
} |
| 6729 |
% \end{macrocode} |
| 6730 |
% |
| 6731 |
% \medskip |
| 6732 |
% For |>|, |!| and |@| |
| 6733 |
% \begin{macrocode} |
| 6734 |
\cs_new_protected:Npn \@@_make_m_preamble_ii:nn #1 #2 |
| 6735 |
{ |
| 6736 |
\tl_gput_right:Nn \g_@@_preamble_tl { #1 { #2 } } |
| 6737 |
\@@_make_m_preamble:n |
| 6738 |
} |
| 6739 |
% \end{macrocode} |
| 6740 |
% |
| 6741 |
% |
| 6742 |
% \medskip |
| 6743 |
% For \verb+|+ |
| 6744 |
% \begin{macrocode} |
| 6745 |
\cs_new_protected:Npn \@@_make_m_preamble_iii:n #1 |
| 6746 |
{ |
| 6747 |
\tl_gput_right:Nn \g_@@_preamble_tl { #1 } |
| 6748 |
\@@_make_m_preamble:n |
| 6749 |
} |
| 6750 |
% \end{macrocode} |
| 6751 |
% |
| 6752 |
% \medskip |
| 6753 |
% For |p|, |m| and |b| |
| 6754 |
% \begin{macrocode} |
| 6755 |
\cs_new_protected:Npn \@@_make_m_preamble_iv:nnn #1 #2 #3 |
| 6756 |
{ |
| 6757 |
\tl_gput_right:Nn \g_@@_preamble_tl |
| 6758 |
{ |
| 6759 |
> { |
| 6760 |
\@@_cell_begin: |
| 6761 |
% \end{macrocode} |
| 6762 |
% We use |\setlength| instead of |\dim_set:N| to allow a specifier |
| 6763 |
% like |p{\widthof{Some words}}|. |widthof| is a command provided by \pkg{calc}. |
| 6764 |
% Of course, even if \pkg{calc} is not loaded, the following code will work with |
| 6765 |
% the standard version of |\setlength|. |
| 6766 |
% \begin{macrocode} |
| 6767 |
\setlength { \l_tmpa_dim } { #3 } |
| 6768 |
\begin { minipage } [ #1 ] { \l_tmpa_dim } |
| 6769 |
\mode_leave_vertical: |
| 6770 |
\arraybackslash |
| 6771 |
\vrule height \box_ht:N \@arstrutbox depth \c_zero_dim width \c_zero_dim |
| 6772 |
} |
| 6773 |
c |
| 6774 |
< { |
| 6775 |
\vrule height \c_zero_dim depth \box_dp:N \@arstrutbox width \c_zero_dim |
| 6776 |
\end { minipage } |
| 6777 |
\@@_cell_end: |
| 6778 |
} |
| 6779 |
} |
| 6780 |
% \end{macrocode} |
| 6781 |
% We test for the presence of a |<|. |
| 6782 |
% \begin{macrocode} |
| 6783 |
\@@_make_m_preamble_x:n |
| 6784 |
} |
| 6785 |
% \end{macrocode} |
| 6786 |
% |
| 6787 |
% \medskip |
| 6788 |
% For |w| and |W| |
| 6789 |
% \begin{macrocode} |
| 6790 |
\cs_new_protected:Npn \@@_make_m_preamble_v:nnnn #1 #2 #3 #4 |
| 6791 |
{ |
| 6792 |
\tl_gput_right:Nn \g_@@_preamble_tl |
| 6793 |
{ |
| 6794 |
> { |
| 6795 |
\dim_set:Nn \l_@@_col_width_dim { #4 } |
| 6796 |
\hbox_set:Nw \l_@@_cell_box |
| 6797 |
\@@_cell_begin: |
| 6798 |
\tl_set:Nn \l_@@_hpos_cell_tl { #3 } |
| 6799 |
} |
| 6800 |
c |
| 6801 |
< { |
| 6802 |
\@@_cell_end: |
| 6803 |
\hbox_set_end: |
| 6804 |
\bool_if:NT \g_@@_rotate_bool { \@@_rotate_cell_box: } |
| 6805 |
#1 |
| 6806 |
\@@_adjust_size_box: |
| 6807 |
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box } |
| 6808 |
} |
| 6809 |
} |
| 6810 |
% \end{macrocode} |
| 6811 |
% We test for the presence of a |<|. |
| 6812 |
% \begin{macrocode} |
| 6813 |
\@@_make_m_preamble_x:n |
| 6814 |
} |
| 6815 |
% \end{macrocode} |
| 6816 |
% |
| 6817 |
% |
| 6818 |
% After a specifier of column, we have to test whether there is one or several |
| 6819 |
% |<{..}|. |
| 6820 |
% \begin{macrocode} |
| 6821 |
\cs_new_protected:Npn \@@_make_m_preamble_x:n #1 |
| 6822 |
{ |
| 6823 |
\str_if_eq:nnTF { #1 } { < } |
| 6824 |
\@@_make_m_preamble_ix:n |
| 6825 |
{ \@@_make_m_preamble:n { #1 } } |
| 6826 |
} |
| 6827 |
% \end{macrocode} |
| 6828 |
% |
| 6829 |
% \begin{macrocode} |
| 6830 |
\cs_new_protected:Npn \@@_make_m_preamble_ix:n #1 |
| 6831 |
{ |
| 6832 |
\tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } } |
| 6833 |
\@@_make_m_preamble_x:n |
| 6834 |
} |
| 6835 |
% \end{macrocode} |
| 6836 |
% |
| 6837 |
% |
| 6838 |
% |
| 6839 |
% \bigskip |
| 6840 |
% The command |\@@_put_box_in_flow:| puts the box |\l_tmpa_box| (which contains |
| 6841 |
% the array) in the flow. It is used for the environments with delimiters. |
| 6842 |
% First, we have to modify the height and the depth to take back into account |
| 6843 |
% the potential exterior rows (the total height of the first row has been |
| 6844 |
% computed in |\l_tmpa_dim| and the total height of the potential last row in |
| 6845 |
% |\l_tmpb_dim|). |
| 6846 |
% \begin{macrocode} |
| 6847 |
\cs_new_protected:Npn \@@_put_box_in_flow: |
| 6848 |
{ |
| 6849 |
\box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } |
| 6850 |
\box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } |
| 6851 |
\str_if_eq:eeTF \l_@@_baseline_tl { c } |
| 6852 |
{ \box_use_drop:N \l_tmpa_box } |
| 6853 |
\@@_put_box_in_flow_i: |
| 6854 |
} |
| 6855 |
% \end{macrocode} |
| 6856 |
% |
| 6857 |
% \bigskip |
| 6858 |
% The command |\@@_put_box_in_flow_i:| is used when the value of |
| 6859 |
% |\l_@@_baseline_tl| is different of |c| (the initial value). |
| 6860 |
% \begin{macrocode} |
| 6861 |
\cs_new_protected:Npn \@@_put_box_in_flow_i: |
| 6862 |
{ |
| 6863 |
\pgfpicture |
| 6864 |
\@@_qpoint:n { row - 1 } |
| 6865 |
\dim_gset_eq:NN \g_tmpa_dim \pgf@y |
| 6866 |
\@@_qpoint:n { row - \int_eval:n { \c@iRow + 1 } } |
| 6867 |
\dim_gadd:Nn \g_tmpa_dim \pgf@y |
| 6868 |
\dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } |
| 6869 |
% \end{macrocode} |
| 6870 |
% Now, |\g_tmpa_dim| contains the $y$-value of the center of the array (the |
| 6871 |
% delimiters are centered in relation with this value). |
| 6872 |
% \begin{macrocode} |
| 6873 |
\tl_if_in:NnTF \l_@@_baseline_tl { line- } |
| 6874 |
{ |
| 6875 |
\int_set:Nn \l_tmpa_int |
| 6876 |
{ \str_range:Nnn \l_@@_baseline_tl { 6 } { -1 } } |
| 6877 |
\bool_lazy_or:nnT |
| 6878 |
{ \int_compare_p:nNn \l_tmpa_int < { 1 } } |
| 6879 |
{ \int_compare_p:nNn \l_tmpa_int > { \c@iRow + 1 } } |
| 6880 |
{ |
| 6881 |
\@@_error:n { bad~value~for~baseline-line } |
| 6882 |
\int_set:Nn \l_tmpa_int 1 |
| 6883 |
} |
| 6884 |
\@@_qpoint:n { row - \int_use:N \l_tmpa_int } |
| 6885 |
} |
| 6886 |
{ |
| 6887 |
\str_if_eq:eeTF t \l_@@_baseline_tl |
| 6888 |
{ \int_set:Nn \l_tmpa_int 1 } |
| 6889 |
{ |
| 6890 |
\str_if_eq:eeTF b \l_@@_baseline_tl |
| 6891 |
{ \int_set_eq:NN \l_tmpa_int \c@iRow } |
| 6892 |
{ \int_set:Nn \l_tmpa_int \l_@@_baseline_tl } |
| 6893 |
} |
| 6894 |
\bool_lazy_or:nnT |
| 6895 |
{ \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int } |
| 6896 |
{ \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int } |
| 6897 |
{ |
| 6898 |
\@@_error:n { bad~value~for~baseline } |
| 6899 |
\int_set:Nn \l_tmpa_int 1 |
| 6900 |
} |
| 6901 |
\@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } |
| 6902 |
% \end{macrocode} |
| 6903 |
% We take into account the position of the mathematical axis. |
| 6904 |
% \begin{macrocode} |
| 6905 |
\dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } |
| 6906 |
} |
| 6907 |
\dim_gsub:Nn \g_tmpa_dim \pgf@y |
| 6908 |
% \end{macrocode} |
| 6909 |
% Now, |\g_tmpa_dim| contains the value of the $y$ translation we have to to. |
| 6910 |
% \begin{macrocode} |
| 6911 |
\endpgfpicture |
| 6912 |
\box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box } |
| 6913 |
% \box_use_drop:N \l_tmpa_box % 2026/04/13 |
| 6914 |
} |
| 6915 |
% \end{macrocode} |
| 6916 |
% |
| 6917 |
% \bigskip |
| 6918 |
% The following command is \emph{always} used by |{NiceArrayWithDelims}| (even |
| 6919 |
% if, in fact, there is no tabular notes: in fact, it's not possible to know |
| 6920 |
% whether there is tabular notes or not before the composition of the blocks). |
| 6921 |
% \begin{macrocode} |
| 6922 |
\cs_new_protected:Npn \@@_use_arraybox_with_notes_c: |
| 6923 |
{ |
| 6924 |
% \end{macrocode} |
| 6925 |
% With an environment |{Matrix}|, you want to remove the exterior |\arraycolsep| |
| 6926 |
% but we don't know the number of columns (since there is no preamble) and |
| 6927 |
% that's why we can't put |@{}| at the end of the preamble. That's why we remove |
| 6928 |
% a |\arraycolsep| now. |
| 6929 |
% \begin{macrocode} |
| 6930 |
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool |
| 6931 |
{ |
| 6932 |
\int_compare:nNnT \c@jCol > 1 |
| 6933 |
{ |
| 6934 |
\box_set_wd:Nn \l_@@_the_array_box |
| 6935 |
{ \box_wd:N \l_@@_the_array_box - \arraycolsep } |
| 6936 |
} |
| 6937 |
} |
| 6938 |
% \end{macrocode} |
| 6939 |
% We need a |{minipage}| because we will insert a LaTeX list for the tabular |
| 6940 |
% notes (that means that a |\vtop{\hsize=...}| is not enough). |
| 6941 |
% \begin{macrocode} |
| 6942 |
\begin { minipage } [ t ] { \box_wd:N \l_@@_the_array_box } |
| 6943 |
\bool_if:NT \l_@@_caption_above_bool |
| 6944 |
{ |
| 6945 |
\tl_if_empty:NF \l_@@_caption_tl |
| 6946 |
{ |
| 6947 |
% \end{macrocode} |
| 6948 |
% |
| 6949 |
% \begin{macrocode} |
| 6950 |
\bool_set_false:N \g_@@_caption_finished_bool |
| 6951 |
\int_gzero:N \c@tabularnote |
| 6952 |
\@@_insert_caption: |
| 6953 |
% \end{macrocode} |
| 6954 |
% If there is one or several commands |\tabularnote| in the caption, we will |
| 6955 |
% write in the |aux| file the number of such tabular notes... but only the |
| 6956 |
% tabular notes for which the command |\tabularnote| has been used without its |
| 6957 |
% optional argument (between square brackets). |
| 6958 |
% \begin{macrocode} |
| 6959 |
\int_compare:nNnT \g_@@_notes_caption_int > \c_zero_int |
| 6960 |
{ |
| 6961 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 6962 |
{ |
| 6963 |
\tl_set:Nn \exp_not:N \l_@@_note_in_caption_tl |
| 6964 |
{ \int_use:N \g_@@_notes_caption_int } |
| 6965 |
} |
| 6966 |
\int_gzero:N \g_@@_notes_caption_int |
| 6967 |
} |
| 6968 |
} |
| 6969 |
} |
| 6970 |
% \end{macrocode} |
| 6971 |
% The |\hbox| avoids that the |pgfpicture| inside |\@@_draw_blocks| adds a extra |
| 6972 |
% vertical space before the notes. |
| 6973 |
% \begin{macrocode} |
| 6974 |
\hbox |
| 6975 |
{ |
| 6976 |
\box_use_drop:N \l_@@_the_array_box |
| 6977 |
% \end{macrocode} |
| 6978 |
% We have to draw the blocks right away because there may be tabular notes in |
| 6979 |
% some blocks (which are not mono-column: the blocks which are mono-column |
| 6980 |
% have been composed in boxes yet)... and we have to create (potentially) the |
| 6981 |
% extra nodes before creating the blocks since there are |medium| nodes to create |
| 6982 |
% for the blocks. |
| 6983 |
% \begin{macrocode} |
| 6984 |
\@@_create_extra_nodes: |
| 6985 |
\seq_if_empty:NF \g_@@_blocks_seq \@@_draw_blocks: |
| 6986 |
} |
| 6987 |
% \end{macrocode} |
| 6988 |
% We don't do the following test with |\c@tabularnote| because the value of that |
| 6989 |
% counter is not reliable when the command |\ttabbox| of \pkg{floatrow} is used |
| 6990 |
% (because |\ttabbox| de-activate |\stepcounter| because it compiles |
| 6991 |
% twice its tabular). |
| 6992 |
% \begin{macrocode} |
| 6993 |
\bool_lazy_any:nT |
| 6994 |
{ |
| 6995 |
{ ! \seq_if_empty_p:N \g_@@_notes_seq } |
| 6996 |
{ ! \seq_if_empty_p:N \g_@@_notes_in_caption_seq } |
| 6997 |
{ ! \tl_if_empty_p:o \g_@@_tabularnote_tl } |
| 6998 |
} |
| 6999 |
{ |
| 7000 |
\bool_if:NTF \l_@@_notes_no_print_bool |
| 7001 |
{ \cs_gset_eq:NN \NiceTabularNotes \@@_tabular_notes: } |
| 7002 |
\@@_tabular_notes: |
| 7003 |
} |
| 7004 |
\cs_set_eq:NN \tabularnote \@@_tabularnote_error:n |
| 7005 |
\bool_if:NF \l_@@_caption_above_bool { \@@_insert_caption: } |
| 7006 |
\end { minipage } |
| 7007 |
} |
| 7008 |
% \end{macrocode} |
| 7009 |
% |
| 7010 |
% |
| 7011 |
% \bigskip |
| 7012 |
% \begin{macrocode} |
| 7013 |
\cs_new_protected:Npn \@@_insert_caption: |
| 7014 |
{ |
| 7015 |
\tl_if_empty:NF \l_@@_caption_tl |
| 7016 |
{ |
| 7017 |
\cs_if_exist:NTF \@captype |
| 7018 |
{ \@@_insert_caption_i: } |
| 7019 |
{ \@@_error:n { caption~outside~float } } |
| 7020 |
} |
| 7021 |
} |
| 7022 |
% \end{macrocode} |
| 7023 |
% |
| 7024 |
% \bigskip |
| 7025 |
% \begin{macrocode} |
| 7026 |
\cs_new_protected:Npn \@@_insert_caption_i: |
| 7027 |
{ |
| 7028 |
\group_begin: |
| 7029 |
% \end{macrocode} |
| 7030 |
% The flag |\l_@@_in_caption_bool| affects only the behavior of the command |
| 7031 |
% |\tabularnote| when used in the caption. |
| 7032 |
% \begin{macrocode} |
| 7033 |
\bool_set_true:N \l_@@_in_caption_bool |
| 7034 |
% \end{macrocode} |
| 7035 |
% The package \pkg{floatrow} does a redefinition of |\@makecaption| which will |
| 7036 |
% extract the caption from the tabular. However, the old version of |
| 7037 |
% |\@makecaption| has been stored by \pkg{floatrow} in |\FR@makecaption|. That's |
| 7038 |
% why we restore the old version. |
| 7039 |
% \begin{macrocode} |
| 7040 |
\IfPackageLoadedT { floatrow } { \cs_set_eq:NN \@makecaption \FR@makecaption } |
| 7041 |
\tl_if_empty:NTF \l_@@_short_caption_tl |
| 7042 |
\caption |
| 7043 |
{ \caption [ \l_@@_short_caption_tl ] } |
| 7044 |
{ \l_@@_caption_tl } |
| 7045 |
% \end{macrocode} |
| 7046 |
% In some circonstancies (in particular when the package \pkg{caption} is |
| 7047 |
% loaded), the caption is composed several times. That's why, when the same |
| 7048 |
% tabular note is encountered (in the caption!), we consider that you are in the |
| 7049 |
% second compilation and you can give to |\g_@@_notes_caption_int| its final |
| 7050 |
% value, which is the number of tabular notes in the caption. But sometimes, the |
| 7051 |
% caption is composed only once. In that case, we fix the value of |
| 7052 |
% |\g_@@_caption_finished_bool| now. |
| 7053 |
% \begin{macrocode} |
| 7054 |
\bool_if:NF \g_@@_caption_finished_bool |
| 7055 |
{ |
| 7056 |
\bool_gset_true:N \g_@@_caption_finished_bool |
| 7057 |
\int_gset_eq:NN \g_@@_notes_caption_int \c@tabularnote |
| 7058 |
\int_gzero:N \c@tabularnote |
| 7059 |
} |
| 7060 |
\tl_if_empty:NF \l_@@_label_tl { \label { \l_@@_label_tl } } |
| 7061 |
\group_end: |
| 7062 |
} |
| 7063 |
% \end{macrocode} |
| 7064 |
% |
| 7065 |
% \begin{macrocode} |
| 7066 |
\cs_new_protected:Npn \@@_tabularnote_error:n #1 |
| 7067 |
{ |
| 7068 |
\@@_error_or_warning:n { tabularnote~below~the~tabular } |
| 7069 |
\cs_gset:Npn \@@_tabularnote_error:n ##1 { } |
| 7070 |
} |
| 7071 |
% \end{macrocode} |
| 7072 |
% |
| 7073 |
% \begin{macrocode} |
| 7074 |
\cs_set_protected:Npn \@@_tabular_notes_error: |
| 7075 |
{ \@@_error:n { Bad~use~of~NiceTabularNotes } } |
| 7076 |
% \end{macrocode} |
| 7077 |
% |
| 7078 |
% \begin{macrocode} |
| 7079 |
\cs_set_eq:NN \NiceTabularNotes \@@_tabular_notes_error: |
| 7080 |
% \end{macrocode} |
| 7081 |
% |
| 7082 |
% \begin{macrocode} |
| 7083 |
\cs_set_protected:Npn \@@_tabular_notes: |
| 7084 |
{ |
| 7085 |
\cs_gset_eq:NN \NiceTabularNotes \@@_tabular_notes_error: |
| 7086 |
\seq_gconcat:NNN \g_@@_notes_seq \g_@@_notes_in_caption_seq \g_@@_notes_seq |
| 7087 |
\int_set:Nn \c@tabularnote { \seq_count:N \g_@@_notes_seq } |
| 7088 |
\skip_vertical:N 0.65ex |
| 7089 |
% \end{macrocode} |
| 7090 |
% The TeX group is for potential specifications in the |
| 7091 |
% |\l_@@_notes_code_before_tl|. |
| 7092 |
% \begin{macrocode} |
| 7093 |
\group_begin: |
| 7094 |
\l_@@_notes_code_before_tl |
| 7095 |
\tl_if_empty:NF \g_@@_tabularnote_tl |
| 7096 |
{ |
| 7097 |
\g_@@_tabularnote_tl \par |
| 7098 |
\tl_gclear:N \g_@@_tabularnote_tl |
| 7099 |
} |
| 7100 |
% \end{macrocode} |
| 7101 |
% We compose the tabular notes with a list of \pkg{enumitem}. The |\strut| and |
| 7102 |
% the |\unskip| are designed to give the ability to put a |\bottomrule| at the |
| 7103 |
% end of the notes with a good vertical space. |
| 7104 |
% \begin{macrocode} |
| 7105 |
\int_compare:nNnT \c@tabularnote > \c_zero_int |
| 7106 |
{ |
| 7107 |
\bool_if:NTF \l_@@_notes_para_bool |
| 7108 |
{ |
| 7109 |
\begin { tabularnotes* } |
| 7110 |
\seq_map_inline:Nn \g_@@_notes_seq |
| 7111 |
{ \@@_one_tabularnote:nn ##1 } |
| 7112 |
\strut |
| 7113 |
\end { tabularnotes* } |
| 7114 |
% \end{macrocode} |
| 7115 |
% The following |\par| is mandatory for the event that the user has put |
| 7116 |
% |\footnotesize| (for example) in the |notes/code-before|. |
| 7117 |
% \begin{macrocode} |
| 7118 |
\par |
| 7119 |
} |
| 7120 |
{ |
| 7121 |
\tabularnotes |
| 7122 |
\seq_map_inline:Nn \g_@@_notes_seq |
| 7123 |
{ \@@_one_tabularnote:nn ##1 } |
| 7124 |
\strut |
| 7125 |
\endtabularnotes |
| 7126 |
} |
| 7127 |
} |
| 7128 |
\unskip |
| 7129 |
\group_end: |
| 7130 |
\bool_if:NT \l_@@_notes_bottomrule_bool |
| 7131 |
{ |
| 7132 |
\IfPackageLoadedTF { booktabs } |
| 7133 |
{ |
| 7134 |
% \end{macrocode} |
| 7135 |
% The two dimensions |\aboverulesep| et |\heavyrulewidth| are parameters defined |
| 7136 |
% by \pkg{booktabs}. |
| 7137 |
% \begin{macrocode} |
| 7138 |
\skip_vertical:N \aboverulesep |
| 7139 |
% \end{macrocode} |
| 7140 |
% |\CT@arc@| is the specification of color defined by \pkg{colortbl} but you use it |
| 7141 |
% even if \pkg{colortbl} is not loaded. |
| 7142 |
% \begin{macrocode} |
| 7143 |
{ \CT@arc@ \hrule height \heavyrulewidth } |
| 7144 |
} |
| 7145 |
{ \@@_error_or_warning:n { bottomrule~without~booktabs } } |
| 7146 |
} |
| 7147 |
\l_@@_notes_code_after_tl |
| 7148 |
\seq_gclear:N \g_@@_notes_seq |
| 7149 |
\seq_gclear:N \g_@@_notes_in_caption_seq |
| 7150 |
\int_gzero:N \c@tabularnote |
| 7151 |
} |
| 7152 |
% \end{macrocode} |
| 7153 |
% |
| 7154 |
% \medskip |
| 7155 |
% The following command will format (after the main tabular) one tabularnote |
| 7156 |
% (with the command |\item|) . |#1| is the label (when the command |
| 7157 |
% |\tabularnote| has been used with an optional argument between square |
| 7158 |
% brackets) and |#2| is the text of the note. The second argument is provided by |
| 7159 |
% curryfication. |
| 7160 |
% \begin{macrocode} |
| 7161 |
\cs_set_protected:Npn \@@_one_tabularnote:nn #1 |
| 7162 |
{ |
| 7163 |
\tl_if_novalue:nTF { #1 } |
| 7164 |
{ \item } |
| 7165 |
{ \item [ \@@_notes_label_in_list:n { #1 } ] } |
| 7166 |
} |
| 7167 |
% \end{macrocode} |
| 7168 |
% |
| 7169 |
% \medskip |
| 7170 |
% The case of |baseline| equal to |b|. Remember that, when the key |b| is used, |
| 7171 |
% the |{array}| (of \pkg{array}) is constructed with the option |t| (and not |
| 7172 |
% |b|). Now, we do the translation to take into account the option |b|. |
| 7173 |
% \begin{macrocode} |
| 7174 |
\cs_new_protected:Npn \@@_use_arraybox_with_notes_b: |
| 7175 |
{ |
| 7176 |
\pgfpicture |
| 7177 |
\@@_qpoint:n { row - 1 } |
| 7178 |
\dim_gset_eq:NN \g_tmpa_dim \pgf@y |
| 7179 |
\@@_qpoint:n { row - \int_use:N \c@iRow - base } |
| 7180 |
\dim_gsub:Nn \g_tmpa_dim \pgf@y |
| 7181 |
\endpgfpicture |
| 7182 |
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth |
| 7183 |
\int_if_zero:nT \l_@@_first_row_int |
| 7184 |
{ |
| 7185 |
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim |
| 7186 |
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim |
| 7187 |
} |
| 7188 |
\box_move_up:nn \g_tmpa_dim { \hbox { \@@_use_arraybox_with_notes_c: } } |
| 7189 |
} |
| 7190 |
% \end{macrocode} |
| 7191 |
% |
| 7192 |
% \medskip |
| 7193 |
% Now, the general case. |
| 7194 |
% \begin{macrocode} |
| 7195 |
\cs_new_protected:Npn \@@_use_arraybox_with_notes: |
| 7196 |
{ |
| 7197 |
% \end{macrocode} |
| 7198 |
% We convert a value of |t| to a value of |1|. |
| 7199 |
% \begin{macrocode} |
| 7200 |
\str_if_eq:eeT \l_@@_baseline_tl { t } |
| 7201 |
{ \tl_set:Nn \l_@@_baseline_tl { 1 } } |
| 7202 |
% \end{macrocode} |
| 7203 |
% Now, we convert the value of |\l_@@_baseline_tl| (which should represent an |
| 7204 |
% integer) to an integer stored in |\l_tmpa_int|. |
| 7205 |
% \begin{macrocode} |
| 7206 |
\pgfpicture |
| 7207 |
\@@_qpoint:n { row - 1 } |
| 7208 |
\dim_gset_eq:NN \g_tmpa_dim \pgf@y |
| 7209 |
\tl_if_in:NnTF \l_@@_baseline_tl { line- } |
| 7210 |
{ |
| 7211 |
\int_set:Nn \l_tmpa_int |
| 7212 |
{ |
| 7213 |
\str_range:Nnn |
| 7214 |
\l_@@_baseline_tl |
| 7215 |
{ 6 } |
| 7216 |
{ \tl_count:o \l_@@_baseline_tl } |
| 7217 |
} |
| 7218 |
\@@_qpoint:n { row - \int_use:N \l_tmpa_int } |
| 7219 |
} |
| 7220 |
{ |
| 7221 |
\int_set:Nn \l_tmpa_int \l_@@_baseline_tl |
| 7222 |
\bool_lazy_or:nnT |
| 7223 |
{ \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int } |
| 7224 |
{ \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int } |
| 7225 |
{ |
| 7226 |
\@@_error:n { bad~value~for~baseline } |
| 7227 |
\int_set:Nn \l_tmpa_int 1 |
| 7228 |
} |
| 7229 |
\@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } |
| 7230 |
} |
| 7231 |
\dim_gsub:Nn \g_tmpa_dim \pgf@y |
| 7232 |
\endpgfpicture |
| 7233 |
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth |
| 7234 |
\int_if_zero:nT \l_@@_first_row_int |
| 7235 |
{ |
| 7236 |
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim |
| 7237 |
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim |
| 7238 |
} |
| 7239 |
\box_move_up:nn \g_tmpa_dim { \hbox { \@@_use_arraybox_with_notes_c: } } |
| 7240 |
} |
| 7241 |
% \end{macrocode} |
| 7242 |
% |
| 7243 |
% |
| 7244 |
% |
| 7245 |
% \bigskip |
| 7246 |
% The command |\@@_put_box_in_flow_bis:| is used when the option |
| 7247 |
% |delimiters/max-width| is used because, in this case, we have to adjust the |
| 7248 |
% widths of the delimiters. The arguments |#1| and |#2| are the delimiters |
| 7249 |
% specified by the user. |
| 7250 |
% \begin{macrocode} |
| 7251 |
\cs_new_protected:Npn \@@_put_box_in_flow_bis:nn #1 #2 |
| 7252 |
{ |
| 7253 |
% \end{macrocode} |
| 7254 |
% We will compute the real width of both delimiters used. |
| 7255 |
% \begin{macrocode} |
| 7256 |
\dim_zero_new:N \l_@@_real_left_delim_dim |
| 7257 |
\dim_zero_new:N \l_@@_real_right_delim_dim |
| 7258 |
\hbox_set:Nn \l_tmpb_box |
| 7259 |
{ |
| 7260 |
\m@th |
| 7261 |
$ % $ |
| 7262 |
\left #1 |
| 7263 |
\vcenter |
| 7264 |
{ |
| 7265 |
\vbox_to_ht:nn |
| 7266 |
{ \box_ht_plus_dp:N \l_tmpa_box } |
| 7267 |
{ } |
| 7268 |
} |
| 7269 |
\right . |
| 7270 |
$ % $ |
| 7271 |
} |
| 7272 |
\dim_set:Nn \l_@@_real_left_delim_dim |
| 7273 |
{ \box_wd:N \l_tmpb_box - \nulldelimiterspace } |
| 7274 |
\hbox_set:Nn \l_tmpb_box |
| 7275 |
{ |
| 7276 |
\m@th |
| 7277 |
$ % $ |
| 7278 |
\left . |
| 7279 |
\vbox_to_ht:nn |
| 7280 |
{ \box_ht_plus_dp:N \l_tmpa_box } |
| 7281 |
{ } |
| 7282 |
\right #2 |
| 7283 |
$ % $ |
| 7284 |
} |
| 7285 |
\dim_set:Nn \l_@@_real_right_delim_dim |
| 7286 |
{ \box_wd:N \l_tmpb_box - \nulldelimiterspace } |
| 7287 |
% \end{macrocode} |
| 7288 |
% |
| 7289 |
% Now, we can put the box in the TeX flow with the horizontal adjustments on |
| 7290 |
% both sides. |
| 7291 |
% \begin{macrocode} |
| 7292 |
\skip_horizontal:n { \l_@@_left_delim_dim - \l_@@_real_left_delim_dim } |
| 7293 |
\@@_put_box_in_flow: |
| 7294 |
\skip_horizontal:n { \l_@@_right_delim_dim - \l_@@_real_right_delim_dim } |
| 7295 |
} |
| 7296 |
% \end{macrocode} |
| 7297 |
% |
| 7298 |
% \interitem |
| 7299 |
% The construction of the array in the environment |{NiceArrayWithDelims}| is, |
| 7300 |
% in fact, done by the environment |{@@-light-syntax}| or by the environment |
| 7301 |
% |{@@-normal-syntax}| (whether the option |light-syntax| is in force or not). |
| 7302 |
% When the key |light-syntax| is not used, the construction is a standard |
| 7303 |
% environment (and, thus, it's possible to use verbatim in the array). |
| 7304 |
% \begin{macrocode} |
| 7305 |
\NewDocumentEnvironment { @@-normal-syntax } { } |
| 7306 |
% \end{macrocode} |
| 7307 |
% First, we test whether the environment is empty. If it is empty, we raise a |
| 7308 |
% fatal error (it's only a security). In order to detect whether it is empty, we |
| 7309 |
% test whether the next token is |\end| and, if it's the case, we test if this |
| 7310 |
% is the end of the environment (if it is not, a standard error will be raised |
| 7311 |
% by LaTeX for incorrect nested environments). |
| 7312 |
% \begin{macrocode} |
| 7313 |
{ |
| 7314 |
\peek_remove_spaces:n |
| 7315 |
{ |
| 7316 |
\peek_meaning:NTF \end |
| 7317 |
\@@_analyze_end:Nn |
| 7318 |
{ |
| 7319 |
\@@_transform_preamble: |
| 7320 |
\@@_array:o \g_@@_array_preamble_tl |
| 7321 |
} |
| 7322 |
} |
| 7323 |
} |
| 7324 |
{ |
| 7325 |
\@@_create_col_nodes: |
| 7326 |
\endarray |
| 7327 |
} |
| 7328 |
% \end{macrocode} |
| 7329 |
% |
| 7330 |
% |
| 7331 |
% \bigskip |
| 7332 |
% When the key |light-syntax| is in force, we use an environment which takes its |
| 7333 |
% whole body as an argument (with the specifier |b|). |
| 7334 |
% % \label{code-light-syntax} |
| 7335 |
% \begin{macrocode} |
| 7336 |
\NewDocumentEnvironment { @@-light-syntax } { b } |
| 7337 |
{ |
| 7338 |
% \end{macrocode} |
| 7339 |
% First, we test whether the environment is empty. It's only a security. Of |
| 7340 |
% course, this test is more easy than the similar test for the ``normal syntax'' |
| 7341 |
% because we have the whole body of the environment in |#1|. |
| 7342 |
% \begin{macrocode} |
| 7343 |
\tl_if_empty:nT { #1 } |
| 7344 |
{ \@@_fatal:n { empty~environment } } |
| 7345 |
\tl_if_in:nnT { #1 } { & } |
| 7346 |
{ \@@_fatal:n { ampersand~in~light-syntax } } |
| 7347 |
\tl_if_in:nnT { #1 } { \\ } |
| 7348 |
{ \@@_fatal:n { double-backslash~in~light-syntax } } |
| 7349 |
% \end{macrocode} |
| 7350 |
% Now, you extract the |\CodeAfter| of the body of the environment. Maybe, there |
| 7351 |
% is no command |\CodeAfter| in the body. That's why you put a marker |
| 7352 |
% |\CodeAfter| after |#1|. If there is yet a |\CodeAfter| in |#1|, this second |
| 7353 |
% (or third...) |\CodeAfter| will be caught in the value of |
| 7354 |
% |\g_nicematrix_code_after_tl|. That doesn't matter because |\CodeAfter| will |
| 7355 |
% be set to \textsl{no-op} before the execution of |
| 7356 |
% |\g_nicematrix_code_after_tl|. |
| 7357 |
% \begin{macrocode} |
| 7358 |
\@@_light_syntax_i:w #1 \CodeAfter \q_stop |
| 7359 |
% \end{macrocode} |
| 7360 |
% The command |\array| is hidden somewhere in |\@@_light_syntax_i:w|. |
| 7361 |
% \begin{macrocode} |
| 7362 |
} |
| 7363 |
% \end{macrocode} |
| 7364 |
% Now, the second part of the environment. We must leave these lines in the |
| 7365 |
% second part (and not put them in the first part even though we caught the |
| 7366 |
% whole body of the environment with an argument of type |b|) in order to have |
| 7367 |
% the columns |S| of \pkg{siunitx} working fine. |
| 7368 |
% \begin{macrocode} |
| 7369 |
{ |
| 7370 |
\@@_create_col_nodes: |
| 7371 |
\endarray |
| 7372 |
} |
| 7373 |
% \end{macrocode} |
| 7374 |
% |
| 7375 |
% |
| 7376 |
% \begin{macrocode} |
| 7377 |
\cs_new_protected:Npn \@@_light_syntax_i:w #1\CodeAfter #2 \q_stop |
| 7378 |
{ |
| 7379 |
\tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } |
| 7380 |
% \end{macrocode} |
| 7381 |
% The body of the array, which is stored in the argument |#1|, is now |
| 7382 |
% split into items (and \emph{not} tokens). |
| 7383 |
% \begin{macrocode} |
| 7384 |
\seq_clear_new:N \l_@@_rows_seq |
| 7385 |
% \end{macrocode} |
| 7386 |
% We rescan the character of end of line in order to have the correct catcode. |
| 7387 |
% \begin{macrocode} |
| 7388 |
\tl_set_rescan:Nno \l_@@_end_of_row_tl { } \l_@@_end_of_row_tl |
| 7389 |
\bool_if:NTF \l_@@_light_syntax_expanded_bool |
| 7390 |
\seq_set_split:Nee |
| 7391 |
\seq_set_split:Non |
| 7392 |
\l_@@_rows_seq \l_@@_end_of_row_tl { #1 } |
| 7393 |
% \end{macrocode} |
| 7394 |
% We delete the last row if it is empty. |
| 7395 |
% \begin{macrocode} |
| 7396 |
\seq_pop_right:NN \l_@@_rows_seq \l_tmpa_tl |
| 7397 |
\tl_if_empty:NF \l_tmpa_tl |
| 7398 |
{ \seq_put_right:No \l_@@_rows_seq \l_tmpa_tl } |
| 7399 |
% \end{macrocode} |
| 7400 |
% If the environment uses the option |last-row| without value (i.e. without |
| 7401 |
% saying the number of the rows), we have now the opportunity to compute that |
| 7402 |
% value. We do it, and so, if the token list |\l_@@_code_for_last_row_tl| is not |
| 7403 |
% empty, we will use directly where it should be. |
| 7404 |
% \begin{macrocode} |
| 7405 |
\int_compare:nNnT \l_@@_last_row_int = { -1 } |
| 7406 |
{ \int_set:Nn \l_@@_last_row_int { \seq_count:N \l_@@_rows_seq } } |
| 7407 |
% \end{macrocode} |
| 7408 |
% |
| 7409 |
% |
| 7410 |
% \bigskip |
| 7411 |
% The new value of the body (that is to say after replacement of the separators |
| 7412 |
% of rows and columns by |\\| and |&|) of the environment will be stored in |
| 7413 |
% |\l_@@_new_body_tl| in order to allow the use of commands such as |
| 7414 |
% |\hline| or |\hdottedline| with the key |light-syntax|). |
| 7415 |
% \begin{macrocode} |
| 7416 |
\tl_build_begin:N \l_@@_new_body_tl |
| 7417 |
\int_zero_new:N \l_@@_nb_cols_int |
| 7418 |
% \end{macrocode} |
| 7419 |
% First, we treat the first row. |
| 7420 |
% \begin{macrocode} |
| 7421 |
\seq_pop_left:NN \l_@@_rows_seq \l_tmpa_tl |
| 7422 |
\@@_line_with_light_syntax:o \l_tmpa_tl |
| 7423 |
% \end{macrocode} |
| 7424 |
% Now, the other rows (with the same treatment, excepted that we have to insert |
| 7425 |
% |\\| between the rows). |
| 7426 |
% \begin{macrocode} |
| 7427 |
\seq_map_inline:Nn \l_@@_rows_seq |
| 7428 |
{ |
| 7429 |
\tl_build_put_right:Nn \l_@@_new_body_tl { \\ } |
| 7430 |
\@@_line_with_light_syntax:n { ##1 } |
| 7431 |
} |
| 7432 |
\tl_build_end:N \l_@@_new_body_tl |
| 7433 |
% \end{macrocode} |
| 7434 |
% |
| 7435 |
% \begin{macrocode} |
| 7436 |
\int_compare:nNnT \l_@@_last_col_int = { -1 } |
| 7437 |
{ |
| 7438 |
\int_set:Nn \l_@@_last_col_int |
| 7439 |
{ \l_@@_nb_cols_int - 1 + \l_@@_first_col_int } |
| 7440 |
} |
| 7441 |
% \end{macrocode} |
| 7442 |
% |
| 7443 |
% Now, we can construct the preamble: if the user has used the key |last-col|, |
| 7444 |
% we have the correct number of columns even though the user has used |last-col| |
| 7445 |
% without value. |
| 7446 |
% \begin{macrocode} |
| 7447 |
\@@_transform_preamble: |
| 7448 |
% \end{macrocode} |
| 7449 |
% \bigskip |
| 7450 |
% |
| 7451 |
% \begin{macrocode} |
| 7452 |
\@@_array:o \g_@@_array_preamble_tl \l_@@_new_body_tl |
| 7453 |
} |
| 7454 |
% \end{macrocode} |
| 7455 |
% |
| 7456 |
% \begin{macrocode} |
| 7457 |
\cs_new_protected:Npn \@@_line_with_light_syntax:n #1 |
| 7458 |
{ |
| 7459 |
\seq_clear_new:N \l_@@_cells_seq |
| 7460 |
\seq_set_split:Nnn \l_@@_cells_seq { ~ } { #1 } |
| 7461 |
\int_set:Nn \l_@@_nb_cols_int |
| 7462 |
{ \int_max:nn \l_@@_nb_cols_int { \seq_count:N \l_@@_cells_seq } } |
| 7463 |
\seq_pop_left:NN \l_@@_cells_seq \l_tmpa_tl |
| 7464 |
\tl_build_put_right:No \l_@@_new_body_tl \l_tmpa_tl |
| 7465 |
\seq_map_inline:Nn \l_@@_cells_seq |
| 7466 |
{ \tl_build_put_right:Nn \l_@@_new_body_tl { & ##1 } } |
| 7467 |
} |
| 7468 |
\cs_generate_variant:Nn \@@_line_with_light_syntax:n { o } |
| 7469 |
% \end{macrocode} |
| 7470 |
% |
| 7471 |
% |
| 7472 |
% \bigskip |
| 7473 |
% The following command is used by the code which detects whether the |
| 7474 |
% environment is empty (we raise a fatal error in this case: it's only a |
| 7475 |
% security). When this command is used, |#1| is, in fact, always |\end|. |
| 7476 |
% \begin{macrocode} |
| 7477 |
\cs_new_protected:Npn \@@_analyze_end:Nn #1 #2 |
| 7478 |
{ |
| 7479 |
\str_if_eq:eeT \g_@@_name_env_str { #2 } |
| 7480 |
{ \@@_fatal:n { empty~environment } } |
| 7481 |
% \end{macrocode} |
| 7482 |
% We reput in the stream the |\end{...}| we have extracted and the user will |
| 7483 |
% have an error for incorrect nested environments. |
| 7484 |
% \begin{macrocode} |
| 7485 |
\end { #2 } |
| 7486 |
} |
| 7487 |
% \end{macrocode} |
| 7488 |
% |
| 7489 |
% \bigskip |
| 7490 |
% The command |\@@_create_col_nodes:| will construct a special last row. |
| 7491 |
% That last row is a false row used to create the |col| nodes and to fix the |
| 7492 |
% width of the columns (when the array is constructed with an option which |
| 7493 |
% specifies the width of the columns such as |columns-width|). |
| 7494 |
% \begin{macrocode} |
| 7495 |
\cs_new:Npn \@@_create_col_nodes: |
| 7496 |
{ |
| 7497 |
\crcr |
| 7498 |
\int_if_zero:nT \l_@@_first_col_int |
| 7499 |
{ |
| 7500 |
\omit |
| 7501 |
\hbox_overlap_left:n |
| 7502 |
{ |
| 7503 |
\bool_if:NT \l_@@_code_before_bool |
| 7504 |
{ \pgfsys@markposition { \@@_env: - col - 0 } } |
| 7505 |
\pgfpicture |
| 7506 |
\pgfrememberpicturepositiononpagetrue |
| 7507 |
\pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin |
| 7508 |
\str_if_empty:NF \l_@@_name_str |
| 7509 |
{ \pgfnodealias { \l_@@_name_str - col - 0 } { \@@_env: - col - 0 } } |
| 7510 |
\endpgfpicture |
| 7511 |
\skip_horizontal:n { 2 \col@sep + \g_@@_width_first_col_dim } |
| 7512 |
} |
| 7513 |
& |
| 7514 |
} |
| 7515 |
\omit |
| 7516 |
% \end{macrocode} |
| 7517 |
% The following instruction must be put after the instruction |\omit| since, of course, |
| 7518 |
% it is not expandable. |
| 7519 |
% \begin{macrocode} |
| 7520 |
\bool_gset_true:N \g_@@_row_of_col_done_bool |
| 7521 |
% \end{macrocode} |
| 7522 |
% First, we put a |col| node on the left of the first column (of course, we |
| 7523 |
% have to do that \emph{after} the |\omit|). |
| 7524 |
% \begin{macrocode} |
| 7525 |
\int_if_zero:nTF \l_@@_first_col_int |
| 7526 |
{ |
| 7527 |
\@@_mark_position:n { 1 } |
| 7528 |
\pgfpicture |
| 7529 |
\pgfrememberpicturepositiononpagetrue |
| 7530 |
\pgfcoordinate { \@@_env: - col - 1 } |
| 7531 |
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } |
| 7532 |
\str_if_empty:NF \l_@@_name_str |
| 7533 |
{ \pgfnodealias { \l_@@_name_str - col - 1 } { \@@_env: - col - 1 } } |
| 7534 |
\endpgfpicture |
| 7535 |
} |
| 7536 |
{ |
| 7537 |
\bool_if:NT \l_@@_code_before_bool |
| 7538 |
{ |
| 7539 |
\hbox |
| 7540 |
{ |
| 7541 |
\skip_horizontal:n { 0.5 \arrayrulewidth } |
| 7542 |
\pgfsys@markposition { \@@_env: - col - 1 } |
| 7543 |
\skip_horizontal:n { -0.5 \arrayrulewidth } |
| 7544 |
} |
| 7545 |
} |
| 7546 |
\pgfpicture |
| 7547 |
\pgfrememberpicturepositiononpagetrue |
| 7548 |
\pgfcoordinate { \@@_env: - col - 1 } |
| 7549 |
{ \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim } |
| 7550 |
\@@_node_alias:n { 1 } |
| 7551 |
\endpgfpicture |
| 7552 |
} |
| 7553 |
% \end{macrocode} |
| 7554 |
% We compute in |\g_tmpa_skip| the common width of the columns (it's a skip and |
| 7555 |
% not a dimension). We use a global variable because we are in a cell of an |
| 7556 |
% |\halign| and because we have to use that variable in other cells (of the same |
| 7557 |
% row). The affectation of |\g_tmpa_skip|, like all the affectations, must be |
| 7558 |
% done after the |\omit| of the cell. |
| 7559 |
% |
| 7560 |
% \smallskip |
| 7561 |
% We give a default value for |\g_tmpa_skip| (|0 pt plus 1 fill|) but we will |
| 7562 |
% add some dimensions to it. |
| 7563 |
% \begin{macrocode} |
| 7564 |
\skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } |
| 7565 |
\bool_if:NF \l_@@_auto_columns_width_bool |
| 7566 |
{ \dim_compare:nNnT \l_@@_columns_width_dim > \c_zero_dim } |
| 7567 |
{ |
| 7568 |
\bool_lazy_and:nnTF |
| 7569 |
\l_@@_auto_columns_width_bool |
| 7570 |
{ \bool_not_p:n \l_@@_block_auto_columns_width_bool } |
| 7571 |
{ \skip_gadd:Nn \g_tmpa_skip \g_@@_max_cell_width_dim } |
| 7572 |
{ \skip_gadd:Nn \g_tmpa_skip \l_@@_columns_width_dim } |
| 7573 |
\skip_gadd:Nn \g_tmpa_skip { 2 \col@sep } |
| 7574 |
} |
| 7575 |
\skip_horizontal:N \g_tmpa_skip |
| 7576 |
\hbox |
| 7577 |
{ |
| 7578 |
\@@_mark_position:n { 2 } |
| 7579 |
\pgfpicture |
| 7580 |
\pgfrememberpicturepositiononpagetrue |
| 7581 |
\pgfcoordinate { \@@_env: - col - 2 } |
| 7582 |
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } |
| 7583 |
\@@_node_alias:n { 2 } |
| 7584 |
\endpgfpicture |
| 7585 |
} |
| 7586 |
% \end{macrocode} |
| 7587 |
% We begin a loop over the columns. The integer |\g_tmpa_int| will be the |
| 7588 |
% number of the current column. This integer is used for the TikZ nodes. |
| 7589 |
% \begin{macrocode} |
| 7590 |
\int_gset:Nn \g_tmpa_int 1 |
| 7591 |
\bool_if:NTF \g_@@_last_col_found_bool |
| 7592 |
{ \prg_replicate:nn { \int_max:nn { \g_@@_col_total_int - 3 } { 0 } } } |
| 7593 |
{ \prg_replicate:nn { \int_max:nn { \g_@@_col_total_int - 2 } { 0 } } } |
| 7594 |
{ |
| 7595 |
& |
| 7596 |
\omit |
| 7597 |
\int_gincr:N \g_tmpa_int |
| 7598 |
% \end{macrocode} |
| 7599 |
% The incrementation of the counter |\g_tmpa_int| must be done after the |\omit| |
| 7600 |
% of the cell. |
| 7601 |
% \begin{macrocode} |
| 7602 |
\skip_horizontal:N \g_tmpa_skip |
| 7603 |
\@@_mark_position:n { \int_eval:n { \g_tmpa_int + 1 } } |
| 7604 |
% \end{macrocode} |
| 7605 |
% We create the |col| node on the right of the current column. |
| 7606 |
% \begin{macrocode} |
| 7607 |
\pgfpicture |
| 7608 |
\pgfrememberpicturepositiononpagetrue |
| 7609 |
\pgfcoordinate { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } } |
| 7610 |
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } |
| 7611 |
\@@_node_alias:n { \int_eval:n { \g_tmpa_int + 1 } } |
| 7612 |
\endpgfpicture |
| 7613 |
} |
| 7614 |
% \end{macrocode} |
| 7615 |
% |
| 7616 |
% |
| 7617 |
% If there is only one column (and a potential ``last column''), we don't have |
| 7618 |
% to put the following code (there is only one column and we have put the |
| 7619 |
% correct code previously). |
| 7620 |
% \begin{macrocode} |
| 7621 |
\bool_lazy_or:nnF |
| 7622 |
{ \int_compare_p:nNn \g_@@_col_total_int = 1 } |
| 7623 |
{ \int_compare_p:nNn \g_@@_col_total_int = 2 && \g_@@_last_col_found_bool } |
| 7624 |
{ |
| 7625 |
& |
| 7626 |
\omit |
| 7627 |
\skip_horizontal:N \g_tmpa_skip |
| 7628 |
\int_gincr:N \g_tmpa_int |
| 7629 |
\bool_lazy_any:nF |
| 7630 |
{ |
| 7631 |
\g_@@_delims_bool |
| 7632 |
\l_@@_tabular_bool |
| 7633 |
{ ! \clist_if_empty_p:N \l_@@_vlines_clist } |
| 7634 |
\l_@@_exterior_arraycolsep_bool |
| 7635 |
\l_@@_bar_at_end_of_pream_bool |
| 7636 |
} |
| 7637 |
{ \skip_horizontal:n { - \col@sep } } |
| 7638 |
\bool_if:NT \l_@@_code_before_bool |
| 7639 |
{ |
| 7640 |
\hbox |
| 7641 |
{ |
| 7642 |
\skip_horizontal:n { -0.5 \arrayrulewidth } |
| 7643 |
% \end{macrocode} |
| 7644 |
% With an environment |{Matrix}|, you want to remove the exterior |\arraycolsep| |
| 7645 |
% but we don't know the number of columns (since there is no preamble) and |
| 7646 |
% that's why we can't put |@{}| at the end of the preamble. That's why we remove |
| 7647 |
% a |\arraycolsep| now. |
| 7648 |
% \begin{macrocode} |
| 7649 |
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool |
| 7650 |
{ \skip_horizontal:n { - \arraycolsep } } |
| 7651 |
\pgfsys@markposition |
| 7652 |
{ \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } } |
| 7653 |
\skip_horizontal:n { 0.5 \arrayrulewidth } |
| 7654 |
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool |
| 7655 |
{ \skip_horizontal:N \arraycolsep } |
| 7656 |
} |
| 7657 |
} |
| 7658 |
\pgfpicture |
| 7659 |
\pgfrememberpicturepositiononpagetrue |
| 7660 |
\pgfcoordinate { \@@_env: - col - \int_eval:n { \g_tmpa_int + 1 } } |
| 7661 |
{ |
| 7662 |
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool |
| 7663 |
{ |
| 7664 |
\pgfpoint |
| 7665 |
{ - 0.5 \arrayrulewidth - \arraycolsep } |
| 7666 |
\c_zero_dim |
| 7667 |
} |
| 7668 |
{ \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } |
| 7669 |
} |
| 7670 |
\@@_node_alias:n { \int_eval:n { \g_tmpa_int + 1 } } |
| 7671 |
\endpgfpicture |
| 7672 |
} |
| 7673 |
% \end{macrocode} |
| 7674 |
% |
| 7675 |
% \bigskip |
| 7676 |
% \begin{macrocode} |
| 7677 |
\bool_if:NT \g_@@_last_col_found_bool |
| 7678 |
{ |
| 7679 |
\hbox_overlap_right:n |
| 7680 |
{ |
| 7681 |
\skip_horizontal:N \g_@@_width_last_col_dim |
| 7682 |
\skip_horizontal:N \col@sep |
| 7683 |
\bool_if:NT \l_@@_code_before_bool |
| 7684 |
{ |
| 7685 |
\pgfsys@markposition |
| 7686 |
{ \@@_env: - col - \int_eval:n { \g_@@_col_total_int + 1 } } |
| 7687 |
} |
| 7688 |
\pgfpicture |
| 7689 |
\pgfrememberpicturepositiononpagetrue |
| 7690 |
\pgfcoordinate |
| 7691 |
{ \@@_env: - col - \int_eval:n { \g_@@_col_total_int + 1 } } |
| 7692 |
\pgfpointorigin |
| 7693 |
\@@_node_alias:n { \int_eval:n { \g_@@_col_total_int + 1 } } |
| 7694 |
\endpgfpicture |
| 7695 |
} |
| 7696 |
} |
| 7697 |
} |
| 7698 |
% \end{macrocode} |
| 7699 |
% |
| 7700 |
% \interitem |
| 7701 |
% \begin{macrocode} |
| 7702 |
\cs_new_protected:Npn \@@_mark_position:n #1 |
| 7703 |
{ |
| 7704 |
\bool_if:NT \l_@@_code_before_bool |
| 7705 |
{ |
| 7706 |
\hbox |
| 7707 |
{ |
| 7708 |
\skip_horizontal:n { -0.5 \arrayrulewidth } |
| 7709 |
\pgfsys@markposition { \@@_env: - col - #1 } |
| 7710 |
\skip_horizontal:n { 0.5 \arrayrulewidth } |
| 7711 |
} |
| 7712 |
} |
| 7713 |
} |
| 7714 |
% \end{macrocode} |
| 7715 |
% |
| 7716 |
% \begin{macrocode} |
| 7717 |
\cs_new_protected:Npn \@@_node_alias:n #1 |
| 7718 |
{ |
| 7719 |
\str_if_empty:NF \l_@@_name_str |
| 7720 |
{ \pgfnodealias { \l_@@_name_str - col - #1 } { \@@_env: - col - #1 } } |
| 7721 |
} |
| 7722 |
% \end{macrocode} |
| 7723 |
% |
| 7724 |
% |
| 7725 |
% \interitem |
| 7726 |
% Here is the preamble for the ``first column'' (if the user uses the key |
| 7727 |
% |first-col|) |
| 7728 |
% \begin{macrocode} |
| 7729 |
\tl_const:Nn \c_@@_preamble_first_col_tl |
| 7730 |
{ |
| 7731 |
> |
| 7732 |
{ |
| 7733 |
% \end{macrocode} |
| 7734 |
% At the beginning of the cell, we link |\CodeAfter| to a command which |
| 7735 |
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does |
| 7736 |
% not). |
| 7737 |
% \begin{macrocode} |
| 7738 |
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i: |
| 7739 |
\bool_gset_true:N \g_@@_after_col_zero_bool |
| 7740 |
\@@_begin_of_row: |
| 7741 |
\hbox_set:Nw \l_@@_cell_box |
| 7742 |
\@@_math_toggle: |
| 7743 |
\@@_tuning_key_small: |
| 7744 |
% \end{macrocode} |
| 7745 |
% We insert |\l_@@_code_for_first_col_tl|... but we don't insert it in the |
| 7746 |
% potential ``first row'' and in the potential ``last row''. |
| 7747 |
% \begin{macrocode} |
| 7748 |
\int_compare:nNnT \c@iRow > \c_zero_int |
| 7749 |
{ |
| 7750 |
\bool_lazy_or:nnT |
| 7751 |
{ \int_compare_p:nNn \l_@@_last_row_int < \c_zero_int } |
| 7752 |
{ \int_compare_p:nNn \c@iRow < \l_@@_last_row_int } |
| 7753 |
{ |
| 7754 |
\l_@@_code_for_first_col_tl |
| 7755 |
\xglobal \colorlet { nicematrix-first-col } { . } |
| 7756 |
} |
| 7757 |
} |
| 7758 |
} |
| 7759 |
% \end{macrocode} |
| 7760 |
% Be careful: despite this letter |l| the cells of the ``first column'' are |
| 7761 |
% composed in a |R| manner since they are composed in a |\hbox_overlap_left:n|. |
| 7762 |
% \begin{macrocode} |
| 7763 |
l |
| 7764 |
< |
| 7765 |
{ |
| 7766 |
\@@_math_toggle: |
| 7767 |
\hbox_set_end: |
| 7768 |
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: |
| 7769 |
\@@_adjust_size_box: |
| 7770 |
\@@_update_for_first_and_last_row: |
| 7771 |
% \end{macrocode} |
| 7772 |
% We actualise the width of the ``first column'' because we will use this width |
| 7773 |
% after the construction of the array. |
| 7774 |
% \begin{macrocode} |
| 7775 |
\dim_gset:Nn \g_@@_width_first_col_dim |
| 7776 |
{ \dim_max:nn \g_@@_width_first_col_dim { \box_wd:N \l_@@_cell_box } } |
| 7777 |
% \end{macrocode} |
| 7778 |
% The content of the cell is inserted in an overlapping position. |
| 7779 |
% \label{overlap-left} |
| 7780 |
% \begin{macrocode} |
| 7781 |
\hbox_overlap_left:n |
| 7782 |
{ |
| 7783 |
\dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim |
| 7784 |
\@@_node_cell: |
| 7785 |
{ \box_use_drop:N \l_@@_cell_box } |
| 7786 |
\skip_horizontal:N \l_@@_left_delim_dim |
| 7787 |
\skip_horizontal:N \l_@@_left_margin_dim |
| 7788 |
\skip_horizontal:N \l_@@_extra_left_margin_dim |
| 7789 |
} |
| 7790 |
\bool_gset_false:N \g_@@_empty_cell_bool |
| 7791 |
\skip_horizontal:n { -2 \col@sep } |
| 7792 |
} |
| 7793 |
} |
| 7794 |
% \end{macrocode} |
| 7795 |
% |
| 7796 |
% |
| 7797 |
% Here is the preamble for the ``last column'' (if the user uses the key |
| 7798 |
% |last-col|). |
| 7799 |
% \begin{macrocode} |
| 7800 |
\tl_const:Nn \c_@@_preamble_last_col_tl |
| 7801 |
{ |
| 7802 |
> |
| 7803 |
{ |
| 7804 |
\bool_set_true:N \l_@@_in_last_col_bool |
| 7805 |
% \end{macrocode} |
| 7806 |
% At the beginning of the cell, we link |\CodeAfter| to a command which |
| 7807 |
% begins with |\\| (whereas the standard version of |\CodeAfter| begins does |
| 7808 |
% not). |
| 7809 |
% \begin{macrocode} |
| 7810 |
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i: |
| 7811 |
% \end{macrocode} |
| 7812 |
% With the flag |\g_@@_last_col_found_bool|, we will know that the ``last |
| 7813 |
% column'' is really used. |
| 7814 |
% \begin{macrocode} |
| 7815 |
\bool_gset_true:N \g_@@_last_col_found_bool |
| 7816 |
\int_gincr:N \c@jCol |
| 7817 |
\int_gset_eq:NN \g_@@_col_total_int \c@jCol |
| 7818 |
\hbox_set:Nw \l_@@_cell_box |
| 7819 |
\@@_math_toggle: |
| 7820 |
\@@_tuning_key_small: |
| 7821 |
% \end{macrocode} |
| 7822 |
% We insert |\l_@@_code_for_last_col_tl|... but we don't insert it in the |
| 7823 |
% potential ``first row'' and in the potential ``last row''. |
| 7824 |
% \begin{macrocode} |
| 7825 |
\int_compare:nNnT \c@iRow > \c_zero_int |
| 7826 |
{ |
| 7827 |
\bool_lazy_or:nnT |
| 7828 |
{ \int_compare_p:nNn \l_@@_last_row_int < \c_zero_int } |
| 7829 |
{ \int_compare_p:nNn \c@iRow < \l_@@_last_row_int } |
| 7830 |
{ |
| 7831 |
\l_@@_code_for_last_col_tl |
| 7832 |
\xglobal \colorlet { nicematrix-last-col } { . } |
| 7833 |
} |
| 7834 |
} |
| 7835 |
} |
| 7836 |
l |
| 7837 |
< |
| 7838 |
{ |
| 7839 |
\@@_math_toggle: |
| 7840 |
\hbox_set_end: |
| 7841 |
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: |
| 7842 |
\@@_adjust_size_box: |
| 7843 |
\@@_update_for_first_and_last_row: |
| 7844 |
% \end{macrocode} |
| 7845 |
% We actualise the width of the ``last column'' because we will use this width |
| 7846 |
% after the construction of the array. |
| 7847 |
% \begin{macrocode} |
| 7848 |
\dim_gset:Nn \g_@@_width_last_col_dim |
| 7849 |
{ \dim_max:nn \g_@@_width_last_col_dim { \box_wd:N \l_@@_cell_box } } |
| 7850 |
\skip_horizontal:n { -2 \col@sep } |
| 7851 |
% \end{macrocode} |
| 7852 |
% The content of the cell is inserted in an overlapping position. |
| 7853 |
% \label{overlap-right} |
| 7854 |
% \begin{macrocode} |
| 7855 |
\hbox_overlap_right:n |
| 7856 |
{ |
| 7857 |
\dim_compare:nNnT { \box_wd:N \l_@@_cell_box } > \c_zero_dim |
| 7858 |
{ |
| 7859 |
\skip_horizontal:N \l_@@_right_delim_dim |
| 7860 |
\skip_horizontal:N \l_@@_right_margin_dim |
| 7861 |
\skip_horizontal:N \l_@@_extra_right_margin_dim |
| 7862 |
\@@_node_cell: |
| 7863 |
} |
| 7864 |
} |
| 7865 |
\bool_gset_false:N \g_@@_empty_cell_bool |
| 7866 |
} |
| 7867 |
} |
| 7868 |
% \end{macrocode} |
| 7869 |
% |
| 7870 |
% |
| 7871 |
% \interitem |
| 7872 |
% The environment |{NiceArray}| is constructed upon the environment |
| 7873 |
% |{NiceArrayWithDelims}|. |
| 7874 |
% \begin{macrocode} |
| 7875 |
\NewDocumentEnvironment { NiceArray } { } |
| 7876 |
{ |
| 7877 |
\bool_gset_false:N \g_@@_delims_bool |
| 7878 |
\str_if_empty:NT \g_@@_name_env_str |
| 7879 |
{ \str_gset:Nn \g_@@_name_env_str { NiceArray } } |
| 7880 |
% \end{macrocode} |
| 7881 |
% We put . and . for the delimiters but, in fact, that doesn't matter because |
| 7882 |
% these arguments won't be used in |{NiceArrayWithDelims}| (because the flag |
| 7883 |
% |\g_@@_delims_bool| is set to false). |
| 7884 |
% \begin{macrocode} |
| 7885 |
\NiceArrayWithDelims . . |
| 7886 |
} |
| 7887 |
{ \endNiceArrayWithDelims } |
| 7888 |
% \end{macrocode} |
| 7889 |
% |
| 7890 |
% |
| 7891 |
% \interitem |
| 7892 |
% We create the variants of the environment |{NiceArrayWithDelims}|. |
| 7893 |
% |
| 7894 |
% \begin{macrocode} |
| 7895 |
\cs_new_protected:Npn \@@_def_env:NNN #1 #2 #3 |
| 7896 |
{ |
| 7897 |
\NewDocumentEnvironment { #1 NiceArray } { } |
| 7898 |
{ |
| 7899 |
\bool_gset_true:N \g_@@_delims_bool |
| 7900 |
\str_if_empty:NT \g_@@_name_env_str |
| 7901 |
{ \str_gset:Nn \g_@@_name_env_str { #1 NiceArray } } |
| 7902 |
\@@_test_if_math_mode: |
| 7903 |
\NiceArrayWithDelims #2 #3 |
| 7904 |
} |
| 7905 |
{ \endNiceArrayWithDelims } |
| 7906 |
} |
| 7907 |
% \end{macrocode} |
| 7908 |
% |
| 7909 |
% \begin{macrocode} |
| 7910 |
\@@_def_env:NNN p ( ) |
| 7911 |
\@@_def_env:NNN b [ ] |
| 7912 |
\@@_def_env:NNN B \{ \} |
| 7913 |
\@@_def_env:NNN v \vert \vert |
| 7914 |
\@@_def_env:NNN V \Vert \Vert |
| 7915 |
% \end{macrocode} |
| 7916 |
% |
| 7917 |
% \bigskip |
| 7918 |
% \section{The environment \{NiceMatrix\} and its variants} |
| 7919 |
% |
| 7920 |
% \subsection{Definition of \{pNiceMatrix\} } |
| 7921 |
% |
| 7922 |
% \begin{macrocode} |
| 7923 |
\cs_new_protected:Npn \@@_begin_of_NiceMatrix:nn #1 #2 |
| 7924 |
{ |
| 7925 |
\bool_set_false:N \l_@@_preamble_bool |
| 7926 |
\tl_clear:N \l_tmpa_tl |
| 7927 |
\bool_if:NT \l_@@_NiceMatrix_without_vlines_bool |
| 7928 |
{ \tl_set:Nn \l_tmpa_tl { @ { } } } |
| 7929 |
\tl_put_right:Nn \l_tmpa_tl |
| 7930 |
{ |
| 7931 |
* |
| 7932 |
{ |
| 7933 |
\int_case:nnF \l_@@_last_col_int |
| 7934 |
{ |
| 7935 |
{ -2 } { \c@MaxMatrixCols } |
| 7936 |
{ -1 } { \int_eval:n { \c@MaxMatrixCols + 1 } } |
| 7937 |
% \end{macrocode} |
| 7938 |
% The value $0$ can't occur here since we are in a matrix (which is an |
| 7939 |
% environment without preamble). |
| 7940 |
% \begin{macrocode} |
| 7941 |
} |
| 7942 |
{ \int_eval:n { \l_@@_last_col_int - 1 } } |
| 7943 |
} |
| 7944 |
{ #2 } |
| 7945 |
} |
| 7946 |
\tl_set:Nn \l_tmpb_tl { \use:c { #1 NiceArray } } |
| 7947 |
\exp_args:No \l_tmpb_tl \l_tmpa_tl |
| 7948 |
} |
| 7949 |
\cs_generate_variant:Nn \@@_begin_of_NiceMatrix:nn { n o } |
| 7950 |
% \end{macrocode} |
| 7951 |
% |
| 7952 |
% |
| 7953 |
% \begin{macrocode} |
| 7954 |
\clist_map_inline:nn { p , b , B , v , V } |
| 7955 |
{ |
| 7956 |
\NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } |
| 7957 |
{ |
| 7958 |
\bool_gset_true:N \g_@@_delims_bool |
| 7959 |
\str_gset:Nn \g_@@_name_env_str { #1 NiceMatrix } |
| 7960 |
\int_if_zero:nT \l_@@_last_col_int |
| 7961 |
{ |
| 7962 |
\bool_set_true:N \l_@@_last_col_without_value_bool |
| 7963 |
\int_set:Nn \l_@@_last_col_int { -1 } |
| 7964 |
} |
| 7965 |
\keys_set:nn { nicematrix / NiceMatrix } { ##1 } |
| 7966 |
\@@_begin_of_NiceMatrix:no { #1 } { \l_@@_columns_type_tl } |
| 7967 |
} |
| 7968 |
{ \use:c { end #1 NiceArray } } |
| 7969 |
} |
| 7970 |
% \end{macrocode} |
| 7971 |
% |
| 7972 |
% \bigskip |
| 7973 |
% We define also an environment |{NiceMatrix}| |
| 7974 |
% \begin{macrocode} |
| 7975 |
\NewDocumentEnvironment { NiceMatrix } { ! O { } } |
| 7976 |
{ |
| 7977 |
\str_gset:Nn \g_@@_name_env_str { NiceMatrix } |
| 7978 |
\int_if_zero:nT \l_@@_last_col_int |
| 7979 |
{ |
| 7980 |
\bool_set_true:N \l_@@_last_col_without_value_bool |
| 7981 |
\int_set:Nn \l_@@_last_col_int { -1 } |
| 7982 |
} |
| 7983 |
\keys_set:nn { nicematrix / NiceMatrix } { #1 } |
| 7984 |
\bool_lazy_or:nnT |
| 7985 |
\l_@@_except_borders_bool |
| 7986 |
{ \clist_if_empty_p:N \l_@@_vlines_clist } |
| 7987 |
{ \bool_set_true:N \l_@@_NiceMatrix_without_vlines_bool } |
| 7988 |
\@@_begin_of_NiceMatrix:no { } { \l_@@_columns_type_tl } |
| 7989 |
} |
| 7990 |
{ \endNiceArray } |
| 7991 |
% \end{macrocode} |
| 7992 |
% |
| 7993 |
% \bigskip |
| 7994 |
% The following command will be linked to |\NotEmpty| in the environments of |
| 7995 |
% \pkg{nicematrix}. |
| 7996 |
% \begin{macrocode} |
| 7997 |
\cs_new_protected:Npn \@@_NotEmpty: |
| 7998 |
{ \bool_gset_true:N \g_@@_not_empty_cell_bool } |
| 7999 |
% \end{macrocode} |
| 8000 |
% |
| 8001 |
% \bigskip |
| 8002 |
% |
| 8003 |
% \subsection{The key renew-matrix} |
| 8004 |
% |
| 8005 |
% \begin{macrocode} |
| 8006 |
\cs_set_protected:Npn \@@_renew_matrix: |
| 8007 |
{ |
| 8008 |
\tl_map_inline:nn { pvVbB } |
| 8009 |
{ \RenewEnvironmentCopy { ##1matrix } { ##1NiceMatrix } } |
| 8010 |
} |
| 8011 |
% \end{macrocode} |
| 8012 |
% |
| 8013 |
% |
| 8014 |
% \bigskip |
| 8015 |
% \section{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}} |
| 8016 |
% |
| 8017 |
% \begin{macrocode} |
| 8018 |
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } |
| 8019 |
{ |
| 8020 |
% \end{macrocode} |
| 8021 |
% If the dimension |\l_@@_width_dim| is equal to $0$~pt, that means that it has |
| 8022 |
% not been set by a previous use of |\NiceMatrixOptions|. |
| 8023 |
% \begin{macrocode} |
| 8024 |
\dim_compare:nNnT\l_@@_width_dim = \c_zero_dim |
| 8025 |
{ \dim_set_eq:NN \l_@@_width_dim \linewidth } |
| 8026 |
\str_gset:Nn \g_@@_name_env_str { NiceTabular } |
| 8027 |
\keys_set:nn { nicematrix / NiceTabular } { #1 , #3 } |
| 8028 |
\tl_if_empty:NF \l_@@_short_caption_tl |
| 8029 |
{ |
| 8030 |
\tl_if_empty:NT \l_@@_caption_tl |
| 8031 |
{ |
| 8032 |
\@@_error_or_warning:n { short-caption~without~caption } |
| 8033 |
\tl_set_eq:NN \l_@@_caption_tl \l_@@_short_caption_tl |
| 8034 |
} |
| 8035 |
} |
| 8036 |
\tl_if_empty:NF \l_@@_label_tl |
| 8037 |
{ |
| 8038 |
\tl_if_empty:NT \l_@@_caption_tl |
| 8039 |
{ \@@_error_or_warning:n { label~without~caption } } |
| 8040 |
} |
| 8041 |
\NewDocumentEnvironment { TabularNote } { b } |
| 8042 |
{ |
| 8043 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 8044 |
{ \@@_error_or_warning:n { TabularNote~in~CodeAfter } } |
| 8045 |
{ |
| 8046 |
\tl_if_empty:NF \g_@@_tabularnote_tl |
| 8047 |
{ \tl_gput_right:Nn \g_@@_tabularnote_tl { \par } } |
| 8048 |
\tl_gput_right:Nn \g_@@_tabularnote_tl { ##1 } |
| 8049 |
} |
| 8050 |
} |
| 8051 |
{ } |
| 8052 |
\@@_settings_for_tabular: |
| 8053 |
\NiceArray { #2 } |
| 8054 |
} |
| 8055 |
{ \endNiceArray } |
| 8056 |
% \end{macrocode} |
| 8057 |
% |
| 8058 |
% \begin{macrocode} |
| 8059 |
\cs_new_protected:Npn \@@_settings_for_tabular: |
| 8060 |
{ |
| 8061 |
\bool_set_true:N \l_@@_tabular_bool |
| 8062 |
\cs_set_eq:NN \@@_math_toggle: \prg_do_nothing: |
| 8063 |
\cs_set_eq:NN \@@_tuning_not_tabular_begin: \prg_do_nothing: |
| 8064 |
\cs_set_eq:NN \@@_tuning_not_tabular_end: \prg_do_nothing: |
| 8065 |
} |
| 8066 |
% \end{macrocode} |
| 8067 |
% |
| 8068 |
% \bigskip |
| 8069 |
% \begin{macrocode} |
| 8070 |
\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } } |
| 8071 |
{ |
| 8072 |
\str_gset:Nn \g_@@_name_env_str { NiceTabularX } |
| 8073 |
\dim_set:Nn \l_@@_width_dim { #1 } |
| 8074 |
\keys_set:nn { nicematrix / NiceTabular } { #2 , #4 } |
| 8075 |
\@@_settings_for_tabular: |
| 8076 |
\NiceArray { #3 } |
| 8077 |
} |
| 8078 |
{ |
| 8079 |
\endNiceArray |
| 8080 |
\fp_compare:nNnT { \g_@@_total_X_weight_fp } = { \c_zero_fp } |
| 8081 |
{ \@@_error:n { NiceTabularX~without~X } } |
| 8082 |
} |
| 8083 |
% \end{macrocode} |
| 8084 |
% |
| 8085 |
% \bigskip |
| 8086 |
% \begin{macrocode} |
| 8087 |
\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } } |
| 8088 |
{ |
| 8089 |
\str_gset:Nn \g_@@_name_env_str { NiceTabular* } |
| 8090 |
\dim_set:Nn \l_@@_tabular_width_dim { #1 } |
| 8091 |
\keys_set:nn { nicematrix / NiceTabular } { #2 , #4 } |
| 8092 |
\@@_settings_for_tabular: |
| 8093 |
\NiceArray { #3 } |
| 8094 |
} |
| 8095 |
{ \endNiceArray } |
| 8096 |
% \end{macrocode} |
| 8097 |
% |
| 8098 |
% |
| 8099 |
% \bigskip |
| 8100 |
% \section{After the construction of the array} |
| 8101 |
% |
| 8102 |
% \bigskip |
| 8103 |
% The following command will be used when the key |rounded-corners| is in force |
| 8104 |
% (this is the key |rounded-corners| for the whole environment and \emph{not} |
| 8105 |
% the key |rounded-corners| of a command |\Block|). |
| 8106 |
% \begin{macrocode} |
| 8107 |
\cs_new_protected:Npn \@@_deal_with_rounded_corners: |
| 8108 |
{ |
| 8109 |
\bool_lazy_all:nT |
| 8110 |
{ |
| 8111 |
{ \dim_compare_p:nNn \l_@@_tab_rounded_corners_dim > \c_zero_dim } |
| 8112 |
{ \l_@@_hvlines_bool } |
| 8113 |
{ ! \g_@@_delims_bool } |
| 8114 |
{ ! \l_@@_except_borders_bool } |
| 8115 |
} |
| 8116 |
{ |
| 8117 |
\bool_set_true:N \l_@@_except_borders_bool |
| 8118 |
\clist_if_empty:NF \l_@@_corners_clist |
| 8119 |
{ \@@_error:n { hvlines,~rounded-corners~and~corners } } |
| 8120 |
\tl_gput_right:Nn \g_@@_rules_tl |
| 8121 |
{ |
| 8122 |
\@@_stroke_block:nnnnn |
| 8123 |
{ |
| 8124 |
rounded-corners = \dim_use:N \l_@@_tab_rounded_corners_dim , |
| 8125 |
draw = \l_@@_rules_color_tl |
| 8126 |
} |
| 8127 |
{ 1 } { 1 } { \int_use:N \c@iRow } { \int_use:N \c@jCol } |
| 8128 |
} |
| 8129 |
} |
| 8130 |
} |
| 8131 |
% \end{macrocode} |
| 8132 |
% |
| 8133 |
% |
| 8134 |
% \medskip |
| 8135 |
% \begin{macrocode} |
| 8136 |
\cs_new_protected:Npn \@@_after_array: |
| 8137 |
{ |
| 8138 |
% \end{macrocode} |
| 8139 |
% There was a |\hook_gput_code:nnn { env / tabular / begin } { nicematrix }| in |
| 8140 |
% the command |\@@_pre_array_after_CodeBefore:| in order to come back to the |
| 8141 |
% standard definition of |\multicolumn| (in the tabulars used by the final user |
| 8142 |
% in the cells of our array of \pkg{nicematrix}) and maybe another linked to |
| 8143 |
% \pkg{colortbl}. |
| 8144 |
% \begin{macrocode} |
| 8145 |
\hook_gremove_code:nn { env / tabular / begin } { nicematrix } |
| 8146 |
\group_begin: |
| 8147 |
% \end{macrocode} |
| 8148 |
% When the option |last-col| is used in the environments with explicit preambles |
| 8149 |
% (like |{NiceArray}|, |{pNiceArray}|, etc.) a special type of column is used at |
| 8150 |
% the end of the preamble in order to compose the cells in an overlapping |
| 8151 |
% position (with |\hbox_overlap_right:n|) but (if |last-col| has been used), we |
| 8152 |
% don't have the number of that last column. However, we have to know that |
| 8153 |
% number for the color of the potential |\Vdots| drawn in that last column. |
| 8154 |
% That's why we fix the correct value of |\l_@@_last_col_int| in that case. |
| 8155 |
% \begin{macrocode} |
| 8156 |
\bool_if:NT \g_@@_last_col_found_bool |
| 8157 |
{ \int_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int } |
| 8158 |
% \end{macrocode} |
| 8159 |
% |
| 8160 |
% If we are in an environment without preamble (like |{NiceMatrix}| or |
| 8161 |
% |{pNiceMatrix}|) and if the option |last-col| has been used without value |
| 8162 |
% we also fix the real value of |\l_@@_last_col_int|. |
| 8163 |
% \begin{macrocode} |
| 8164 |
\bool_if:NT \l_@@_last_col_without_value_bool |
| 8165 |
{ \int_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int } |
| 8166 |
% \end{macrocode} |
| 8167 |
% |
| 8168 |
% \medskip |
| 8169 |
% It's also time to give to |\l_@@_last_row_int| its real value. |
| 8170 |
% \begin{macrocode} |
| 8171 |
\bool_if:NT \l_@@_last_row_without_value_bool |
| 8172 |
{ \int_set_eq:NN \l_@@_last_row_int \g_@@_row_total_int } |
| 8173 |
% \end{macrocode} |
| 8174 |
% |
| 8175 |
% \medskip |
| 8176 |
% \begin{macrocode} |
| 8177 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 8178 |
{ |
| 8179 |
\seq_gset_from_clist:Nn \exp_not:N \g_@@_size_seq |
| 8180 |
{ |
| 8181 |
\int_use:N \l_@@_first_row_int , |
| 8182 |
\int_use:N \c@iRow , |
| 8183 |
\int_use:N \g_@@_row_total_int , |
| 8184 |
\int_use:N \l_@@_first_col_int , |
| 8185 |
\int_use:N \c@jCol , |
| 8186 |
\int_use:N \g_@@_col_total_int |
| 8187 |
} |
| 8188 |
} |
| 8189 |
% \end{macrocode} |
| 8190 |
% |
| 8191 |
% \begin{macrocode} |
| 8192 |
\clist_if_empty:NF \g_@@_cbic_clist \@@_create_blocks_in_col: |
| 8193 |
% \end{macrocode} |
| 8194 |
% |
| 8195 |
% \begin{macrocode} |
| 8196 |
% \end{macrocode} |
| 8197 |
% |
| 8198 |
% We write also the potential content of |\g_@@_pos_of_blocks_seq|. It will be |
| 8199 |
% used to recreate the blocks with a name in the |\CodeBefore| and also if the |
| 8200 |
% command |\rowcolors| is used with the key |respect-blocks|). |
| 8201 |
% \begin{macrocode} |
| 8202 |
\seq_if_empty:NF \g_@@_pos_of_blocks_seq |
| 8203 |
{ |
| 8204 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 8205 |
{ |
| 8206 |
\seq_gset_from_clist:Nn \exp_not:N \g_@@_pos_of_blocks_seq |
| 8207 |
{ \seq_use:Nn \g_@@_pos_of_blocks_seq { , } } |
| 8208 |
} |
| 8209 |
} |
| 8210 |
\seq_if_empty:NF \g_@@_multicolumn_cells_seq |
| 8211 |
{ |
| 8212 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 8213 |
{ |
| 8214 |
\seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_cells_seq |
| 8215 |
{ \seq_use:Nn \g_@@_multicolumn_cells_seq { , } } |
| 8216 |
\seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_sizes_seq |
| 8217 |
{ \seq_use:Nn \g_@@_multicolumn_sizes_seq { , } } |
| 8218 |
} |
| 8219 |
} |
| 8220 |
% \end{macrocode} |
| 8221 |
% |
| 8222 |
% \medskip |
| 8223 |
% Now, you create the diagonal nodes by using the |row| nodes and the |col| |
| 8224 |
% nodes. |
| 8225 |
% \begin{macrocode} |
| 8226 |
\@@_create_diag_nodes: |
| 8227 |
% \end{macrocode} |
| 8228 |
% |
| 8229 |
% \medskip |
| 8230 |
% We create the aliases using |last| for the nodes of the cells in the last row |
| 8231 |
% and the last column. |
| 8232 |
% \begin{macrocode} |
| 8233 |
\pgfpicture |
| 8234 |
\@@_create_aliases_last: |
| 8235 |
\str_if_empty:NF \l_@@_name_str \@@_create_alias_nodes: |
| 8236 |
\endpgfpicture |
| 8237 |
% \end{macrocode} |
| 8238 |
% |
| 8239 |
% By default, the diagonal lines will be parallelized\footnote{It's possible to |
| 8240 |
% use the option |parallelize-diags| to disable this parallelization.}. There |
| 8241 |
% are two types of diagonals lines: the $|\Ddots|$ diagonals and the |\Iddots| |
| 8242 |
% diagonals. We have to count both types in order to know whether a diagonal is |
| 8243 |
% the first of its type in the current |{NiceArray}| environment. |
| 8244 |
% \begin{macrocode} |
| 8245 |
\bool_if:NT \l_@@_parallelize_diags_bool |
| 8246 |
{ |
| 8247 |
\int_gzero:N \g_@@_ddots_int |
| 8248 |
\int_gzero:N \g_@@_iddots_int |
| 8249 |
% \end{macrocode} |
| 8250 |
% |
| 8251 |
% The dimensions |\g_@@_delta_x_one_dim| and |\g_@@_delta_y_one_dim| will |
| 8252 |
% contain the $\Delta_x$ and $\Delta_y$ of the first |\Ddots| diagonal. We have |
| 8253 |
% to store these values in order to draw the others |\Ddots| diagonals parallel |
| 8254 |
% to the first one. Similarly |\g_@@_delta_x_two_dim| and |
| 8255 |
% |\g_@@_delta_y_two_dim| are the $\Delta_x$ and $\Delta_y$ of the first |
| 8256 |
% |\Iddots| diagonal. |
| 8257 |
% \begin{macrocode} |
| 8258 |
\dim_gzero:N \g_@@_delta_x_one_dim |
| 8259 |
\dim_gzero:N \g_@@_delta_y_one_dim |
| 8260 |
\dim_gzero:N \g_@@_delta_x_two_dim |
| 8261 |
\dim_gzero:N \g_@@_delta_y_two_dim |
| 8262 |
} |
| 8263 |
% \end{macrocode} |
| 8264 |
% |
| 8265 |
% \begin{macrocode} |
| 8266 |
\bool_set_false:N \l_@@_initial_open_bool |
| 8267 |
\bool_set_false:N \l_@@_final_open_bool |
| 8268 |
% \end{macrocode} |
| 8269 |
% |
| 8270 |
% If the option |small| is used, the values |\l_@@_xdots_radius_dim| and |
| 8271 |
% |\l_@@_xdots_inter_dim| (used to draw the dotted lines created by |
| 8272 |
% |\hdottedline| and |\vdottedline| and also for all the other dotted lines when |
| 8273 |
% |line-style| is equal to |standard|, which is the initial value) are changed. |
| 8274 |
% \begin{macrocode} |
| 8275 |
\bool_if:NT \l_@@_small_bool { \@@_tuning_key_small_for_dots: } |
| 8276 |
% \end{macrocode} |
| 8277 |
% |
| 8278 |
% \bigskip |
| 8279 |
% Now, we actually draw the dotted lines (specified by |\Cdots|, |\Vdots|, |
| 8280 |
% etc.). |
| 8281 |
% \begin{macrocode} |
| 8282 |
\@@_draw_dotted_lines: |
| 8283 |
% \end{macrocode} |
| 8284 |
% |
| 8285 |
% |
| 8286 |
% \bigskip |
| 8287 |
% The following computes the ``corners'' (made up of empty cells) but if there |
| 8288 |
% is no corner to compute, it won't do anything. The corners are computed |
| 8289 |
% in |\l_@@_corners_cells_clist| which will contain all the cells which are empty |
| 8290 |
% (and not in a block) considered in the corners of the array. |
| 8291 |
% \begin{macrocode} |
| 8292 |
\clist_if_empty:NF \l_@@_corners_clist |
| 8293 |
{ |
| 8294 |
\bool_if:NTF \l_@@_no_cell_nodes_bool |
| 8295 |
{ \@@_error:n { corners~with~no-cell-nodes } } |
| 8296 |
\@@_compute_corners: |
| 8297 |
} |
| 8298 |
% \end{macrocode} |
| 8299 |
% |
| 8300 |
% \bigskip |
| 8301 |
% By design, we have computed the corners before the adjonction of |
| 8302 |
% |\g_@@_future_pos_of_blocks_seq| is used by |\EmptyRow| and |\EmptyColumn| in the |
| 8303 |
% |\CodeBefore|. |
| 8304 |
% \begin{macrocode} |
| 8305 |
\seq_gconcat:NNN \g_@@_pos_of_blocks_seq |
| 8306 |
\g_@@_pos_of_blocks_seq |
| 8307 |
\g_@@_future_pos_of_blocks_seq |
| 8308 |
\seq_gclear:N \g_@@_future_pos_of_blocks_seq |
| 8309 |
% \end{macrocode} |
| 8310 |
% |
| 8311 |
% \bigskip |
| 8312 |
% The sequence |\g_@@_pos_of_blocks_seq| must be ``adjusted'' (for the case |
| 8313 |
% where the user have written something like |\Block{1-*}|). |
| 8314 |
% \begin{macrocode} |
| 8315 |
\@@_adjust_pos_of_blocks_seq: |
| 8316 |
% \end{macrocode} |
| 8317 |
% |
| 8318 |
% \begin{macrocode} |
| 8319 |
\@@_deal_with_rounded_corners: |
| 8320 |
\legacy_if:nF { measuring@ } \@@_draw_rules: |
| 8321 |
\tl_gclear:N \g_@@_rules_tl |
| 8322 |
% \end{macrocode} |
| 8323 |
% |
| 8324 |
% \bigskip |
| 8325 |
% Now, the pre-code-after and then, the |\CodeAfter|. |
| 8326 |
% \begin{macrocode} |
| 8327 |
\IfPackageLoadedT { tikz } |
| 8328 |
{ |
| 8329 |
\tikzset |
| 8330 |
{ |
| 8331 |
every~picture / .style = |
| 8332 |
{ |
| 8333 |
overlay , |
| 8334 |
remember~picture , |
| 8335 |
name~prefix = \@@_env: - |
| 8336 |
} |
| 8337 |
} |
| 8338 |
} |
| 8339 |
\cs_set_eq:NN \ar@ialign \@@_old_ar@ialign: |
| 8340 |
\cs_set_eq:NN \SubMatrix \@@_SubMatrix |
| 8341 |
\cs_set_eq:NN \UnderBrace \@@_UnderBrace |
| 8342 |
\cs_set_eq:NN \OverBrace \@@_OverBrace |
| 8343 |
\cs_set_eq:NN \ShowCellNames \@@_ShowCellNames |
| 8344 |
\cs_set_eq:NN \TikzEveryCell \@@_TikzEveryCell |
| 8345 |
\cs_set_eq:NN \line \@@_line |
| 8346 |
% \end{macrocode} |
| 8347 |
% |
| 8348 |
% The LaTeX-style boolean |\ifmeasuring@| is used by \pkg{amsmath} during the |
| 8349 |
% phase of measure in environments such as |{align}|, etc. |
| 8350 |
% \begin{macrocode} |
| 8351 |
\legacy_if:nF { measuring@ } \g_@@_pre_code_after_tl |
| 8352 |
\tl_gclear:N \g_@@_pre_code_after_tl |
| 8353 |
% \end{macrocode} |
| 8354 |
% When |light-syntax| is used, we insert systematically a |\CodeAfter| in the |
| 8355 |
% flow. Thus, it's possible to have two instructions |\CodeAfter| and the second |
| 8356 |
% may be in |\g_nicematrix_code_after_tl|. That's why we set |
| 8357 |
% |\CodeAfter| to be \textsl{no-op} now. |
| 8358 |
% \begin{macrocode} |
| 8359 |
\cs_set_eq:NN \CodeAfter \prg_do_nothing: |
| 8360 |
% \end{macrocode} |
| 8361 |
% |
| 8362 |
% We clear the list of the names of the potential |\SubMatrix| that will appear |
| 8363 |
% in the |\CodeAfter| (unfortunately, that list has to be global). |
| 8364 |
% \begin{macrocode} |
| 8365 |
\seq_gclear:N \g_@@_submatrix_names_seq |
| 8366 |
% \end{macrocode} |
| 8367 |
% |
| 8368 |
% \medskip |
| 8369 |
% The following code is a security for the case the user has used \pkg{babel} |
| 8370 |
% with the option \pkg{spanish}: in that case, the characters |>| and |<| are |
| 8371 |
% activated and TikZ is not able to solve the problem (even with the TikZ |
| 8372 |
% library \pkg{babel}). |
| 8373 |
% \begin{macrocode} |
| 8374 |
\int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } |
| 8375 |
{ \@@_rescan_for_spanish:N \g_nicematrix_code_after_tl } |
| 8376 |
% \end{macrocode} |
| 8377 |
% |
| 8378 |
% \medskip |
| 8379 |
% And here's the |\CodeAfter|. Since the |\CodeAfter| may begin with an |
| 8380 |
% ``argument'' between square brackets of the options, we extract and treat that |
| 8381 |
% potential ``argument'' with the command |\@@_CodeAfter_keys:|. |
| 8382 |
% \begin{macrocode} |
| 8383 |
\bool_set_true:N \l_@@_in_code_after_bool |
| 8384 |
\exp_last_unbraced:No \@@_CodeAfter_keys: \g_nicematrix_code_after_tl |
| 8385 |
\scan_stop: |
| 8386 |
\tl_gclear:N \g_nicematrix_code_after_tl |
| 8387 |
\clist_if_empty:NF \g_@@_col_with_trees_clist \@@_draw_trees: |
| 8388 |
\group_end: |
| 8389 |
% \end{macrocode} |
| 8390 |
% |
| 8391 |
% |
| 8392 |
% \medskip |
| 8393 |
% |\g_@@_pre_code_before_tl| is for instructions in the cells of the array such as |
| 8394 |
% |\rowcolor| and |\cellcolor|. These instructions will be written on the |aux| |
| 8395 |
% file to be added to the |code-before| in the next run. |
| 8396 |
% \begin{macrocode} |
| 8397 |
\seq_if_empty:NF \g_@@_rowlistcolors_seq \@@_clear_rowlistcolors_seq: |
| 8398 |
\tl_if_empty:NF \g_@@_pre_code_before_tl |
| 8399 |
{ |
| 8400 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 8401 |
{ |
| 8402 |
\tl_gset:Nn \exp_not:N \g_@@_pre_code_before_tl |
| 8403 |
{ \exp_not:o \g_@@_pre_code_before_tl } |
| 8404 |
} |
| 8405 |
\tl_gclear:N \g_@@_pre_code_before_tl |
| 8406 |
} |
| 8407 |
\tl_if_empty:NF \g_nicematrix_code_before_tl |
| 8408 |
{ |
| 8409 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 8410 |
{ |
| 8411 |
\tl_gset:Nn \exp_not:N \g_@@_code_before_tl |
| 8412 |
{ \exp_not:o \g_nicematrix_code_before_tl } |
| 8413 |
} |
| 8414 |
\tl_gclear:N \g_nicematrix_code_before_tl |
| 8415 |
} |
| 8416 |
% \end{macrocode} |
| 8417 |
% |
| 8418 |
% \medskip |
| 8419 |
% \begin{macrocode} |
| 8420 |
\str_gclear:N \g_@@_name_env_str |
| 8421 |
\@@_restore_iRow_jCol: |
| 8422 |
% \end{macrocode} |
| 8423 |
% The command |\CT@arc@| contains the instruction of color for the rules of the |
| 8424 |
% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |
| 8425 |
% |\CT@arc@| but we use it also for compatibility with \pkg{colortbl}. But we |
| 8426 |
% want also to be able to use color for the rules of the array when |
| 8427 |
% \pkg{colortbl} is \emph{not} loaded. That's why we do the following |
| 8428 |
% instruction which is in the patch of the end of arrays done by \pkg{colortbl}. |
| 8429 |
% \begin{macrocode} |
| 8430 |
\cs_gset_eq:NN \CT@arc@ \@@_old_CT@arc@ |
| 8431 |
} |
| 8432 |
% \end{macrocode} |
| 8433 |
% |
| 8434 |
% \bigskip |
| 8435 |
% \begin{macrocode} |
| 8436 |
\cs_new_protected:Npn \@@_tuning_key_small_for_dots: |
| 8437 |
{ |
| 8438 |
\dim_set:Nn \l_@@_xdots_radius_dim { 0.7 \l_@@_xdots_radius_dim } |
| 8439 |
\dim_set:Nn \l_@@_xdots_inter_dim { 0.55 \l_@@_xdots_inter_dim } |
| 8440 |
% \end{macrocode} |
| 8441 |
% The dimensions |\l_@@_xdots_shorten_start_dim| and |
| 8442 |
% |\l_@@_xdots_shorten_start_dim| correspond to the options |
| 8443 |
% |xdots/shorten-start| and |xdots/shorten-end| available to the user. |
| 8444 |
% \begin{macrocode} |
| 8445 |
\dim_set:Nn \l_@@_xdots_shorten_start_dim |
| 8446 |
{ 0.6 \l_@@_xdots_shorten_start_dim } |
| 8447 |
\dim_set:Nn \l_@@_xdots_shorten_end_dim |
| 8448 |
{ 0.6 \l_@@_xdots_shorten_end_dim } |
| 8449 |
} |
| 8450 |
% \end{macrocode} |
| 8451 |
% |
| 8452 |
% \bigskip |
| 8453 |
% The following command will extract the potential options (between square |
| 8454 |
% brackets) at the beginning of the |\CodeAfter| (that is to say, when |
| 8455 |
% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). Idem for |
| 8456 |
% the |\CodeBefore.| |
| 8457 |
% \begin{macrocode} |
| 8458 |
\NewDocumentCommand \@@_CodeAfter_keys: { O { } } |
| 8459 |
{ \keys_set:nn { nicematrix / CodeAfter } { #1 } } |
| 8460 |
% \end{macrocode} |
| 8461 |
% |
| 8462 |
% |
| 8463 |
% \bigskip |
| 8464 |
% \begin{macrocode} |
| 8465 |
\cs_new_protected:Npn \@@_create_alias_nodes: |
| 8466 |
{ |
| 8467 |
\int_step_inline:nn \c@iRow |
| 8468 |
{ |
| 8469 |
\pgfnodealias |
| 8470 |
{ \l_@@_name_str - ##1 - last } |
| 8471 |
{ \@@_env: - ##1 - \int_use:N \c@jCol } |
| 8472 |
} |
| 8473 |
\int_step_inline:nn \c@jCol |
| 8474 |
{ |
| 8475 |
\pgfnodealias |
| 8476 |
{ \l_@@_name_str - last - ##1 } |
| 8477 |
{ \@@_env: - \int_use:N \c@iRow - ##1 } |
| 8478 |
} |
| 8479 |
\pgfnodealias |
| 8480 |
{ \l_@@_name_str - last - last } |
| 8481 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 8482 |
} |
| 8483 |
% \end{macrocode} |
| 8484 |
% |
| 8485 |
% \bigskip |
| 8486 |
% We remind that the first mandatory argument of the command |\Block| is the |
| 8487 |
% size of the block with the special format $i$|-|$j$. However, the user is |
| 8488 |
% allowed to omit $i$ or $j$ (or both). This will be interpreted as: the last |
| 8489 |
% row (resp. column) of the block will be the last row (resp. column) of the |
| 8490 |
% block (without the potential exterior row---resp. column---of the array). By |
| 8491 |
% convention, this is stored in |\g_@@_pos_of_blocks_seq| (and |
| 8492 |
% |\g_@@_blocks_seq|) as a number of rows (resp. columns) for the block equal to |
| 8493 |
% 100. It's possible, after the construction of the array, to replace these |
| 8494 |
% values by the correct ones (since we know the number of rows and columns of |
| 8495 |
% the array). |
| 8496 |
% \begin{macrocode} |
| 8497 |
\cs_new_protected:Npn \@@_adjust_pos_of_blocks_seq: |
| 8498 |
{ |
| 8499 |
\seq_gset_map_e:NNn \g_@@_pos_of_blocks_seq \g_@@_pos_of_blocks_seq |
| 8500 |
{ \@@_adjust_pos_of_blocks_seq_i:nnnnn ##1 } |
| 8501 |
} |
| 8502 |
% \end{macrocode} |
| 8503 |
% |
| 8504 |
% The following command must \emph{not} be protected. |
| 8505 |
% \begin{macrocode} |
| 8506 |
\cs_new:Npn \@@_adjust_pos_of_blocks_seq_i:nnnnn #1 #2 #3 #4 #5 |
| 8507 |
{ |
| 8508 |
{ #1 } |
| 8509 |
{ #2 } |
| 8510 |
{ |
| 8511 |
\int_compare:nNnTF { #3 } > { 98 } |
| 8512 |
{ \int_use:N \c@iRow } |
| 8513 |
{ #3 } |
| 8514 |
} |
| 8515 |
{ |
| 8516 |
\int_compare:nNnTF { #4 } > { 98 } |
| 8517 |
{ \int_use:N \c@jCol } |
| 8518 |
{ #4 } |
| 8519 |
} |
| 8520 |
{ #5 } |
| 8521 |
} |
| 8522 |
% \end{macrocode} |
| 8523 |
% |
| 8524 |
% \bigskip |
| 8525 |
% We recall that, when externalization is used, |\tikzpicture| and |
| 8526 |
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly |
| 8527 |
% ``visible''. That's why we have to define the adequate version of |
| 8528 |
% |\@@_draw_dotted_lines:| whether TikZ is loaded or not (in that case, only |
| 8529 |
% \textsc{pgf} is loaded). |
| 8530 |
% \begin{macrocode} |
| 8531 |
\AtBeginDocument |
| 8532 |
{ |
| 8533 |
\cs_new_protected:Npe \@@_draw_dotted_lines: |
| 8534 |
{ |
| 8535 |
\c_@@_pgfortikzpicture_tl |
| 8536 |
\@@_draw_dotted_lines_i: |
| 8537 |
\c_@@_endpgfortikzpicture_tl |
| 8538 |
} |
| 8539 |
} |
| 8540 |
% \end{macrocode} |
| 8541 |
% |
| 8542 |
% The following command \emph{must} be protected because it will appear in the |
| 8543 |
% construction of the command |\@@_draw_dotted_lines:|. |
| 8544 |
% \begin{macrocode} |
| 8545 |
\cs_new_protected:Npn \@@_draw_dotted_lines_i: |
| 8546 |
{ |
| 8547 |
\pgfrememberpicturepositiononpagetrue |
| 8548 |
\pgf@relevantforpicturesizefalse |
| 8549 |
\g_@@_HVdotsfor_lines_tl |
| 8550 |
\g_@@_Vdots_lines_tl |
| 8551 |
\g_@@_Ddots_lines_tl |
| 8552 |
\g_@@_Iddots_lines_tl |
| 8553 |
\g_@@_Cdots_lines_tl |
| 8554 |
\g_@@_Ldots_lines_tl |
| 8555 |
} |
| 8556 |
% \end{macrocode} |
| 8557 |
% |
| 8558 |
% \bigskip |
| 8559 |
% \begin{macrocode} |
| 8560 |
\cs_new_protected:Npn \@@_restore_iRow_jCol: |
| 8561 |
{ |
| 8562 |
\cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l_@@_old_iRow_int } |
| 8563 |
\cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l_@@_old_jCol_int } |
| 8564 |
} |
| 8565 |
% \end{macrocode} |
| 8566 |
% |
| 8567 |
% \bigskip |
| 8568 |
% We define a new \textsc{pgf} shape for the diag nodes because we want to |
| 8569 |
% provide an anchor called |.5| for those nodes. |
| 8570 |
% \begin{macrocode} |
| 8571 |
\pgfdeclareshape { @@_diag_node } |
| 8572 |
{ |
| 8573 |
\savedanchor { \five } |
| 8574 |
{ |
| 8575 |
\dim_gset_eq:NN \pgf@x \l_tmpa_dim |
| 8576 |
\dim_gset_eq:NN \pgf@y \l_tmpb_dim |
| 8577 |
} |
| 8578 |
\anchor { 5 } { \five } |
| 8579 |
\anchor { center } { \pgfpointorigin } |
| 8580 |
\anchor { 1 } { \five \pgf@x = 0.2 \pgf@x \pgf@y = 0.2 \pgf@y } |
| 8581 |
\anchor { 2 } { \five \pgf@x = 0.4 \pgf@x \pgf@y = 0.4 \pgf@y } |
| 8582 |
\anchor { 25 } { \five \pgf@x = 0.5 \pgf@x \pgf@y = 0.5 \pgf@y } |
| 8583 |
\anchor { 3 } { \five \pgf@x = 0.6 \pgf@x \pgf@y = 0.6 \pgf@y } |
| 8584 |
\anchor { 4 } { \five \pgf@x = 0.8 \pgf@x \pgf@y = 0.8 \pgf@y } |
| 8585 |
\anchor { 6 } { \five \pgf@x = 1.2 \pgf@x \pgf@y = 1.2 \pgf@y } |
| 8586 |
\anchor { 7 } { \five \pgf@x = 1.4 \pgf@x \pgf@y = 1.4 \pgf@y } |
| 8587 |
\anchor { 75 } { \five \pgf@x = 1.5 \pgf@x \pgf@y = 1.5 \pgf@y } |
| 8588 |
\anchor { 8 } { \five \pgf@x = 1.6 \pgf@x \pgf@y = 1.6 \pgf@y } |
| 8589 |
\anchor { 9 } { \five \pgf@x = 1.8 \pgf@x \pgf@y = 1.8 \pgf@y } |
| 8590 |
} |
| 8591 |
% \end{macrocode} |
| 8592 |
% |
| 8593 |
% |
| 8594 |
% |
| 8595 |
% \bigskip |
| 8596 |
% The following command creates the diagonal nodes (in fact, if the matrix is |
| 8597 |
% not a square matrix, not all the nodes are on the diagonal). |
| 8598 |
% \begin{macrocode} |
| 8599 |
\cs_new_protected:Npn \@@_create_diag_nodes: |
| 8600 |
{ |
| 8601 |
\pgfpicture |
| 8602 |
\pgfrememberpicturepositiononpagetrue |
| 8603 |
\int_step_inline:nn { \int_max:nn \c@iRow \c@jCol } |
| 8604 |
{ |
| 8605 |
\@@_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } } |
| 8606 |
\dim_set_eq:NN \l_tmpa_dim \pgf@x |
| 8607 |
\@@_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } } |
| 8608 |
\dim_set_eq:NN \l_tmpb_dim \pgf@y |
| 8609 |
\@@_qpoint:n { col - \int_min:nn { ##1 + 1 } { \c@jCol + 1 } } |
| 8610 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x |
| 8611 |
\@@_qpoint:n { row - \int_min:nn { ##1 + 1 } { \c@iRow + 1 } } |
| 8612 |
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@y |
| 8613 |
\pgftransformshift { \pgfpoint \l_tmpa_dim \l_tmpb_dim } |
| 8614 |
% \end{macrocode} |
| 8615 |
% Now, |\l_tmpa_dim| and |\l_tmpb_dim| become the width and the height of the |
| 8616 |
% node (of shape |@@_diag_node|) that we will construct. |
| 8617 |
% \begin{macrocode} |
| 8618 |
\dim_set:Nn \l_tmpa_dim { ( \l_@@_tmpc_dim - \l_tmpa_dim ) / 2 } |
| 8619 |
\dim_set:Nn \l_tmpb_dim { ( \l_@@_tmpd_dim - \l_tmpb_dim ) / 2 } |
| 8620 |
\pgfnode { @@_diag_node } { center } { } { \@@_env: - ##1 } { } |
| 8621 |
\str_if_empty:NF \l_@@_name_str |
| 8622 |
{ \pgfnodealias { \l_@@_name_str - ##1 } { \@@_env: - ##1 } } |
| 8623 |
} |
| 8624 |
% \end{macrocode} |
| 8625 |
% Now, the last node. Of course, that is only a |coordinate| because there is |
| 8626 |
% not |.5| anchor for that node. |
| 8627 |
% \begin{macrocode} |
| 8628 |
\int_set:Nn \l_tmpa_int { 1 + \int_max:nn \c@iRow \c@jCol } % modified |
| 8629 |
\@@_qpoint:n { row - \int_min:nn \l_tmpa_int { \c@iRow + 1 } } |
| 8630 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 8631 |
\@@_qpoint:n { col - \int_min:nn \l_tmpa_int { \c@jCol + 1 } } |
| 8632 |
\pgfcoordinate |
| 8633 |
{ \@@_env: - \int_use:N \l_tmpa_int } { \pgfpoint \pgf@x \l_tmpa_dim } |
| 8634 |
\pgfnodealias |
| 8635 |
{ \@@_env: - last } |
| 8636 |
{ \@@_env: - \int_eval:n { 1 + \int_max:nn \c@iRow \c@jCol } } |
| 8637 |
\str_if_empty:NF \l_@@_name_str |
| 8638 |
{ |
| 8639 |
\pgfnodealias |
| 8640 |
{ \l_@@_name_str - \int_use:N \l_tmpa_int } |
| 8641 |
{ \@@_env: - \int_use:N \l_tmpa_int } |
| 8642 |
\pgfnodealias |
| 8643 |
{ \l_@@_name_str - last } |
| 8644 |
{ \@@_env: - last } |
| 8645 |
} |
| 8646 |
\endpgfpicture |
| 8647 |
} |
| 8648 |
% \end{macrocode} |
| 8649 |
% |
| 8650 |
% |
| 8651 |
% \bigskip |
| 8652 |
% \section{We draw the dotted lines} |
| 8653 |
% |
| 8654 |
% A dotted line will be said \emph{open} in one of its extremities when it stops |
| 8655 |
% on the edge of the matrix and \emph{closed} otherwise. In the following |
| 8656 |
% matrix, the dotted line is closed on its left extremity and open on its right. |
| 8657 |
% \[ \begin{pNiceMatrix} |
| 8658 |
% a+b+c & a+b & a\\ |
| 8659 |
% a & \Cdots \\ |
| 8660 |
% a & a+b & a+b+c |
| 8661 |
% \end{pNiceMatrix}\] |
| 8662 |
% |
| 8663 |
% |
| 8664 |
% \bigskip |
| 8665 |
% The command |\@@_find_extremities:nnnn| takes four arguments: |
| 8666 |
% |
| 8667 |
% \begin{itemize} |
| 8668 |
% \item the first argument is the row of the cell where the command was issued; |
| 8669 |
% \item the second argument is the column of the cell where the command was |
| 8670 |
% issued; |
| 8671 |
% \item the third argument is the $x$-value of the orientation vector of the |
| 8672 |
% line; |
| 8673 |
% \item the fourth argument is the $y$-value of the orientation vector of the |
| 8674 |
% line. |
| 8675 |
% \end{itemize} |
| 8676 |
% |
| 8677 |
% This command computes: |
| 8678 |
% |
| 8679 |
% \begin{itemize} |
| 8680 |
% \item |\l_@@_initial_i_int| and |\l_@@_initial_j_int| which are the |
| 8681 |
% coordinates of one extremity of the line; |
| 8682 |
% \item |\l_@@_final_i_int| and |\l_@@_final_j_int| which are the coordinates of |
| 8683 |
% the other extremity of the line; |
| 8684 |
% \item |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| to indicate |
| 8685 |
% whether the extremities are open or not. |
| 8686 |
% \end{itemize} |
| 8687 |
% |
| 8688 |
% We provide first a version in the L3 syntax, and, then a version slightly |
| 8689 |
% more efficient. |
| 8690 |
% \begin{Verbatim}[formatcom = \small] |
| 8691 |
% \cs_new_protected:Npn \@@_find_extremities:nnnn #1 #2 #3 #4 |
| 8692 |
% { |
| 8693 |
% \cs_set:cpn { @@ _ dotted _ #1 - #2 } { } |
| 8694 |
% \int_set:Nn \l_@@_initial_i_int { #1 } |
| 8695 |
% \int_set:Nn \l_@@_initial_j_int { #2 } |
| 8696 |
% \int_set:Nn \l_@@_final_i_int { #1 } |
| 8697 |
% \int_set:Nn \l_@@_final_j_int { #2 } |
| 8698 |
% \bool_set_false:N \l_@@_stop_loop_bool |
| 8699 |
% \bool_do_until:Nn \l_@@_stop_loop_bool |
| 8700 |
% { |
| 8701 |
% \int_add:Nn \l_@@_final_i_int { #3 } |
| 8702 |
% \int_add:Nn \l_@@_final_j_int { #4 } |
| 8703 |
% \bool_set_false:N \l_@@_final_open_bool |
| 8704 |
% \int_compare:nNnTF { \l_@@_final_i_int } > { \l_@@_row_max_int } |
| 8705 |
% { |
| 8706 |
% \int_compare:nNnTF { #3 } = { 1 } |
| 8707 |
% { \bool_set_true:N \l_@@_final_open_bool } |
| 8708 |
% { |
| 8709 |
% \int_compare:nNnT { \l_@@_final_j_int } > { \l_@@_col_max_int } |
| 8710 |
% { \bool_set_true:N \l_@@_final_open_bool } |
| 8711 |
% } |
| 8712 |
% } |
| 8713 |
% { |
| 8714 |
% \int_compare:nNnTF \l_@@_final_j_int < \l_@@_col_min_int |
| 8715 |
% { |
| 8716 |
% \int_compare:nNnT { #4 } = { -1 } |
| 8717 |
% { \bool_set_true:N \l_@@_final_open_bool } |
| 8718 |
% } |
| 8719 |
% { |
| 8720 |
% \int_compare:nNnT { \l_@@_final_j_int } > { \l_@@_col_max_int } |
| 8721 |
% { |
| 8722 |
% \int_compare:nNnT { #4 } = { 1 } |
| 8723 |
% { \bool_set_true:N \l_@@_final_open_bool } |
| 8724 |
% } |
| 8725 |
% } |
| 8726 |
% } |
| 8727 |
% \bool_if:NTF \l_@@_final_open_bool |
| 8728 |
% { |
| 8729 |
% \int_sub:Nn \l_@@_final_i_int { #3 } |
| 8730 |
% \int_sub:Nn \l_@@_final_j_int { #4 } |
| 8731 |
% \bool_set_true:N \l_@@_stop_loop_bool |
| 8732 |
% } |
| 8733 |
% { |
| 8734 |
% \cs_if_exist:cTF |
| 8735 |
% { |
| 8736 |
% @@ _ dotted _ |
| 8737 |
% \int_use:N \l_@@_final_i_int - |
| 8738 |
% \int_use:N \l_@@_final_j_int |
| 8739 |
% } |
| 8740 |
% { |
| 8741 |
% \int_sub:Nn \l_@@_final_i_int { #3 } |
| 8742 |
% \int_sub:Nn \l_@@_final_j_int { #4 } |
| 8743 |
% \bool_set_true:N \l_@@_final_open_bool |
| 8744 |
% \bool_set_true:N \l_@@_stop_loop_bool |
| 8745 |
% } |
| 8746 |
% { |
| 8747 |
% \cs_if_exist:cTF |
| 8748 |
% { |
| 8749 |
% pgf @ sh @ ns @ \@@_env: |
| 8750 |
% - \int_use:N \l_@@_final_i_int |
| 8751 |
% - \int_use:N \l_@@_final_j_int |
| 8752 |
% } |
| 8753 |
% { \bool_set_true:N \l_@@_stop_loop_bool } |
| 8754 |
% { |
| 8755 |
% \cs_set_nopar:cpn |
| 8756 |
% { |
| 8757 |
% @@ _ dotted _ |
| 8758 |
% \int_use:N \l_@@_final_i_int - |
| 8759 |
% \int_use:N \l_@@_final_j_int |
| 8760 |
% } |
| 8761 |
% { } |
| 8762 |
% } |
| 8763 |
% } |
| 8764 |
% } |
| 8765 |
% } |
| 8766 |
% \bool_set_false:N \l_@@_stop_loop_bool |
| 8767 |
% \int_set:Nn \l_tmpa_int { \l_@@_col_min_int - 1 } |
| 8768 |
% \bool_do_until:Nn \l_@@_stop_loop_bool |
| 8769 |
% { |
| 8770 |
% \int_sub:Nn \l_@@_initial_i_int { #3 } |
| 8771 |
% \int_sub:Nn \l_@@_initial_j_int { #4 } |
| 8772 |
% \bool_set_false:N \l_@@_initial_open_bool |
| 8773 |
% \int_compare:nNnTF { \l_@@_initial_i_int } < { \l_@@_row_min_int } |
| 8774 |
% { |
| 8775 |
% \int_compare:nNnTF { #3} = { 1 } |
| 8776 |
% { \bool_set_true:N \l_@@_initial_open_bool } |
| 8777 |
% { |
| 8778 |
% \int_compare:nNnT { \l_@@_initial_j_int } = { \l_tmpa_int } |
| 8779 |
% { \bool_set_true:N \l_@@_initial_open_bool } |
| 8780 |
% } |
| 8781 |
% } |
| 8782 |
% { |
| 8783 |
% \int_compare:nNnTF { \l_@@_initial_j_int } < { \l_@@_col_min_int } |
| 8784 |
% { |
| 8785 |
% \int_compare:nNnT { #4 } = { 1 } |
| 8786 |
% { \bool_set_true:N \l_@@_initial_open_bool } |
| 8787 |
% } |
| 8788 |
% { |
| 8789 |
% \int_compare:nNnT { \l_@@_initial_j_int } > { \l_@@_col_max_int } |
| 8790 |
% { |
| 8791 |
% \int_compare:nNnT { #4 } = { -1 } |
| 8792 |
% { \bool_set_true:N \l_@@_initial_open_bool } |
| 8793 |
% } |
| 8794 |
% } |
| 8795 |
% } |
| 8796 |
% \bool_if:NTF \l_@@_initial_open_bool |
| 8797 |
% { |
| 8798 |
% \int_add:Nn \l_@@_initial_i_int { #3 } |
| 8799 |
% \int_add:Nn \l_@@_initial_j_int { #4 } |
| 8800 |
% \bool_set_true:N \l_@@_stop_loop_bool |
| 8801 |
% } |
| 8802 |
% { |
| 8803 |
% \cs_if_exist:cTF |
| 8804 |
% { |
| 8805 |
% @@ _ dotted _ |
| 8806 |
% \int_use:N \l_@@_initial_i_int - |
| 8807 |
% \int_use:N \l_@@_initial_j_int |
| 8808 |
% } |
| 8809 |
% { |
| 8810 |
% \int_add:Nn \l_@@_initial_i_int { #3 } |
| 8811 |
% \int_add:Nn \l_@@_initial_j_int { #4 } |
| 8812 |
% \bool_set_true:N \l_@@_initial_open_bool |
| 8813 |
% \bool_set_true:N \l_@@_stop_loop_bool |
| 8814 |
% } |
| 8815 |
% { |
| 8816 |
% \cs_if_exist:cTF |
| 8817 |
% { |
| 8818 |
% pgf @ sh @ ns @ \@@_env: |
| 8819 |
% - \int_use:N \l_@@_initial_i_int |
| 8820 |
% - \int_use:N \l_@@_initial_j_int |
| 8821 |
% } |
| 8822 |
% { \bool_set_true:N \l_@@_stop_loop_bool } |
| 8823 |
% { |
| 8824 |
% \cs_set_nopar:cpn |
| 8825 |
% { |
| 8826 |
% @@ _ dotted _ |
| 8827 |
% \int_use:N \l_@@_initial_i_int - |
| 8828 |
% \int_use:N \l_@@_initial_j_int |
| 8829 |
% } |
| 8830 |
% { } |
| 8831 |
% } |
| 8832 |
% } |
| 8833 |
% } |
| 8834 |
% } |
| 8835 |
% \seq_gput_right:Ne \g_@@_pos_of_xdots_seq |
| 8836 |
% { |
| 8837 |
% { \int_use:N \l_@@_initial_i_int } |
| 8838 |
% { \int_min:nn { \l_@@_initial_j_int } { \l_@@_final_j_int } } |
| 8839 |
% { \int_use:N \l_@@_final_i_int } |
| 8840 |
% { \int_max:nn { \l_@@_initial_j_int } { \l_@@_final_j_int } } |
| 8841 |
% { } |
| 8842 |
% } |
| 8843 |
% } |
| 8844 |
% \end{Verbatim} |
| 8845 |
% |
| 8846 |
% |
| 8847 |
% \bigskip |
| 8848 |
% The following version is slightly more efficient. |
| 8849 |
% \begin{macrocode} |
| 8850 |
\cs_new_protected:Npn \@@_find_extremities:nnnn #1 #2 #3 #4 |
| 8851 |
{ |
| 8852 |
% \end{macrocode} |
| 8853 |
% First, we declare the current cell as ``dotted'' because we forbide |
| 8854 |
% intersections of dotted lines. |
| 8855 |
% \begin{macrocode} |
| 8856 |
\cs_set_nopar:cpn { @@ _ dotted _ #1 - #2 } { } |
| 8857 |
% \end{macrocode} |
| 8858 |
% Initialization of variables. |
| 8859 |
% \begin{macrocode} |
| 8860 |
\l_@@_initial_i_int = #1 |
| 8861 |
\l_@@_initial_j_int = #2 |
| 8862 |
\l_@@_final_i_int = #1 |
| 8863 |
\l_@@_final_j_int = #2 |
| 8864 |
% \end{macrocode} |
| 8865 |
% We will do two loops: one when determining the initial cell and the other |
| 8866 |
% when determining the final cell. The boolean |\l_@@_stop_loop_bool| will be |
| 8867 |
% used to control these loops. In the first loop, we search the ``final'' |
| 8868 |
% extremity of the line. |
| 8869 |
% \begin{macrocode} |
| 8870 |
\let \l_@@_stop_loop_bool \c_false_bool |
| 8871 |
\bool_do_until:Nn \l_@@_stop_loop_bool |
| 8872 |
{ |
| 8873 |
% \end{macrocode} |
| 8874 |
% We test if we are still in the matrix. |
| 8875 |
% \begin{macrocode} |
| 8876 |
\advance \l_@@_final_i_int by #3 |
| 8877 |
\advance \l_@@_final_j_int by #4 |
| 8878 |
\let \l_@@_final_open_bool \c_false_bool |
| 8879 |
\if_int_compare:w \l_@@_final_i_int > \l_@@_row_max_int |
| 8880 |
\if_int_compare:w #3 = \c_one_int |
| 8881 |
\let \l_@@_final_open_bool \c_true_bool |
| 8882 |
\else: |
| 8883 |
\if_int_compare:w \l_@@_final_j_int > \l_@@_col_max_int |
| 8884 |
\let \l_@@_final_open_bool \c_true_bool |
| 8885 |
\fi: |
| 8886 |
\fi: |
| 8887 |
\else: |
| 8888 |
\if_int_compare:w \l_@@_final_j_int < \l_@@_col_min_int |
| 8889 |
\if_int_compare:w #4 = -1 |
| 8890 |
\let \l_@@_final_open_bool \c_true_bool |
| 8891 |
\fi: |
| 8892 |
\else: |
| 8893 |
\if_int_compare:w \l_@@_final_j_int > \l_@@_col_max_int |
| 8894 |
\if_int_compare:w #4 = \c_one_int |
| 8895 |
\let \l_@@_final_open_bool \c_true_bool |
| 8896 |
\fi: |
| 8897 |
\fi: |
| 8898 |
\fi: |
| 8899 |
\fi: |
| 8900 |
\bool_if:NTF \l_@@_final_open_bool |
| 8901 |
% \end{macrocode} |
| 8902 |
% If we are outside the matrix, we have found the extremity of the dotted line |
| 8903 |
% and it's an \emph{open} extremity. |
| 8904 |
% \begin{macrocode} |
| 8905 |
{ |
| 8906 |
% \end{macrocode} |
| 8907 |
% We do a step backwards. |
| 8908 |
% \begin{macrocode} |
| 8909 |
\advance \l_@@_final_i_int by - #3 |
| 8910 |
\advance \l_@@_final_j_int by - #4 |
| 8911 |
\let \l_@@_stop_loop_bool \c_true_bool |
| 8912 |
} |
| 8913 |
% \end{macrocode} |
| 8914 |
% If we are in the matrix, we test whether the cell is empty. If it's not the |
| 8915 |
% case, we stop the loop because we have found the correct values for |
| 8916 |
% |\l_@@_final_i_int| and |\l_@@_final_j_int|. |
| 8917 |
% \begin{macrocode} |
| 8918 |
{ |
| 8919 |
\cs_if_exist:cTF |
| 8920 |
{ |
| 8921 |
@@ _ dotted _ |
| 8922 |
\int_use:N \l_@@_final_i_int - |
| 8923 |
\int_use:N \l_@@_final_j_int |
| 8924 |
} |
| 8925 |
{ |
| 8926 |
\advance \l_@@_final_i_int by - #3 |
| 8927 |
\advance \l_@@_final_j_int by - #4 |
| 8928 |
\let \l_@@_final_open_bool \c_true_bool |
| 8929 |
\let \l_@@_stop_loop_bool \c_true_bool |
| 8930 |
} |
| 8931 |
{ |
| 8932 |
\cs_if_exist:cTF |
| 8933 |
{ |
| 8934 |
pgf @ sh @ ns @ \@@_env: |
| 8935 |
- \int_use:N \l_@@_final_i_int |
| 8936 |
- \int_use:N \l_@@_final_j_int |
| 8937 |
} |
| 8938 |
{ \let \l_@@_stop_loop_bool \c_true_bool } |
| 8939 |
% \end{macrocode} |
| 8940 |
% If the case is empty, we declare that the cell as non-empty. Indeed, we will |
| 8941 |
% draw a dotted line and the cell will be on that dotted line. All the cells of |
| 8942 |
% a dotted line have to be marked as ``dotted'' because we don't want |
| 8943 |
% intersections between dotted lines. We recall that the research of the |
| 8944 |
% extremities of the lines are all done in the same TeX group (the group of the |
| 8945 |
% environment), even though, when the extremities are found, each line is |
| 8946 |
% drawn in a TeX group that we will open for the options of the line. |
| 8947 |
% \begin{macrocode} |
| 8948 |
{ |
| 8949 |
\cs_set_nopar:cpn |
| 8950 |
{ |
| 8951 |
@@ _ dotted _ |
| 8952 |
\int_use:N \l_@@_final_i_int - |
| 8953 |
\int_use:N \l_@@_final_j_int |
| 8954 |
} |
| 8955 |
{ } |
| 8956 |
} |
| 8957 |
} |
| 8958 |
} |
| 8959 |
} |
| 8960 |
% \end{macrocode} |
| 8961 |
% |
| 8962 |
% \interitem |
| 8963 |
% For |\l_@@_initial_i_int| and |\l_@@_initial_j_int| the programmation is |
| 8964 |
% similar to the previous one. |
| 8965 |
% \begin{macrocode} |
| 8966 |
\let \l_@@_stop_loop_bool \c_false_bool |
| 8967 |
% \end{macrocode} |
| 8968 |
% The following line of code is only for efficiency in the following loop. |
| 8969 |
% \begin{macrocode} |
| 8970 |
\l_tmpa_int = \l_@@_col_min_int |
| 8971 |
\advance \l_tmpa_int by -1 |
| 8972 |
% \end{macrocode} |
| 8973 |
% \begin{macrocode} |
| 8974 |
\bool_do_until:Nn \l_@@_stop_loop_bool |
| 8975 |
{ |
| 8976 |
\advance \l_@@_initial_i_int by - #3 |
| 8977 |
\advance \l_@@_initial_j_int by - #4 |
| 8978 |
\let \l_@@_initial_open_bool \c_false_bool |
| 8979 |
% \end{macrocode} |
| 8980 |
% |
| 8981 |
% We test if we are still in the matrix. Since this is the core of the loop, we |
| 8982 |
% \textbf{optimize} the code by using a TeX-style of conditionals. |
| 8983 |
% \begin{macrocode} |
| 8984 |
\if_int_compare:w \l_@@_initial_i_int < \l_@@_row_min_int |
| 8985 |
\if_int_compare:w #3 = \c_one_int |
| 8986 |
\let \l_@@_initial_open_bool \c_true_bool |
| 8987 |
\else: |
| 8988 |
% \end{macrocode} |
| 8989 |
% |\l_tmpa_int| contains |\l_@@_col_min_int - 1| (only for efficiency). |
| 8990 |
% \begin{macrocode} |
| 8991 |
\if_int_compare:w \l_@@_initial_j_int = \l_tmpa_int |
| 8992 |
\let \l_@@_initial_open_bool \c_true_bool |
| 8993 |
\fi: |
| 8994 |
\fi: |
| 8995 |
\else: |
| 8996 |
\if_int_compare:w \l_@@_initial_j_int < \l_@@_col_min_int |
| 8997 |
\if_int_compare:w #4 = \c_one_int |
| 8998 |
\let \l_@@_initial_open_bool \c_true_bool |
| 8999 |
\fi: |
| 9000 |
\else: |
| 9001 |
\if_int_compare:w \l_@@_initial_j_int > \l_@@_col_max_int |
| 9002 |
\if_int_compare:w #4 = -1 |
| 9003 |
\let \l_@@_initial_open_bool \c_true_bool |
| 9004 |
\fi: |
| 9005 |
\fi: |
| 9006 |
\fi: |
| 9007 |
\fi: |
| 9008 |
% \end{macrocode} |
| 9009 |
% |
| 9010 |
% \begin{macrocode} |
| 9011 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9012 |
{ |
| 9013 |
\advance \l_@@_initial_i_int by #3 |
| 9014 |
\advance \l_@@_initial_j_int by #4 |
| 9015 |
\let \l_@@_stop_loop_bool \c_true_bool |
| 9016 |
} |
| 9017 |
{ |
| 9018 |
\cs_if_exist:cTF |
| 9019 |
{ |
| 9020 |
@@ _ dotted _ |
| 9021 |
\int_use:N \l_@@_initial_i_int - |
| 9022 |
\int_use:N \l_@@_initial_j_int |
| 9023 |
} |
| 9024 |
{ |
| 9025 |
\advance \l_@@_initial_i_int by #3 |
| 9026 |
\advance \l_@@_initial_j_int by #4 |
| 9027 |
\let \l_@@_initial_open_bool \c_true_bool |
| 9028 |
\let \l_@@_stop_loop_bool \c_true_bool |
| 9029 |
} |
| 9030 |
{ |
| 9031 |
\cs_if_exist:cTF |
| 9032 |
{ |
| 9033 |
pgf @ sh @ ns @ \@@_env: |
| 9034 |
- \int_use:N \l_@@_initial_i_int |
| 9035 |
- \int_use:N \l_@@_initial_j_int |
| 9036 |
} |
| 9037 |
{ \let \l_@@_stop_loop_bool \c_true_bool } |
| 9038 |
{ |
| 9039 |
\cs_set_nopar:cpn |
| 9040 |
{ |
| 9041 |
@@ _ dotted _ |
| 9042 |
\int_use:N \l_@@_initial_i_int - |
| 9043 |
\int_use:N \l_@@_initial_j_int |
| 9044 |
} |
| 9045 |
{ } |
| 9046 |
} |
| 9047 |
} |
| 9048 |
} |
| 9049 |
} |
| 9050 |
% \end{macrocode} |
| 9051 |
% We remind the rectangle described by all the dotted lines in order to respect |
| 9052 |
% the corresponding virtual ``block'' when drawing the horizontal and vertical |
| 9053 |
% rules. |
| 9054 |
% \begin{macrocode} |
| 9055 |
\seq_gput_right:Ne \g_@@_pos_of_xdots_seq |
| 9056 |
{ |
| 9057 |
{ \int_use:N \l_@@_initial_i_int } |
| 9058 |
% \end{macrocode} |
| 9059 |
% Be careful: with |\Iddots|, |\l_@@_final_j_int| is inferior to |
| 9060 |
% |\l_@@_initial_j_int|. That's why we use |\int_min:nn| and |\int_max:nn|. |
| 9061 |
% \begin{macrocode} |
| 9062 |
{ \int_min:nn \l_@@_initial_j_int \l_@@_final_j_int } |
| 9063 |
{ \int_use:N \l_@@_final_i_int } |
| 9064 |
{ \int_max:nn \l_@@_initial_j_int \l_@@_final_j_int } |
| 9065 |
{ } |
| 9066 |
} |
| 9067 |
} |
| 9068 |
% \end{macrocode} |
| 9069 |
% |
| 9070 |
% |
| 9071 |
% \medskip |
| 9072 |
% If the final user uses the key |xdots/shorten| in |\NiceMatrixOptions| or at the |
| 9073 |
% level of an environment (such as |{pNiceMatrix}|, etc.), only the so called |
| 9074 |
% ``closed extremities'' will be shortened by that key. The following command |
| 9075 |
% will be used \emph{after} the detection of the extremities of a dotted line |
| 9076 |
% (hence at a time when we known whether the extremities are closed or open) but |
| 9077 |
% before the analysis of the keys of the individual command |\Cdots|, |\Vdots|. |
| 9078 |
% Hence, the keys |shorten|, |shorten-start| and |shorten-end| of that |
| 9079 |
% individual command will be applied. |
| 9080 |
% \begin{macrocode} |
| 9081 |
\cs_new_protected:Npn \@@_open_shorten: |
| 9082 |
{ |
| 9083 |
\bool_if:NT \l_@@_initial_open_bool |
| 9084 |
{ \dim_zero:N \l_@@_xdots_shorten_start_dim } |
| 9085 |
\bool_if:NT \l_@@_final_open_bool |
| 9086 |
{ \dim_zero:N \l_@@_xdots_shorten_end_dim } |
| 9087 |
} |
| 9088 |
% \end{macrocode} |
| 9089 |
% |
| 9090 |
% \medskip |
| 9091 |
% The following command (\emph{when it will be written}) will set the four |
| 9092 |
% counters |\l_@@_row_min_int|, |\l_@@_row_max_int|, |\l_@@_col_min_int| and |
| 9093 |
% |\l_@@_col_max_int| to the intersections of the sub-matrices which contains |
| 9094 |
% the cell of row |#1| and column |#2|. As of now, it's only the whole array |
| 9095 |
% (excepted exterior rows and columns). |
| 9096 |
% \begin{macrocode} |
| 9097 |
\cs_new_protected:Npn \@@_adjust_to_submatrix:nn #1 #2 |
| 9098 |
{ |
| 9099 |
\int_set_eq:NN \l_@@_row_min_int \c_one_int |
| 9100 |
\int_set_eq:NN \l_@@_col_min_int \c_one_int |
| 9101 |
\int_set_eq:NN \l_@@_row_max_int \c@iRow |
| 9102 |
\int_set_eq:NN \l_@@_col_max_int \c@jCol |
| 9103 |
% \end{macrocode} |
| 9104 |
% If there is no submatrices, we will speed~up a little for the potential other |
| 9105 |
% dotted lines to draw. |
| 9106 |
% |
| 9107 |
% \begin{macrocode} |
| 9108 |
\seq_if_empty:NTF \g_@@_submatrix_seq |
| 9109 |
{ \cs_set_eq:NN \@@_adjust_to_submatrix:nn \use_none:nn } |
| 9110 |
{ |
| 9111 |
% \end{macrocode} |
| 9112 |
% We do a loop over all the submatrices specified in the |code-before|. We have |
| 9113 |
% stored the position of all those submatrices in |\g_@@_submatrix_seq|. |
| 9114 |
% \begin{macrocode} |
| 9115 |
\seq_map_inline:Nn \g_@@_submatrix_seq |
| 9116 |
{ \@@_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 } |
| 9117 |
} |
| 9118 |
} |
| 9119 |
% \end{macrocode} |
| 9120 |
% |
| 9121 |
% \medskip |
| 9122 |
% |#1| and |#2| are the numbers of row and columns of the cell where the command |
| 9123 |
% of dotted line (ex.: |\Vdots|) has been issued. |#3|, |#4|, |#5| and |#6| are |
| 9124 |
% the specification (in $i$ and $j$) of the submatrix we are analyzing. |
| 9125 |
% |
| 9126 |
% |
| 9127 |
% Here is the programmation of that command with the the standard syntax of L3. |
| 9128 |
% \begin{Verbatim}[formatcom=\small] |
| 9129 |
% \cs_new_protected:Npn \@@_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6 |
| 9130 |
% { |
| 9131 |
% \bool_if:nT |
| 9132 |
% { |
| 9133 |
% \int_compare_p:n { #3 <= #1 <= #5 } |
| 9134 |
% && |
| 9135 |
% \int_compare_p:n { #4 <= #2 <= #6 } |
| 9136 |
% } |
| 9137 |
% { |
| 9138 |
% \int_set:Nn \l_@@_row_min_int { \int_max:nn \l_@@_row_min_int { #3 } } |
| 9139 |
% \int_set:Nn \l_@@_col_min_int { \int_max:nn \l_@@_col_min_int { #4 } } |
| 9140 |
% \int_set:Nn \l_@@_row_max_int { \int_min:nn \l_@@_row_max_int { #5 } } |
| 9141 |
% \int_set:Nn \l_@@_col_max_int { \int_min:nn \l_@@_col_max_int { #6 } } |
| 9142 |
% } |
| 9143 |
% } |
| 9144 |
% \end{Verbatim} |
| 9145 |
% |
| 9146 |
% \medskip |
| 9147 |
% However, for efficiency, we will use the following version. |
| 9148 |
% \begin{macrocode} |
| 9149 |
\cs_new_protected:Npn \@@_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6 |
| 9150 |
{ |
| 9151 |
\if_int_compare:w #3 > #1 |
| 9152 |
\else: |
| 9153 |
\if_int_compare:w #1 > #5 |
| 9154 |
\else: |
| 9155 |
\if_int_compare:w #4 > #2 |
| 9156 |
\else: |
| 9157 |
\if_int_compare:w #2 > #6 |
| 9158 |
\else: |
| 9159 |
\if_int_compare:w \l_@@_row_min_int < #3 \l_@@_row_min_int = #3 \fi: |
| 9160 |
\if_int_compare:w \l_@@_col_min_int < #4 \l_@@_col_min_int = #4 \fi: |
| 9161 |
\if_int_compare:w \l_@@_row_max_int > #5 \l_@@_row_max_int = #5 \fi: |
| 9162 |
\if_int_compare:w \l_@@_col_max_int > #6 \l_@@_col_max_int = #6 \fi: |
| 9163 |
\fi: |
| 9164 |
\fi: |
| 9165 |
\fi: |
| 9166 |
\fi: |
| 9167 |
} |
| 9168 |
% \end{macrocode} |
| 9169 |
% |
| 9170 |
% \medskip |
| 9171 |
% \begin{macrocode} |
| 9172 |
\cs_new_protected:Npn \@@_set_initial_coords: |
| 9173 |
{ |
| 9174 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9175 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 9176 |
} |
| 9177 |
\cs_new_protected:Npn \@@_set_final_coords: |
| 9178 |
{ |
| 9179 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 9180 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 9181 |
} |
| 9182 |
\cs_new_protected:Npn \@@_set_initial_coords_from_anchor:n #1 |
| 9183 |
{ |
| 9184 |
\pgfpointanchor |
| 9185 |
{ |
| 9186 |
\@@_env: |
| 9187 |
- \int_use:N \l_@@_initial_i_int |
| 9188 |
- \int_use:N \l_@@_initial_j_int |
| 9189 |
} |
| 9190 |
{ #1 } |
| 9191 |
\@@_set_initial_coords: |
| 9192 |
} |
| 9193 |
\cs_new_protected:Npn \@@_set_final_coords_from_anchor:n #1 |
| 9194 |
{ |
| 9195 |
\pgfpointanchor |
| 9196 |
{ |
| 9197 |
\@@_env: |
| 9198 |
- \int_use:N \l_@@_final_i_int |
| 9199 |
- \int_use:N \l_@@_final_j_int |
| 9200 |
} |
| 9201 |
{ #1 } |
| 9202 |
\@@_set_final_coords: |
| 9203 |
} |
| 9204 |
% \end{macrocode} |
| 9205 |
% |
| 9206 |
% |
| 9207 |
% \begin{macrocode} |
| 9208 |
\cs_new_protected:Npn \@@_open_x_initial_dim: |
| 9209 |
{ |
| 9210 |
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim |
| 9211 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 9212 |
{ |
| 9213 |
\cs_if_exist:cT |
| 9214 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int } |
| 9215 |
{ |
| 9216 |
\pgfpointanchor |
| 9217 |
{ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int } |
| 9218 |
{ west } |
| 9219 |
\dim_set:Nn \l_@@_x_initial_dim |
| 9220 |
{ \dim_min:nn \l_@@_x_initial_dim \pgf@x } |
| 9221 |
} |
| 9222 |
} |
| 9223 |
% \end{macrocode} |
| 9224 |
% If, in fact, all the cells of the column are empty (no PGF/TikZ nodes in |
| 9225 |
% those cells). |
| 9226 |
% \begin{macrocode} |
| 9227 |
\dim_compare:nNnT \l_@@_x_initial_dim = \c_max_dim |
| 9228 |
{ |
| 9229 |
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } |
| 9230 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9231 |
\dim_add:Nn \l_@@_x_initial_dim \col@sep |
| 9232 |
} |
| 9233 |
} |
| 9234 |
% \end{macrocode} |
| 9235 |
% |
| 9236 |
% \begin{macrocode} |
| 9237 |
\cs_new_protected:Npn \@@_open_x_final_dim: |
| 9238 |
{ |
| 9239 |
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } |
| 9240 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 9241 |
{ |
| 9242 |
\cs_if_exist:cT |
| 9243 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int } |
| 9244 |
{ |
| 9245 |
\pgfpointanchor |
| 9246 |
{ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int } |
| 9247 |
{ east } |
| 9248 |
\dim_compare:nNnT \pgf@x > \l_@@_x_final_dim |
| 9249 |
{ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } |
| 9250 |
} |
| 9251 |
} |
| 9252 |
% \end{macrocode} |
| 9253 |
% If, in fact, all the cells of the columns are empty (no PGF/TikZ nodes in |
| 9254 |
% those cells). |
| 9255 |
% \begin{macrocode} |
| 9256 |
\dim_compare:nNnT \l_@@_x_final_dim = { - \c_max_dim } |
| 9257 |
{ |
| 9258 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_final_j_int + 1 } } |
| 9259 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 9260 |
\dim_sub:Nn \l_@@_x_final_dim \col@sep |
| 9261 |
} |
| 9262 |
} |
| 9263 |
% \end{macrocode} |
| 9264 |
% |
| 9265 |
% |
| 9266 |
% |
| 9267 |
% \interitem |
| 9268 |
% The first and the second arguments are the coordinates of the cell where the |
| 9269 |
% command has been issued. The third argument is the list of the options. |
| 9270 |
% \begin{macrocode} |
| 9271 |
\cs_new_protected:Npn \@@_draw_Ldots:nnn #1 #2 #3 |
| 9272 |
{ |
| 9273 |
\@@_adjust_to_submatrix:nn { #1 } { #2 } |
| 9274 |
\cs_if_free:cT { @@ _ dotted _ #1 - #2 } |
| 9275 |
{ |
| 9276 |
\@@_find_extremities:nnnn { #1 } { #2 } 0 1 |
| 9277 |
% \end{macrocode} |
| 9278 |
% The previous command may have changed the current environment by marking some |
| 9279 |
% cells as ``dotted'', but, fortunately, it is outside the group for the options |
| 9280 |
% of the line. |
| 9281 |
% \begin{macrocode} |
| 9282 |
\bool_if:NT \g_@@_aux_found_bool |
| 9283 |
{ |
| 9284 |
{ |
| 9285 |
\@@_open_shorten: |
| 9286 |
\int_if_zero:nTF { #1 } |
| 9287 |
{ \color { nicematrix-first-row } } |
| 9288 |
{ |
| 9289 |
% \end{macrocode} |
| 9290 |
% We remind that, when there is a ``last row'' |\l_@@_last_row_int| will always |
| 9291 |
% be (after the construction of the array) the number of that ``last row'' even |
| 9292 |
% if the option |last-row| has been used without value. |
| 9293 |
% \begin{macrocode} |
| 9294 |
\int_compare:nNnT { #1 } = \l_@@_last_row_int |
| 9295 |
{ \color { nicematrix-last-row } } |
| 9296 |
} |
| 9297 |
\keys_set:nn { nicematrix / xdots } { #3 } |
| 9298 |
\@@_color:o \l_@@_xdots_color_tl |
| 9299 |
\@@_actually_draw_Ldots: |
| 9300 |
} |
| 9301 |
} |
| 9302 |
} |
| 9303 |
} |
| 9304 |
% \end{macrocode} |
| 9305 |
% |
| 9306 |
% |
| 9307 |
% \medskip |
| 9308 |
% The command |\@@_actually_draw_Ldots:| has the following implicit arguments: |
| 9309 |
% \begin{itemize} |
| 9310 |
% \item |\l_@@_initial_i_int| |
| 9311 |
% \item |\l_@@_initial_j_int| |
| 9312 |
% \item |\l_@@_initial_open_bool| |
| 9313 |
% \item |\l_@@_final_i_int| |
| 9314 |
% \item |\l_@@_final_j_int| |
| 9315 |
% \item |\l_@@_final_open_bool|. |
| 9316 |
% \end{itemize} |
| 9317 |
% |
| 9318 |
% The following function is also used by |\Hdotsfor|. |
| 9319 |
% \begin{macrocode} |
| 9320 |
\cs_new_protected:Npn \@@_actually_draw_Ldots: |
| 9321 |
{ |
| 9322 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9323 |
{ |
| 9324 |
\@@_open_x_initial_dim: |
| 9325 |
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } |
| 9326 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 9327 |
} |
| 9328 |
{ \@@_set_initial_coords_from_anchor:n { base~east } } |
| 9329 |
\bool_if:NTF \l_@@_final_open_bool |
| 9330 |
{ |
| 9331 |
\@@_open_x_final_dim: |
| 9332 |
\@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } |
| 9333 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 9334 |
} |
| 9335 |
{ \@@_set_final_coords_from_anchor:n { base~west } } |
| 9336 |
% \end{macrocode} |
| 9337 |
% Now the case of a |\Hdotsfor| (or when there is only a |\Ldots|) in the ``last |
| 9338 |
% row'' (that case will probably arise when the final user draws an arrow to |
| 9339 |
% indicate the number of columns of the matrix). In the ``first row'', we don't |
| 9340 |
% need any adjustment. |
| 9341 |
% \begin{macrocode} |
| 9342 |
\bool_lazy_all:nTF |
| 9343 |
{ |
| 9344 |
\l_@@_initial_open_bool |
| 9345 |
\l_@@_final_open_bool |
| 9346 |
{ \int_compare_p:nNn \l_@@_initial_i_int = \l_@@_last_row_int } |
| 9347 |
} |
| 9348 |
{ |
| 9349 |
\dim_add:Nn \l_@@_y_initial_dim \c_@@_shift_Ldots_last_row_dim |
| 9350 |
\dim_add:Nn \l_@@_y_final_dim \c_@@_shift_Ldots_last_row_dim |
| 9351 |
} |
| 9352 |
% \end{macrocode} |
| 9353 |
% We raise the line of a quantity equal to the radius of the dots because we |
| 9354 |
% want the dots really ``on'' the line of texte. Of course, maybe we should not |
| 9355 |
% do that when the option |line-style| is used (?). |
| 9356 |
% \begin{macrocode} |
| 9357 |
{ |
| 9358 |
\dim_add:Nn \l_@@_y_initial_dim \l_@@_xdots_radius_dim |
| 9359 |
\dim_add:Nn \l_@@_y_final_dim \l_@@_xdots_radius_dim |
| 9360 |
} |
| 9361 |
\@@_draw_line: |
| 9362 |
} |
| 9363 |
% \end{macrocode} |
| 9364 |
% |
| 9365 |
% \interitem |
| 9366 |
% The first and the second arguments are the coordinates of the cell where the |
| 9367 |
% command has been issued. The third argument is the list of the options. |
| 9368 |
% \begin{macrocode} |
| 9369 |
\cs_new_protected:Npn \@@_draw_Cdots:nnn #1 #2 #3 |
| 9370 |
{ |
| 9371 |
\@@_adjust_to_submatrix:nn { #1 } { #2 } |
| 9372 |
\cs_if_free:cT { @@ _ dotted _ #1 - #2 } |
| 9373 |
{ |
| 9374 |
\@@_find_extremities:nnnn { #1 } { #2 } 0 1 |
| 9375 |
% \end{macrocode} |
| 9376 |
% The previous command may have changed the current environment by marking some |
| 9377 |
% cells as ``dotted'', but, fortunately, it is outside the group for the options |
| 9378 |
% of the line. |
| 9379 |
% \begin{macrocode} |
| 9380 |
\bool_if:NT \g_@@_aux_found_bool |
| 9381 |
{ |
| 9382 |
{ |
| 9383 |
\@@_open_shorten: |
| 9384 |
\int_if_zero:nTF { #1 } |
| 9385 |
{ \color { nicematrix-first-row } } |
| 9386 |
{ |
| 9387 |
% \end{macrocode} |
| 9388 |
% We remind that, when there is a ``last row'' |\l_@@_last_row_int| will always |
| 9389 |
% be (after the construction of the array) the number of that ``last row'' even |
| 9390 |
% if the option |last-row| has been used without value. |
| 9391 |
% \begin{macrocode} |
| 9392 |
\int_compare:nNnT { #1 } = \l_@@_last_row_int |
| 9393 |
{ \color { nicematrix-last-row } } |
| 9394 |
} |
| 9395 |
\keys_set:nn { nicematrix / xdots } { #3 } |
| 9396 |
\@@_color:o \l_@@_xdots_color_tl |
| 9397 |
\@@_actually_draw_Cdots: |
| 9398 |
} |
| 9399 |
} |
| 9400 |
} |
| 9401 |
} |
| 9402 |
% \end{macrocode} |
| 9403 |
% |
| 9404 |
% |
| 9405 |
% \medskip |
| 9406 |
% The command |\@@_actually_draw_Cdots:| has the following implicit arguments: |
| 9407 |
% \begin{itemize} |
| 9408 |
% \item |\l_@@_initial_i_int| |
| 9409 |
% \item |\l_@@_initial_j_int| |
| 9410 |
% \item |\l_@@_initial_open_bool| |
| 9411 |
% \item |\l_@@_final_i_int| |
| 9412 |
% \item |\l_@@_final_j_int| |
| 9413 |
% \item |\l_@@_final_open_bool|. |
| 9414 |
% \end{itemize} |
| 9415 |
% |
| 9416 |
% \begin{macrocode} |
| 9417 |
\cs_new_protected:Npn \@@_actually_draw_Cdots: |
| 9418 |
{ |
| 9419 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9420 |
\@@_open_x_initial_dim: |
| 9421 |
{ \@@_set_initial_coords_from_anchor:n { mid~east } } |
| 9422 |
\bool_if:NTF \l_@@_final_open_bool |
| 9423 |
\@@_open_x_final_dim: |
| 9424 |
{ \@@_set_final_coords_from_anchor:n { mid~west } } |
| 9425 |
\bool_lazy_and:nnTF \l_@@_initial_open_bool \l_@@_final_open_bool |
| 9426 |
{ |
| 9427 |
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } |
| 9428 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 9429 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_initial_i_int + 1 } } |
| 9430 |
\dim_set:Nn \l_@@_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } |
| 9431 |
\dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim |
| 9432 |
} |
| 9433 |
{ |
| 9434 |
\bool_if:NT \l_@@_initial_open_bool |
| 9435 |
{ \dim_set_eq:NN \l_@@_y_initial_dim \l_@@_y_final_dim } |
| 9436 |
\bool_if:NT \l_@@_final_open_bool |
| 9437 |
{ \dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim } |
| 9438 |
} |
| 9439 |
\@@_draw_line: |
| 9440 |
} |
| 9441 |
% \end{macrocode} |
| 9442 |
% |
| 9443 |
% \begin{macrocode} |
| 9444 |
\cs_new_protected:Npn \@@_open_y_initial_dim: |
| 9445 |
{ |
| 9446 |
\dim_set:Nn \l_@@_y_initial_dim { - \c_max_dim } |
| 9447 |
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int |
| 9448 |
{ |
| 9449 |
\cs_if_exist:cT |
| 9450 |
{ pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 } |
| 9451 |
{ |
| 9452 |
\pgfpointanchor |
| 9453 |
{ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 } |
| 9454 |
{ north } |
| 9455 |
\dim_compare:nNnT \pgf@y > \l_@@_y_initial_dim |
| 9456 |
{ \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y } |
| 9457 |
} |
| 9458 |
} |
| 9459 |
\dim_compare:nNnT \l_@@_y_initial_dim = { - \c_max_dim } |
| 9460 |
{ |
| 9461 |
\@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } |
| 9462 |
\dim_set:Nn \l_@@_y_initial_dim |
| 9463 |
{ |
| 9464 |
\fp_to_dim:n |
| 9465 |
{ |
| 9466 |
\pgf@y |
| 9467 |
+ ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch |
| 9468 |
} |
| 9469 |
} |
| 9470 |
} |
| 9471 |
} |
| 9472 |
% \end{macrocode} |
| 9473 |
% |
| 9474 |
% |
| 9475 |
% \begin{macrocode} |
| 9476 |
\cs_new_protected:Npn \@@_open_y_final_dim: |
| 9477 |
{ |
| 9478 |
\dim_set_eq:NN \l_@@_y_final_dim \c_max_dim |
| 9479 |
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int |
| 9480 |
{ |
| 9481 |
\cs_if_exist:cT |
| 9482 |
{ pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 } |
| 9483 |
{ |
| 9484 |
\pgfpointanchor |
| 9485 |
{ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 } |
| 9486 |
{ south } |
| 9487 |
\dim_compare:nNnT \pgf@y < \l_@@_y_final_dim |
| 9488 |
{ \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } |
| 9489 |
} |
| 9490 |
} |
| 9491 |
\dim_compare:nNnT \l_@@_y_final_dim = \c_max_dim |
| 9492 |
{ |
| 9493 |
\@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } |
| 9494 |
\dim_set:Nn \l_@@_y_final_dim |
| 9495 |
{ \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } } |
| 9496 |
} |
| 9497 |
} |
| 9498 |
% \end{macrocode} |
| 9499 |
% |
| 9500 |
% The first and the second arguments are the coordinates of the cell where the |
| 9501 |
% command has been issued. The third argument is the list of the options. |
| 9502 |
% \begin{macrocode} |
| 9503 |
\cs_new_protected:Npn \@@_draw_Vdots:nnn #1 #2 #3 |
| 9504 |
{ |
| 9505 |
\@@_adjust_to_submatrix:nn { #1 } { #2 } |
| 9506 |
\cs_if_free:cT { @@ _ dotted _ #1 - #2 } |
| 9507 |
{ |
| 9508 |
\@@_find_extremities:nnnn { #1 } { #2 } 1 0 |
| 9509 |
% \end{macrocode} |
| 9510 |
% The previous command may have changed the current environment by marking some |
| 9511 |
% cells as ``dotted'', but, fortunately, it is outside the group for the options |
| 9512 |
% of the line. |
| 9513 |
% \begin{macrocode} |
| 9514 |
\bool_if:NT \g_@@_aux_found_bool |
| 9515 |
{ |
| 9516 |
{ |
| 9517 |
\@@_open_shorten: |
| 9518 |
\int_if_zero:nTF { #2 } |
| 9519 |
{ \color { nicematrix-first-col } } |
| 9520 |
{ |
| 9521 |
\int_compare:nNnT { #2 } = \l_@@_last_col_int |
| 9522 |
{ \color { nicematrix-last-col } } |
| 9523 |
} |
| 9524 |
\keys_set:nn { nicematrix / xdots } { #3 } |
| 9525 |
\@@_color:o \l_@@_xdots_color_tl |
| 9526 |
\bool_if:NTF \l_@@_Vbrace_bool |
| 9527 |
\@@_actually_draw_Vbrace: |
| 9528 |
\@@_actually_draw_Vdots: |
| 9529 |
} |
| 9530 |
} |
| 9531 |
} |
| 9532 |
} |
| 9533 |
% \end{macrocode} |
| 9534 |
% |
| 9535 |
% \bigskip |
| 9536 |
% The following function is used by regular calls of |\Vdots| or |\Vdotsfor| but |
| 9537 |
% not by |\Vbrace|. |
| 9538 |
% |
| 9539 |
% The command |\@@_actually_draw_Vdots:| has the following implicit arguments: |
| 9540 |
% \begin{itemize} |
| 9541 |
% \item |\l_@@_initial_i_int| |
| 9542 |
% \item |\l_@@_initial_j_int| |
| 9543 |
% \item |\l_@@_initial_open_bool| |
| 9544 |
% \item |\l_@@_final_i_int| |
| 9545 |
% \item |\l_@@_final_j_int| |
| 9546 |
% \item |\l_@@_final_open_bool|. |
| 9547 |
% \end{itemize} |
| 9548 |
% |
| 9549 |
% |
| 9550 |
% |
| 9551 |
% \begin{macrocode} |
| 9552 |
\cs_new_protected:Npn \@@_actually_draw_Vdots: |
| 9553 |
{ |
| 9554 |
\bool_lazy_and:nnTF \l_@@_initial_open_bool \l_@@_final_open_bool |
| 9555 |
\@@_actually_draw_Vdots_i: |
| 9556 |
\@@_actually_draw_Vdots_ii: |
| 9557 |
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim |
| 9558 |
\@@_draw_line: |
| 9559 |
} |
| 9560 |
% \end{macrocode} |
| 9561 |
% |
| 9562 |
% |
| 9563 |
% \bigskip |
| 9564 |
% First, the case of a dotted line open on both sides. |
| 9565 |
% \begin{macrocode} |
| 9566 |
\cs_new_protected:Npn \@@_actually_draw_Vdots_i: |
| 9567 |
{ |
| 9568 |
\@@_open_y_initial_dim: |
| 9569 |
\@@_open_y_final_dim: |
| 9570 |
\int_if_zero:nTF \l_@@_initial_j_int |
| 9571 |
% \end{macrocode} |
| 9572 |
% We have a dotted line open on both sides in the ``first column''. |
| 9573 |
% \begin{macrocode} |
| 9574 |
{ |
| 9575 |
\@@_qpoint:n { col - 1 } |
| 9576 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9577 |
\dim_sub:Nn \l_@@_x_initial_dim |
| 9578 |
{ \@@_colsep: + \l_@@_left_margin_dim + \l_@@_extra_left_margin_dim } |
| 9579 |
} |
| 9580 |
{ |
| 9581 |
\bool_lazy_and:nnTF |
| 9582 |
{ \int_compare_p:nNn \l_@@_last_col_int > { -2 } } |
| 9583 |
{ \int_compare_p:nNn \l_@@_initial_j_int = \g_@@_col_total_int } |
| 9584 |
% \end{macrocode} |
| 9585 |
% We have a dotted line open on both sides and which is in the ``last column''. |
| 9586 |
% \begin{macrocode} |
| 9587 |
{ |
| 9588 |
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } |
| 9589 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9590 |
\dim_add:Nn \l_@@_x_initial_dim |
| 9591 |
{ \@@_colsep: + \l_@@_right_margin_dim + \l_@@_extra_right_margin_dim } |
| 9592 |
} |
| 9593 |
% \end{macrocode} |
| 9594 |
% We have a dotted line open on both sides which is \emph{not} in an exterior column. |
| 9595 |
% \begin{macrocode} |
| 9596 |
{ |
| 9597 |
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } |
| 9598 |
\dim_set_eq:NN \l_tmpa_dim \pgf@x |
| 9599 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_initial_j_int + 1 } } |
| 9600 |
\dim_set:Nn \l_@@_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } |
| 9601 |
} |
| 9602 |
} |
| 9603 |
} |
| 9604 |
% \end{macrocode} |
| 9605 |
% The command |\@@_draw_line:| is in |\@@_actually_draw_Vdots:| |
| 9606 |
% |
| 9607 |
% \bigskip |
| 9608 |
% Now, the dotted line is \emph{not} open on both sides (maybe open on only one side). |
| 9609 |
% |
| 9610 |
% The main task is to determine the $x$-value of the dotted line to draw. |
| 9611 |
% |
| 9612 |
% The boolean |\l_tmpa_bool| will indicate whether the column is of type |l| or |
| 9613 |
% may be considered as if. |
| 9614 |
% |
| 9615 |
% \begin{macrocode} |
| 9616 |
\cs_new_protected:Npn \@@_actually_draw_Vdots_ii: |
| 9617 |
{ |
| 9618 |
\bool_set_false:N \l_tmpa_bool |
| 9619 |
\bool_if:NF \l_@@_initial_open_bool |
| 9620 |
{ |
| 9621 |
\bool_if:NF \l_@@_final_open_bool |
| 9622 |
{ |
| 9623 |
\@@_set_initial_coords_from_anchor:n { south~west } |
| 9624 |
\@@_set_final_coords_from_anchor:n { north~west } |
| 9625 |
\bool_set:Nn \l_tmpa_bool |
| 9626 |
{ \dim_compare_p:nNn \l_@@_x_initial_dim = \l_@@_x_final_dim } |
| 9627 |
} |
| 9628 |
} |
| 9629 |
% \end{macrocode} |
| 9630 |
% Now, we try to determine whether the column is of type |c| or may be |
| 9631 |
% considered as if. |
| 9632 |
% \begin{macrocode} |
| 9633 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9634 |
{ |
| 9635 |
\@@_open_y_initial_dim: |
| 9636 |
\@@_set_final_coords_from_anchor:n { north } |
| 9637 |
\dim_set_eq:NN \l_@@_x_initial_dim \l_@@_x_final_dim |
| 9638 |
} |
| 9639 |
{ |
| 9640 |
\@@_set_initial_coords_from_anchor:n { south } |
| 9641 |
\bool_if:NTF \l_@@_final_open_bool |
| 9642 |
\@@_open_y_final_dim: |
| 9643 |
% \end{macrocode} |
| 9644 |
% Now the case where both extremities are closed. The first conditional tests |
| 9645 |
% whether the column is of type |c| or may be considered as if. |
| 9646 |
% \begin{macrocode} |
| 9647 |
{ |
| 9648 |
\@@_set_final_coords_from_anchor:n { north } |
| 9649 |
\dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim |
| 9650 |
{ |
| 9651 |
\dim_set:Nn \l_@@_x_initial_dim |
| 9652 |
{ |
| 9653 |
\bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn |
| 9654 |
\l_@@_x_initial_dim \l_@@_x_final_dim |
| 9655 |
} |
| 9656 |
} |
| 9657 |
} |
| 9658 |
} |
| 9659 |
} |
| 9660 |
% \end{macrocode} |
| 9661 |
% |
| 9662 |
% \bigskip |
| 9663 |
% The following function is used by |\Vbrace| but not by regular uses of |
| 9664 |
% |\Vdots| or |\Vdotsfor|. |
| 9665 |
% |
| 9666 |
% The command |\@@_actually_draw_Vbrace:| has the following implicit arguments: |
| 9667 |
% \begin{itemize} |
| 9668 |
% \item |\l_@@_initial_i_int| |
| 9669 |
% \item |\l_@@_initial_j_int| |
| 9670 |
% \item |\l_@@_initial_open_bool| |
| 9671 |
% \item |\l_@@_final_i_int| |
| 9672 |
% \item |\l_@@_final_j_int| |
| 9673 |
% \item |\l_@@_final_open_bool|. |
| 9674 |
% \end{itemize} |
| 9675 |
% |
| 9676 |
% \begin{macrocode} |
| 9677 |
\cs_new_protected:Npn \@@_actually_draw_Vbrace: |
| 9678 |
{ |
| 9679 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9680 |
\@@_open_y_initial_dim: |
| 9681 |
{ \@@_set_initial_coords_from_anchor:n { south } } |
| 9682 |
\bool_if:NTF \l_@@_final_open_bool |
| 9683 |
\@@_open_y_final_dim: |
| 9684 |
{ \@@_set_final_coords_from_anchor:n { north } } |
| 9685 |
% \end{macrocode} |
| 9686 |
% Now, we have the correct values for the $y$-values of both extremities of the brace. |
| 9687 |
% We have to compute the $x$-value (there is only one $x$-value since, of course, |
| 9688 |
% the brace is vertical). |
| 9689 |
% |
| 9690 |
% \medskip |
| 9691 |
% If we are in the first (exterior) column, the brace must be drawn right flush. |
| 9692 |
% \begin{macrocode} |
| 9693 |
\int_if_zero:nTF \l_@@_initial_j_int |
| 9694 |
{ |
| 9695 |
\@@_qpoint:n { col - 1 } |
| 9696 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9697 |
\dim_sub:Nn \l_@@_x_initial_dim |
| 9698 |
{ \@@_colsep: + \l_@@_left_margin_dim + \l_@@_extra_left_margin_dim } |
| 9699 |
} |
| 9700 |
% \end{macrocode} |
| 9701 |
% Elsewhere, the brace must be drawn left flush. |
| 9702 |
% \begin{macrocode} |
| 9703 |
{ |
| 9704 |
\@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } |
| 9705 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 9706 |
\dim_add:Nn \l_@@_x_initial_dim |
| 9707 |
{ \@@_colsep: + \l_@@_right_margin_dim + \l_@@_extra_right_margin_dim } |
| 9708 |
} |
| 9709 |
% \end{macrocode} |
| 9710 |
% We draw a vertical rule and that's why, of course, both $x$-values are equal. |
| 9711 |
% \begin{macrocode} |
| 9712 |
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim |
| 9713 |
\@@_draw_line: |
| 9714 |
} |
| 9715 |
% \end{macrocode} |
| 9716 |
% |
| 9717 |
% \bigskip |
| 9718 |
% \begin{macrocode} |
| 9719 |
\cs_new:Npn \@@_colsep: |
| 9720 |
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep } |
| 9721 |
% \end{macrocode} |
| 9722 |
% |
| 9723 |
% \interitem |
| 9724 |
% For the diagonal lines, the situation is a bit more complicated because, by |
| 9725 |
% default, we parallelize the diagonals lines. The first diagonal line is drawn |
| 9726 |
% and then, all the other diagonal lines are drawn parallel to the first one. |
| 9727 |
% |
| 9728 |
% The first and the second arguments are the coordinates of the cell where the |
| 9729 |
% command has been issued. The third argument is the list of the options. |
| 9730 |
% \begin{macrocode} |
| 9731 |
\cs_new_protected:Npn \@@_draw_Ddots:nnn #1 #2 #3 |
| 9732 |
{ |
| 9733 |
\@@_adjust_to_submatrix:nn { #1 } { #2 } |
| 9734 |
\cs_if_free:cT { @@ _ dotted _ #1 - #2 } |
| 9735 |
{ |
| 9736 |
\@@_find_extremities:nnnn { #1 } { #2 } { 1 } { 1 } |
| 9737 |
% \end{macrocode} |
| 9738 |
% The previous command may have changed the current environment by marking some |
| 9739 |
% cells as ``dotted'', but, fortunately, it is outside the group for the options |
| 9740 |
% of the line. |
| 9741 |
% \begin{macrocode} |
| 9742 |
\bool_if:NT \g_@@_aux_found_bool |
| 9743 |
{ |
| 9744 |
{ |
| 9745 |
\@@_open_shorten: |
| 9746 |
\keys_set:nn { nicematrix / xdots } { #3 } |
| 9747 |
\@@_color:o \l_@@_xdots_color_tl |
| 9748 |
\@@_actually_draw_Ddots: |
| 9749 |
} |
| 9750 |
} |
| 9751 |
} |
| 9752 |
} |
| 9753 |
% \end{macrocode} |
| 9754 |
% |
| 9755 |
% \bigskip |
| 9756 |
% The command |\@@_actually_draw_Ddots:| has the following implicit arguments: |
| 9757 |
% \begin{itemize} |
| 9758 |
% \item |\l_@@_initial_i_int| |
| 9759 |
% \item |\l_@@_initial_j_int| |
| 9760 |
% \item |\l_@@_initial_open_bool| |
| 9761 |
% \item |\l_@@_final_i_int| |
| 9762 |
% \item |\l_@@_final_j_int| |
| 9763 |
% \item |\l_@@_final_open_bool|. |
| 9764 |
% \end{itemize} |
| 9765 |
% |
| 9766 |
% \begin{macrocode} |
| 9767 |
\cs_new_protected:Npn \@@_actually_draw_Ddots: |
| 9768 |
{ |
| 9769 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9770 |
{ |
| 9771 |
\@@_open_y_initial_dim: |
| 9772 |
\@@_open_x_initial_dim: |
| 9773 |
} |
| 9774 |
{ \@@_set_initial_coords_from_anchor:n { south~east } } |
| 9775 |
\bool_if:NTF \l_@@_final_open_bool |
| 9776 |
{ |
| 9777 |
\@@_open_x_final_dim: |
| 9778 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 9779 |
} |
| 9780 |
{ \@@_set_final_coords_from_anchor:n { north~west } } |
| 9781 |
% \end{macrocode} |
| 9782 |
% We have retrieved the coordinates in the usual way (they are stored in |
| 9783 |
% |\l_@@_x_initial_dim|, etc.). If the parallelization of the diagonals is set, |
| 9784 |
% we will have (maybe) to adjust the fourth coordinate. |
| 9785 |
% \begin{macrocode} |
| 9786 |
\bool_if:NT \l_@@_parallelize_diags_bool |
| 9787 |
{ |
| 9788 |
\int_gincr:N \g_@@_ddots_int |
| 9789 |
% \end{macrocode} |
| 9790 |
% We test if the diagonal line is the first one (the counter |\g_@@_ddots_int| |
| 9791 |
% is created for this usage). |
| 9792 |
% \begin{macrocode} |
| 9793 |
\int_compare:nNnTF \g_@@_ddots_int = 1 |
| 9794 |
% \end{macrocode} |
| 9795 |
% If the diagonal line is the first one, we have no adjustment of the line to do |
| 9796 |
% but we store the $\Delta_x$ and the $\Delta_y$ of the line because these |
| 9797 |
% values will be used to draw the others diagonal lines parallels to the first |
| 9798 |
% one. |
| 9799 |
% \begin{macrocode} |
| 9800 |
{ |
| 9801 |
\dim_gset:Nn \g_@@_delta_x_one_dim |
| 9802 |
{ \l_@@_x_final_dim - \l_@@_x_initial_dim } |
| 9803 |
\dim_gset:Nn \g_@@_delta_y_one_dim |
| 9804 |
{ \l_@@_y_final_dim - \l_@@_y_initial_dim } |
| 9805 |
} |
| 9806 |
% \end{macrocode} |
| 9807 |
% If the diagonal line is not the first one, we have to adjust the second |
| 9808 |
% extremity of the line by modifying the coordinate |\l_@@_x_initial_dim|. |
| 9809 |
% \begin{macrocode} |
| 9810 |
{ |
| 9811 |
\dim_compare:nNnF \g_@@_delta_x_one_dim = \c_zero_dim |
| 9812 |
{ |
| 9813 |
\dim_set:Nn \l_@@_y_final_dim |
| 9814 |
{ |
| 9815 |
\l_@@_y_initial_dim + |
| 9816 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) * |
| 9817 |
\dim_ratio:nn \g_@@_delta_y_one_dim \g_@@_delta_x_one_dim |
| 9818 |
} |
| 9819 |
} |
| 9820 |
} |
| 9821 |
} |
| 9822 |
\@@_draw_line: |
| 9823 |
} |
| 9824 |
% \end{macrocode} |
| 9825 |
% |
| 9826 |
% \bigskip |
| 9827 |
% We draw the |\Iddots| diagonals in the same way. |
| 9828 |
% |
| 9829 |
% The first and the second arguments are the coordinates of the cell where the |
| 9830 |
% command has been issued. The third argument is the list of the options. |
| 9831 |
% \begin{macrocode} |
| 9832 |
\cs_new_protected:Npn \@@_draw_Iddots:nnn #1 #2 #3 |
| 9833 |
{ |
| 9834 |
\@@_adjust_to_submatrix:nn { #1 } { #2 } |
| 9835 |
\cs_if_free:cT { @@ _ dotted _ #1 - #2 } |
| 9836 |
{ |
| 9837 |
\@@_find_extremities:nnnn { #1 } { #2 } { 1 } { -1 } |
| 9838 |
% \end{macrocode} |
| 9839 |
% The previous command may have changed the current environment by marking some |
| 9840 |
% cells as ``dotted'', but, fortunately, it is outside the group for the options |
| 9841 |
% of the line. |
| 9842 |
% \begin{macrocode} |
| 9843 |
\bool_if:NT \g_@@_aux_found_bool |
| 9844 |
{ |
| 9845 |
{ |
| 9846 |
\@@_open_shorten: |
| 9847 |
\keys_set:nn { nicematrix / xdots } { #3 } |
| 9848 |
\@@_color:o \l_@@_xdots_color_tl |
| 9849 |
\@@_actually_draw_Iddots: |
| 9850 |
} |
| 9851 |
} |
| 9852 |
} |
| 9853 |
} |
| 9854 |
% \end{macrocode} |
| 9855 |
% |
| 9856 |
% \bigskip |
| 9857 |
% The command |\@@_actually_draw_Iddots:| has the following implicit arguments: |
| 9858 |
% \begin{itemize} |
| 9859 |
% \item |\l_@@_initial_i_int| |
| 9860 |
% \item |\l_@@_initial_j_int| |
| 9861 |
% \item |\l_@@_initial_open_bool| |
| 9862 |
% \item |\l_@@_final_i_int| |
| 9863 |
% \item |\l_@@_final_j_int| |
| 9864 |
% \item |\l_@@_final_open_bool|. |
| 9865 |
% \end{itemize} |
| 9866 |
% |
| 9867 |
% \begin{macrocode} |
| 9868 |
\cs_new_protected:Npn \@@_actually_draw_Iddots: |
| 9869 |
{ |
| 9870 |
\bool_if:NTF \l_@@_initial_open_bool |
| 9871 |
{ |
| 9872 |
\@@_open_y_initial_dim: |
| 9873 |
\@@_open_x_initial_dim: |
| 9874 |
} |
| 9875 |
{ \@@_set_initial_coords_from_anchor:n { south~west } } |
| 9876 |
\bool_if:NTF \l_@@_final_open_bool |
| 9877 |
{ |
| 9878 |
\@@_open_y_final_dim: |
| 9879 |
\@@_open_x_final_dim: |
| 9880 |
} |
| 9881 |
{ \@@_set_final_coords_from_anchor:n { north~east } } |
| 9882 |
\bool_if:NT \l_@@_parallelize_diags_bool |
| 9883 |
{ |
| 9884 |
\int_gincr:N \g_@@_iddots_int |
| 9885 |
\int_compare:nNnTF \g_@@_iddots_int = 1 |
| 9886 |
{ |
| 9887 |
\dim_gset:Nn \g_@@_delta_x_two_dim |
| 9888 |
{ \l_@@_x_final_dim - \l_@@_x_initial_dim } |
| 9889 |
\dim_gset:Nn \g_@@_delta_y_two_dim |
| 9890 |
{ \l_@@_y_final_dim - \l_@@_y_initial_dim } |
| 9891 |
} |
| 9892 |
{ |
| 9893 |
\dim_compare:nNnF \g_@@_delta_x_two_dim = \c_zero_dim |
| 9894 |
{ |
| 9895 |
\dim_set:Nn \l_@@_y_final_dim |
| 9896 |
{ |
| 9897 |
\l_@@_y_initial_dim + |
| 9898 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) * |
| 9899 |
\dim_ratio:nn \g_@@_delta_y_two_dim \g_@@_delta_x_two_dim |
| 9900 |
} |
| 9901 |
} |
| 9902 |
} |
| 9903 |
} |
| 9904 |
\@@_draw_line: |
| 9905 |
} |
| 9906 |
% \end{macrocode} |
| 9907 |
% |
| 9908 |
% |
| 9909 |
% \bigskip |
| 9910 |
% \section{The actual instructions for drawing the dotted lines with TikZ} |
| 9911 |
% |
| 9912 |
% The command |\@@_draw_line:| has six implicit arguments: |
| 9913 |
% |
| 9914 |
% \begin{itemize} |
| 9915 |
% \item |\l_@@_x_initial_dim| |
| 9916 |
% \item |\l_@@_y_initial_dim| |
| 9917 |
% \item |\l_@@_x_final_dim| |
| 9918 |
% \item |\l_@@_y_final_dim| |
| 9919 |
% \item |\l_@@_initial_open_bool| |
| 9920 |
% \item |\l_@@_final_open_bool| |
| 9921 |
% \end{itemize} |
| 9922 |
% |
| 9923 |
% |
| 9924 |
% \begin{macrocode} |
| 9925 |
\cs_new_protected:Npn \@@_draw_line: |
| 9926 |
{ |
| 9927 |
\pgfrememberpicturepositiononpagetrue |
| 9928 |
\pgf@relevantforpicturesizefalse |
| 9929 |
\bool_lazy_or:nnTF |
| 9930 |
\l_@@_dotted_bool |
| 9931 |
{ \tl_if_eq_p:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl } |
| 9932 |
\@@_draw_standard_dotted_line: |
| 9933 |
\@@_draw_unstandard_dotted_line: |
| 9934 |
} |
| 9935 |
% \end{macrocode} |
| 9936 |
% |
| 9937 |
% \medskip |
| 9938 |
% We have to do a special construction with |\exp_args:No| to be able to put in |
| 9939 |
% the list of options in the correct place in the TikZ instruction. |
| 9940 |
% \begin{macrocode} |
| 9941 |
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line: |
| 9942 |
{ |
| 9943 |
\begin { scope } |
| 9944 |
\@@_draw_unstandard_dotted_line:o |
| 9945 |
{ \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } |
| 9946 |
} |
| 9947 |
% \end{macrocode} |
| 9948 |
% We have used the fact that, in \textsc{pgf}, a color name can be put directly |
| 9949 |
% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). |
| 9950 |
% |
| 9951 |
% \smallskip |
| 9952 |
% The argument of |\@@_draw_unstandard_dotted_line:n| is, in fact, the list of options. |
| 9953 |
% \begin{macrocode} |
| 9954 |
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:n #1 |
| 9955 |
{ |
| 9956 |
\@@_draw_unstandard_dotted_line:nooo |
| 9957 |
{ #1 } |
| 9958 |
\l_@@_xdots_up_tl |
| 9959 |
\l_@@_xdots_down_tl |
| 9960 |
\l_@@_xdots_middle_tl |
| 9961 |
} |
| 9962 |
\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:n { o } |
| 9963 |
% \end{macrocode} |
| 9964 |
% |
| 9965 |
% |
| 9966 |
% \bigskip |
| 9967 |
% The following TikZ styles are for the three labels (set by the symbols |_|, |
| 9968 |
% |^| and |=|) of a continuous line with a non-standard style. |
| 9969 |
% \begin{macrocode} |
| 9970 |
\AtBeginDocument |
| 9971 |
{ |
| 9972 |
\IfPackageLoadedT { tikz } |
| 9973 |
{ |
| 9974 |
\tikzset |
| 9975 |
{ |
| 9976 |
@@_node_above / .style = { sloped , above } , |
| 9977 |
@@_node_below / .style = { sloped , below } , |
| 9978 |
@@_node_middle / .style = |
| 9979 |
{ |
| 9980 |
sloped , |
| 9981 |
inner~sep = \c_@@_innersep_middle_dim |
| 9982 |
} |
| 9983 |
} |
| 9984 |
} |
| 9985 |
} |
| 9986 |
% \end{macrocode} |
| 9987 |
% |
| 9988 |
% \bigskip |
| 9989 |
% \begin{macrocode} |
| 9990 |
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line:nnnn #1 #2 #3 #4 |
| 9991 |
{ |
| 9992 |
% \end{macrocode} |
| 9993 |
% We take into account the parameters |xdots/shorten-start| and |
| 9994 |
% |xdots/shorten-end| ``by hand'' because, when we use the key |shorten >| and |
| 9995 |
% |shorten <| of TikZ in the command |\draw|, we don't have the expected output |
| 9996 |
% with |{decorate,decoration=brace}| is used. |
| 9997 |
% |
| 9998 |
% \medskip |
| 9999 |
% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use |
| 10000 |
% the floating point reals of the L3 programming layer to compute this length. |
| 10001 |
% \begin{macrocode} |
| 10002 |
\dim_zero_new:N \l_@@_l_dim |
| 10003 |
\dim_set:Nn \l_@@_l_dim |
| 10004 |
{ |
| 10005 |
\fp_to_dim:n |
| 10006 |
{ |
| 10007 |
sqrt |
| 10008 |
( |
| 10009 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) ^ 2 |
| 10010 |
+ |
| 10011 |
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) ^ 2 |
| 10012 |
) |
| 10013 |
} |
| 10014 |
} |
| 10015 |
% \end{macrocode} |
| 10016 |
% It seems that, during the first compilations, the value of |\l_@@_l_dim| may |
| 10017 |
% be erroneous (equal to zero or very large). We must detect these cases |
| 10018 |
% because they would cause errors during the drawing of the dotted line. Maybe |
| 10019 |
% we should also write something in the |aux| file to say that one more |
| 10020 |
% compilation should be done. |
| 10021 |
% \begin{macrocode} |
| 10022 |
\dim_compare:nNnT \l_@@_l_dim < \c_@@_max_l_dim |
| 10023 |
{ |
| 10024 |
\dim_compare:nNnT \l_@@_l_dim > { 1 pt } |
| 10025 |
\@@_draw_unstandard_dotted_line_i: |
| 10026 |
} |
| 10027 |
% \end{macrocode} |
| 10028 |
% |
| 10029 |
% If the key |xdots/horizontal-labels| has been used. |
| 10030 |
% \begin{macrocode} |
| 10031 |
\bool_if:NT \l_@@_xdots_h_labels_bool |
| 10032 |
{ |
| 10033 |
\tikzset |
| 10034 |
{ |
| 10035 |
@@_node_above / .style = { auto = left } , |
| 10036 |
@@_node_below / .style = { auto = right } , |
| 10037 |
@@_node_middle / .style = { inner~sep = \c_@@_innersep_middle_dim } |
| 10038 |
} |
| 10039 |
} |
| 10040 |
\tl_if_empty:nF { #4 } |
| 10041 |
{ \tikzset { @@_node_middle / .append~style = { fill = white } } } |
| 10042 |
% \end{macrocode} |
| 10043 |
% |
| 10044 |
% |
| 10045 |
% \begin{macrocode} |
| 10046 |
\dim_zero:N \l_tmpa_dim |
| 10047 |
\dim_zero:N \l_tmpb_dim |
| 10048 |
\tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_brace_tl |
| 10049 |
{ |
| 10050 |
% \end{macrocode} |
| 10051 |
% We test whether the brace is vertical or horizontal. |
| 10052 |
% \begin{macrocode} |
| 10053 |
\dim_compare:nNnTF \l_@@_x_final_dim = \l_@@_x_initial_dim |
| 10054 |
{ \dim_set_eq:NN \l_tmpa_dim \l_@@_brace_shift_dim } |
| 10055 |
{ \dim_set_eq:NN \l_tmpb_dim \l_@@_brace_shift_dim } |
| 10056 |
} |
| 10057 |
{ |
| 10058 |
\tl_if_eq:NNT \l_@@_xdots_line_style_tl \c_@@_mirrored_brace_tl |
| 10059 |
{ |
| 10060 |
\dim_compare:nNnTF \l_@@_x_final_dim = \l_@@_x_initial_dim |
| 10061 |
{ \dim_set:Nn \l_tmpa_dim { - \l_@@_brace_shift_dim } } |
| 10062 |
{ \dim_set:Nn \l_tmpb_dim { - \l_@@_brace_shift_dim } } |
| 10063 |
} |
| 10064 |
} |
| 10065 |
\use:e |
| 10066 |
{ |
| 10067 |
\exp_not:N \begin { scope } |
| 10068 |
[ shift = {(\dim_use:N \l_tmpa_dim, \dim_use:N \l_tmpb_dim)} ] |
| 10069 |
} |
| 10070 |
\draw |
| 10071 |
[ #1 ] |
| 10072 |
( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) |
| 10073 |
-- node [ @@_node_middle] { $ \scriptstyle #4 $ } |
| 10074 |
node [ @@_node_below ] { $ \scriptstyle #3 $ } |
| 10075 |
node [ @@_node_above ] { $ \scriptstyle #2 $ } |
| 10076 |
( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; |
| 10077 |
\end { scope } |
| 10078 |
\end { scope } |
| 10079 |
} |
| 10080 |
\cs_generate_variant:Nn \@@_draw_unstandard_dotted_line:nnnn { n o o o } |
| 10081 |
% \end{macrocode} |
| 10082 |
% |
| 10083 |
% \begin{macrocode} |
| 10084 |
\cs_new_protected:Npn \@@_draw_unstandard_dotted_line_i: |
| 10085 |
{ |
| 10086 |
\dim_set:Nn \l_tmpa_dim |
| 10087 |
{ |
| 10088 |
\l_@@_x_initial_dim |
| 10089 |
+ ( \l_@@_x_final_dim - \l_@@_x_initial_dim ) |
| 10090 |
* \dim_ratio:nn \l_@@_xdots_shorten_start_dim \l_@@_l_dim |
| 10091 |
} |
| 10092 |
\dim_set:Nn \l_tmpb_dim |
| 10093 |
{ |
| 10094 |
\l_@@_y_initial_dim |
| 10095 |
+ ( \l_@@_y_final_dim - \l_@@_y_initial_dim ) |
| 10096 |
* \dim_ratio:nn \l_@@_xdots_shorten_start_dim \l_@@_l_dim |
| 10097 |
} |
| 10098 |
\dim_set:Nn \l_@@_tmpc_dim |
| 10099 |
{ |
| 10100 |
\l_@@_x_final_dim |
| 10101 |
- ( \l_@@_x_final_dim - \l_@@_x_initial_dim ) |
| 10102 |
* \dim_ratio:nn \l_@@_xdots_shorten_end_dim \l_@@_l_dim |
| 10103 |
} |
| 10104 |
\dim_set:Nn \l_@@_tmpd_dim |
| 10105 |
{ |
| 10106 |
\l_@@_y_final_dim |
| 10107 |
- ( \l_@@_y_final_dim - \l_@@_y_initial_dim ) |
| 10108 |
* \dim_ratio:nn \l_@@_xdots_shorten_end_dim \l_@@_l_dim |
| 10109 |
} |
| 10110 |
\dim_set_eq:NN \l_@@_x_initial_dim \l_tmpa_dim |
| 10111 |
\dim_set_eq:NN \l_@@_y_initial_dim \l_tmpb_dim |
| 10112 |
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_tmpc_dim |
| 10113 |
\dim_set_eq:NN \l_@@_y_final_dim \l_@@_tmpd_dim |
| 10114 |
} |
| 10115 |
% \end{macrocode} |
| 10116 |
% |
| 10117 |
% |
| 10118 |
% \bigskip |
| 10119 |
% The command |\@@_draw_standard_dotted_line:| draws the line with our system of dots |
| 10120 |
% (which gives a dotted line with real rounded dots). |
| 10121 |
% \begin{macrocode} |
| 10122 |
\cs_new_protected:Npn \@@_draw_standard_dotted_line: |
| 10123 |
{ |
| 10124 |
{ |
| 10125 |
% \end{macrocode} |
| 10126 |
% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use |
| 10127 |
% the floating point reals of the L3 programming layer to compute this length. |
| 10128 |
% \begin{macrocode} |
| 10129 |
\dim_zero_new:N \l_@@_l_dim |
| 10130 |
\dim_set:Nn \l_@@_l_dim |
| 10131 |
{ |
| 10132 |
\fp_to_dim:n |
| 10133 |
{ |
| 10134 |
sqrt |
| 10135 |
( |
| 10136 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) ^ 2 |
| 10137 |
+ |
| 10138 |
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) ^ 2 |
| 10139 |
) |
| 10140 |
} |
| 10141 |
} |
| 10142 |
% \end{macrocode} |
| 10143 |
% It seems that, during the first compilations, the value of |\l_@@_l_dim| may |
| 10144 |
% be erroneous (equal to zero or very large). We must detect these cases |
| 10145 |
% because they would cause errors during the drawing of the dotted line. Maybe |
| 10146 |
% we should also write something in the |aux| file to say that one more |
| 10147 |
% compilation should be done. |
| 10148 |
% \begin{macrocode} |
| 10149 |
\dim_compare:nNnT \l_@@_l_dim < \c_@@_max_l_dim |
| 10150 |
{ |
| 10151 |
\dim_compare:nNnT \l_@@_l_dim > { 1 pt } |
| 10152 |
\@@_draw_standard_dotted_line_i: |
| 10153 |
} |
| 10154 |
} |
| 10155 |
% \end{macrocode} |
| 10156 |
% \begin{macrocode} |
| 10157 |
\bool_lazy_all:nF |
| 10158 |
{ |
| 10159 |
{ \tl_if_empty_p:N \l_@@_xdots_up_tl } |
| 10160 |
{ \tl_if_empty_p:N \l_@@_xdots_down_tl } |
| 10161 |
{ \tl_if_empty_p:N \l_@@_xdots_middle_tl } |
| 10162 |
} |
| 10163 |
\@@_labels_standard_dotted_line: |
| 10164 |
} |
| 10165 |
% \end{macrocode} |
| 10166 |
% |
| 10167 |
% \begin{macrocode} |
| 10168 |
\dim_const:Nn \c_@@_max_l_dim { 50 cm } |
| 10169 |
% \end{macrocode} |
| 10170 |
% |
| 10171 |
% \begin{macrocode} |
| 10172 |
\cs_new_protected:Npn \@@_draw_standard_dotted_line_i: |
| 10173 |
{ |
| 10174 |
% \end{macrocode} |
| 10175 |
% The number of dots will be |\l_tmpa_int + 1|. |
| 10176 |
% \begin{macrocode} |
| 10177 |
\int_set:Nn \l_tmpa_int |
| 10178 |
{ |
| 10179 |
\dim_ratio:nn |
| 10180 |
{ |
| 10181 |
\l_@@_l_dim |
| 10182 |
- \l_@@_xdots_shorten_start_dim |
| 10183 |
- \l_@@_xdots_shorten_end_dim |
| 10184 |
} |
| 10185 |
\l_@@_xdots_inter_dim |
| 10186 |
} |
| 10187 |
% \end{macrocode} |
| 10188 |
% |
| 10189 |
% \medskip |
| 10190 |
% The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the |
| 10191 |
% vector between two dots in the dotted line. |
| 10192 |
% \begin{macrocode} |
| 10193 |
\dim_set:Nn \l_tmpa_dim |
| 10194 |
{ |
| 10195 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) * |
| 10196 |
\dim_ratio:nn \l_@@_xdots_inter_dim \l_@@_l_dim |
| 10197 |
} |
| 10198 |
\dim_set:Nn \l_tmpb_dim |
| 10199 |
{ |
| 10200 |
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) * |
| 10201 |
\dim_ratio:nn \l_@@_xdots_inter_dim \l_@@_l_dim |
| 10202 |
} |
| 10203 |
% \end{macrocode} |
| 10204 |
% |
| 10205 |
% In the loop over the dots, the dimensions |\l_@@_x_initial_dim| and |
| 10206 |
% |\l_@@_y_initial_dim| will be used for the coordinates of the dots. But, |
| 10207 |
% before the loop, we must move until the first dot. |
| 10208 |
% |
| 10209 |
% \begin{macrocode} |
| 10210 |
\dim_gadd:Nn \l_@@_x_initial_dim |
| 10211 |
{ |
| 10212 |
( \l_@@_x_final_dim - \l_@@_x_initial_dim ) * |
| 10213 |
\dim_ratio:nn |
| 10214 |
{ |
| 10215 |
\l_@@_l_dim - \l_@@_xdots_inter_dim * \l_tmpa_int |
| 10216 |
+ \l_@@_xdots_shorten_start_dim - \l_@@_xdots_shorten_end_dim |
| 10217 |
} |
| 10218 |
{ 2 \l_@@_l_dim } |
| 10219 |
} |
| 10220 |
\dim_gadd:Nn \l_@@_y_initial_dim |
| 10221 |
{ |
| 10222 |
( \l_@@_y_final_dim - \l_@@_y_initial_dim ) * |
| 10223 |
\dim_ratio:nn |
| 10224 |
{ |
| 10225 |
\l_@@_l_dim - \l_@@_xdots_inter_dim * \l_tmpa_int |
| 10226 |
+ \l_@@_xdots_shorten_start_dim - \l_@@_xdots_shorten_end_dim |
| 10227 |
} |
| 10228 |
{ 2 \l_@@_l_dim } |
| 10229 |
} |
| 10230 |
\pgf@relevantforpicturesizefalse |
| 10231 |
\int_step_inline:nnn \c_zero_int \l_tmpa_int |
| 10232 |
{ |
| 10233 |
\pgfpathcircle |
| 10234 |
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 10235 |
\l_@@_xdots_radius_dim |
| 10236 |
\dim_add:Nn \l_@@_x_initial_dim \l_tmpa_dim |
| 10237 |
\dim_add:Nn \l_@@_y_initial_dim \l_tmpb_dim |
| 10238 |
} |
| 10239 |
\pgfusepathqfill |
| 10240 |
} |
| 10241 |
% \end{macrocode} |
| 10242 |
% |
| 10243 |
% \bigskip |
| 10244 |
% \begin{macrocode} |
| 10245 |
\cs_new_protected:Npn \@@_labels_standard_dotted_line: |
| 10246 |
{ |
| 10247 |
\pgfscope |
| 10248 |
\pgftransformshift |
| 10249 |
{ |
| 10250 |
\pgfpointlineattime { 0.5 } |
| 10251 |
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 10252 |
{ \pgfpoint \l_@@_x_final_dim \l_@@_y_final_dim } |
| 10253 |
} |
| 10254 |
\fp_set:Nn \l_tmpa_fp |
| 10255 |
{ |
| 10256 |
atand |
| 10257 |
( |
| 10258 |
\l_@@_y_final_dim - \l_@@_y_initial_dim , |
| 10259 |
\l_@@_x_final_dim - \l_@@_x_initial_dim |
| 10260 |
) |
| 10261 |
} |
| 10262 |
\pgftransformrotate { \fp_use:N \l_tmpa_fp } |
| 10263 |
\bool_if:NF \l_@@_xdots_h_labels_bool { \fp_zero:N \l_tmpa_fp } |
| 10264 |
\tl_if_empty:NF \l_@@_xdots_middle_tl |
| 10265 |
{ |
| 10266 |
\begin { pgfscope } |
| 10267 |
\pgfset { inner~sep = \c_@@_innersep_middle_dim } |
| 10268 |
\pgfnode |
| 10269 |
{ rectangle } |
| 10270 |
{ center } |
| 10271 |
{ |
| 10272 |
\rotatebox { \fp_eval:n { - \l_tmpa_fp } } |
| 10273 |
{ |
| 10274 |
$ % $ |
| 10275 |
\scriptstyle \l_@@_xdots_middle_tl |
| 10276 |
$ % $ |
| 10277 |
} |
| 10278 |
} |
| 10279 |
{ } |
| 10280 |
{ |
| 10281 |
\pgfsetfillcolor { white } |
| 10282 |
\pgfusepath { fill } |
| 10283 |
} |
| 10284 |
\end { pgfscope } |
| 10285 |
} |
| 10286 |
\tl_if_empty:NF \l_@@_xdots_up_tl |
| 10287 |
{ |
| 10288 |
\pgfnode |
| 10289 |
{ rectangle } |
| 10290 |
{ south } |
| 10291 |
{ |
| 10292 |
\rotatebox { \fp_eval:n { - \l_tmpa_fp } } |
| 10293 |
{ |
| 10294 |
$ % $ |
| 10295 |
\scriptstyle \l_@@_xdots_up_tl |
| 10296 |
$ % $ |
| 10297 |
} |
| 10298 |
} |
| 10299 |
{ } |
| 10300 |
{ \pgfusepath { } } |
| 10301 |
} |
| 10302 |
\tl_if_empty:NF \l_@@_xdots_down_tl |
| 10303 |
{ |
| 10304 |
\pgfnode |
| 10305 |
{ rectangle } |
| 10306 |
{ north } |
| 10307 |
{ |
| 10308 |
\rotatebox { \fp_eval:n { - \l_tmpa_fp } } |
| 10309 |
{ |
| 10310 |
$ % $ |
| 10311 |
\scriptstyle \l_@@_xdots_down_tl |
| 10312 |
$ % $ |
| 10313 |
} |
| 10314 |
} |
| 10315 |
{ } |
| 10316 |
{ \pgfusepath { } } |
| 10317 |
} |
| 10318 |
\endpgfscope |
| 10319 |
} |
| 10320 |
% \end{macrocode} |
| 10321 |
% |
| 10322 |
% \bigskip |
| 10323 |
% \section{User commands available in the new environments} |
| 10324 |
% |
| 10325 |
% |
| 10326 |
% The commands |\@@_Ldots:|, |\@@_Cdots:|, |\@@_Vdots:|, |\@@_Ddots:| and |
| 10327 |
% |\@@_Iddots:| will be linked to |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and |
| 10328 |
% |\Iddots| in the environments |{NiceArray}| (the other environments of |
| 10329 |
% \pkg{nicematrix} rely upon |{NiceArray}|). |
| 10330 |
% |
| 10331 |
% |
| 10332 |
% \medskip |
| 10333 |
% The syntax of these commands uses the character |_| as embellishment and |
| 10334 |
% that's why we have to insert a character |_| in the \emph{arg spec} of these |
| 10335 |
% commands. However, we don't know the future catcode of |_| in the main |
| 10336 |
% document (maybe the user will use \pkg{underscore}, and, in that case, the |
| 10337 |
% catcode is $13$ because \pkg{underscore} activates |_|). That's why these |
| 10338 |
% commands will be defined in a |\AtBeginDocument| |
| 10339 |
% and the \emph{arg spec} will be rescanned. |
| 10340 |
% |
| 10341 |
% \begin{macrocode} |
| 10342 |
\AtBeginDocument |
| 10343 |
{ |
| 10344 |
% \end{macrocode} |
| 10345 |
% We rescan the \emph{argspec} in order the correct catcode of |_| in the main |
| 10346 |
% document (and that's why we are in a |\AtBeginDocument|). |
| 10347 |
% \begin{macrocode} |
| 10348 |
\tl_set_rescan:Nnn \l_@@_argspec_tl { } { m E { _ ^ : } { { } { } { } } } |
| 10349 |
\cs_new_protected:Npn \@@_Ldots: { \@@_collect_options:n { \@@_Ldots_i } } |
| 10350 |
\exp_args:NNo \NewDocumentCommand \@@_Ldots_i \l_@@_argspec_tl |
| 10351 |
{ |
| 10352 |
\int_if_zero:nTF \c@jCol |
| 10353 |
{ \@@_error:nn { in~first~col } { \Ldots } } |
| 10354 |
{ |
| 10355 |
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int |
| 10356 |
{ \@@_error:nn { in~last~col } { \Ldots } } |
| 10357 |
{ |
| 10358 |
\@@_instruction_of_type:nnn { \c_false_bool } { Ldots } |
| 10359 |
{ #1 , down = #2 , up = #3 , middle = #4 } |
| 10360 |
} |
| 10361 |
} |
| 10362 |
\bool_if:NF \l_@@_nullify_dots_bool |
| 10363 |
{ \phantom { \ensuremath { \@@_old_ldots: } } } |
| 10364 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10365 |
} |
| 10366 |
% \end{macrocode} |
| 10367 |
% |
| 10368 |
% \bigskip |
| 10369 |
% \begin{macrocode} |
| 10370 |
\cs_new_protected:Npn \@@_Cdots: { \@@_collect_options:n { \@@_Cdots_i } } |
| 10371 |
\exp_args:NNo \NewDocumentCommand \@@_Cdots_i \l_@@_argspec_tl |
| 10372 |
{ |
| 10373 |
\int_if_zero:nTF \c@jCol |
| 10374 |
{ \@@_error:nn { in~first~col } { \Cdots } } |
| 10375 |
{ |
| 10376 |
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int |
| 10377 |
{ \@@_error:nn { in~last~col } { \Cdots } } |
| 10378 |
{ |
| 10379 |
\@@_instruction_of_type:nnn { \c_false_bool } { Cdots } |
| 10380 |
{ #1 , down = #2 , up = #3 , middle = #4 } |
| 10381 |
} |
| 10382 |
} |
| 10383 |
\bool_if:NF \l_@@_nullify_dots_bool |
| 10384 |
{ \phantom { \ensuremath { \@@_old_cdots: } } } |
| 10385 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10386 |
} |
| 10387 |
% \end{macrocode} |
| 10388 |
% |
| 10389 |
% \bigskip |
| 10390 |
% \begin{macrocode} |
| 10391 |
\cs_new_protected:Npn \@@_Vdots: { \@@_collect_options:n { \@@_Vdots_i } } |
| 10392 |
\exp_args:NNo \NewDocumentCommand \@@_Vdots_i \l_@@_argspec_tl |
| 10393 |
{ |
| 10394 |
\int_if_zero:nTF \c@iRow |
| 10395 |
{ \@@_error:nn { in~first~row } { \Vdots } } |
| 10396 |
{ |
| 10397 |
\int_compare:nNnTF \c@iRow = \l_@@_last_row_int |
| 10398 |
{ \@@_error:nn { in~last~row } { \Vdots } } |
| 10399 |
{ |
| 10400 |
\@@_instruction_of_type:nnn { \c_false_bool } { Vdots } |
| 10401 |
{ #1 , down = #2 , up = #3 , middle = #4 } |
| 10402 |
} |
| 10403 |
} |
| 10404 |
\bool_if:NF \l_@@_nullify_dots_bool |
| 10405 |
{ \phantom { \ensuremath { \@@_old_vdots: } } } |
| 10406 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10407 |
} |
| 10408 |
% \end{macrocode} |
| 10409 |
% |
| 10410 |
% |
| 10411 |
% \bigskip |
| 10412 |
% \begin{macrocode} |
| 10413 |
\cs_new_protected:Npn \@@_Ddots: { \@@_collect_options:n { \@@_Ddots_i } } |
| 10414 |
\exp_args:NNo \NewDocumentCommand \@@_Ddots_i \l_@@_argspec_tl |
| 10415 |
{ |
| 10416 |
\int_case:nnF \c@iRow |
| 10417 |
{ |
| 10418 |
0 { \@@_error:nn { in~first~row } { \Ddots } } |
| 10419 |
\l_@@_last_row_int { \@@_error:nn { in~last~row } { \Ddots } } |
| 10420 |
} |
| 10421 |
{ |
| 10422 |
\int_case:nnF \c@jCol |
| 10423 |
{ |
| 10424 |
0 { \@@_error:nn { in~first~col } { \Ddots } } |
| 10425 |
\l_@@_last_col_int { \@@_error:nn { in~last~col } { \Ddots } } |
| 10426 |
} |
| 10427 |
{ |
| 10428 |
\keys_set_known:nn { nicematrix / Ddots } { #1 } |
| 10429 |
\@@_instruction_of_type:nnn \l_@@_draw_first_bool { Ddots } |
| 10430 |
{ #1 , down = #2 , up = #3 , middle = #4 } |
| 10431 |
} |
| 10432 |
|
| 10433 |
} |
| 10434 |
\bool_if:NF \l_@@_nullify_dots_bool |
| 10435 |
{ \phantom { \ensuremath { \@@_old_ddots: } } } |
| 10436 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10437 |
} |
| 10438 |
% \end{macrocode} |
| 10439 |
% |
| 10440 |
% \bigskip |
| 10441 |
% \begin{macrocode} |
| 10442 |
\cs_new_protected:Npn \@@_Iddots: |
| 10443 |
{ \@@_collect_options:n { \@@_Iddots_i } } |
| 10444 |
\exp_args:NNo \NewDocumentCommand \@@_Iddots_i \l_@@_argspec_tl |
| 10445 |
{ |
| 10446 |
\int_case:nnF \c@iRow |
| 10447 |
{ |
| 10448 |
0 { \@@_error:nn { in~first~row } { \Iddots } } |
| 10449 |
\l_@@_last_row_int { \@@_error:nn { in~last~row } { \Iddots } } |
| 10450 |
} |
| 10451 |
{ |
| 10452 |
\int_case:nnF \c@jCol |
| 10453 |
{ |
| 10454 |
0 { \@@_error:nn { in~first~col } { \Iddots } } |
| 10455 |
\l_@@_last_col_int { \@@_error:nn { in~last~col } { \Iddots } } |
| 10456 |
} |
| 10457 |
{ |
| 10458 |
\keys_set_known:nn { nicematrix / Ddots } { #1 } |
| 10459 |
\@@_instruction_of_type:nnn { \l_@@_draw_first_bool } { Iddots } |
| 10460 |
{ #1 , down = #2 , up = #3 , middle = #4 } |
| 10461 |
} |
| 10462 |
} |
| 10463 |
\bool_if:NF \l_@@_nullify_dots_bool |
| 10464 |
{ \phantom { \ensuremath { \@@_old_iddots: } } } |
| 10465 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10466 |
} |
| 10467 |
} |
| 10468 |
% \end{macrocode} |
| 10469 |
% End of the |\AddToHook|. |
| 10470 |
% |
| 10471 |
% |
| 10472 |
% \bigskip |
| 10473 |
% Despite its name, the following set of keys will be used for |\Ddots| but also |
| 10474 |
% for |\Iddots|. |
| 10475 |
% \begin{macrocode} |
| 10476 |
\keys_define:nn { nicematrix / Ddots } |
| 10477 |
{ |
| 10478 |
draw-first .bool_set:N = \l_@@_draw_first_bool , |
| 10479 |
draw-first .value_forbidden:n = true , |
| 10480 |
} |
| 10481 |
% \end{macrocode} |
| 10482 |
% |
| 10483 |
% \bigskip |
| 10484 |
% The command |\@@_Hspace:| will be linked to |\hspace| in |{NiceArray}|. |
| 10485 |
% \begin{macrocode} |
| 10486 |
\cs_new_protected:Npn \@@_Hspace: |
| 10487 |
{ |
| 10488 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10489 |
\hspace |
| 10490 |
} |
| 10491 |
% \end{macrocode} |
| 10492 |
% |
| 10493 |
% \bigskip |
| 10494 |
% In the environments of |nicematrix|, the command |\multicolumn| is redefined. |
| 10495 |
% We will patch the environment |{tabular}| to go back to the previous value of |
| 10496 |
% |\multicolumn|. |
| 10497 |
% \begin{macrocode} |
| 10498 |
\cs_new_eq:NN \@@_old_multicolumn: \multicolumn |
| 10499 |
% \end{macrocode} |
| 10500 |
% |
| 10501 |
% |
| 10502 |
% |
| 10503 |
% \bigskip |
| 10504 |
% The command |\@@_Hdotsfor| will be linked to |\Hdotsfor| in |
| 10505 |
% |{NiceArrayWithDelims}|. TikZ nodes are created also in the implicit cells of |
| 10506 |
% the |\Hdotsfor| (maybe we should modify that point). |
| 10507 |
% |
| 10508 |
% \medskip |
| 10509 |
% This command must \emph{not} be protected since it begins with |\multicolumn|. |
| 10510 |
% \begin{macrocode} |
| 10511 |
\cs_new:Npn \@@_Hdotsfor: |
| 10512 |
{ |
| 10513 |
\bool_lazy_and:nnTF |
| 10514 |
{ \int_if_zero_p:n \c@jCol } |
| 10515 |
{ \int_if_zero_p:n \l_@@_first_col_int } |
| 10516 |
{ |
| 10517 |
\bool_if:NTF \g_@@_after_col_zero_bool |
| 10518 |
{ |
| 10519 |
\multicolumn { 1 } { c } { } |
| 10520 |
\@@_Hdotsfor_i: |
| 10521 |
} |
| 10522 |
{ \@@_fatal:n { Hdotsfor~in~col~0 } } |
| 10523 |
} |
| 10524 |
{ |
| 10525 |
\multicolumn { 1 } { c } { } |
| 10526 |
\@@_Hdotsfor_i: |
| 10527 |
} |
| 10528 |
} |
| 10529 |
% \end{macrocode} |
| 10530 |
% |
| 10531 |
% |
| 10532 |
% The command |\@@_Hdotsfor_i:| is defined with |\NewDocumentCommand| because it |
| 10533 |
% has an optional argument. Note that such a command defined by |
| 10534 |
% |\NewDocumentCommand| is protected and that's why we have put the |
| 10535 |
% |\multicolumn| before (in the definition of |\@@_Hdotsfor:|). |
| 10536 |
% \begin{macrocode} |
| 10537 |
\AtBeginDocument |
| 10538 |
{ |
| 10539 |
% \end{macrocode} |
| 10540 |
% We don't put |!| before the last optional argument for homogeneity with |
| 10541 |
% |\Cdots|, etc. which have only one optional argument. |
| 10542 |
% \begin{macrocode} |
| 10543 |
\cs_new_protected:Npn \@@_Hdotsfor_i: |
| 10544 |
{ \@@_collect_options:n { \@@_Hdotsfor_ii } } |
| 10545 |
% \end{macrocode} |
| 10546 |
% We rescan the \emph{argspec} in order the correct catcode of |_| in the main |
| 10547 |
% document (and that's why we are in a |\AtBeginDocument|). |
| 10548 |
% \begin{macrocode} |
| 10549 |
\tl_set_rescan:Nnn \l_tmpa_tl { } { m m O { } E { _ ^ : } { { } { } { } } } |
| 10550 |
\exp_args:NNo \NewDocumentCommand \@@_Hdotsfor_ii \l_tmpa_tl |
| 10551 |
{ |
| 10552 |
\tl_gput_right:Ne \g_@@_HVdotsfor_lines_tl |
| 10553 |
{ |
| 10554 |
\@@_Hdotsfor:nnnn |
| 10555 |
{ \int_use:N \c@iRow } |
| 10556 |
{ \int_use:N \c@jCol } |
| 10557 |
{ #2 } |
| 10558 |
{ |
| 10559 |
#1 , #3 , |
| 10560 |
down = \exp_not:n { #4 } , |
| 10561 |
up = \exp_not:n { #5 } , |
| 10562 |
middle = \exp_not:n { #6 } |
| 10563 |
} |
| 10564 |
} |
| 10565 |
\prg_replicate:nn { #2 - 1 } |
| 10566 |
{ |
| 10567 |
& |
| 10568 |
\multicolumn { 1 } { c } { } |
| 10569 |
\cs_set_eq:NN \CodeAfter \@@_CodeAfter_i: |
| 10570 |
} |
| 10571 |
} |
| 10572 |
} |
| 10573 |
% \end{macrocode} |
| 10574 |
% |
| 10575 |
% \medskip |
| 10576 |
% \begin{macrocode} |
| 10577 |
\cs_new_protected:Npn \@@_Hdotsfor:nnnn #1 #2 #3 #4 |
| 10578 |
{ |
| 10579 |
\bool_set_false:N \l_@@_initial_open_bool |
| 10580 |
\bool_set_false:N \l_@@_final_open_bool |
| 10581 |
% \end{macrocode} |
| 10582 |
% For the row, it's easy. |
| 10583 |
% \begin{macrocode} |
| 10584 |
\int_set:Nn \l_@@_initial_i_int { #1 } |
| 10585 |
\int_set_eq:NN \l_@@_final_i_int \l_@@_initial_i_int |
| 10586 |
% \end{macrocode} |
| 10587 |
% For the column, it's a bit more complicated. |
| 10588 |
% \begin{macrocode} |
| 10589 |
\int_compare:nNnTF { #2 } = 1 |
| 10590 |
{ |
| 10591 |
\int_set:Nn \l_@@_initial_j_int 1 |
| 10592 |
\bool_set_true:N \l_@@_initial_open_bool |
| 10593 |
} |
| 10594 |
{ |
| 10595 |
\cs_if_exist:cTF |
| 10596 |
{ |
| 10597 |
pgf @ sh @ ns @ \@@_env: |
| 10598 |
- \int_use:N \l_@@_initial_i_int |
| 10599 |
- \int_eval:n { #2 - 1 } |
| 10600 |
} |
| 10601 |
{ \int_set:Nn \l_@@_initial_j_int { #2 - 1 } } |
| 10602 |
{ |
| 10603 |
\int_set:Nn \l_@@_initial_j_int { #2 } |
| 10604 |
\bool_set_true:N \l_@@_initial_open_bool |
| 10605 |
} |
| 10606 |
} |
| 10607 |
\int_compare:nNnTF { #2 + #3 -1 } = \c@jCol |
| 10608 |
{ |
| 10609 |
\int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 } |
| 10610 |
\bool_set_true:N \l_@@_final_open_bool |
| 10611 |
} |
| 10612 |
{ |
| 10613 |
\cs_if_exist:cTF |
| 10614 |
{ |
| 10615 |
pgf @ sh @ ns @ \@@_env: |
| 10616 |
- \int_use:N \l_@@_final_i_int |
| 10617 |
- \int_eval:n { #2 + #3 } |
| 10618 |
} |
| 10619 |
{ \int_set:Nn \l_@@_final_j_int { #2 + #3 } } |
| 10620 |
{ |
| 10621 |
\int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 } |
| 10622 |
\bool_set_true:N \l_@@_final_open_bool |
| 10623 |
} |
| 10624 |
} |
| 10625 |
% \end{macrocode} |
| 10626 |
% |
| 10627 |
% \begin{macrocode} |
| 10628 |
\bool_if:NT \g_@@_aux_found_bool |
| 10629 |
{ |
| 10630 |
{ |
| 10631 |
\@@_open_shorten: |
| 10632 |
\int_if_zero:nTF { #1 } |
| 10633 |
{ \color { nicematrix-first-row } } |
| 10634 |
{ |
| 10635 |
\int_compare:nNnT { #1 } = \g_@@_row_total_int |
| 10636 |
{ \color { nicematrix-last-row } } |
| 10637 |
} |
| 10638 |
\keys_set:nn { nicematrix / xdots } { #4 } |
| 10639 |
\@@_color:o \l_@@_xdots_color_tl |
| 10640 |
\@@_actually_draw_Ldots: |
| 10641 |
} |
| 10642 |
} |
| 10643 |
% \end{macrocode} |
| 10644 |
% |
| 10645 |
% \medskip |
| 10646 |
% We declare all the cells concerned by the |\Hdotsfor| as ``dotted'' (for the |
| 10647 |
% dotted lines created by |\Cdots|, |\Ldots|, etc., this job is done by |
| 10648 |
% |\@@_find_extremities:nnnn|). This declaration is done by defining a |
| 10649 |
% special control sequence (to nil). |
| 10650 |
% \begin{macrocode} |
| 10651 |
\int_step_inline:nnn { #2 } { #2 + #3 - 1 } |
| 10652 |
{ \cs_set_nopar:cpn { @@ _ dotted _ #1 - ##1 } { } } |
| 10653 |
} |
| 10654 |
% \end{macrocode} |
| 10655 |
% |
| 10656 |
% \bigskip |
| 10657 |
% \begin{macrocode} |
| 10658 |
\AtBeginDocument |
| 10659 |
{ |
| 10660 |
\cs_new_protected:Npn \@@_Vdotsfor: |
| 10661 |
{ \@@_collect_options:n { \@@_Vdotsfor_i } } |
| 10662 |
% \end{macrocode} |
| 10663 |
% We rescan the \emph{argspec} in order the correct catcode of |_| in the main |
| 10664 |
% document (and that's why we are in a |\AtBeginDocument|). |
| 10665 |
% \begin{macrocode} |
| 10666 |
\tl_set_rescan:Nnn \l_tmpa_tl { } { m m O { } E { _ ^ : } { { } { } { } } } |
| 10667 |
\exp_args:NNo \NewDocumentCommand \@@_Vdotsfor_i \l_tmpa_tl |
| 10668 |
{ |
| 10669 |
\bool_gset_true:N \g_@@_empty_cell_bool |
| 10670 |
\tl_gput_right:Ne \g_@@_HVdotsfor_lines_tl |
| 10671 |
{ |
| 10672 |
\@@_Vdotsfor:nnnn |
| 10673 |
{ \int_use:N \c@iRow } |
| 10674 |
{ \int_use:N \c@jCol } |
| 10675 |
{ #2 } |
| 10676 |
{ |
| 10677 |
#1 , #3 , |
| 10678 |
down = \exp_not:n { #4 } , |
| 10679 |
up = \exp_not:n { #5 } , |
| 10680 |
middle = \exp_not:n { #6 } |
| 10681 |
} |
| 10682 |
} |
| 10683 |
} |
| 10684 |
} |
| 10685 |
% \end{macrocode} |
| 10686 |
% |
| 10687 |
% \bigskip |
| 10688 |
% |#1| is the number of row; |
| 10689 |
% |
| 10690 |
% |#2| is the number of column; |
| 10691 |
% |
| 10692 |
% |#3| is the numbers of rows which are involved; |
| 10693 |
% \begin{macrocode} |
| 10694 |
\cs_new_protected:Npn \@@_Vdotsfor:nnnn #1 #2 #3 #4 |
| 10695 |
{ |
| 10696 |
\bool_set_false:N \l_@@_initial_open_bool |
| 10697 |
\bool_set_false:N \l_@@_final_open_bool |
| 10698 |
% \end{macrocode} |
| 10699 |
% For the column, it's easy. |
| 10700 |
% \begin{macrocode} |
| 10701 |
\int_set:Nn \l_@@_initial_j_int { #2 } |
| 10702 |
\int_set_eq:NN \l_@@_final_j_int \l_@@_initial_j_int |
| 10703 |
% \end{macrocode} |
| 10704 |
% For the row, it's a bit more complicated. |
| 10705 |
% \begin{macrocode} |
| 10706 |
\int_compare:nNnTF { #1 } = 1 |
| 10707 |
{ |
| 10708 |
\int_set:Nn \l_@@_initial_i_int 1 |
| 10709 |
\bool_set_true:N \l_@@_initial_open_bool |
| 10710 |
} |
| 10711 |
{ |
| 10712 |
\cs_if_exist:cTF |
| 10713 |
{ |
| 10714 |
pgf @ sh @ ns @ \@@_env: |
| 10715 |
- \int_eval:n { #1 - 1 } |
| 10716 |
- \int_use:N \l_@@_initial_j_int |
| 10717 |
} |
| 10718 |
{ \int_set:Nn \l_@@_initial_i_int { #1 - 1 } } |
| 10719 |
{ |
| 10720 |
\int_set:Nn \l_@@_initial_i_int { #1 } |
| 10721 |
\bool_set_true:N \l_@@_initial_open_bool |
| 10722 |
} |
| 10723 |
} |
| 10724 |
\int_compare:nNnTF { #1 + #3 - 1 } = \c@iRow |
| 10725 |
{ |
| 10726 |
\int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 } |
| 10727 |
\bool_set_true:N \l_@@_final_open_bool |
| 10728 |
} |
| 10729 |
{ |
| 10730 |
\cs_if_exist:cTF |
| 10731 |
{ |
| 10732 |
pgf @ sh @ ns @ \@@_env: |
| 10733 |
- \int_eval:n { #1 + #3 } |
| 10734 |
- \int_use:N \l_@@_final_j_int |
| 10735 |
} |
| 10736 |
{ \int_set:Nn \l_@@_final_i_int { #1 + #3 } } |
| 10737 |
{ |
| 10738 |
\int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 } |
| 10739 |
\bool_set_true:N \l_@@_final_open_bool |
| 10740 |
} |
| 10741 |
} |
| 10742 |
% \end{macrocode} |
| 10743 |
% |
| 10744 |
% \begin{macrocode} |
| 10745 |
\bool_if:NT \g_@@_aux_found_bool |
| 10746 |
{ |
| 10747 |
{ |
| 10748 |
\@@_open_shorten: |
| 10749 |
\int_if_zero:nTF { #2 } |
| 10750 |
{ \color { nicematrix-first-col } } |
| 10751 |
{ |
| 10752 |
\int_compare:nNnT { #2 } = \g_@@_col_total_int |
| 10753 |
{ \color { nicematrix-last-col } } |
| 10754 |
} |
| 10755 |
\keys_set:nn { nicematrix / xdots } { #4 } |
| 10756 |
\@@_color:o \l_@@_xdots_color_tl |
| 10757 |
\bool_if:NTF \l_@@_Vbrace_bool |
| 10758 |
\@@_actually_draw_Vbrace: |
| 10759 |
\@@_actually_draw_Vdots: |
| 10760 |
} |
| 10761 |
} |
| 10762 |
% \end{macrocode} |
| 10763 |
% |
| 10764 |
% \medskip |
| 10765 |
% We declare all the cells concerned by the |\Vdotsfor| as ``dotted'' (for the |
| 10766 |
% dotted lines created by |\Cdots|, |\Ldots|, etc., this job is done by |
| 10767 |
% |\@@_find_extremities:nnnn|). This declaration is done by defining a |
| 10768 |
% special control sequence (to nil). |
| 10769 |
% \begin{macrocode} |
| 10770 |
\int_step_inline:nnn { #1 } { #1 + #3 - 1 } |
| 10771 |
{ \cs_set_nopar:cpn { @@ _ dotted _ ##1 - #2 } { } } |
| 10772 |
} |
| 10773 |
% \end{macrocode} |
| 10774 |
% |
| 10775 |
% |
| 10776 |
% \vspace{1cm} |
| 10777 |
% The command |\@@_rotate:| will be linked to |\rotate| in |
| 10778 |
% |{NiceArrayWithDelims}|. |
| 10779 |
% \begin{macrocode} |
| 10780 |
\NewDocumentCommand \@@_rotate: { O { } } |
| 10781 |
{ |
| 10782 |
\bool_gset_true:N \g_@@_rotate_bool |
| 10783 |
\keys_set:nn { nicematrix / rotate } { #1 } |
| 10784 |
\ignorespaces |
| 10785 |
} |
| 10786 |
% \end{macrocode} |
| 10787 |
% |
| 10788 |
% \bigskip |
| 10789 |
% The command |\@@_rotate_p_col:| will be linked to |\rotate| in the |
| 10790 |
% the cells of the columns of type |p| \emph{and al}. |
| 10791 |
% \begin{macrocode} |
| 10792 |
\cs_new_protected:Npn \@@_rotate_p_col: { \@@_error:n { rotate~in~p~col } } |
| 10793 |
% \end{macrocode} |
| 10794 |
% |
| 10795 |
% \bigskip |
| 10796 |
% \begin{macrocode} |
| 10797 |
\keys_define:nn { nicematrix / rotate } |
| 10798 |
{ |
| 10799 |
c .code:n = \bool_gset_true:N \g_@@_rotate_c_bool , |
| 10800 |
c .value_forbidden:n = true , |
| 10801 |
-90 .code:n = \bool_gset_true:N \g_@@_rotate_minus_bool , |
| 10802 |
-90 .value_forbidden:n = true , |
| 10803 |
unknown .code:n = \@@_error:n { Unknown~key~for~rotate } |
| 10804 |
} |
| 10805 |
% \end{macrocode} |
| 10806 |
% |
| 10807 |
% \bigskip |
| 10808 |
% \section{The command \textbackslash line accessible in \textbackslash CodeAfter} |
| 10809 |
% |
| 10810 |
% In the |\CodeAfter|, the command |\@@_line:nn| will be linked to |\line|. This |
| 10811 |
% command takes two arguments which are the specifications of two cells in the |
| 10812 |
% array (in the format $i$-$j$) and draws a dotted line between these cells. In |
| 10813 |
% fact, if also works with names of blocks. |
| 10814 |
% |
| 10815 |
% \medskip |
| 10816 |
% First, we write a command with the following behaviour: |
| 10817 |
% \begin{itemize} |
| 10818 |
% \item If the argument is of the format $i$-$j$, our command applies |
| 10819 |
% the command |\int_eval:n| to $i$ and~$j$ ; |
| 10820 |
% \item If not (that is to say, when it's a name of a |\Block|), the argument is |
| 10821 |
% left unchanged. |
| 10822 |
% \end{itemize} |
| 10823 |
% This must \emph{not} be protected (and is, of course fully |
| 10824 |
% expandable).\footnote{Indeed, we want that the user may use the command |
| 10825 |
% |\line| in |\CodeAfter| with LaTeX counters in the arguments --- with the |
| 10826 |
% command |\value|.} |
| 10827 |
% \begin{macrocode} |
| 10828 |
\cs_new:Npn \@@_double_int_eval:n #1-#2 \q_stop |
| 10829 |
{ |
| 10830 |
\tl_if_empty:nTF { #2 } |
| 10831 |
{ #1 } |
| 10832 |
{ \@@_double_int_eval_i:n #1-#2 \q_stop } |
| 10833 |
} |
| 10834 |
\cs_new:Npn \@@_double_int_eval_i:n #1-#2- \q_stop |
| 10835 |
{ \int_eval:n { #1 } - \int_eval:n { #2 } } |
| 10836 |
% \end{macrocode} |
| 10837 |
% |
| 10838 |
% |
| 10839 |
% \medskip |
| 10840 |
% With the following construction, the command |\@@_double_int_eval:n| is |
| 10841 |
% applied to both arguments before the application of |\@@_line_i:nn| (the |
| 10842 |
% construction uses the fact the |\@@_line_i:nn| is protected and that |
| 10843 |
% |\@@_double_int_eval:n| is fully expandable). |
| 10844 |
% \begin{macrocode} |
| 10845 |
\AtBeginDocument |
| 10846 |
{ |
| 10847 |
% \end{macrocode} |
| 10848 |
% We rescan the \emph{argspec} in order the correct catcode of |_| in the main |
| 10849 |
% document (and that's why we are in a |\AtBeginDocument|). |
| 10850 |
% \begin{macrocode} |
| 10851 |
\tl_set_rescan:Nnn \l_tmpa_tl { } |
| 10852 |
{ O { } m m ! O { } E { _ ^ : } { { } { } { } } } |
| 10853 |
\exp_args:NNo \NewDocumentCommand \@@_line \l_tmpa_tl |
| 10854 |
{ |
| 10855 |
{ |
| 10856 |
\keys_set:nn { nicematrix / xdots } { #1 , #4 , down = #5 , up = #6 } |
| 10857 |
\@@_color:o \l_@@_xdots_color_tl |
| 10858 |
\use:e |
| 10859 |
{ |
| 10860 |
\@@_line_i:nn |
| 10861 |
{ \@@_double_int_eval:n #2 - \q_stop } |
| 10862 |
{ \@@_double_int_eval:n #3 - \q_stop } |
| 10863 |
} |
| 10864 |
} |
| 10865 |
} |
| 10866 |
} |
| 10867 |
% \end{macrocode} |
| 10868 |
% |
| 10869 |
% \begin{macrocode} |
| 10870 |
\cs_new_protected:Npn \@@_line_i:nn #1 #2 |
| 10871 |
{ |
| 10872 |
\bool_set_false:N \l_@@_initial_open_bool |
| 10873 |
\bool_set_false:N \l_@@_final_open_bool |
| 10874 |
\bool_lazy_or:nnTF |
| 10875 |
{ \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #1 } } |
| 10876 |
{ \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #2 } } |
| 10877 |
{ \@@_error:nnn { unknown~cell~for~line~in~CodeAfter } { #1 } { #2 } } |
| 10878 |
% \end{macrocode} |
| 10879 |
% The test of |measuring@| is a security (cf. question 686649 on TeX StackExchange). |
| 10880 |
% \begin{macrocode} |
| 10881 |
{ \legacy_if:nF { measuring@ } { \@@_draw_line_ii:nn { #1 } { #2 } } } |
| 10882 |
} |
| 10883 |
% \end{macrocode} |
| 10884 |
% |
| 10885 |
% \begin{macrocode} |
| 10886 |
\AtBeginDocument |
| 10887 |
{ |
| 10888 |
\cs_new_protected:Npe \@@_draw_line_ii:nn #1 #2 |
| 10889 |
{ |
| 10890 |
% \end{macrocode} |
| 10891 |
% We recall that, when externalization is used, |\tikzpicture| and |
| 10892 |
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly |
| 10893 |
% ``visible'' and that why we do this static construction of the command |
| 10894 |
% |\@@_draw_line_ii:|. |
| 10895 |
% \begin{macrocode} |
| 10896 |
\c_@@_pgfortikzpicture_tl |
| 10897 |
\@@_draw_line_iii:nn { #1 } { #2 } |
| 10898 |
\c_@@_endpgfortikzpicture_tl |
| 10899 |
} |
| 10900 |
} |
| 10901 |
% \end{macrocode} |
| 10902 |
% |
| 10903 |
% \bigskip |
| 10904 |
% The following command \emph{must} be protected (it's used in the |
| 10905 |
% construction of |\@@_draw_line_ii:nn|). |
| 10906 |
% \begin{macrocode} |
| 10907 |
\cs_new_protected:Npn \@@_draw_line_iii:nn #1 #2 |
| 10908 |
{ |
| 10909 |
\pgfrememberpicturepositiononpagetrue |
| 10910 |
\pgfpointshapeborder { \@@_env: - #1 } { \@@_qpoint:n { #2 } } |
| 10911 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 10912 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 10913 |
\pgfpointshapeborder { \@@_env: - #2 } { \@@_qpoint:n { #1 } } |
| 10914 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 10915 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 10916 |
\@@_draw_line: |
| 10917 |
} |
| 10918 |
% \end{macrocode} |
| 10919 |
% |
| 10920 |
% |
| 10921 |
% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots| don't use |
| 10922 |
% this command because they have to do other settings (for example, the diagonal |
| 10923 |
% lines must be parallelized). |
| 10924 |
% |
| 10925 |
% |
| 10926 |
% |
| 10927 |
% \bigskip |
| 10928 |
% \section{The command \textbackslash RowStyle} |
| 10929 |
% |
| 10930 |
% |
| 10931 |
% |\g_@@_row_style_tl| may contain several instructions of the form: |
| 10932 |
% |
| 10933 |
% \qquad |\@@_if_row_less_than:nn { number } { instructions }| |
| 10934 |
% |
| 10935 |
% \smallskip |
| 10936 |
% Then, |\g_@@_row_style_tl| will be inserted in all the cells of the array (and |
| 10937 |
% also in both components of a |\diagbox| in a cell of in a mono-row block). |
| 10938 |
% |
| 10939 |
% The test |\@@_if_row_less_then:nn| ensures that the instructions are inserted |
| 10940 |
% only if you are in a row which is (still) in the scope of that instructions |
| 10941 |
% (which depends on the value of the key |nb-rows| of |\RowStyle|). |
| 10942 |
% |
| 10943 |
% That test will be active even in an expandable context because |
| 10944 |
% |\@@_if_row_less_then:nn| is \emph{not} protected. |
| 10945 |
% |
| 10946 |
% |#1| is the first row \emph{after} the scope of the instructions in |#2| |
| 10947 |
% |
| 10948 |
% However, both arguments are implicit because they are taken by curryfication. |
| 10949 |
% \begin{macrocode} |
| 10950 |
\cs_new:Npn \@@_if_row_less_than:nn { \int_compare:nNnT \c@iRow < } |
| 10951 |
\cs_new:Npn \@@_if_col_greater_than:nn { \int_compare:nNnF \c@jCol < } |
| 10952 |
% \end{macrocode} |
| 10953 |
% |
| 10954 |
% \bigskip |
| 10955 |
% |\@@_put_in_row_style| will be used several times in |\RowStyle|. |
| 10956 |
% \begin{macrocode} |
| 10957 |
\cs_set_protected:Npn \@@_put_in_row_style:n #1 |
| 10958 |
{ |
| 10959 |
\tl_gput_right:Ne \g_@@_row_style_tl |
| 10960 |
{ |
| 10961 |
% \end{macrocode} |
| 10962 |
% Be careful, |\exp_not:N \@@_if_row_less_than:nn| can't be replaced by a |
| 10963 |
% protected version of |\@@_if_row_less_than:nn|. |
| 10964 |
% \begin{macrocode} |
| 10965 |
\exp_not:N |
| 10966 |
\@@_if_row_less_than:nn |
| 10967 |
{ \int_eval:n { \c@iRow + \l_@@_key_nb_rows_int } } |
| 10968 |
% \end{macrocode} |
| 10969 |
% The |\scan_stop:| is mandatory (for ex. for the case where |\rotate| is used |
| 10970 |
% in the argument of |\RowStyle|). |
| 10971 |
% \begin{macrocode} |
| 10972 |
{ |
| 10973 |
\exp_not:N |
| 10974 |
\@@_if_col_greater_than:nn |
| 10975 |
{ \int_use:N \c@jCol } |
| 10976 |
{ \exp_not:n { #1 } \scan_stop: } |
| 10977 |
} |
| 10978 |
} |
| 10979 |
} |
| 10980 |
\cs_generate_variant:Nn \@@_put_in_row_style:n { e } |
| 10981 |
% \end{macrocode} |
| 10982 |
% \medskip |
| 10983 |
% \begin{macrocode} |
| 10984 |
\keys_define:nn { nicematrix / RowStyle } |
| 10985 |
{ |
| 10986 |
cell-space-top-limit .dim_set:N = \l_tmpa_dim , |
| 10987 |
cell-space-top-limit+ .code:n = |
| 10988 |
\dim_set:Nn \l_tmpa_dim { \l_@@_cell_space_top_limit_dim + #1 } , |
| 10989 |
cell-space-top-limit+ .value_required:n = true , |
| 10990 |
cell-space-top-limit~+ .meta:n = { cell-space-top-limit+ = #1 } , |
| 10991 |
cell-space-bottom-limit .dim_set:N = \l_tmpb_dim , |
| 10992 |
cell-space-bottom-limit+ .code:n = |
| 10993 |
\dim_set:Nn \l_tmpb_dim { \l_@@_cell_space_bottom_limit_dim + #1 } , |
| 10994 |
cell-space-bottom-limit+ .value_required:n = true , |
| 10995 |
cell-space-bottom-limit~+ .meta:n = { cell-space-bottom-limit+ = #1 } , |
| 10996 |
cell-space-limits .meta:n = |
| 10997 |
{ |
| 10998 |
cell-space-top-limit = #1 , |
| 10999 |
cell-space-bottom-limit = #1 , |
| 11000 |
} , |
| 11001 |
cell-space-limits+ .meta:n = |
| 11002 |
{ |
| 11003 |
cell-space-top-limit += #1 , |
| 11004 |
cell-space-bottom-limit += #1 , |
| 11005 |
} , |
| 11006 |
cell-space-limits~+ .meta:n = { cell-space-limits+ = #1 } , |
| 11007 |
color .tl_set:N = \l_@@_color_tl , |
| 11008 |
color .value_required:n = true , |
| 11009 |
bold .bool_set:N = \l_@@_bold_row_style_bool , |
| 11010 |
nb-rows .code:n = |
| 11011 |
\str_if_eq:eeTF { #1 } { * } |
| 11012 |
{ \int_set:Nn \l_@@_key_nb_rows_int { 500 } } |
| 11013 |
{ \int_set:Nn \l_@@_key_nb_rows_int { #1 } } , |
| 11014 |
nb-rows .value_required:n = true , |
| 11015 |
fill .tl_set:N = \l_@@_fill_tl , |
| 11016 |
fill .value_required:n = true , |
| 11017 |
% \end{macrocode} |
| 11018 |
% \emph{In fine}, the opacity will be applied by |\pgfsetfillopacity|. |
| 11019 |
% \begin{macrocode} |
| 11020 |
opacity .tl_set:N = \l_@@_opacity_tl , |
| 11021 |
opacity .value_required:n = true , |
| 11022 |
rowcolor .tl_set:N = \l_@@_fill_tl , |
| 11023 |
rowcolor .value_required:n = true , |
| 11024 |
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , |
| 11025 |
rounded-corners .default:n = 4 pt , |
| 11026 |
unknown .code:n = |
| 11027 |
\@@_unknown_key:nn |
| 11028 |
{ nicematrix / RowStyle } |
| 11029 |
{ Unknown~key~for~RowStyle } |
| 11030 |
} |
| 11031 |
% \end{macrocode} |
| 11032 |
% |
| 11033 |
% |
| 11034 |
% \bigskip |
| 11035 |
% \begin{macrocode} |
| 11036 |
\NewDocumentCommand \@@_RowStyle:n { O { } m } |
| 11037 |
{ |
| 11038 |
\group_begin: |
| 11039 |
\tl_clear:N \l_@@_fill_tl |
| 11040 |
\tl_clear:N \l_@@_opacity_tl |
| 11041 |
\tl_clear:N \l_@@_color_tl |
| 11042 |
\int_set:Nn \l_@@_key_nb_rows_int 1 |
| 11043 |
\dim_zero:N \l_@@_rounded_corners_dim |
| 11044 |
\dim_zero:N \l_tmpa_dim |
| 11045 |
\dim_zero:N \l_tmpb_dim |
| 11046 |
\keys_set:nn { nicematrix / RowStyle } { #1 } |
| 11047 |
% \end{macrocode} |
| 11048 |
% If the key |fill| (or its alias |rowcolor|) has been used. |
| 11049 |
% \begin{macrocode} |
| 11050 |
\tl_if_empty:NF \l_@@_fill_tl |
| 11051 |
{ |
| 11052 |
\@@_add_opacity_to_fill: |
| 11053 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 11054 |
{ |
| 11055 |
% \end{macrocode} |
| 11056 |
% The command |\@@_exp_color_arg:No| is \emph{fully expandable}. |
| 11057 |
% \begin{macrocode} |
| 11058 |
\@@_exp_color_arg:No \@@_roundedrectanglecolor \l_@@_fill_tl |
| 11059 |
{ \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 11060 |
{ |
| 11061 |
\int_eval:n { \c@iRow + \l_@@_key_nb_rows_int - 1 } |
| 11062 |
- * |
| 11063 |
} |
| 11064 |
{ \dim_use:N \l_@@_rounded_corners_dim } |
| 11065 |
} |
| 11066 |
} |
| 11067 |
\@@_put_in_row_style:n { \exp_not:n { #2 } } |
| 11068 |
% \end{macrocode} |
| 11069 |
% |\l_tmpa_dim| is the value of the key |cell-space-top-limit| of |\RowStyle|. |
| 11070 |
% \begin{macrocode} |
| 11071 |
\dim_compare:nNnT \l_tmpa_dim > \c_zero_dim |
| 11072 |
{ |
| 11073 |
\@@_put_in_row_style:e |
| 11074 |
{ |
| 11075 |
\@@_put_in_cell_after_hook:n |
| 11076 |
{ |
| 11077 |
% \end{macrocode} |
| 11078 |
% It's not possible to change the following code by using |\dim_set_eq:NN| |
| 11079 |
% (because of expansion). |
| 11080 |
% \begin{macrocode} |
| 11081 |
\dim_set:Nn \l_@@_cell_space_top_limit_dim |
| 11082 |
{ \dim_use:N \l_tmpa_dim } |
| 11083 |
} |
| 11084 |
} |
| 11085 |
} |
| 11086 |
% \end{macrocode} |
| 11087 |
% |\l_tmpb_dim| is the value of the key |cell-space-bottom-limit| of |\RowStyle|. |
| 11088 |
% \begin{macrocode} |
| 11089 |
\dim_compare:nNnT \l_tmpb_dim > \c_zero_dim |
| 11090 |
{ |
| 11091 |
\@@_put_in_row_style:e |
| 11092 |
{ |
| 11093 |
\@@_put_in_cell_after_hook:n |
| 11094 |
{ |
| 11095 |
\dim_set:Nn \l_@@_cell_space_bottom_limit_dim |
| 11096 |
{ \dim_use:N \l_tmpb_dim } |
| 11097 |
} |
| 11098 |
} |
| 11099 |
} |
| 11100 |
% \end{macrocode} |
| 11101 |
% |
| 11102 |
% |
| 11103 |
% |\l_@@_color_tl| is the value of the key |color| of |\RowStyle|. |
| 11104 |
% \begin{macrocode} |
| 11105 |
\tl_if_empty:NF \l_@@_color_tl |
| 11106 |
{ |
| 11107 |
\@@_put_in_row_style:e |
| 11108 |
{ |
| 11109 |
\mode_leave_vertical: |
| 11110 |
\@@_color:n { \l_@@_color_tl } |
| 11111 |
} |
| 11112 |
} |
| 11113 |
% \end{macrocode} |
| 11114 |
% |\l_@@_bold_row_style_bool| is the value of the key |bold|. |
| 11115 |
% \begin{macrocode} |
| 11116 |
\bool_if:NT \l_@@_bold_row_style_bool |
| 11117 |
{ |
| 11118 |
\@@_put_in_row_style:n |
| 11119 |
{ |
| 11120 |
\exp_not:n |
| 11121 |
{ |
| 11122 |
\if_mode_math: |
| 11123 |
$ % $ |
| 11124 |
\bfseries \boldmath |
| 11125 |
$ % $ |
| 11126 |
\else: |
| 11127 |
\bfseries \boldmath |
| 11128 |
\fi: |
| 11129 |
} |
| 11130 |
} |
| 11131 |
} |
| 11132 |
\group_end: |
| 11133 |
\g_@@_row_style_tl |
| 11134 |
\ignorespaces |
| 11135 |
} |
| 11136 |
% \end{macrocode} |
| 11137 |
% |
| 11138 |
% \medskip |
| 11139 |
% The following commande must \emph{not} be protected. |
| 11140 |
% \begin{macrocode} |
| 11141 |
\cs_new:Npn \@@_rounded_from_row:n #1 |
| 11142 |
{ |
| 11143 |
\@@_exp_color_arg:No \@@_roundedrectanglecolor \l_@@_fill_tl |
| 11144 |
% \end{macrocode} |
| 11145 |
% In the following code, the ``|- 1|'' is \emph{not} a subtraction. |
| 11146 |
% \begin{macrocode} |
| 11147 |
{ \int_eval:n { #1 } - 1 } |
| 11148 |
{ |
| 11149 |
\int_eval:n { \c@iRow + \l_@@_key_nb_rows_int - 1 } |
| 11150 |
- \exp_not:n { \int_use:N \c@jCol } |
| 11151 |
} |
| 11152 |
{ \dim_use:N \l_@@_rounded_corners_dim } |
| 11153 |
} |
| 11154 |
% \end{macrocode} |
| 11155 |
% |
| 11156 |
% \bigskip |
| 11157 |
% \section{Colors of cells, rows and columns} |
| 11158 |
% |
| 11159 |
% We want to avoid the thin white lines that are shown in some \textsc{pdf} |
| 11160 |
% viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to |
| 11161 |
% draw rectangles of the same color in the same instruction |\pgfusepath { fill }| |
| 11162 |
% (and they will be in the same instruction |fill|---coded |f|---in the |
| 11163 |
% resulting \textsc{pdf}). |
| 11164 |
% |
| 11165 |
% The commands |\@@_rowcolor|, |\@@_columncolor|, |\@@_rectanglecolor| and |
| 11166 |
% |\@@_rowlistcolors| don't directly draw the corresponding rectangles. Instead, |
| 11167 |
% they store their instructions color by color: |
| 11168 |
% \begin{itemize} |
| 11169 |
% \item A sequence |\g_@@_colors_seq| will be built containing all the colors |
| 11170 |
% used by at least one of these instructions. Each \emph{color} may be prefixed |
| 11171 |
% by its color model (eg: |[gray]{0.5}|). |
| 11172 |
% \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of |
| 11173 |
% instructions which use that color will be constructed in the token list |
| 11174 |
% |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written |
| 11175 |
% using |\@@_cartesian_color:nn| and |\@@_rectanglecolor:nn|. |
| 11176 |
% \end{itemize} |
| 11177 |
% |
| 11178 |
% |
| 11179 |
% \bigskip |
| 11180 |
% |#1| is the color and |#2| is an instruction using that color. Despite its |
| 11181 |
% name, the command |\@@_add_to_colors_seq:nn| doesn't only add a color to |
| 11182 |
% |\g_@@_colors_seq|: it also updates the corresponding token list |
| 11183 |
% |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use |
| 11184 |
% the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the |
| 11185 |
% |\CodeBefore| (and we recall that a loop of \pkg{pgffor} is encapsulated in a |
| 11186 |
% group). |
| 11187 |
% \begin{macrocode} |
| 11188 |
\cs_new_protected:Npn \@@_add_to_colors_seq:nn #1 #2 |
| 11189 |
{ |
| 11190 |
% \end{macrocode} |
| 11191 |
% First, we look for the number of the color and, if it's found, we store it in |
| 11192 |
% |\l_tmpa_int|. If the color is not present in |\l_@@_colors_seq|, |
| 11193 |
% |\l_tmpa_int| will remain equal to $0$. |
| 11194 |
% \begin{macrocode} |
| 11195 |
\int_zero:N \l_tmpa_int |
| 11196 |
% \end{macrocode} |
| 11197 |
% We don't take into account the colors like |myserie!!+| because those colors |
| 11198 |
% are special color from a |\definecolorseries| of \pkg{xcolor}. |
| 11199 |
% |\str_if_in:nnF| is mandatory: don't use |\tl_if_in:nnF|. |
| 11200 |
% \begin{macrocode} |
| 11201 |
\str_if_in:nnF { #1 } { !! } |
| 11202 |
{ |
| 11203 |
\seq_map_indexed_inline:Nn \g_@@_colors_seq |
| 11204 |
% \end{macrocode} |
| 11205 |
% We use |\str_if_eq:eeTF| which is slightly faster than |\tl_if_eq:nnTF|. |
| 11206 |
% \begin{macrocode} |
| 11207 |
{ \str_if_eq:eeT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } } |
| 11208 |
} |
| 11209 |
\int_if_zero:nTF \l_tmpa_int |
| 11210 |
% \end{macrocode} |
| 11211 |
% First, the case where the color is a \emph{new} color (not in the sequence). |
| 11212 |
% \begin{macrocode} |
| 11213 |
{ |
| 11214 |
\seq_gput_right:Nn \g_@@_colors_seq { #1 } |
| 11215 |
\tl_gset:ce { g_@@_color _ \seq_count:N \g_@@_colors_seq _ tl } { #2 } |
| 11216 |
} |
| 11217 |
% \end{macrocode} |
| 11218 |
% Now, the case where the color is \emph{not} a new color (the color is in the |
| 11219 |
% sequence at the position |\l_tmpa_int|). |
| 11220 |
% \begin{macrocode} |
| 11221 |
{ \tl_gput_right:ce { g_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } } |
| 11222 |
} |
| 11223 |
\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { e } |
| 11224 |
% \end{macrocode} |
| 11225 |
% |
| 11226 |
% |
| 11227 |
% \bigskip |
| 11228 |
% The following command must be used within a |\pgfpicture|. |
| 11229 |
% \begin{macrocode} |
| 11230 |
\cs_new_protected:Npn \@@_clip_with_rounded_corners: |
| 11231 |
{ |
| 11232 |
\dim_compare:nNnT \l_@@_tab_rounded_corners_dim > \c_zero_dim |
| 11233 |
{ |
| 11234 |
% \end{macrocode} |
| 11235 |
% The TeX group is for |\pgfsetcornersarced| (whose scope is the TeX scope). |
| 11236 |
% \begin{macrocode} |
| 11237 |
\group_begin: |
| 11238 |
\pgfsetcornersarced |
| 11239 |
{ \pgfpoint \l_@@_tab_rounded_corners_dim \l_@@_tab_rounded_corners_dim } |
| 11240 |
% \end{macrocode} |
| 11241 |
% Because we want \pkg{nicematrix} compatible with arrays constructed by |
| 11242 |
% \pkg{array}, the nodes for the rows and columns (that is to say the nodes |
| 11243 |
% |row-|\textsl{i} and |col-|\textsl{j}) have not always the expected position, |
| 11244 |
% that is to say, there is sometimes a slight shifting of something such as |
| 11245 |
% |\arrayrulewidth|. Now, for the clipping, we have to change slightly the |
| 11246 |
% position of that clipping whether a rounded rectangle around the array is |
| 11247 |
% required. That's the point which is tested in the following line. |
| 11248 |
% \begin{macrocode} |
| 11249 |
\bool_if:NTF \l_@@_hvlines_bool |
| 11250 |
{ |
| 11251 |
\pgfpathrectanglecorners |
| 11252 |
{ |
| 11253 |
\pgfpointadd |
| 11254 |
{ \@@_qpoint:n { row-1 } } |
| 11255 |
{ \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim } |
| 11256 |
} |
| 11257 |
{ |
| 11258 |
\pgfpointadd |
| 11259 |
{ |
| 11260 |
\@@_qpoint:n |
| 11261 |
{ \int_eval:n { 1 + \int_max:nn \c@iRow \c@jCol } } |
| 11262 |
} |
| 11263 |
{ \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } } |
| 11264 |
} |
| 11265 |
} |
| 11266 |
{ |
| 11267 |
\pgfpathrectanglecorners |
| 11268 |
{ \@@_qpoint:n { row-1 } } |
| 11269 |
{ |
| 11270 |
\pgfpointadd |
| 11271 |
{ |
| 11272 |
\@@_qpoint:n |
| 11273 |
{ \int_eval:n { 1 + \int_max:nn \c@iRow \c@jCol } } |
| 11274 |
} |
| 11275 |
{ \pgfpoint \c_zero_dim \arrayrulewidth } |
| 11276 |
} |
| 11277 |
} |
| 11278 |
\pgfusepath { clip } |
| 11279 |
\group_end: |
| 11280 |
% \end{macrocode} |
| 11281 |
% The TeX group was for |\pgfsetcornersarced|. |
| 11282 |
% \begin{macrocode} |
| 11283 |
} |
| 11284 |
} |
| 11285 |
% \end{macrocode} |
| 11286 |
% |
| 11287 |
% \bigskip |
| 11288 |
% The command |\@@_actually_color:| will actually fill the rectangles, color by color, |
| 11289 |
% as specified in the sequence |\g_@@_colors_seq|. |
| 11290 |
% \begin{macrocode} |
| 11291 |
\cs_new_protected:Npn \@@_actually_color: |
| 11292 |
{ |
| 11293 |
\pgfpicture |
| 11294 |
\pgf@relevantforpicturesizefalse |
| 11295 |
% \end{macrocode} |
| 11296 |
% |
| 11297 |
% If the final user has used the key |rounded-corners| for the environment |
| 11298 |
% |{NiceTabular}|, we will clip to a rectangle with rounded corners before |
| 11299 |
% filling the rectangles. |
| 11300 |
% \begin{macrocode} |
| 11301 |
\@@_clip_with_rounded_corners: |
| 11302 |
% \end{macrocode} |
| 11303 |
% |
| 11304 |
% We will now actually fill all the rectangles, color by color (using the |
| 11305 |
% sequence |\l_@@_colors_seq| and all the token lists of the form |
| 11306 |
% |\l_@@_color_|$i$|_tl|). |
| 11307 |
% \begin{macrocode} |
| 11308 |
\seq_map_indexed_inline:Nn \g_@@_colors_seq |
| 11309 |
{ |
| 11310 |
\int_compare:nNnTF { ##1 } = 1 |
| 11311 |
{ |
| 11312 |
\cs_set_eq:NN \@@_cartesian_path:n \@@_cartesian_path_nocolor:n |
| 11313 |
\use:c { g_@@_color _ 1 _tl } |
| 11314 |
\cs_set_eq:NN \@@_cartesian_path:n \@@_cartesian_path_normal:n |
| 11315 |
} |
| 11316 |
{ |
| 11317 |
\pgfscope |
| 11318 |
\@@_color_opacity: ##2 |
| 11319 |
\use:c { g_@@_color _ ##1 _tl } |
| 11320 |
\tl_gclear:c { g_@@_color _ ##1 _tl } |
| 11321 |
\pgfusepath { fill } |
| 11322 |
\endpgfscope |
| 11323 |
} |
| 11324 |
} |
| 11325 |
\endpgfpicture |
| 11326 |
} |
| 11327 |
% \end{macrocode} |
| 11328 |
% |
| 11329 |
% |
| 11330 |
% \bigskip |
| 11331 |
% The following command will extract the potential key |opacity| in its optional |
| 11332 |
% argument (between square brackets) and (of course) then apply the command |\color|. |
| 11333 |
% \begin{macrocode} |
| 11334 |
\cs_new_protected:Npn \@@_color_opacity: |
| 11335 |
{ |
| 11336 |
\peek_meaning:NTF [ |
| 11337 |
\@@_color_opacity:w |
| 11338 |
{ \@@_color_opacity:w [ ] } |
| 11339 |
} |
| 11340 |
% \end{macrocode} |
| 11341 |
% |
| 11342 |
% \bigskip |
| 11343 |
% The command |\@@_color_opacity:w| takes in as argument only the optional |
| 11344 |
% argument. One may consider that the second argument (the actual definition of |
| 11345 |
% the color) is provided by curryfication. |
| 11346 |
% \begin{macrocode} |
| 11347 |
\cs_new_protected:Npn \@@_color_opacity:w [ #1 ] |
| 11348 |
{ |
| 11349 |
\tl_clear:N \l_tmpa_tl |
| 11350 |
\keys_set_known:nnN { nicematrix / color-opacity } { #1 } \l_tmpb_tl |
| 11351 |
% \end{macrocode} |
| 11352 |
% |\l_tmpa_tl| (if not empty) is now the opacity and |\l_tmpb_tl| (if not empty) |
| 11353 |
% is now the colorimetric space. |
| 11354 |
% \begin{macrocode} |
| 11355 |
\tl_if_empty:NF \l_tmpa_tl { \exp_args:No \pgfsetfillopacity \l_tmpa_tl } |
| 11356 |
\tl_if_empty:NTF \l_tmpb_tl |
| 11357 |
\@declaredcolor |
| 11358 |
{ \use:e { \exp_not:N \@undeclaredcolor [ \l_tmpb_tl ] } } |
| 11359 |
} |
| 11360 |
% \end{macrocode} |
| 11361 |
% |
| 11362 |
% \bigskip |
| 11363 |
% The following set of keys is used by the command |\@@_color_opacity:w|. |
| 11364 |
% \begin{macrocode} |
| 11365 |
\keys_define:nn { nicematrix / color-opacity } |
| 11366 |
{ |
| 11367 |
opacity .tl_set:N = \l_tmpa_tl , |
| 11368 |
opacity .value_required:n = true |
| 11369 |
} |
| 11370 |
% \end{macrocode} |
| 11371 |
% |
| 11372 |
% \bigskip |
| 11373 |
% Here, we use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 11374 |
% \begin{macrocode} |
| 11375 |
\cs_new_protected:Npn \@@_cartesian_color:nn #1 #2 |
| 11376 |
{ |
| 11377 |
\def \l_@@_rows_tl { #1 } |
| 11378 |
\def \l_@@_cols_tl { #2 } |
| 11379 |
\@@_cartesian_path: |
| 11380 |
} |
| 11381 |
% \end{macrocode} |
| 11382 |
% |
| 11383 |
% \bigskip |
| 11384 |
% Here is an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}| |
| 11385 |
% \begin{macrocode} |
| 11386 |
\NewDocumentCommand \@@_rowcolor { O { } m m } |
| 11387 |
{ |
| 11388 |
\tl_if_blank:nF { #2 } |
| 11389 |
{ |
| 11390 |
\@@_add_to_colors_seq:en |
| 11391 |
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } |
| 11392 |
{ \@@_cartesian_color:nn { #3 } { - } } |
| 11393 |
} |
| 11394 |
} |
| 11395 |
% \end{macrocode} |
| 11396 |
% |
| 11397 |
% \bigskip |
| 11398 |
% Here an example: |\@@_columncolor:nn {red!15} {1,3,5-7,10-}| |
| 11399 |
% \begin{macrocode} |
| 11400 |
\NewDocumentCommand \@@_columncolor { O { } m m } |
| 11401 |
{ |
| 11402 |
\tl_if_blank:nF { #2 } |
| 11403 |
{ |
| 11404 |
\@@_add_to_colors_seq:en |
| 11405 |
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } |
| 11406 |
{ \@@_cartesian_color:nn { - } { #3 } } |
| 11407 |
} |
| 11408 |
} |
| 11409 |
% \end{macrocode} |
| 11410 |
% |
| 11411 |
% \bigskip |
| 11412 |
% Here is an example: |\@@_rectanglecolor{red!15}{2-3}{5-6}| |
| 11413 |
% \begin{macrocode} |
| 11414 |
\NewDocumentCommand \@@_rectanglecolor { O { } m m m } |
| 11415 |
{ |
| 11416 |
\tl_if_blank:nF { #2 } |
| 11417 |
{ |
| 11418 |
\@@_add_to_colors_seq:en |
| 11419 |
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } |
| 11420 |
{ \@@_rectanglecolor:nnn { #3 } { #4 } { \c_zero_dim } } |
| 11421 |
} |
| 11422 |
} |
| 11423 |
% \end{macrocode} |
| 11424 |
% |
| 11425 |
% \bigskip |
| 11426 |
% The last argument is the radius of the corners of the rectangle. |
| 11427 |
% \begin{macrocode} |
| 11428 |
\NewDocumentCommand \@@_roundedrectanglecolor { O { } m m m m } |
| 11429 |
{ |
| 11430 |
\tl_if_blank:nF { #2 } |
| 11431 |
{ |
| 11432 |
\@@_add_to_colors_seq:en |
| 11433 |
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } |
| 11434 |
{ \@@_rectanglecolor:nnn { #3 } { #4 } { #5 } } |
| 11435 |
} |
| 11436 |
} |
| 11437 |
% \end{macrocode} |
| 11438 |
% |
| 11439 |
% \bigskip |
| 11440 |
% The last argument is the radius of the corners of the rectangle. |
| 11441 |
% \begin{macrocode} |
| 11442 |
\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3 |
| 11443 |
{ |
| 11444 |
\@@_cut_on_hyphen:w #1 \q_stop |
| 11445 |
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl |
| 11446 |
\tl_set_eq:NN \l_@@_tmpd_tl \l_tmpb_tl |
| 11447 |
\@@_cut_on_hyphen:w #2 \q_stop |
| 11448 |
\tl_set:Ne \l_@@_rows_tl { \l_@@_tmpc_tl - \l_tmpa_tl } |
| 11449 |
\tl_set:Ne \l_@@_cols_tl { \l_@@_tmpd_tl - \l_tmpb_tl } |
| 11450 |
% \end{macrocode} |
| 11451 |
% The command |\@@_cartesian_path:n| takes in two implicit arguments: |
| 11452 |
% |\l_@@_cols_tl| and |\l_@@_rows_tl|. |
| 11453 |
% \begin{macrocode} |
| 11454 |
\@@_cartesian_path:n { #3 } |
| 11455 |
} |
| 11456 |
% \end{macrocode} |
| 11457 |
% |
| 11458 |
% |
| 11459 |
% \bigskip |
| 11460 |
% Here is an example: |\@@_cellcolor[rgb]{0.5,0.5,0}{2-3,3-4,4-5,5-6}| |
| 11461 |
% \begin{macrocode} |
| 11462 |
\NewDocumentCommand \@@_cellcolor { O { } m m } |
| 11463 |
{ |
| 11464 |
\clist_map_inline:nn { #3 } |
| 11465 |
{ \@@_rectanglecolor [ #1 ] { #2 } { ##1 } { ##1 } } |
| 11466 |
} |
| 11467 |
% \end{macrocode} |
| 11468 |
% |
| 11469 |
% \bigskip |
| 11470 |
% \begin{macrocode} |
| 11471 |
\NewDocumentCommand \@@_chessboardcolors { O { } m m } |
| 11472 |
{ |
| 11473 |
\int_step_inline:nn \c@iRow |
| 11474 |
{ |
| 11475 |
\int_step_inline:nn \c@jCol |
| 11476 |
{ |
| 11477 |
\int_if_even:nTF { ####1 + ##1 } |
| 11478 |
{ \@@_cellcolor [ #1 ] { #2 } } |
| 11479 |
{ \@@_cellcolor [ #1 ] { #3 } } |
| 11480 |
{ ##1 - ####1 } |
| 11481 |
} |
| 11482 |
} |
| 11483 |
} |
| 11484 |
% \end{macrocode} |
| 11485 |
% |
| 11486 |
% \bigskip |
| 11487 |
% The command |\@@_arraycolor| (linked to |\arraycolor| at the beginning of |
| 11488 |
% the |\CodeBefore|) will color the whole tabular (excepted the potential |
| 11489 |
% exterior rows and columns) and the cells in the ``corners''. |
| 11490 |
% \begin{macrocode} |
| 11491 |
\NewDocumentCommand \@@_arraycolor { O { } m } |
| 11492 |
{ |
| 11493 |
\@@_rectanglecolor [ #1 ] { #2 } |
| 11494 |
{ 1 - 1 } |
| 11495 |
{ \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 11496 |
} |
| 11497 |
% \end{macrocode} |
| 11498 |
% |
| 11499 |
% \bigskip |
| 11500 |
% \begin{macrocode} |
| 11501 |
\keys_define:nn { nicematrix / rowcolors } |
| 11502 |
{ |
| 11503 |
respect-blocks .bool_set:N = \l_@@_respect_blocks_bool , |
| 11504 |
cols .tl_set:N = \l_@@_cols_tl , |
| 11505 |
restart .bool_set:N = \l_@@_rowcolors_restart_bool , |
| 11506 |
unknown .code:n = \@@_error:n { Unknown~key~for~rowcolors } |
| 11507 |
} |
| 11508 |
% \end{macrocode} |
| 11509 |
% |
| 11510 |
% \medskip |
| 11511 |
% The command |\rowcolors| (accessible in the |\CodeBefore|) is inspired by the |
| 11512 |
% command |\rowcolors| of the package \pkg{xcolor} (with the option |table|). |
| 11513 |
% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the |
| 11514 |
% optional argument of the command |\rowcolors| of \pkg{xcolor}. |
| 11515 |
% |
| 11516 |
% Here is an example: |\rowcolors{1}{blue!10}{}[respect-blocks]|. |
| 11517 |
% |
| 11518 |
% In \pkg{nicematrix}, the command |\@@_rowcolors| appears as a special case of |
| 11519 |
% |\@@_rowlistcolors|. |
| 11520 |
% |
| 11521 |
% |#1| (optional) is the color space; |
| 11522 |
% |#2| is a list of intervals of rows; |
| 11523 |
% |#3| is the list of colors; |
| 11524 |
% |#4| is for the optional list of pairs \textsl{key=value}. |
| 11525 |
% \begin{macrocode} |
| 11526 |
\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } } |
| 11527 |
{ |
| 11528 |
% \end{macrocode} |
| 11529 |
% |
| 11530 |
% |\l_@@_colors_seq| will be the list of colors. |
| 11531 |
% \begin{macrocode} |
| 11532 |
\seq_clear_new:N \l_@@_colors_seq |
| 11533 |
\seq_set_split:Nnn \l_@@_colors_seq { , } { #3 } |
| 11534 |
\tl_clear_new:N \l_@@_cols_tl |
| 11535 |
\tl_set:Nn \l_@@_cols_tl { - } |
| 11536 |
\keys_set:nn { nicematrix / rowcolors } { #4 } |
| 11537 |
% \end{macrocode} |
| 11538 |
% The counter |\l_@@_color_int| will be the rank of the current color in the list of |
| 11539 |
% colors (modulo the length of the list). |
| 11540 |
% \begin{macrocode} |
| 11541 |
\int_zero_new:N \l_@@_color_int |
| 11542 |
\int_set:Nn \l_@@_color_int 1 |
| 11543 |
\bool_if:NT \l_@@_respect_blocks_bool |
| 11544 |
{ |
| 11545 |
% \end{macrocode} |
| 11546 |
% We don't want to take into account a block which is entirely in the ``first |
| 11547 |
% column'' (number~$0$) or in the ``last column'' and that's why we filter |
| 11548 |
% the sequence of the blocks (in the sequence |\l_tmpa_seq|). |
| 11549 |
% \begin{macrocode} |
| 11550 |
% modified 2026-02-18 |
| 11551 |
\seq_set_filter:NNn \l_tmpa_seq \g_@@_pos_of_blocks_seq |
| 11552 |
{ \@@_not_in_exterior_p:nnnnn ##1 } |
| 11553 |
} |
| 11554 |
% \end{macrocode} |
| 11555 |
% |#2| is the list of intervals of rows. |
| 11556 |
% \begin{macrocode} |
| 11557 |
\clist_map_inline:nn { #2 } |
| 11558 |
{ |
| 11559 |
\tl_set:Nn \l_tmpa_tl { ##1 } |
| 11560 |
\tl_if_in:NnTF \l_tmpa_tl { - } |
| 11561 |
{ \@@_cut_on_hyphen:w ##1 \q_stop } |
| 11562 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \c@iRow } } |
| 11563 |
% \end{macrocode} |
| 11564 |
% Now, |l_tmpa_tl| and |l_tmpb_tl| are the first row and the last row of the |
| 11565 |
% interval of rows that we have to treat. The counter |\l_tmpa_int| will be the |
| 11566 |
% index of the loop over the rows. |
| 11567 |
% \begin{macrocode} |
| 11568 |
\int_set:Nn \l_tmpa_int \l_tmpa_tl |
| 11569 |
\int_set:Nn \l_@@_color_int |
| 11570 |
{ \bool_if:NTF \l_@@_rowcolors_restart_bool { 1 } \l_tmpa_tl } |
| 11571 |
\int_set:Nn \l_@@_tmpc_int \l_tmpb_tl |
| 11572 |
\int_do_until:nNnn \l_tmpa_int > \l_@@_tmpc_int |
| 11573 |
{ |
| 11574 |
% \end{macrocode} |
| 11575 |
% We will compute in |\l_tmpb_int| the last row of the ``block''. |
| 11576 |
% \begin{macrocode} |
| 11577 |
\int_set_eq:NN \l_tmpb_int \l_tmpa_int |
| 11578 |
% \end{macrocode} |
| 11579 |
% If the key |respect-blocks| is in force, we have to adjust that value (of |
| 11580 |
% course). |
| 11581 |
% \begin{macrocode} |
| 11582 |
\bool_if:NT \l_@@_respect_blocks_bool |
| 11583 |
{ |
| 11584 |
\seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq |
| 11585 |
{ \@@_intersect_our_row_p:nnnnn ####1 } |
| 11586 |
\seq_map_inline:Nn \l_tmpb_seq { \@@_rowcolors_i:nnnnn ####1 } |
| 11587 |
% \end{macrocode} |
| 11588 |
% Now, the last row of the block is computed in |\l_tmpb_int|. |
| 11589 |
% \begin{macrocode} |
| 11590 |
} |
| 11591 |
\tl_set:Ne \l_@@_rows_tl |
| 11592 |
{ \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int } |
| 11593 |
% \end{macrocode} |
| 11594 |
% |\l_@@_tmpc_tl| will be the color that we will use. |
| 11595 |
% \begin{macrocode} |
| 11596 |
\tl_set:Ne \l_@@_color_tl |
| 11597 |
{ |
| 11598 |
\@@_color_index:n |
| 11599 |
{ |
| 11600 |
\int_mod:nn |
| 11601 |
{ \l_@@_color_int - 1 } |
| 11602 |
{ \seq_count:N \l_@@_colors_seq } |
| 11603 |
+ 1 |
| 11604 |
} |
| 11605 |
} |
| 11606 |
\tl_if_empty:NF \l_@@_color_tl |
| 11607 |
{ |
| 11608 |
\use:e |
| 11609 |
{ |
| 11610 |
\@@_add_to_colors_seq:nn |
| 11611 |
{ \tl_if_blank:nF { #1 } { [ #1 ] } { \l_@@_color_tl } } |
| 11612 |
{ \@@_cartesian_color:nn { \l_@@_rows_tl } { \l_@@_cols_tl } } |
| 11613 |
} |
| 11614 |
} |
| 11615 |
\int_incr:N \l_@@_color_int |
| 11616 |
\int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 } |
| 11617 |
} |
| 11618 |
} |
| 11619 |
} |
| 11620 |
% \end{macrocode} |
| 11621 |
% |
| 11622 |
% \medskip |
| 11623 |
% The command |\@@_color_index:n| peeks in |\l_@@_colors_seq| the color at the |
| 11624 |
% index |#1|. However, if that color is the symbol |=|, the previous one is |
| 11625 |
% poken. This macro is recursive. |
| 11626 |
% \begin{macrocode} |
| 11627 |
\cs_new:Npn \@@_color_index:n #1 |
| 11628 |
{ |
| 11629 |
% \end{macrocode} |
| 11630 |
% Be careful: this command |\@@_color_index:n| must be ``\emph{fully expandable}''. |
| 11631 |
% \begin{macrocode} |
| 11632 |
\str_if_eq:eeTF { \seq_item:Nn \l_@@_colors_seq { #1 } } { = } |
| 11633 |
{ \@@_color_index:n { #1 - 1 } } |
| 11634 |
{ \seq_item:Nn \l_@@_colors_seq { #1 } } |
| 11635 |
} |
| 11636 |
% \end{macrocode} |
| 11637 |
% |
| 11638 |
% \bigskip |
| 11639 |
% The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation |
| 11640 |
% of the more general command |\rowlistcolors|. The last argument, which is a |
| 11641 |
% optional argument between square brackets is provided by curryfication. |
| 11642 |
% \begin{macrocode} |
| 11643 |
\NewDocumentCommand \@@_rowcolors { O { } m m m } |
| 11644 |
{ \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } } |
| 11645 |
% \end{macrocode} |
| 11646 |
% The braces around |#3| and |#4| are mandatory. |
| 11647 |
% |
| 11648 |
% \bigskip |
| 11649 |
% \begin{macrocode} |
| 11650 |
\cs_new_protected:Npn \@@_rowcolors_i:nnnnn #1 #2 #3 #4 #5 |
| 11651 |
{ |
| 11652 |
\int_compare:nNnT { #3 } > \l_tmpb_int |
| 11653 |
{ \int_set:Nn \l_tmpb_int { #3 } } |
| 11654 |
} |
| 11655 |
% \end{macrocode} |
| 11656 |
% |
| 11657 |
% |
| 11658 |
% \bigskip |
| 11659 |
% \begin{macrocode} |
| 11660 |
\prg_new_conditional:Nnn \@@_not_in_exterior:nnnnn { p } |
| 11661 |
{ |
| 11662 |
\int_if_zero:nTF { #4 } |
| 11663 |
\prg_return_false: |
| 11664 |
{ |
| 11665 |
\int_compare:nNnTF { #2 } > \c@jCol |
| 11666 |
\prg_return_false: |
| 11667 |
\prg_return_true: |
| 11668 |
} |
| 11669 |
} |
| 11670 |
% \end{macrocode} |
| 11671 |
% |
| 11672 |
% \bigskip |
| 11673 |
% The following command return |true| when the block intersects the row |
| 11674 |
% |\l_tmpa_int|. |
| 11675 |
% \begin{macrocode} |
| 11676 |
\prg_new_conditional:Nnn \@@_intersect_our_row:nnnnn { p } |
| 11677 |
{ |
| 11678 |
\int_compare:nNnTF { #1 } > \l_tmpa_int |
| 11679 |
\prg_return_false: |
| 11680 |
{ |
| 11681 |
\int_compare:nNnTF \l_tmpa_int > { #3 } |
| 11682 |
\prg_return_false: |
| 11683 |
\prg_return_true: |
| 11684 |
} |
| 11685 |
} |
| 11686 |
% \end{macrocode} |
| 11687 |
% |
| 11688 |
% \bigskip |
| 11689 |
% The following command uses two implicit arguments: |\l_@@_rows_tl| and |
| 11690 |
% |\l_@@_cols_tl| which are specifications for a set of rows and a set of |
| 11691 |
% columns. It creates a path but does \emph{not} fill it. It must be filled by |
| 11692 |
% another command after. The argument is the radius of the corners. We define |
| 11693 |
% below a command |\@@_cartesian_path:| which corresponds to a value $0$~pt for |
| 11694 |
% the radius of the corners. |
| 11695 |
% |
| 11696 |
% This command is, in particular, used in |\@@_rectanglecolor:nnn| (used in |
| 11697 |
% |\@@_rectanglecolor|, itself used in |\@@_cellcolor|). |
| 11698 |
% \begin{macrocode} |
| 11699 |
\cs_new_protected:Npn \@@_cartesian_path_normal:n #1 |
| 11700 |
{ |
| 11701 |
\dim_compare:nNnTF { #1 } = \c_zero_dim |
| 11702 |
{ |
| 11703 |
\bool_if:NTF \l_@@_nocolor_used_bool |
| 11704 |
{ \@@_cartesian_path_normal_ii: } |
| 11705 |
{ |
| 11706 |
\clist_if_empty:NTF \l_@@_corners_cells_clist |
| 11707 |
{ \@@_cartesian_path_normal_i:n { #1 } } |
| 11708 |
{ \@@_cartesian_path_normal_ii: } |
| 11709 |
} |
| 11710 |
} |
| 11711 |
{ \@@_cartesian_path_normal_i:n { #1 } } |
| 11712 |
} |
| 11713 |
% \end{macrocode} |
| 11714 |
% |
| 11715 |
% |
| 11716 |
% \bigskip |
| 11717 |
% First, the situation where is a rectangular zone of cells will be colored as a |
| 11718 |
% whole (in the instructions of the resulting \textsc{pdf}). The argument is the |
| 11719 |
% radius of the corners. |
| 11720 |
% \begin{macrocode} |
| 11721 |
\cs_new_protected:Npn \@@_cartesian_path_normal_i:n #1 |
| 11722 |
{ |
| 11723 |
\pgfsetcornersarced { \pgfpoint { #1 } { #1 } } |
| 11724 |
% \end{macrocode} |
| 11725 |
% We begin the loop over the columns. |
| 11726 |
% \begin{macrocode} |
| 11727 |
\clist_map_inline:Nn \l_@@_cols_tl |
| 11728 |
{ |
| 11729 |
% \end{macrocode} |
| 11730 |
% We use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 11731 |
% \begin{macrocode} |
| 11732 |
\def \l_tmpa_tl { ##1 } |
| 11733 |
\tl_if_in:NnTF \l_tmpa_tl { - } |
| 11734 |
{ \@@_cut_on_hyphen:w ##1 \q_stop } |
| 11735 |
{ \def \l_tmpb_tl { ##1 } } |
| 11736 |
\tl_if_empty:NTF \l_tmpa_tl |
| 11737 |
{ \def \l_tmpa_tl { 1 } } |
| 11738 |
{ |
| 11739 |
\str_if_eq:eeT \l_tmpa_tl { * } |
| 11740 |
{ \def \l_tmpa_tl { 1 } } |
| 11741 |
} |
| 11742 |
\int_compare:nNnT \l_tmpa_tl > \g_@@_col_total_int |
| 11743 |
{ \@@_error:n { Invalid~col~number } } |
| 11744 |
\tl_if_empty:NTF \l_tmpb_tl |
| 11745 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \c@jCol } } |
| 11746 |
{ |
| 11747 |
\str_if_eq:eeT \l_tmpb_tl { * } |
| 11748 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \c@jCol } } |
| 11749 |
} |
| 11750 |
\int_compare:nNnT \l_tmpb_tl > \g_@@_col_total_int |
| 11751 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \g_@@_col_total_int } } |
| 11752 |
% \end{macrocode} |
| 11753 |
% |\l_@@_tmpc_tl| will contain the number of column. |
| 11754 |
% \begin{macrocode} |
| 11755 |
\tl_set_eq:NN \l_@@_tmpc_tl \l_tmpa_tl |
| 11756 |
\@@_qpoint:n { col - \l_tmpa_tl } |
| 11757 |
\int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl |
| 11758 |
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } |
| 11759 |
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } |
| 11760 |
\@@_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } } |
| 11761 |
\dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } |
| 11762 |
% \end{macrocode} |
| 11763 |
% We begin the loop over the rows. We use |\def| instead of |\tl_set:Nn| for |
| 11764 |
% efficiency only. |
| 11765 |
% \begin{macrocode} |
| 11766 |
\clist_map_inline:Nn \l_@@_rows_tl |
| 11767 |
{ |
| 11768 |
\def \l_tmpa_tl { ####1 } |
| 11769 |
\tl_if_in:NnTF \l_tmpa_tl { - } |
| 11770 |
{ \@@_cut_on_hyphen:w ####1 \q_stop } |
| 11771 |
{ \@@_cut_on_hyphen:w ####1 - ####1 \q_stop } |
| 11772 |
\tl_if_empty:NTF \l_tmpa_tl |
| 11773 |
{ \def \l_tmpa_tl { 1 } } |
| 11774 |
{ |
| 11775 |
\str_if_eq:eeT \l_tmpa_tl { * } |
| 11776 |
{ \def \l_tmpa_tl { 1 } } |
| 11777 |
} |
| 11778 |
\tl_if_empty:NTF \l_tmpb_tl |
| 11779 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \c@iRow } } |
| 11780 |
{ |
| 11781 |
\str_if_eq:eeT \l_tmpb_tl { * } |
| 11782 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \c@iRow } } |
| 11783 |
} |
| 11784 |
\int_compare:nNnT \l_tmpa_tl > \g_@@_row_total_int |
| 11785 |
{ \@@_error:n { Invalid~row~number } } |
| 11786 |
\int_compare:nNnT \l_tmpb_tl > \g_@@_row_total_int |
| 11787 |
{ \tl_set:No \l_tmpb_tl { \int_use:N \g_@@_row_total_int } } |
| 11788 |
% \end{macrocode} |
| 11789 |
% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|. |
| 11790 |
% \begin{macrocode} |
| 11791 |
\cs_if_exist:cF |
| 11792 |
{ @@ _ nocolor _ \l_tmpa_tl - \l_@@_tmpc_tl } |
| 11793 |
{ |
| 11794 |
\@@_qpoint:n { row - \int_eval:n { \l_tmpb_tl + 1 } } |
| 11795 |
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } |
| 11796 |
\@@_qpoint:n { row - \l_tmpa_tl } |
| 11797 |
\dim_set:Nn \l_@@_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } |
| 11798 |
\pgfpathrectanglecorners |
| 11799 |
{ \pgfpoint \l_@@_tmpc_dim \l_@@_tmpd_dim } |
| 11800 |
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim } |
| 11801 |
} |
| 11802 |
} |
| 11803 |
} |
| 11804 |
} |
| 11805 |
% \end{macrocode} |
| 11806 |
% |
| 11807 |
% |
| 11808 |
% Now, the case where the cells will be colored cell by cell (it's mandatory for |
| 11809 |
% example if the key |corners| is used). |
| 11810 |
% \begin{macrocode} |
| 11811 |
\cs_new_protected:Npn \@@_cartesian_path_normal_ii: |
| 11812 |
{ |
| 11813 |
\@@_expand_clist:NN \l_@@_cols_tl \c@jCol |
| 11814 |
\@@_expand_clist:NN \l_@@_rows_tl \c@iRow |
| 11815 |
% \end{macrocode} |
| 11816 |
% We begin the loop over the columns. |
| 11817 |
% \begin{macrocode} |
| 11818 |
\clist_map_inline:Nn \l_@@_cols_tl |
| 11819 |
{ |
| 11820 |
\@@_qpoint:n { col - ##1 } |
| 11821 |
\int_compare:nNnTF \l_@@_first_col_int = { ##1 } |
| 11822 |
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } |
| 11823 |
{ \dim_set:Nn \l_@@_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } |
| 11824 |
\@@_qpoint:n { col - \int_eval:n { ##1 + 1 } } |
| 11825 |
\dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } |
| 11826 |
% \end{macrocode} |
| 11827 |
% We begin the loop over the rows. |
| 11828 |
% \begin{macrocode} |
| 11829 |
\clist_map_inline:Nn \l_@@_rows_tl |
| 11830 |
{ |
| 11831 |
\@@_if_in_corner:nF { ####1 - ##1 } |
| 11832 |
{ |
| 11833 |
\@@_qpoint:n { row - \int_eval:n { ####1 + 1 } } |
| 11834 |
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } |
| 11835 |
\@@_qpoint:n { row - ####1 } |
| 11836 |
\dim_set:Nn \l_@@_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } |
| 11837 |
\cs_if_exist:cF { @@ _ nocolor _ ####1 - ##1 } |
| 11838 |
{ |
| 11839 |
\pgfpathrectanglecorners |
| 11840 |
{ \pgfpoint \l_@@_tmpc_dim \l_@@_tmpd_dim } |
| 11841 |
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim } |
| 11842 |
} |
| 11843 |
} |
| 11844 |
} |
| 11845 |
} |
| 11846 |
} |
| 11847 |
% \end{macrocode} |
| 11848 |
% |
| 11849 |
% |
| 11850 |
% |
| 11851 |
% \bigskip |
| 11852 |
% The following command corresponds to a radius of the corners equal to $0$~pt. |
| 11853 |
% This command is used by the commands |\@@_rowcolors|, |\@@_columncolor| and |
| 11854 |
% |\@@_rowcolor:n| (used in |\@@_rowcolor|). |
| 11855 |
% \begin{macrocode} |
| 11856 |
\cs_new_protected:Npn \@@_cartesian_path: { \@@_cartesian_path:n \c_zero_dim } |
| 11857 |
% \end{macrocode} |
| 11858 |
% |
| 11859 |
% |
| 11860 |
% \bigskip |
| 11861 |
% Despite its name, the following command does not create a PGF path. It |
| 11862 |
% declares as colored by the ``empty color'' all the cells in what would be the |
| 11863 |
% path. Hence, the other coloring instructions of \pkg{nicematrix} won't put |
| 11864 |
% color in those cells. |
| 11865 |
% the |
| 11866 |
% \begin{macrocode} |
| 11867 |
\cs_new_protected:Npn \@@_cartesian_path_nocolor:n #1 |
| 11868 |
{ |
| 11869 |
\bool_set_true:N \l_@@_nocolor_used_bool |
| 11870 |
\@@_expand_clist:NN \l_@@_cols_tl \c@jCol |
| 11871 |
\@@_expand_clist:NN \l_@@_rows_tl \c@iRow |
| 11872 |
% \end{macrocode} |
| 11873 |
% We begin the loop over the columns. |
| 11874 |
% \begin{macrocode} |
| 11875 |
\clist_map_inline:Nn \l_@@_rows_tl |
| 11876 |
{ |
| 11877 |
\clist_map_inline:Nn \l_@@_cols_tl |
| 11878 |
{ \cs_set_nopar:cpn { @@ _ nocolor _ ##1 - ####1 } { } } |
| 11879 |
} |
| 11880 |
} |
| 11881 |
% \end{macrocode} |
| 11882 |
% |
| 11883 |
% |
| 11884 |
% \bigskip |
| 11885 |
% The following command will be used only with |\l_@@_cols_tl| and |\c@jCol| (first |
| 11886 |
% case) or with |\l_@@_rows_tl| and |\c@iRow| (second case). For instance, with |
| 11887 |
% |\l_@@_cols_tl| equal to |2,4-6,8-*| and |\c@jCol| equal to |10|, the clist |
| 11888 |
% |\l_@@_cols_tl| will be replaced by |2,4,5,6,8,9,10|. |
| 11889 |
% \begin{macrocode} |
| 11890 |
\cs_new_protected:Npn \@@_expand_clist:NN #1 #2 |
| 11891 |
{ |
| 11892 |
\clist_set_eq:NN \l_tmpa_clist #1 |
| 11893 |
\clist_clear:N #1 |
| 11894 |
\clist_map_inline:Nn \l_tmpa_clist |
| 11895 |
{ |
| 11896 |
% \end{macrocode} |
| 11897 |
% We use |\def| instead of |\tl_set:Nn| for efficiency only. |
| 11898 |
% \begin{macrocode} |
| 11899 |
\def \l_tmpa_tl { ##1 } |
| 11900 |
\tl_if_in:NnTF \l_tmpa_tl { - } |
| 11901 |
{ \@@_cut_on_hyphen:w ##1 \q_stop } |
| 11902 |
{ \@@_cut_on_hyphen:w ##1 - ##1 \q_stop } |
| 11903 |
\bool_lazy_or:nnT |
| 11904 |
{ \str_if_eq_p:ee \l_tmpa_tl { * } } |
| 11905 |
{ \tl_if_blank_p:o \l_tmpa_tl } |
| 11906 |
{ \def \l_tmpa_tl { 1 } } |
| 11907 |
\bool_lazy_or:nnT |
| 11908 |
{ \str_if_eq_p:ee \l_tmpb_tl { * } } |
| 11909 |
{ \tl_if_blank_p:o \l_tmpb_tl } |
| 11910 |
{ \tl_set:No \l_tmpb_tl { \int_use:N #2 } } |
| 11911 |
\int_compare:nNnT \l_tmpb_tl > { #2 } |
| 11912 |
{ \tl_set:No \l_tmpb_tl { \int_use:N #2 } } |
| 11913 |
\int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl |
| 11914 |
{ \clist_put_right:Nn #1 { ####1 } } |
| 11915 |
} |
| 11916 |
} |
| 11917 |
% \end{macrocode} |
| 11918 |
% |
| 11919 |
% \bigskip |
| 11920 |
% The following command will be linked to |\cellcolor| in the tabular. |
| 11921 |
% \begin{macrocode} |
| 11922 |
\NewDocumentCommand \@@_cellcolor_tabular { O { } m } |
| 11923 |
{ |
| 11924 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 11925 |
{ |
| 11926 |
% \end{macrocode} |
| 11927 |
% We must not expand the color (|#2|) because the color may contain the token |
| 11928 |
% |!| which may be activated by some packages (ex.: \pkg{babel} with the option |
| 11929 |
% |french| on latex and pdflatex). |
| 11930 |
% \begin{macrocode} |
| 11931 |
\@@_cellcolor [ #1 ] { \exp_not:n { #2 } } |
| 11932 |
{ \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 11933 |
} |
| 11934 |
\ignorespaces |
| 11935 |
} |
| 11936 |
% \end{macrocode} |
| 11937 |
% |
| 11938 |
% \begin{macrocode} |
| 11939 |
\NewDocumentCommand \@@_cellcolor_error { O { } m } |
| 11940 |
{ \@@_error:n { cellcolor~in~Block } } |
| 11941 |
% \end{macrocode} |
| 11942 |
% |
| 11943 |
% \begin{macrocode} |
| 11944 |
\NewDocumentCommand \@@_rowcolor_error { O { } m } |
| 11945 |
{ \@@_error:n { rowcolor~in~Block } } |
| 11946 |
% \end{macrocode} |
| 11947 |
% |
| 11948 |
% \bigskip |
| 11949 |
% The following command will be linked to |\rowcolor| in the tabular. |
| 11950 |
% \begin{macrocode} |
| 11951 |
\NewDocumentCommand \@@_rowcolor_tabular { O { } m } |
| 11952 |
{ |
| 11953 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 11954 |
{ |
| 11955 |
\@@_rectanglecolor [ #1 ] { \exp_not:n { #2 } } |
| 11956 |
{ \int_use:N \c@iRow - \int_use:N \c@jCol } |
| 11957 |
{ \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } } |
| 11958 |
} |
| 11959 |
\ignorespaces |
| 11960 |
} |
| 11961 |
% \end{macrocode} |
| 11962 |
% |
| 11963 |
% \bigskip |
| 11964 |
% The following command will be linked to |\rowcolors| in the tabular. The last |
| 11965 |
% argument (an optional argument between square brackets is taken by |
| 11966 |
% curryfication). |
| 11967 |
% \begin{macrocode} |
| 11968 |
\NewDocumentCommand { \@@_rowcolors_tabular } { O { } m m } |
| 11969 |
{ \@@_rowlistcolors_tabular [ #1 ] { { #2 } , { #3 } } } |
| 11970 |
% \end{macrocode} |
| 11971 |
% The braces around |#2| and |#3| are mandatory. |
| 11972 |
% |
| 11973 |
% \bigskip |
| 11974 |
% The following command will be linked to |\rowlistcolors| in the tabular. |
| 11975 |
% \begin{macrocode} |
| 11976 |
\NewDocumentCommand { \@@_rowlistcolors_tabular } { O { } m O { } } |
| 11977 |
{ |
| 11978 |
% \end{macrocode} |
| 11979 |
% A use of |\rowlistcolors| in the tabular erases the instructions |
| 11980 |
% |\rowlistcolors| which are in force. However, it's possible to put \emph{several} |
| 11981 |
% instructions |\rowlistcolors| in the same row of a tabular: it may be useful |
| 11982 |
% when those instructions |\rowlistcolors| concerns different columns of the |
| 11983 |
% tabular (thanks to the key |cols| of |\rowlistcolors|). That's why we store |
| 11984 |
% the different instructions |\rowlistcolors| which are in force in a sequence |
| 11985 |
% |\g_@@_rowlistcolors_seq|. Now, we will filter that sequence to keep only the |
| 11986 |
% elements which have been issued on the actual row. We will store the elements |
| 11987 |
% to keep in the |\g_tmpa_seq|. |
| 11988 |
% \begin{macrocode} |
| 11989 |
\seq_gclear:N \g_tmpa_seq |
| 11990 |
\seq_map_inline:Nn \g_@@_rowlistcolors_seq |
| 11991 |
{ \@@_rowlistcolors_tabular:nnnn ##1 } |
| 11992 |
\seq_gset_eq:NN \g_@@_rowlistcolors_seq \g_tmpa_seq |
| 11993 |
% \end{macrocode} |
| 11994 |
% Now, we add to the sequence |\g_@@_rowlistcolors_seq| (which is the list of |
| 11995 |
% the commands |\rowlistcolors| which are in force) the current instruction |
| 11996 |
% |\rowlistcolors|. |
| 11997 |
% \begin{macrocode} |
| 11998 |
\seq_gput_right:Ne \g_@@_rowlistcolors_seq |
| 11999 |
{ |
| 12000 |
{ \int_use:N \c@iRow } |
| 12001 |
{ \exp_not:n { #1 } } |
| 12002 |
{ \exp_not:n { #2 } } |
| 12003 |
{ restart , cols = \int_use:N \c@jCol - , \exp_not:n { #3 } } |
| 12004 |
} |
| 12005 |
\ignorespaces |
| 12006 |
} |
| 12007 |
% \end{macrocode} |
| 12008 |
% |
| 12009 |
% |
| 12010 |
% \bigskip |
| 12011 |
% The following command will be applied to each component of |
| 12012 |
% |\g_@@_rowlistcolors_seq|. Each component of that sequence is a kind of 4-uple |
| 12013 |
% of the form |{#1}{#2}{#3}{#4}|. |
| 12014 |
% |
| 12015 |
% |#1| is the number of the row where the command |\rowlistcolors| has been |
| 12016 |
% issued. |
| 12017 |
% |
| 12018 |
% |#2| is the colorimetric space (optional argument of the |\rowlistcolors|). |
| 12019 |
% |
| 12020 |
% |#3| is the list of colors (mandatory argument of |\rowlistcolors|). |
| 12021 |
% |
| 12022 |
% |#4| is the list of \textsl{key=value} pairs (last optional argument of |
| 12023 |
% |\rowlistcolors|). |
| 12024 |
% |
| 12025 |
% \begin{macrocode} |
| 12026 |
\cs_new_protected:Npn \@@_rowlistcolors_tabular:nnnn #1 #2 #3 #4 |
| 12027 |
{ |
| 12028 |
\int_compare:nNnTF { #1 } = \c@iRow |
| 12029 |
% \end{macrocode} |
| 12030 |
% We (temporary) keep in memory in |\g_tmpa_seq| the instructions which will |
| 12031 |
% still be in force after the current instruction (because they have been issued |
| 12032 |
% in the same row of the tabular). |
| 12033 |
% \begin{macrocode} |
| 12034 |
{ \seq_gput_right:Nn \g_tmpa_seq { { #1 } { #2 } { #3 } { #4 } } } |
| 12035 |
{ |
| 12036 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 12037 |
{ |
| 12038 |
\@@_rowlistcolors |
| 12039 |
[ \exp_not:n { #2 } ] |
| 12040 |
{ #1 - \int_eval:n { \c@iRow - 1 } } |
| 12041 |
{ \exp_not:n { #3 } } |
| 12042 |
[ \exp_not:n { #4 } ] |
| 12043 |
} |
| 12044 |
} |
| 12045 |
} |
| 12046 |
% \end{macrocode} |
| 12047 |
% |
| 12048 |
% \bigskip |
| 12049 |
% The following command will be used at the end of the tabular, just before the |
| 12050 |
% execution of the |\g_@@_pre_code_before_tl|. It clears the sequence |
| 12051 |
% |\g_@@_rowlistcolors_seq| of all the commands |\rowlistcolors| which are |
| 12052 |
% (still) in force. |
| 12053 |
% \begin{macrocode} |
| 12054 |
\cs_new_protected:Npn \@@_clear_rowlistcolors_seq: |
| 12055 |
{ |
| 12056 |
\seq_map_inline:Nn \g_@@_rowlistcolors_seq |
| 12057 |
{ \@@_rowlistcolors_tabular_ii:nnnn ##1 } |
| 12058 |
\seq_gclear:N \g_@@_rowlistcolors_seq |
| 12059 |
} |
| 12060 |
% \end{macrocode} |
| 12061 |
% |
| 12062 |
% \medskip |
| 12063 |
% \begin{macrocode} |
| 12064 |
\cs_new_protected:Npn \@@_rowlistcolors_tabular_ii:nnnn #1 #2 #3 #4 |
| 12065 |
{ |
| 12066 |
\tl_gput_right:Nn \g_@@_pre_code_before_tl |
| 12067 |
{ \@@_rowlistcolors [ #2 ] { #1 } { #3 } [ #4 ] } |
| 12068 |
} |
| 12069 |
% \end{macrocode} |
| 12070 |
% The first mandatory argument of the command |\@@_rowlistcolors| which is |
| 12071 |
% writtent in the pre-|\CodeBefore| is of the form |i|: it means that the |
| 12072 |
% command must be applied to all the rows from the row~$i$ until the end of the |
| 12073 |
% tabular. |
| 12074 |
% |
| 12075 |
% \bigskip |
| 12076 |
% \begin{macrocode} |
| 12077 |
\NewDocumentCommand \@@_columncolor_preamble { O { } m } |
| 12078 |
{ |
| 12079 |
% \end{macrocode} |
| 12080 |
% With the following line, we test whether the cell is the first one that we actually |
| 12081 |
% encounter in its column (don't forget that some rows may be incomplete and that |
| 12082 |
% an instruction |\multicolumn| may be used, leading to cells which are not ``evaluated''). |
| 12083 |
% \begin{macrocode} |
| 12084 |
\seq_if_in:NVF \g_@@_columncolor_seq \c@jCol |
| 12085 |
{ |
| 12086 |
\seq_gput_right:NV \g_@@_columncolor_seq \c@jCol |
| 12087 |
% \end{macrocode} |
| 12088 |
% You use |gput_left| because we want the specification of colors for the |
| 12089 |
% columns drawn before the specifications of color for the rows (and the cells). |
| 12090 |
% Be careful: maybe this is not effective since we have an analyze of the |
| 12091 |
% instructions in the |\CodeBefore| in order to fill color by color (to avoid |
| 12092 |
% the thin white lines). |
| 12093 |
% \begin{macrocode} |
| 12094 |
\tl_gput_left:Ne \g_@@_pre_code_before_tl |
| 12095 |
{ |
| 12096 |
\exp_not:N \columncolor [ #1 ] |
| 12097 |
{ \exp_not:n { #2 } } { \int_use:N \c@jCol } |
| 12098 |
} |
| 12099 |
} |
| 12100 |
} |
| 12101 |
% \end{macrocode} |
| 12102 |
% |
| 12103 |
% |
| 12104 |
% \bigskip |
| 12105 |
% \begin{macrocode} |
| 12106 |
\cs_new_protected:Npn \@@_EmptyColumn:n #1 |
| 12107 |
{ |
| 12108 |
\clist_map_inline:nn { #1 } |
| 12109 |
{ |
| 12110 |
\seq_gput_right:Nn \g_@@_future_pos_of_blocks_seq |
| 12111 |
{ { -2 } { #1 } { 98 } { ##1 } { } } % 98 and not 99 ! |
| 12112 |
\columncolor { nocolor } { ##1 } |
| 12113 |
} |
| 12114 |
} |
| 12115 |
% \end{macrocode} |
| 12116 |
% |
| 12117 |
% \begin{macrocode} |
| 12118 |
\cs_new_protected:Npn \@@_EmptyRow:n #1 |
| 12119 |
{ |
| 12120 |
\clist_map_inline:nn { #1 } |
| 12121 |
{ |
| 12122 |
\seq_gput_right:Nn \g_@@_future_pos_of_blocks_seq |
| 12123 |
{ { ##1 } { -2 } { ##1 } { 98 } { } } % 98 and not 99 ! |
| 12124 |
\rowcolor { nocolor } { ##1 } |
| 12125 |
} |
| 12126 |
} |
| 12127 |
% \end{macrocode} |
| 12128 |
% |
| 12129 |
% \bigskip |
| 12130 |
% \section{The vertical and horizontal rules} |
| 12131 |
% |
| 12132 |
% |
| 12133 |
% \bigskip |
| 12134 |
% \subsubsection*{OnlyMainNiceMatrix} |
| 12135 |
% |
| 12136 |
% We give to the user the possibility to define new types of columns (with |
| 12137 |
% |\newcolumntype| of \pkg{array}) for special vertical rules (\emph{e.g.} rules |
| 12138 |
% thicker than the standard ones) which will not extend in the potential |
| 12139 |
% exterior rows of the array. |
| 12140 |
% |
| 12141 |
% We provide the command |\OnlyMainNiceMatrix| in that goal. However, that |
| 12142 |
% command must be no-op outside the environments of \pkg{nicematrix} (and so the |
| 12143 |
% user will be allowed to use the same new type of column in the environments |
| 12144 |
% of \pkg{nicematrix} and in the standard environments of \pkg{array}). |
| 12145 |
% |
| 12146 |
% That's why we provide first a global definition of |\OnlyMainNiceMatrix|. |
| 12147 |
% \begin{macrocode} |
| 12148 |
\cs_new_eq:NN \OnlyMainNiceMatrix \use:n |
| 12149 |
% \end{macrocode} |
| 12150 |
% |
| 12151 |
% \medskip |
| 12152 |
% Another definition of |\OnlyMainNiceMatrix| will be linked to the command in |
| 12153 |
% the environments of \pkg{nicematrix}. Here is that definition, called |
| 12154 |
% |\@@_OnlyMainNiceMatrix:n|. |
| 12155 |
% |
| 12156 |
% \begin{macrocode} |
| 12157 |
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix:n #1 |
| 12158 |
{ |
| 12159 |
\int_if_zero:nTF \l_@@_first_col_int |
| 12160 |
{ \@@_OnlyMainNiceMatrix_i:n { #1 } } |
| 12161 |
{ |
| 12162 |
\int_if_zero:nTF \c@jCol |
| 12163 |
{ |
| 12164 |
\int_compare:nNnF \c@iRow = { -1 } |
| 12165 |
{ |
| 12166 |
\int_compare:nNnF \c@iRow = { \l_@@_last_row_int - 1 } |
| 12167 |
{ #1 } |
| 12168 |
} |
| 12169 |
} |
| 12170 |
{ \@@_OnlyMainNiceMatrix_i:n { #1 } } |
| 12171 |
} |
| 12172 |
} |
| 12173 |
% \end{macrocode} |
| 12174 |
% This definition may seem complicated but we must remind that the number of row |
| 12175 |
% |\c@iRow| is incremented in the first cell of the row, \emph{after} a |
| 12176 |
% potential vertical rule on the left side of the first cell. |
| 12177 |
% |
| 12178 |
% \smallskip |
| 12179 |
% The command |\@@_OnlyMainNiceMatrix_i:n| is only a short-cut which is used |
| 12180 |
% twice in the above command. This command must \emph{not} be protected. |
| 12181 |
% \begin{macrocode} |
| 12182 |
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1 |
| 12183 |
{ |
| 12184 |
\int_if_zero:nF \c@iRow |
| 12185 |
{ |
| 12186 |
\int_compare:nNnF \c@iRow = \l_@@_last_row_int |
| 12187 |
{ |
| 12188 |
\int_compare:nNnT \c@jCol > \c_zero_int |
| 12189 |
{ \bool_if:NF \l_@@_in_last_col_bool { #1 } } |
| 12190 |
} |
| 12191 |
} |
| 12192 |
} |
| 12193 |
% \end{macrocode} |
| 12194 |
% Remember that |\c@iRow| is not always inferior to |\l_@@_last_row_int| because |
| 12195 |
% |\l_@@_last_row_int| may be equal to $-2$ or $-1$ (we can't write |
| 12196 |
% |\int_compare:nNnT \c@iRow < \l_@@_last_row_int|). |
| 12197 |
% |
| 12198 |
% \bigskip |
| 12199 |
% The following command will be used for |\Toprule|, |\BottomRule| and |\MidRule|. |
| 12200 |
% \begin{macrocode} |
| 12201 |
\cs_new:Npn \@@_tikz_booktabs_loaded:nn #1 #2 |
| 12202 |
{ |
| 12203 |
\IfPackageLoadedTF { tikz } |
| 12204 |
{ |
| 12205 |
\IfPackageLoadedTF { booktabs } |
| 12206 |
{ #2 } |
| 12207 |
{ \@@_error:nn { TopRule~without~booktabs } { #1 } } |
| 12208 |
} |
| 12209 |
{ \@@_error:nn { TopRule~without~tikz } { #1 } } |
| 12210 |
} |
| 12211 |
% \end{macrocode} |
| 12212 |
% |
| 12213 |
% \begin{macrocode} |
| 12214 |
\NewExpandableDocumentCommand { \@@_TopRule } { } |
| 12215 |
{ \@@_tikz_booktabs_loaded:nn { \TopRule } { \@@_TopRule_i: } } |
| 12216 |
% \end{macrocode} |
| 12217 |
% |
| 12218 |
% |
| 12219 |
% \begin{macrocode} |
| 12220 |
\cs_new:Npn \@@_TopRule_i: |
| 12221 |
{ |
| 12222 |
\noalign \bgroup |
| 12223 |
\peek_meaning:NTF [ |
| 12224 |
{ \@@_TopRule_ii: } |
| 12225 |
{ \@@_TopRule_ii: [ \dim_use:N \heavyrulewidth ] } |
| 12226 |
} |
| 12227 |
% \end{macrocode} |
| 12228 |
% |
| 12229 |
% \begin{macrocode} |
| 12230 |
\NewDocumentCommand \@@_TopRule_ii: { o } |
| 12231 |
{ |
| 12232 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 12233 |
{ |
| 12234 |
\@@_draw_hrule:n |
| 12235 |
{ |
| 12236 |
position = \int_eval:n { \c@iRow + 1 } , |
| 12237 |
tikz = |
| 12238 |
{ |
| 12239 |
line~width = #1 , |
| 12240 |
yshift = 0.25 \arrayrulewidth , |
| 12241 |
shorten~< = - 0.5 \arrayrulewidth |
| 12242 |
} , |
| 12243 |
total-width = #1 |
| 12244 |
} |
| 12245 |
} |
| 12246 |
\skip_vertical:n { \belowrulesep + #1 } |
| 12247 |
\egroup |
| 12248 |
} |
| 12249 |
% \end{macrocode} |
| 12250 |
% |
| 12251 |
% \begin{macrocode} |
| 12252 |
\NewExpandableDocumentCommand { \@@_BottomRule } { } |
| 12253 |
{ \@@_tikz_booktabs_loaded:nn { \BottomRule } { \@@_BottomRule_i: } } |
| 12254 |
% \end{macrocode} |
| 12255 |
% |
| 12256 |
% \begin{macrocode} |
| 12257 |
\cs_new:Npn \@@_BottomRule_i: |
| 12258 |
{ |
| 12259 |
\noalign \bgroup |
| 12260 |
\peek_meaning:NTF [ |
| 12261 |
{ \@@_BottomRule_ii: } |
| 12262 |
{ \@@_BottomRule_ii: [ \dim_use:N \heavyrulewidth ] } |
| 12263 |
} |
| 12264 |
% \end{macrocode} |
| 12265 |
% |
| 12266 |
% |
| 12267 |
% \begin{macrocode} |
| 12268 |
\NewDocumentCommand \@@_BottomRule_ii: { o } |
| 12269 |
{ |
| 12270 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 12271 |
{ |
| 12272 |
\@@_draw_hrule:n |
| 12273 |
{ |
| 12274 |
position = \int_eval:n { \c@iRow + 1 } , |
| 12275 |
tikz = |
| 12276 |
{ |
| 12277 |
line~width = #1 , |
| 12278 |
yshift = 0.25 \arrayrulewidth , |
| 12279 |
shorten~< = - 0.5 \arrayrulewidth |
| 12280 |
} , |
| 12281 |
total-width = #1 , |
| 12282 |
} |
| 12283 |
} |
| 12284 |
\skip_vertical:N \aboverulesep |
| 12285 |
\@@_create_row_node_i: |
| 12286 |
\skip_vertical:n { #1 } |
| 12287 |
\egroup |
| 12288 |
} |
| 12289 |
% \end{macrocode} |
| 12290 |
% |
| 12291 |
% |
| 12292 |
% \begin{macrocode} |
| 12293 |
\NewExpandableDocumentCommand { \@@_MidRule } { } |
| 12294 |
{ \@@_tikz_booktabs_loaded:nn { \MidRule } { \@@_MidRule_i: } } |
| 12295 |
% \end{macrocode} |
| 12296 |
% |
| 12297 |
% |
| 12298 |
% \begin{macrocode} |
| 12299 |
\cs_new:Npn \@@_MidRule_i: |
| 12300 |
{ |
| 12301 |
\noalign \bgroup |
| 12302 |
\peek_meaning:NTF [ |
| 12303 |
{ \@@_MidRule_ii: } |
| 12304 |
{ \@@_MidRule_ii: [ \dim_use:N \lightrulewidth ] } |
| 12305 |
} |
| 12306 |
% \end{macrocode} |
| 12307 |
% |
| 12308 |
% \begin{macrocode} |
| 12309 |
\NewDocumentCommand \@@_MidRule_ii: { o } |
| 12310 |
{ |
| 12311 |
\skip_vertical:N \aboverulesep |
| 12312 |
\@@_create_row_node_i: |
| 12313 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 12314 |
{ |
| 12315 |
\@@_draw_hrule:n |
| 12316 |
{ |
| 12317 |
position = \int_eval:n { \c@iRow + 1 } , |
| 12318 |
tikz = |
| 12319 |
{ |
| 12320 |
line~width = #1 , |
| 12321 |
yshift = 0.25 \arrayrulewidth , |
| 12322 |
shorten~< = - 0.5 \arrayrulewidth |
| 12323 |
} , |
| 12324 |
total-width = #1 , |
| 12325 |
} |
| 12326 |
} |
| 12327 |
\skip_vertical:n { \belowrulesep + #1 } |
| 12328 |
\egroup |
| 12329 |
} |
| 12330 |
% \end{macrocode} |
| 12331 |
% |
| 12332 |
% \bigskip |
| 12333 |
% \subsubsection*{General system for drawing rules} |
| 12334 |
% |
| 12335 |
% |
| 12336 |
% \begin{macrocode} |
| 12337 |
\AtBeginDocument |
| 12338 |
{ |
| 12339 |
\cs_new_protected:Npe \@@_draw_rules: |
| 12340 |
{ |
| 12341 |
\c_@@_pgfortikzpicture_tl |
| 12342 |
\@@_draw_rules_i: |
| 12343 |
\c_@@_endpgfortikzpicture_tl |
| 12344 |
} |
| 12345 |
} |
| 12346 |
% \end{macrocode} |
| 12347 |
% |
| 12348 |
% \begin{macrocode} |
| 12349 |
\cs_new_protected:Npn \@@_draw_rules_i: |
| 12350 |
{ |
| 12351 |
\bool_lazy_all:nT |
| 12352 |
{ |
| 12353 |
{ \clist_if_empty_p:N \l_@@_corners_clist } |
| 12354 |
{ \seq_if_empty_p:N \g_@@_pos_of_blocks_seq } |
| 12355 |
{ \seq_if_empty_p:N \g_@@_pos_of_xdots_seq } |
| 12356 |
{ \seq_if_empty_p:N \g_@@_pos_of_stroken_blocks_seq } |
| 12357 |
{ ! \l_@@_fix_vertex_bool } % added 2026/04/28 |
| 12358 |
} |
| 12359 |
{ |
| 12360 |
\socket_assign_plug:nn { nicematrix / draw-hrule } { quick } |
| 12361 |
\socket_assign_plug:nn { nicematrix / draw-vrule } { quick } |
| 12362 |
} |
| 12363 |
\pgfrememberpicturepositiononpagetrue |
| 12364 |
\pgf@relevantforpicturesizefalse |
| 12365 |
\pgfsetrectcap |
| 12366 |
\pgfsetlinewidth { 1.1 \arrayrulewidth } |
| 12367 |
\CT@arc@ |
| 12368 |
\clist_if_empty:NF \l_@@_hlines_clist \@@_draw_key_hlines: |
| 12369 |
\clist_if_empty:NF \l_@@_vlines_clist \@@_draw_key_vlines: |
| 12370 |
\g_@@_rules_tl |
| 12371 |
} |
| 12372 |
% \end{macrocode} |
| 12373 |
% |
| 12374 |
% When a command, environment or ``subsystem'' of \pkg{nicematrix} wants to draw |
| 12375 |
% a rule, it will write in |\g_@@_rules_tl| a command |\@@_draw_vrule:n| or |
| 12376 |
% |\@@_draw_hrule:n|. Both commands take in as argument a list of \textsl{key=value} |
| 12377 |
% pairs. |
| 12378 |
% |
| 12379 |
% That list will first be analyzed with the following set of keys which is a kind of |
| 12380 |
% ``internal set of keys''. |
| 12381 |
% |
| 12382 |
% \begin{macrocode} |
| 12383 |
\keys_define:nn { nicematrix / rules-after } |
| 12384 |
{ |
| 12385 |
position .int_set:N = \l_@@_position_int , |
| 12386 |
start .int_set:N = \l_@@_start_int , |
| 12387 |
start .initial:n = 1 , |
| 12388 |
end .int_set:N = \l_@@_end_int , |
| 12389 |
multiplicity .code:n = \@@_set_multiplicity:n { #1 } , |
| 12390 |
dotted .code:n = |
| 12391 |
\bool_set_true:N \l_@@_dotted_bool |
| 12392 |
\socket_assign_plug:nn { nicematrix / vsegment } { dotted } |
| 12393 |
\socket_assign_plug:nn { nicematrix / hsegment } { dotted } , |
| 12394 |
dotted .value_forbidden:n = true , |
| 12395 |
% \end{macrocode} |
| 12396 |
% We want that, even when the rule has been defined with TikZ by the key |tikz|, |
| 12397 |
% the user has still the possibility to change the color of the rule with the key |
| 12398 |
% |color| (in the command |\Hline|, not in the key |tikz| of the command |
| 12399 |
% |\Hline|). The main use is, when the user has defined its own command |
| 12400 |
% |\MyDashedLine| by |\newcommand{\MyDashedRule}{\Hline[tikz=dashed]}|, to give |
| 12401 |
% the ability to write |\MyDashedRule[color=red]|. |
| 12402 |
% \begin{macrocode} |
| 12403 |
color .code:n = |
| 12404 |
\@@_set_CTarc:n { #1 } |
| 12405 |
\CT@arc@ |
| 12406 |
\tl_set:Nn \l_@@_rule_color_tl { #1 } , |
| 12407 |
color .value_required:n = true , |
| 12408 |
sep-color .code:n = \@@_set_CTdrsc:n { #1 } , |
| 12409 |
sep-color .value_required:n = true , |
| 12410 |
% \end{macrocode} |
| 12411 |
% |
| 12412 |
% Example for the key |total-width|: |
| 12413 |
% \begin{Verbatim} |
| 12414 |
% \NiceMatrixOptions |
| 12415 |
% { |
| 12416 |
% custom-line = |
| 12417 |
% { |
| 12418 |
% letter = I , |
| 12419 |
% tikz = { line width = 1pt , dotted} , |
| 12420 |
% total-width = 1 pt |
| 12421 |
% } |
| 12422 |
% } |
| 12423 |
% \end{Verbatim} |
| 12424 |
% |
| 12425 |
% \begin{macrocode} |
| 12426 |
total-width .dim_set:N = \l_@@_rule_width_after_dim , |
| 12427 |
unknown .code:n = |
| 12428 |
\@@_unknown_key:nn |
| 12429 |
{ nicematrix / rules-after } |
| 12430 |
{ Unknown~key~for~a~rule } , |
| 12431 |
tikz .value_required:n = true |
| 12432 |
} |
| 12433 |
% \end{macrocode} |
| 12434 |
% |
| 12435 |
% If the user uses the key |tikz|, the rule (or more precisely: the different |
| 12436 |
% segments since a rule may be broken by blocks or others) will be drawn with |
| 12437 |
% TikZ. |
| 12438 |
% \begin{macrocode} |
| 12439 |
\AtBeginDocument |
| 12440 |
{ |
| 12441 |
\IfPackageLoadedTF { tikz } |
| 12442 |
{ |
| 12443 |
\keys_define:nn { nicematrix / rules-after } |
| 12444 |
{ |
| 12445 |
tikz .code:n = |
| 12446 |
\clist_put_right:Nn \l_@@_tikz_rule_tl { #1 } |
| 12447 |
\socket_assign_plug:nn { nicematrix / vsegment } { tikz } |
| 12448 |
\socket_assign_plug:nn { nicematrix / hsegment } { tikz } , |
| 12449 |
dashed .meta:n = |
| 12450 |
{ |
| 12451 |
tikz = nicematrix / dashed , |
| 12452 |
total-width = \pgflinewidth |
| 12453 |
} |
| 12454 |
} |
| 12455 |
} |
| 12456 |
{ |
| 12457 |
\keys_define:nn { nicematrix / rules-after } |
| 12458 |
{ tikz .code:n = \@@_error:n { tikz~without~tikz } } |
| 12459 |
} |
| 12460 |
} |
| 12461 |
% \end{macrocode} |
| 12462 |
% |
| 12463 |
% \bigskip |
| 12464 |
% \begin{macrocode} |
| 12465 |
\cs_new_protected:Npn \@@_set_multiplicity:n #1 |
| 12466 |
{ |
| 12467 |
\int_set:Nn \l_@@_multiplicity_int { #1 } |
| 12468 |
\socket_assign_plug:nn { nicematrix / vsegment } { multiple } |
| 12469 |
\socket_assign_plug:nn { nicematrix / hsegment } { multiple } |
| 12470 |
} |
| 12471 |
% \end{macrocode} |
| 12472 |
% |
| 12473 |
% \begin{macrocode} |
| 12474 |
\AtBeginDocument |
| 12475 |
{ |
| 12476 |
\IfPackageLoadedT { tikz } |
| 12477 |
{ |
| 12478 |
\tikzset |
| 12479 |
{ |
| 12480 |
nicematrix / dashed / .style = |
| 12481 |
{ |
| 12482 |
dash~pattern = on~4~pt~off~2pt , |
| 12483 |
line~cap = butt |
| 12484 |
} |
| 12485 |
} |
| 12486 |
\cs_if_exist:cT { tikz@library@decorations@loaded } |
| 12487 |
{ \tikzset { nicematrix / dashed / .append~style = dash~expand~off } } |
| 12488 |
} |
| 12489 |
} |
| 12490 |
% \end{macrocode} |
| 12491 |
% |
| 12492 |
% \subsubsection*{The vertical rules} |
| 12493 |
% |
| 12494 |
% |\@@_draw_vrule:n| and the socket |draw-vrule| will appear in |
| 12495 |
% |\@@_draw_key_vlines:n| and in the token list |\g_@@_rules_tl| (or within |
| 12496 |
% other functions used in |\g_@@_rules_tl|) and those token lists will be |
| 12497 |
% executed within a PGF pseudo-environment. |
| 12498 |
% |
| 12499 |
% \bigskip |
| 12500 |
% The argument |#1| is a list of \textsl{key=value} pairs. |
| 12501 |
% \begin{macrocode} |
| 12502 |
\cs_new_protected:Npn \@@_draw_vrule:n #1 |
| 12503 |
{ |
| 12504 |
% \end{macrocode} |
| 12505 |
% The group is for the options. |
| 12506 |
% \begin{macrocode} |
| 12507 |
{ |
| 12508 |
\int_set_eq:NN \l_@@_end_int \c@iRow |
| 12509 |
\keys_set:nn { nicematrix / rules-after } { #1 } |
| 12510 |
% \end{macrocode} |
| 12511 |
% The following test is for the case where the user does not use all the columns |
| 12512 |
% specified in the preamble of the environment (for instance, a preamble of |
| 12513 |
% \verb+|c|c|c|+ but only two columns used). |
| 12514 |
% \begin{macrocode} |
| 12515 |
\int_compare:nNnT \l_@@_position_int < { \c@jCol + 2 } |
| 12516 |
\socket_use:n { nicematrix / draw-vrule } |
| 12517 |
} |
| 12518 |
} |
| 12519 |
% \end{macrocode} |
| 12520 |
% |
| 12521 |
% \bigskip |
| 12522 |
% The socket ``|nicematrix / draw-vrule|'' will draw a vertical rule. That vertical |
| 12523 |
% rule may potentially be composed of several disconnected segments. |
| 12524 |
% |
| 12525 |
% The plug |general| will break the vertical rule in several segments. |
| 12526 |
% |
| 12527 |
% The plug |quick| will draw directly the vertical rule. That plug is used when we are |
| 12528 |
% sure that the whole rule must be drawn, that is to say when: |
| 12529 |
% \begin{itemize} |
| 12530 |
% \item there is no corners; |
| 12531 |
% \item there is no blocks; |
| 12532 |
% \item there is no implicit blocks created by the continuous dotted lines; |
| 12533 |
% \item there is no stroken blocks. |
| 12534 |
% \end{itemize} |
| 12535 |
% |
| 12536 |
% \begin{macrocode} |
| 12537 |
\socket_new:nn { nicematrix / draw-vrule } { 0 } |
| 12538 |
% \end{macrocode} |
| 12539 |
% |
| 12540 |
% \begin{macrocode} |
| 12541 |
\socket_new_plug:nnn { nicematrix / draw-vrule } { general } |
| 12542 |
{ |
| 12543 |
\group_begin: |
| 12544 |
% \end{macrocode} |
| 12545 |
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When |
| 12546 |
% we have found a row corresponding to a rule to draw, we note its number in |
| 12547 |
% |\l_@@_tmpc_tl|. |
| 12548 |
% \begin{macrocode} |
| 12549 |
\tl_set:No \l_tmpb_tl { \int_use:N \l_@@_position_int } |
| 12550 |
% \end{macrocode} |
| 12551 |
% |\l_@@_x_initial_dim| will be the $x$-value of the rule to draw (used in all the plugs). |
| 12552 |
% \begin{macrocode} |
| 12553 |
\@@_qpoint:n { col - \int_use:N \l_@@_position_int } |
| 12554 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 12555 |
\int_step_variable:nnNn \l_@@_start_int \l_@@_end_int |
| 12556 |
\l_tmpa_tl |
| 12557 |
{ |
| 12558 |
% \end{macrocode} |
| 12559 |
% After the execution of |\test_v:|, |\g_tmpa_bool| will be equal to |true| |
| 12560 |
% if we have to draw that rule. |
| 12561 |
% \begin{macrocode} |
| 12562 |
\@@_test_v: |
| 12563 |
\bool_if:NTF \g_tmpa_bool |
| 12564 |
{ |
| 12565 |
\int_if_zero:nTF \l_@@_segment_start_int |
| 12566 |
% \end{macrocode} |
| 12567 |
% We keep in memory that we have a rule to draw. |\l_@@_segment_start_int| will be |
| 12568 |
% the starting row of the rule that we will have to draw. |
| 12569 |
% \begin{macrocode} |
| 12570 |
{ \int_set:Nn \l_@@_segment_start_int \l_tmpa_tl } |
| 12571 |
% \end{macrocode} |
| 12572 |
% |
| 12573 |
% \begin{macrocode} |
| 12574 |
{ \socket_use:nn { nicematrix / draw-at-odd-vertex-v } } |
| 12575 |
} |
| 12576 |
{ |
| 12577 |
\int_compare:nNnT \l_@@_segment_start_int > \c_zero_int |
| 12578 |
{ |
| 12579 |
\int_set:Nn \l_@@_segment_end_int { \l_tmpa_tl - 1 } |
| 12580 |
% \end{macrocode} |
| 12581 |
% The socket |vsegment| is defined below with its four plugs. |
| 12582 |
% \begin{macrocode} |
| 12583 |
\socket_use:n { nicematrix / vsegment } |
| 12584 |
\int_zero:N \l_@@_segment_start_int |
| 12585 |
} |
| 12586 |
} |
| 12587 |
} |
| 12588 |
\int_compare:nNnT \l_@@_segment_start_int > \c_zero_int |
| 12589 |
{ |
| 12590 |
\int_set_eq:NN \l_@@_segment_end_int \l_@@_end_int |
| 12591 |
\socket_use:n { nicematrix / vsegment } |
| 12592 |
} |
| 12593 |
\group_end: |
| 12594 |
} |
| 12595 |
% \end{macrocode} |
| 12596 |
% |
| 12597 |
% \begin{macrocode} |
| 12598 |
\socket_assign_plug:nn { nicematrix / draw-vrule } { general } |
| 12599 |
% \end{macrocode} |
| 12600 |
% |
| 12601 |
% \begin{macrocode} |
| 12602 |
\socket_new_plug:nnn { nicematrix / draw-vrule } { quick } |
| 12603 |
{ |
| 12604 |
\group_begin: |
| 12605 |
\@@_qpoint:n { col - \int_use:N \l_@@_position_int } |
| 12606 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 12607 |
\int_set_eq:NN \l_@@_segment_start_int \l_@@_start_int |
| 12608 |
\int_set_eq:NN \l_@@_segment_end_int \l_@@_end_int |
| 12609 |
\socket_use:n { nicematrix / vsegment } |
| 12610 |
\group_end: |
| 12611 |
} |
| 12612 |
% \end{macrocode} |
| 12613 |
% |
| 12614 |
% |
| 12615 |
% The boolean |\g_tmpa_bool| indicates whether the small vertical rule will be |
| 12616 |
% drawn. If we find that it is in a block (a real block, created by |\Block| or |
| 12617 |
% |create-blocks-in-col| or a virtual block corresponding to a dotted line, |
| 12618 |
% created by |\Cdots|, |\Vdots|, etc.), we will set |\g_tmpa_bool| to |false| |
| 12619 |
% and the small vertical rule won't be drawn. |
| 12620 |
% \begin{macrocode} |
| 12621 |
\cs_new_protected:Npn \@@_test_v: |
| 12622 |
{ |
| 12623 |
\bool_gset_true:N \g_tmpa_bool |
| 12624 |
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_v: |
| 12625 |
\bool_if:NT \g_tmpa_bool |
| 12626 |
{ |
| 12627 |
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq |
| 12628 |
{ \@@_test_vline_in_block:nnnnn ##1 } |
| 12629 |
\bool_if:NT \g_tmpa_bool |
| 12630 |
{ |
| 12631 |
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq |
| 12632 |
{ \@@_test_vline_in_block:nnnnn ##1 } |
| 12633 |
\bool_if:NT \g_tmpa_bool |
| 12634 |
{ |
| 12635 |
\seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq |
| 12636 |
{ \@@_test_vline_in_stroken_block:nnnn ##1 } |
| 12637 |
} |
| 12638 |
} |
| 12639 |
} |
| 12640 |
} |
| 12641 |
% \end{macrocode} |
| 12642 |
% |
| 12643 |
% \begin{macrocode} |
| 12644 |
\socket_new:nn { nicematrix / draw-at-odd-vertex-v } { 0 } |
| 12645 |
\socket_new_plug:nnn { nicematrix / draw-at-odd-vertex-v } { active } |
| 12646 |
{ |
| 12647 |
{ |
| 12648 |
\int_compare:nNnTF \l_@@_position_int > \c@jCol |
| 12649 |
{ \bool_set_false:N \l_tmpa_bool } |
| 12650 |
{ |
| 12651 |
\@@_test_h: |
| 12652 |
\bool_set_eq:NN \l_tmpa_bool \g_tmpa_bool |
| 12653 |
} |
| 12654 |
\int_compare:nNnTF \l_@@_position_int = 1 |
| 12655 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 12656 |
{ |
| 12657 |
\tl_set:Ne \l_tmpb_tl { \int_eval:n { \l_tmpb_tl - 1 } } |
| 12658 |
\@@_test_h: |
| 12659 |
} |
| 12660 |
\bool_gset:Nn \g_tmpa_bool |
| 12661 |
{ \bool_xor_p:nn \g_tmpa_bool \l_tmpa_bool } |
| 12662 |
} |
| 12663 |
\bool_if:NT \g_tmpa_bool |
| 12664 |
{ |
| 12665 |
\int_set:Nn \l_@@_segment_end_int { \l_tmpa_tl - 1 } |
| 12666 |
\socket_use:n { nicematrix / vsegment } |
| 12667 |
\int_set:Nn \l_@@_segment_start_int \l_tmpa_tl |
| 12668 |
} |
| 12669 |
} |
| 12670 |
% \end{macrocode} |
| 12671 |
% |
| 12672 |
% \bigskip |
| 12673 |
% \begin{macrocode} |
| 12674 |
\cs_new_protected:Npn \@@_test_in_corner_v: |
| 12675 |
{ |
| 12676 |
\int_compare:nNnTF \l_tmpb_tl = { \c@jCol + 1 } |
| 12677 |
{ |
| 12678 |
\@@_if_in_corner:nT { \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } } |
| 12679 |
{ \bool_set_false:N \g_tmpa_bool } |
| 12680 |
} |
| 12681 |
{ |
| 12682 |
\@@_if_in_corner:nT { \l_tmpa_tl - \l_tmpb_tl } |
| 12683 |
{ |
| 12684 |
\int_compare:nNnTF \l_tmpb_tl = 1 |
| 12685 |
{ \bool_set_false:N \g_tmpa_bool } |
| 12686 |
{ |
| 12687 |
\@@_if_in_corner:nT |
| 12688 |
{ \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } } |
| 12689 |
{ \bool_set_false:N \g_tmpa_bool } |
| 12690 |
} |
| 12691 |
} |
| 12692 |
} |
| 12693 |
} |
| 12694 |
% \end{macrocode} |
| 12695 |
% |
| 12696 |
% \bigskip |
| 12697 |
% For the drawing of the (vertical) segments, we will use a socket with four plugs : |
| 12698 |
% \begin{itemize} |
| 12699 |
% \item a plug |standard| for the simple rules. |
| 12700 |
% \item a plug |multiple| for the rules similar to the standard rules of \pkg{array} and |
| 12701 |
% \pkg{colortbl}, that is to say with |multiplicity|, etc; |
| 12702 |
% \item a plug |dotted| for the rules with our own system of dotted rules; |
| 12703 |
% \item a plug |tikz| for the rules drawn with TikZ, including |
| 12704 |
% the key |dashed| of |custom-line|. |
| 12705 |
% \end{itemize} |
| 12706 |
% |
| 12707 |
% \begin{macrocode} |
| 12708 |
\socket_new:nn { nicematrix / vsegment } { 0 } |
| 12709 |
% \end{macrocode} |
| 12710 |
% |
| 12711 |
% \bigskip |
| 12712 |
% In the following plug, the $x$-value for the line has been computed previously |
| 12713 |
% in |\l_@@_x_initial_dim|. |
| 12714 |
% \begin{macrocode} |
| 12715 |
\socket_new_plug:nnn { nicematrix / vsegment } { standard } |
| 12716 |
{ |
| 12717 |
\@@_qpoint:n { row - \int_use:N \l_@@_segment_start_int } |
| 12718 |
\pgfpathmoveto { \pgfpoint \l_@@_x_initial_dim \pgf@y } |
| 12719 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 12720 |
\pgfpathlineto { \pgfpoint \l_@@_x_initial_dim \pgf@y } |
| 12721 |
\pgfusepathqstroke |
| 12722 |
} |
| 12723 |
% \end{macrocode} |
| 12724 |
% |
| 12725 |
% \begin{macrocode} |
| 12726 |
\socket_assign_plug:nn { nicematrix / vsegment } { standard } |
| 12727 |
% \end{macrocode} |
| 12728 |
% |
| 12729 |
% |
| 12730 |
% \begin{macrocode} |
| 12731 |
\socket_new_plug:nnn { nicematrix / vsegment } { multiple } |
| 12732 |
{ |
| 12733 |
\dim_add:Nn \l_@@_x_initial_dim |
| 12734 |
{ |
| 12735 |
- 0.5 \l_@@_rule_width_after_dim |
| 12736 |
+ |
| 12737 |
( \arrayrulewidth * \l_@@_multiplicity_int |
| 12738 |
+ \doublerulesep * ( \l_@@_multiplicity_int - 1 ) ) / 2 |
| 12739 |
} |
| 12740 |
\@@_qpoint:n { row - \int_use:N \l_@@_segment_start_int } |
| 12741 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 12742 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 12743 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 12744 |
\bool_lazy_and:nnT |
| 12745 |
{ \cs_if_exist_p:N \CT@drsc@ } |
| 12746 |
{ ! \tl_if_blank_p:o \CT@drsc@ } |
| 12747 |
{ |
| 12748 |
{ |
| 12749 |
\CT@drsc@ |
| 12750 |
\dim_add:Nn \l_@@_y_initial_dim { 0.5 \arrayrulewidth } |
| 12751 |
\dim_sub:Nn \l_@@_y_final_dim { 0.5 \arrayrulewidth } |
| 12752 |
\dim_set:Nn \l_@@_tmpd_dim |
| 12753 |
{ |
| 12754 |
\l_@@_x_initial_dim - ( \doublerulesep + \arrayrulewidth ) |
| 12755 |
* ( \l_@@_multiplicity_int - 1 ) |
| 12756 |
} |
| 12757 |
\pgfpathrectanglecorners |
| 12758 |
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 12759 |
{ \pgfpoint \l_@@_tmpd_dim \l_@@_y_final_dim } |
| 12760 |
\pgfusepath { fill } |
| 12761 |
} |
| 12762 |
} |
| 12763 |
\pgfpathmoveto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 12764 |
\pgfpathlineto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_final_dim } |
| 12765 |
\prg_replicate:nn { \l_@@_multiplicity_int - 1 } |
| 12766 |
{ |
| 12767 |
\dim_sub:Nn \l_@@_x_initial_dim { \arrayrulewidth + \doublerulesep } |
| 12768 |
\pgfpathmoveto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 12769 |
\pgfpathlineto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_final_dim } |
| 12770 |
} |
| 12771 |
\pgfusepathqstroke |
| 12772 |
} |
| 12773 |
% \end{macrocode} |
| 12774 |
% |
| 12775 |
% \bigskip |
| 12776 |
% \begin{macrocode} |
| 12777 |
\socket_new_plug:nnn { nicematrix / vsegment } { dotted } |
| 12778 |
{ |
| 12779 |
\dim_sub:Nn \l_@@_x_initial_dim { 0.5 \l_@@_rule_width_after_dim } |
| 12780 |
\dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim |
| 12781 |
\@@_qpoint:n { row - \int_use:N \l_@@_segment_start_int } |
| 12782 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 12783 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 12784 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 12785 |
% \end{macrocode} |
| 12786 |
% |
| 12787 |
% The command |\@@_draw_line:| has six implicit arguments: |
| 12788 |
% |
| 12789 |
% \begin{itemize} |
| 12790 |
% \item |\l_@@_x_initial_dim| |
| 12791 |
% \item |\l_@@_y_initial_dim| |
| 12792 |
% \item |\l_@@_x_final_dim| |
| 12793 |
% \item |\l_@@_y_final_dim| |
| 12794 |
% \item |\l_@@_initial_open_bool| |
| 12795 |
% \item |\l_@@_final_open_bool| |
| 12796 |
% \end{itemize} |
| 12797 |
% |
| 12798 |
% \begin{macrocode} |
| 12799 |
\@@_draw_line: |
| 12800 |
} |
| 12801 |
% \end{macrocode} |
| 12802 |
% |
| 12803 |
% \bigskip |
| 12804 |
% \begin{macrocode} |
| 12805 |
\socket_new_plug:nnn { nicematrix / vsegment } { tikz } |
| 12806 |
{ |
| 12807 |
{ |
| 12808 |
% \end{macrocode} |
| 12809 |
% By default, the color defined by |\arrayrulecolor| or by |rules/color| will be |
| 12810 |
% used, but it's still possible to change the color by using the key |color| or, |
| 12811 |
% of course, the key |color| inside the key |tikz| (that is to say the key |
| 12812 |
% |color| provided by \textsc{pgf}. |
| 12813 |
% \begin{macrocode} |
| 12814 |
\tl_if_empty:NF \l_@@_rule_color_tl |
| 12815 |
{ \tl_put_right:Ne \l_@@_tikz_rule_tl { , color = \l_@@_rule_color_tl } } |
| 12816 |
\@@_qpoint:n { row - \int_use:N \l_@@_segment_start_int } |
| 12817 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 12818 |
\dim_sub:Nn \l_@@_x_initial_dim { 0.5 \l_@@_rule_width_after_dim } |
| 12819 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 12820 |
% \end{macrocode} |
| 12821 |
% The following line can't be short-cutted. |
| 12822 |
% \begin{macrocode} |
| 12823 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 12824 |
\use:e { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] } |
| 12825 |
( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) -- |
| 12826 |
( \l_@@_x_initial_dim , \l_@@_y_final_dim ) ; |
| 12827 |
} |
| 12828 |
} |
| 12829 |
% \end{macrocode} |
| 12830 |
% |
| 12831 |
% |
| 12832 |
% \bigskip |
| 12833 |
% The command |\@@_draw_key_vlines:| draws the horizontal rules specified by |
| 12834 |
% the key |vlines|. These rules are not drawn in the blocks (even the virtual |
| 12835 |
% blocks determined by commands such as |\Cdots|) and in the corners --- if the |
| 12836 |
% key |corners| is used). |
| 12837 |
% \begin{macrocode} |
| 12838 |
\cs_new_protected:Npn \@@_draw_key_vlines: |
| 12839 |
{ |
| 12840 |
{ |
| 12841 |
\dim_set_eq:NN \l_@@_rule_width_after_dim \arrayrulewidth |
| 12842 |
\int_set:Nn \l_@@_end_int \c@iRow |
| 12843 |
% \end{macrocode} |
| 12844 |
% There is a currifycation in the following code. |
| 12845 |
% \begin{macrocode} |
| 12846 |
\str_if_eq:eeTF \l_@@_vlines_clist { all } |
| 12847 |
{ \@@_lines_step_inline:n \c@jCol } |
| 12848 |
{ \clist_map_inline:Nn \l_@@_vlines_clist } |
| 12849 |
{ |
| 12850 |
\int_set:Nn \l_@@_position_int { ##1 } |
| 12851 |
\socket_use:n { nicematrix / draw-vrule } |
| 12852 |
} |
| 12853 |
} |
| 12854 |
} |
| 12855 |
% \end{macrocode} |
| 12856 |
% |
| 12857 |
% |
| 12858 |
% \medskip The following command is used in |\@@_draw_key_vlines:| and in |
| 12859 |
% |\@@_draw_key_hlines:|. |
| 12860 |
% \begin{macrocode} |
| 12861 |
\cs_new_protected:Npn \@@_lines_step_inline:n #1 |
| 12862 |
{ |
| 12863 |
\int_step_inline:nnn |
| 12864 |
{ \bool_lazy_or:nnTF \g_@@_delims_bool \l_@@_except_borders_bool 2 1 } |
| 12865 |
{ |
| 12866 |
\bool_lazy_or:nnTF \g_@@_delims_bool \l_@@_except_borders_bool |
| 12867 |
{ #1 } |
| 12868 |
{ \int_eval:n { #1 + 1 } } |
| 12869 |
} |
| 12870 |
} |
| 12871 |
% \end{macrocode} |
| 12872 |
% |
| 12873 |
% |
| 12874 |
% \subsubsection*{The horizontal rules} |
| 12875 |
% |
| 12876 |
% |\@@_draw_hrule:n| and the socket |draw-hrule| will appear in |
| 12877 |
% |\@@_draw_key_hlines:n| and in the token rules |\g_@@_rules_tl| (or within |
| 12878 |
% other functions used in |\g_@@_rules_tl|) and those token lists will be |
| 12879 |
% executed within a PGF pseudo-environment. |
| 12880 |
% |
| 12881 |
% \bigskip |
| 12882 |
% The argument |#1| is a list of \textsl{key=value} pairs. |
| 12883 |
% \begin{macrocode} |
| 12884 |
\cs_new_protected:Npn \@@_draw_hrule:n #1 |
| 12885 |
{ |
| 12886 |
{ |
| 12887 |
\int_set_eq:NN \l_@@_end_int \c@jCol |
| 12888 |
\keys_set_known:nn { nicematrix / rules-after } { #1 } |
| 12889 |
\socket_use:nn { nicematrix / draw-hrule } |
| 12890 |
} |
| 12891 |
} |
| 12892 |
% \end{macrocode} |
| 12893 |
% |
| 12894 |
% \bigskip |
| 12895 |
% \bigskip |
| 12896 |
% The socket ``|nicematrix / draw-hrule|'' will draw an horizontal rule. That horizontal |
| 12897 |
% rule may potentially be composed of several disconnected segments. |
| 12898 |
% |
| 12899 |
% The plug |general| will break the vertical rule in several segments. |
| 12900 |
% |
| 12901 |
% The plug |quick| will draw directly the vertical rule. That plug is used when we are |
| 12902 |
% sure that the whole rule must be drawn, that is to say when: |
| 12903 |
% \begin{itemize} |
| 12904 |
% \item there is no corners; |
| 12905 |
% \item there is no blocks; |
| 12906 |
% \item there is no implicit blocks created by the continuous dotted lines; |
| 12907 |
% \item there is no stroken blocks. |
| 12908 |
% \end{itemize} |
| 12909 |
% |
| 12910 |
% |
| 12911 |
% |
| 12912 |
% \begin{macrocode} |
| 12913 |
\socket_new:nn { nicematrix / draw-hrule } { 0 } |
| 12914 |
% \end{macrocode} |
| 12915 |
% |
| 12916 |
% \begin{macrocode} |
| 12917 |
\socket_new_plug:nnn { nicematrix / draw-hrule} { general } |
| 12918 |
{ |
| 12919 |
\group_begin: |
| 12920 |
% \end{macrocode} |
| 12921 |
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When |
| 12922 |
% we have found a column corresponding to a rule to draw, we note its number in |
| 12923 |
% |\l_@@_tmpc_tl|. |
| 12924 |
% \begin{macrocode} |
| 12925 |
\tl_set:No \l_tmpa_tl { \int_use:N \l_@@_position_int } |
| 12926 |
% \end{macrocode} |
| 12927 |
% |\l_@@_y_initial_dim| will be the $y$-value of the rule to draw (used in all |
| 12928 |
% the plugs). |
| 12929 |
% \begin{macrocode} |
| 12930 |
\@@_qpoint:n { row - \int_use:N \l_@@_position_int } |
| 12931 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 12932 |
\int_step_variable:nnNn \l_@@_start_int \l_@@_end_int |
| 12933 |
\l_tmpb_tl |
| 12934 |
{ |
| 12935 |
% \end{macrocode} |
| 12936 |
% After the execution of |\test_v:|, |\g_tmpa_bool| will be equal to |true| |
| 12937 |
% if we have to draw that rule. |
| 12938 |
% \begin{macrocode} |
| 12939 |
\@@_test_h: |
| 12940 |
\bool_if:NTF \g_tmpa_bool |
| 12941 |
{ |
| 12942 |
\int_if_zero:nTF \l_@@_segment_start_int |
| 12943 |
% \end{macrocode} |
| 12944 |
% We keep in memory that we have a segment to draw. |\l_@@_segment_start_int| will be |
| 12945 |
% the starting row of the rule that we will have to draw. |
| 12946 |
% \begin{macrocode} |
| 12947 |
{ \int_set:Nn \l_@@_segment_start_int \l_tmpb_tl } |
| 12948 |
% \end{macrocode} |
| 12949 |
% |
| 12950 |
% \begin{macrocode} |
| 12951 |
{ \socket_use:n { nicematrix / draw-at-odd-vertex-h } } |
| 12952 |
} |
| 12953 |
{ |
| 12954 |
\int_compare:nNnT \l_@@_segment_start_int > \c_zero_int |
| 12955 |
{ |
| 12956 |
\int_set:Nn \l_@@_segment_end_int { \l_tmpb_tl - 1 } |
| 12957 |
% \end{macrocode} |
| 12958 |
% The socket |hsegment| is defined below with its four plugs. |
| 12959 |
% \begin{macrocode} |
| 12960 |
\socket_use:n { nicematrix / hsegment } |
| 12961 |
\int_zero:N \l_@@_segment_start_int |
| 12962 |
} |
| 12963 |
} |
| 12964 |
} |
| 12965 |
\int_compare:nNnT \l_@@_segment_start_int > \c_zero_int |
| 12966 |
{ |
| 12967 |
\int_set_eq:NN \l_@@_segment_end_int \l_@@_end_int |
| 12968 |
\socket_use:n { nicematrix / hsegment } |
| 12969 |
} |
| 12970 |
\group_end: |
| 12971 |
} |
| 12972 |
% \end{macrocode} |
| 12973 |
% |
| 12974 |
% \begin{macrocode} |
| 12975 |
\socket_assign_plug:nn { nicematrix / draw-hrule } { general } |
| 12976 |
% \end{macrocode} |
| 12977 |
% |
| 12978 |
% \begin{macrocode} |
| 12979 |
\socket_new_plug:nnn { nicematrix / draw-hrule} { quick } |
| 12980 |
{ |
| 12981 |
\group_begin: |
| 12982 |
\@@_qpoint:n { row - \int_use:N \l_@@_position_int } |
| 12983 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 12984 |
\int_set_eq:NN \l_@@_segment_start_int \l_@@_start_int |
| 12985 |
\int_set_eq:NN \l_@@_segment_end_int \l_@@_end_int |
| 12986 |
\socket_use:n { nicematrix / hsegment } |
| 12987 |
\group_end: |
| 12988 |
} |
| 12989 |
% \end{macrocode} |
| 12990 |
% |
| 12991 |
% |
| 12992 |
% |
| 12993 |
% |
| 12994 |
% The boolean |\g_tmpa_bool| indicates whether the small horizontal rule will be |
| 12995 |
% drawn. If we find that it is in a block (a real block, created by |\Block| or |
| 12996 |
% |create-blocks-in-col| or a virtual block corresponding to a dotted line, |
| 12997 |
% created by |\Cdots|, |\Vdots|, etc.), we will set |\g_tmpa_bool| to |false| |
| 12998 |
% and the small horizontal rule won't be drawn. |
| 12999 |
% \begin{macrocode} |
| 13000 |
\cs_new_protected:Npn \@@_test_h: |
| 13001 |
{ |
| 13002 |
\bool_gset_true:N \g_tmpa_bool |
| 13003 |
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_h: |
| 13004 |
\bool_if:NT \g_tmpa_bool |
| 13005 |
{ |
| 13006 |
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq |
| 13007 |
{ \@@_test_hline_in_block:nnnnn ##1 } |
| 13008 |
\bool_if:NT \g_tmpa_bool |
| 13009 |
{ |
| 13010 |
\seq_map_inline:Nn \g_@@_pos_of_xdots_seq |
| 13011 |
{ \@@_test_hline_in_block:nnnnn ##1 } |
| 13012 |
\bool_if:NT \g_tmpa_bool |
| 13013 |
{ |
| 13014 |
\seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq |
| 13015 |
{ \@@_test_hline_in_stroken_block:nnnn ##1 } |
| 13016 |
} |
| 13017 |
} |
| 13018 |
} |
| 13019 |
} |
| 13020 |
% \end{macrocode} |
| 13021 |
% |
| 13022 |
% \bigskip |
| 13023 |
% \begin{macrocode} |
| 13024 |
\socket_new:nn { nicematrix / draw-at-odd-vertex-h } { 0 } |
| 13025 |
\socket_new_plug:nnn { nicematrix / draw-at-odd-vertex-h } { active } |
| 13026 |
{ |
| 13027 |
{ |
| 13028 |
\int_compare:nNnTF \l_@@_position_int > \c@iRow |
| 13029 |
{ \bool_set_false:N \l_tmpa_bool } |
| 13030 |
{ |
| 13031 |
\@@_test_v: |
| 13032 |
\bool_set_eq:NN \l_tmpa_bool \g_tmpa_bool |
| 13033 |
} |
| 13034 |
\int_compare:nNnTF \l_@@_position_int = 1 |
| 13035 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13036 |
{ |
| 13037 |
\tl_set:Ne \l_tmpa_tl { \int_eval:n { \l_tmpa_tl - 1 } } |
| 13038 |
\@@_test_v: |
| 13039 |
} |
| 13040 |
\bool_gset:Nn \g_tmpa_bool |
| 13041 |
{ \bool_xor_p:nn \g_tmpa_bool \l_tmpa_bool } |
| 13042 |
} |
| 13043 |
\bool_if:NT \g_tmpa_bool |
| 13044 |
{ |
| 13045 |
\int_set:Nn \l_@@_segment_end_int { \l_tmpb_tl - 1 } |
| 13046 |
\socket_use:n { nicematrix / hsegment } |
| 13047 |
\int_set:Nn \l_@@_segment_start_int \l_tmpb_tl |
| 13048 |
} |
| 13049 |
} |
| 13050 |
% \end{macrocode} |
| 13051 |
% |
| 13052 |
% \bigskip |
| 13053 |
% \begin{macrocode} |
| 13054 |
\cs_new_protected:Npn \@@_test_in_corner_h: |
| 13055 |
{ |
| 13056 |
\int_compare:nNnTF \l_tmpa_tl = { \c@iRow + 1 } |
| 13057 |
{ |
| 13058 |
\@@_if_in_corner:nT { \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl } |
| 13059 |
{ \bool_set_false:N \g_tmpa_bool } |
| 13060 |
} |
| 13061 |
{ |
| 13062 |
\@@_if_in_corner:nT { \l_tmpa_tl - \l_tmpb_tl } |
| 13063 |
{ |
| 13064 |
\int_compare:nNnTF \l_tmpa_tl = 1 |
| 13065 |
{ \bool_set_false:N \g_tmpa_bool } |
| 13066 |
{ |
| 13067 |
\@@_if_in_corner:nT |
| 13068 |
{ \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl } |
| 13069 |
{ \bool_set_false:N \g_tmpa_bool } |
| 13070 |
} |
| 13071 |
} |
| 13072 |
} |
| 13073 |
} |
| 13074 |
% \end{macrocode} |
| 13075 |
% |
| 13076 |
% |
| 13077 |
% \bigskip |
| 13078 |
% For the drawing of the (horizontal) segments, we will use a socket with four plugs : |
| 13079 |
% \begin{itemize} |
| 13080 |
% \item a plug |standard| for simple rules; |
| 13081 |
% \item a plug |multiple| for the rules similar to the standard rules of \pkg{array} and |
| 13082 |
% \pkg{colortbl}, that is to say with |multiplicity|, etc; |
| 13083 |
% \item a plug |dotted| for the rules with our own system of dotted rules; |
| 13084 |
% \item a plug |tikz| for the rules drawn with TikZ, including the key |dashed| of |
| 13085 |
% |custom-line|. |
| 13086 |
% \end{itemize} |
| 13087 |
% |
| 13088 |
% \begin{macrocode} |
| 13089 |
\socket_new:nn { nicematrix / hsegment } { 0 } |
| 13090 |
% \end{macrocode} |
| 13091 |
% |
| 13092 |
% \bigskip |
| 13093 |
% In the following plug, the $y$-value for the line has been computed previously |
| 13094 |
% in |\l_@@_y_initial_dim|. |
| 13095 |
% \begin{macrocode} |
| 13096 |
\socket_new_plug:nnn { nicematrix / hsegment } { standard } |
| 13097 |
{ |
| 13098 |
\@@_qpoint:n { col - \int_use:N \l_@@_segment_start_int } |
| 13099 |
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } |
| 13100 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 13101 |
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_initial_dim } |
| 13102 |
\pgfusepathqstroke |
| 13103 |
} |
| 13104 |
% \end{macrocode} |
| 13105 |
% |
| 13106 |
% \begin{macrocode} |
| 13107 |
\socket_assign_plug:nn { nicematrix / hsegment } { standard } |
| 13108 |
% \end{macrocode} |
| 13109 |
% |
| 13110 |
% \begin{macrocode} |
| 13111 |
\socket_new_plug:nnn { nicematrix / hsegment } { multiple } |
| 13112 |
{ |
| 13113 |
\dim_add:Nn \l_@@_y_initial_dim |
| 13114 |
{ |
| 13115 |
- 0.5 \l_@@_rule_width_after_dim |
| 13116 |
+ |
| 13117 |
( \arrayrulewidth * \l_@@_multiplicity_int |
| 13118 |
+ \doublerulesep * ( \l_@@_multiplicity_int - 1 ) ) / 2 |
| 13119 |
} |
| 13120 |
\@@_qpoint:n { col - \int_use:N \l_@@_segment_start_int } |
| 13121 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 13122 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 13123 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 13124 |
\bool_lazy_and:nnT |
| 13125 |
{ \cs_if_exist_p:N \CT@drsc@ } |
| 13126 |
{ ! \tl_if_blank_p:o \CT@drsc@ } |
| 13127 |
{ |
| 13128 |
{ |
| 13129 |
\CT@drsc@ |
| 13130 |
\dim_set:Nn \l_@@_tmpd_dim |
| 13131 |
{ |
| 13132 |
\l_@@_y_initial_dim - ( \doublerulesep + \arrayrulewidth ) |
| 13133 |
* ( \l_@@_multiplicity_int - 1 ) |
| 13134 |
} |
| 13135 |
\pgfpathrectanglecorners |
| 13136 |
{ \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 13137 |
{ \pgfpoint \l_@@_x_final_dim \l_@@_tmpd_dim } |
| 13138 |
\pgfusepathqfill |
| 13139 |
} |
| 13140 |
} |
| 13141 |
\pgfpathmoveto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 13142 |
\pgfpathlineto { \pgfpoint \l_@@_x_final_dim \l_@@_y_initial_dim } |
| 13143 |
\prg_replicate:nn { \l_@@_multiplicity_int - 1 } |
| 13144 |
{ |
| 13145 |
\dim_sub:Nn \l_@@_y_initial_dim { \arrayrulewidth + \doublerulesep } |
| 13146 |
\pgfpathmoveto { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } |
| 13147 |
\pgfpathlineto { \pgfpoint \l_@@_x_final_dim \l_@@_y_initial_dim } |
| 13148 |
} |
| 13149 |
\pgfusepathqstroke |
| 13150 |
} |
| 13151 |
% \end{macrocode} |
| 13152 |
% |
| 13153 |
% |
| 13154 |
% \bigskip |
| 13155 |
% Now, the case of a dotted line. |
| 13156 |
% |
| 13157 |
% \begin{BVerbatim}[baseline=c,boxwidth=10cm] |
| 13158 |
% \begin{bNiceMatrix} |
| 13159 |
% 1 & 2 & 3 & 4 \\ |
| 13160 |
% \hline |
| 13161 |
% 1 & 2 & 3 & 4 \\ |
| 13162 |
% \hdottedline |
| 13163 |
% 1 & 2 & 3 & 4 |
| 13164 |
% \end{bNiceMatrix} |
| 13165 |
% \end{BVerbatim} |
| 13166 |
% $\begin{bNiceMatrix} |
| 13167 |
% 1 & 2 & 3 & 4 \\ |
| 13168 |
% \hline |
| 13169 |
% 1 & 2 & 3 & 4 \\ |
| 13170 |
% \hdottedline |
| 13171 |
% 1 & 2 & 3 & 4 |
| 13172 |
% \end{bNiceMatrix}$ |
| 13173 |
% |
| 13174 |
% \smallskip |
| 13175 |
% But, if the user uses |margin|, the dotted line extends to have the same width |
| 13176 |
% as a |\hline|. |
| 13177 |
% |
| 13178 |
% \smallskip |
| 13179 |
% \begin{BVerbatim}[baseline=c,boxwidth=10cm] |
| 13180 |
% \begin{bNiceMatrix}[margin] |
| 13181 |
% 1 & 2 & 3 & 4 \\ |
| 13182 |
% \hline |
| 13183 |
% 1 & 2 & 3 & 4 \\ |
| 13184 |
% \hdottedline |
| 13185 |
% 1 & 2 & 3 & 4 |
| 13186 |
% \end{bNiceMatrix} |
| 13187 |
% \end{BVerbatim} |
| 13188 |
% $\begin{bNiceMatrix}[margin] |
| 13189 |
% 1 & 2 & 3 & 4 \\ |
| 13190 |
% \hline |
| 13191 |
% 1 & 2 & 3 & 4 \\ |
| 13192 |
% \hdottedline |
| 13193 |
% 1 & 2 & 3 & 4 |
| 13194 |
% \end{bNiceMatrix}$ |
| 13195 |
% |
| 13196 |
% \begin{macrocode} |
| 13197 |
\socket_new_plug:nnn { nicematrix / hsegment } { dotted } |
| 13198 |
{ |
| 13199 |
\dim_sub:Nn \l_@@_y_initial_dim { 0.5 \l_@@_rule_width_after_dim } |
| 13200 |
\dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim |
| 13201 |
\@@_qpoint:n { col - \int_use:N \l_@@_segment_start_int } |
| 13202 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 13203 |
\int_compare:nNnT \l_@@_segment_start_int = 1 |
| 13204 |
{ |
| 13205 |
\dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim |
| 13206 |
\bool_if:NF \g_@@_delims_bool |
| 13207 |
{ \dim_sub:Nn \l_@@_x_initial_dim \arraycolsep } |
| 13208 |
% \end{macrocode} |
| 13209 |
% For reasons purely aesthetic, we do an adjustment in the case of a rounded |
| 13210 |
% bracket. The correction by |0.5 \l_@@_xdots_inter_dim| is \emph{ad hoc} for a |
| 13211 |
% better result. |
| 13212 |
% \begin{macrocode} |
| 13213 |
\tl_if_eq:NnF \g_@@_left_delim_tl ( |
| 13214 |
{ \dim_add:Nn \l_@@_x_initial_dim { 0.5 \l_@@_xdots_inter_dim } } |
| 13215 |
} |
| 13216 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 13217 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 13218 |
\int_compare:nNnT \l_@@_segment_end_int = \c@jCol |
| 13219 |
{ |
| 13220 |
\dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim |
| 13221 |
\bool_if:NF \g_@@_delims_bool |
| 13222 |
{ \dim_add:Nn \l_@@_x_final_dim \arraycolsep } |
| 13223 |
\tl_if_eq:NnF \g_@@_right_delim_tl ) |
| 13224 |
{ \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_xdots_inter_dim } } |
| 13225 |
} |
| 13226 |
% \end{macrocode} |
| 13227 |
% |
| 13228 |
% The command |\@@_draw_line:| has six implicit arguments: |
| 13229 |
% |
| 13230 |
% \begin{itemize} |
| 13231 |
% \item |\l_@@_x_initial_dim| |
| 13232 |
% \item |\l_@@_y_initial_dim| |
| 13233 |
% \item |\l_@@_x_final_dim| |
| 13234 |
% \item |\l_@@_y_final_dim| |
| 13235 |
% \item |\l_@@_initial_open_bool| |
| 13236 |
% \item |\l_@@_final_open_bool| |
| 13237 |
% \end{itemize} |
| 13238 |
% |
| 13239 |
% \begin{macrocode} |
| 13240 |
\@@_draw_line: |
| 13241 |
} |
| 13242 |
% \end{macrocode} |
| 13243 |
% |
| 13244 |
% \bigskip |
| 13245 |
% \begin{macrocode} |
| 13246 |
\socket_new_plug:nnn { nicematrix / hsegment } { tikz } |
| 13247 |
{ |
| 13248 |
{ |
| 13249 |
% \end{macrocode} |
| 13250 |
% By default, the color defined by |\arrayrulecolor| or by |rules/color| will be |
| 13251 |
% used, but it's still possible to change the color by using the key |color| or, |
| 13252 |
% of course, the key |color| inside the key |tikz| (that is to say the key |
| 13253 |
% |color| provided by \textsc{pgf}. |
| 13254 |
% \begin{macrocode} |
| 13255 |
\tl_if_empty:NF \l_@@_rule_color_tl |
| 13256 |
{ \tl_put_right:Ne \l_@@_tikz_rule_tl { , color = \l_@@_rule_color_tl } } |
| 13257 |
\@@_qpoint:n { col - \int_use:N \l_@@_segment_start_int } |
| 13258 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 13259 |
\dim_sub:Nn \l_@@_y_initial_dim { 0.5 \l_@@_rule_width_after_dim } |
| 13260 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_segment_end_int + 1 } } |
| 13261 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 13262 |
\use:e { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] } |
| 13263 |
( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) |
| 13264 |
-- ( \l_@@_x_final_dim , \l_@@_y_initial_dim ) ; |
| 13265 |
} |
| 13266 |
} |
| 13267 |
% \end{macrocode} |
| 13268 |
% |
| 13269 |
% |
| 13270 |
% \bigskip |
| 13271 |
% The command |\@@_draw_key_hlines:| draws the horizontal rules specified by |
| 13272 |
% the key |hlines|. These rules are not drawn in the blocks (even the virtual |
| 13273 |
% blocks determined by commands such as |\Cdots|) and in the corners --- if the |
| 13274 |
% key |corners| is used). |
| 13275 |
% \begin{macrocode} |
| 13276 |
\cs_new_protected:Npn \@@_draw_key_hlines: |
| 13277 |
{ |
| 13278 |
{ |
| 13279 |
\dim_set_eq:NN \l_@@_rule_width_after_dim \arrayrulewidth |
| 13280 |
\int_set:Nn \l_@@_end_int \c@jCol |
| 13281 |
% \end{macrocode} |
| 13282 |
% There is a currifycation in the following code. |
| 13283 |
% \begin{macrocode} |
| 13284 |
\str_if_eq:eeTF \l_@@_hlines_clist { all } |
| 13285 |
{ \@@_lines_step_inline:n \c@iRow } |
| 13286 |
{ \clist_map_inline:Nn \l_@@_hlines_clist } |
| 13287 |
{ |
| 13288 |
\int_set:Nn \l_@@_position_int { ##1 } |
| 13289 |
\socket_use:n { nicematrix / draw-hrule } |
| 13290 |
} |
| 13291 |
} |
| 13292 |
} |
| 13293 |
% \end{macrocode} |
| 13294 |
% |
| 13295 |
% |
| 13296 |
% \medskip |
| 13297 |
% The command |\@@_Hline:| will be linked to |\Hline| in the environments of |
| 13298 |
% \pkg{nicematrix}. |
| 13299 |
% \begin{macrocode} |
| 13300 |
\cs_set:Npn \@@_Hline: { \noalign \bgroup \@@_Hline_i:n { 1 } } |
| 13301 |
% \end{macrocode} |
| 13302 |
% |
| 13303 |
% \medskip |
| 13304 |
% The argument of the command |\@@_Hline_i:n| is the number of successive |
| 13305 |
% |\Hline| found. |
| 13306 |
% \begin{macrocode} |
| 13307 |
\cs_set:Npn \@@_Hline_i:n #1 |
| 13308 |
{ |
| 13309 |
\peek_remove_spaces:n |
| 13310 |
{ |
| 13311 |
\peek_meaning:NTF \Hline |
| 13312 |
{ \@@_Hline_ii:nn { #1 + 1 } } |
| 13313 |
{ \@@_Hline_iii:n { #1 } } |
| 13314 |
} |
| 13315 |
} |
| 13316 |
% \end{macrocode} |
| 13317 |
% |
| 13318 |
% \begin{macrocode} |
| 13319 |
\cs_set:Npn \@@_Hline_ii:nn #1 #2 { \@@_Hline_i:n { #1 } } |
| 13320 |
% \end{macrocode} |
| 13321 |
% |
| 13322 |
% \begin{macrocode} |
| 13323 |
\cs_set:Npn \@@_Hline_iii:n #1 |
| 13324 |
{ \@@_collect_options:n { \@@_Hline_iv:nn { #1 } } } |
| 13325 |
% \end{macrocode} |
| 13326 |
% |
| 13327 |
% |
| 13328 |
% \begin{macrocode} |
| 13329 |
\cs_set_protected:Npn \@@_Hline_iv:nn #1 #2 |
| 13330 |
{ |
| 13331 |
\@@_compute_rule_width:n { multiplicity = #1 , #2 } |
| 13332 |
\skip_vertical:N \l_@@_rule_width_before_dim |
| 13333 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 13334 |
{ |
| 13335 |
% \end{macrocode} |
| 13336 |
% |
| 13337 |
% |
| 13338 |
% \bigskip |
| 13339 |
% With the keys of |nicematrix / rules-after| we would write: |
| 13340 |
% |
| 13341 |
% \begin{Verbatim} |
| 13342 |
% \@@_draw_hrule:n |
| 13343 |
% { |
| 13344 |
% multiplicity = #1 , |
| 13345 |
% position = \int_eval:n { \c@iRow + 1 } , |
| 13346 |
% total-width = \dim_use:N \l_@@_rule_width_before_dim , |
| 13347 |
% #2 |
| 13348 |
% } |
| 13349 |
% \end{Verbatim} |
| 13350 |
% |
| 13351 |
% We will use a version slightly more efficient: |
| 13352 |
% \begin{macrocode} |
| 13353 |
{ |
| 13354 |
\int_compare:nNnT { #1 } > 1 { \@@_set_multiplicity:n { #1 } } |
| 13355 |
\int_set:Nn \l_@@_position_int { \int_eval:n { \c@iRow + 1 } } |
| 13356 |
\dim_set:Nn \l_@@_rule_width_after_dim |
| 13357 |
{ \dim_use:N \l_@@_rule_width_before_dim } |
| 13358 |
\@@_draw_hrule:n { #2 } |
| 13359 |
} |
| 13360 |
} |
| 13361 |
\egroup |
| 13362 |
} |
| 13363 |
% \end{macrocode} |
| 13364 |
% |
| 13365 |
% \subsubsection*{Customized rules defined by the final user} |
| 13366 |
% |
| 13367 |
% The final user can define a customized rule by using the key |custom-line| in |
| 13368 |
% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value} |
| 13369 |
% pairs. |
| 13370 |
% |
| 13371 |
% |
| 13372 |
% |
| 13373 |
% \medskip |
| 13374 |
% The following command will create the customized rule (it is executed when the |
| 13375 |
% final user uses the key |custom-line|, for example in |\NiceMatrixOptions|). |
| 13376 |
% \begin{macrocode} |
| 13377 |
\cs_new_protected:Npn \@@_custom_line:n #1 |
| 13378 |
{ |
| 13379 |
\str_clear:N \l_@@_letter_str |
| 13380 |
\str_clear:N \l_@@_command_str |
| 13381 |
\str_clear:N \l_@@_ccommand_str |
| 13382 |
\tl_clear_new:N \l_@@_other_keys_tl |
| 13383 |
\keys_set_known:nnN { nicematrix / custom-line } { #1 } \l_@@_other_keys_tl |
| 13384 |
\str_if_eq:eeT \c_backslash_str { \str_head:N \l_@@_command_str } |
| 13385 |
{ |
| 13386 |
\str_set:Ne \l_@@_command_str { \str_tail:N \l_@@_command_str } |
| 13387 |
% \end{macrocode} |
| 13388 |
% We delete the last character which is a space. |
| 13389 |
% \begin{macrocode} |
| 13390 |
\str_set:Ne \l_@@_command_str |
| 13391 |
{ \str_range:Nnn \l_@@_command_str { 1 } { -2 } } |
| 13392 |
} |
| 13393 |
\str_if_eq:eeT \c_backslash_str { \str_head:N \l_@@_ccommand_str } |
| 13394 |
{ |
| 13395 |
\str_set:Ne \l_@@_ccommand_str |
| 13396 |
{ \str_tail:N \l_@@_ccommand_str } |
| 13397 |
\str_set:Ne \l_@@_ccommand_str |
| 13398 |
{ \str_range:Nnn \l_@@_ccommand_str { 1 } { -2 } } |
| 13399 |
} |
| 13400 |
% \end{macrocode} |
| 13401 |
% If the final user only wants to draw horizontal rules, he does not need to |
| 13402 |
% specify a letter (for the vertical rules in the preamble of the array). On the |
| 13403 |
% other hand, if he only wants to draw vertical rules, he does not need to |
| 13404 |
% define a command (which is the tool to draw horizontal rules in the array). Of |
| 13405 |
% course, a definition of custom lines with no letter and no command would be point-less. |
| 13406 |
% |
| 13407 |
% \begin{macrocode} |
| 13408 |
\bool_lazy_all:nTF |
| 13409 |
{ |
| 13410 |
{ \str_if_empty_p:N \l_@@_letter_str } |
| 13411 |
{ \str_if_empty_p:N \l_@@_command_str } |
| 13412 |
{ \str_if_empty_p:N \l_@@_ccommand_str } |
| 13413 |
} |
| 13414 |
{ \@@_error:n { No~letter~and~no~command } } |
| 13415 |
{ \@@_custom_line_i:o \l_@@_other_keys_tl } |
| 13416 |
} |
| 13417 |
% \end{macrocode} |
| 13418 |
% |
| 13419 |
% |
| 13420 |
% \begin{macrocode} |
| 13421 |
\keys_define:nn { nicematrix / custom-line } |
| 13422 |
{ |
| 13423 |
letter .str_set:N = \l_@@_letter_str , |
| 13424 |
letter .value_required:n = true , |
| 13425 |
command .str_set:N = \l_@@_command_str , |
| 13426 |
command .value_required:n = true , |
| 13427 |
ccommand .str_set:N = \l_@@_ccommand_str , |
| 13428 |
ccommand .value_required:n = true |
| 13429 |
} |
| 13430 |
% \end{macrocode} |
| 13431 |
% |
| 13432 |
% \bigskip |
| 13433 |
% \begin{macrocode} |
| 13434 |
\cs_new_protected:Npn \@@_custom_line_i:n #1 |
| 13435 |
{ |
| 13436 |
% \end{macrocode} |
| 13437 |
% The following flags will be raised when the keys |tikz|, |dotted| and |color| |
| 13438 |
% are used (in the |custom-line|). |
| 13439 |
% \begin{macrocode} |
| 13440 |
\bool_set_false:N \l_@@_tikz_rule_bool |
| 13441 |
\bool_set_false:N \l_@@_dotted_rule_bool |
| 13442 |
\bool_set_false:N \l_@@_color_bool |
| 13443 |
% \end{macrocode} |
| 13444 |
% \begin{macrocode} |
| 13445 |
\keys_set:nn { nicematrix / custom-line-bis } { #1 } |
| 13446 |
\bool_if:NT \l_@@_tikz_rule_bool |
| 13447 |
{ |
| 13448 |
\IfPackageLoadedF { tikz } |
| 13449 |
{ \@@_error:n { tikz~in~custom-line~without~tikz } } |
| 13450 |
\bool_if:NT \l_@@_color_bool |
| 13451 |
{ \@@_error:n { color~in~custom-line~with~tikz } } |
| 13452 |
} |
| 13453 |
\bool_if:NT \l_@@_dotted_rule_bool |
| 13454 |
{ |
| 13455 |
\int_compare:nNnT \l_@@_multiplicity_int > 1 |
| 13456 |
{ \@@_error:n { key~multiplicity~with~dotted } } |
| 13457 |
} |
| 13458 |
\str_if_empty:NF \l_@@_letter_str |
| 13459 |
{ |
| 13460 |
\int_compare:nTF { \str_count:N \l_@@_letter_str != 1 } |
| 13461 |
{ \@@_error:n { Several~letters } } |
| 13462 |
{ |
| 13463 |
\tl_if_in:NoTF |
| 13464 |
\c_@@_forbidden_letters_str |
| 13465 |
\l_@@_letter_str |
| 13466 |
{ \@@_error:ne { Forbidden~letter } \l_@@_letter_str } |
| 13467 |
{ |
| 13468 |
% \end{macrocode} |
| 13469 |
% During the analysis of the preamble provided by the final user, our automaton, |
| 13470 |
% for the letter corresponding at the custom line, will directly use the |
| 13471 |
% following command that you define in the main hash table of TeX. |
| 13472 |
% \begin{macrocode} |
| 13473 |
\cs_set_nopar:cpn { @@ _ \l_@@_letter_str : } ##1 |
| 13474 |
{ \@@_v_custom_line:nn { #1 } } |
| 13475 |
} |
| 13476 |
} |
| 13477 |
} |
| 13478 |
\str_if_empty:NF \l_@@_command_str { \@@_h_custom_line:n { #1 } } |
| 13479 |
\str_if_empty:NF \l_@@_ccommand_str { \@@_c_custom_line:n { #1 } } |
| 13480 |
} |
| 13481 |
\cs_generate_variant:Nn \@@_custom_line_i:n { o } |
| 13482 |
% \end{macrocode} |
| 13483 |
% |
| 13484 |
% |
| 13485 |
% \begin{macrocode} |
| 13486 |
\tl_const:Nn \c_@@_forbidden_letters_tl { lcrpmbVX|()[]!@<> } |
| 13487 |
\str_const:Nn \c_@@_forbidden_letters_str { lcrpmbVX|()[]!@<> } |
| 13488 |
% \end{macrocode} |
| 13489 |
% |
| 13490 |
% \medskip |
| 13491 |
% The previous command |\@@_custom_line_i:n| uses the following set of keys. |
| 13492 |
% However, the whole definition of the customized lines (as provided by the |
| 13493 |
% final user as argument of |custom-line|) will also be used further with |
| 13494 |
% other sets of keys (for instance |{nicematrix/rules-after}|). That's why the |
| 13495 |
% following set of keys has some keys which are no-op. |
| 13496 |
% \begin{macrocode} |
| 13497 |
\keys_define:nn { nicematrix / custom-line-bis } |
| 13498 |
{ |
| 13499 |
multiplicity .int_set:N = \l_@@_multiplicity_int , |
| 13500 |
color .code:n = \bool_set_true:N \l_@@_color_bool , |
| 13501 |
color .value_required:n = true , |
| 13502 |
tikz .code:n = \bool_set_true:N \l_@@_tikz_rule_bool , |
| 13503 |
tikz .value_required:n = true , |
| 13504 |
dotted .code:n = \bool_set_true:N \l_@@_dotted_rule_bool , |
| 13505 |
dotted .value_forbidden:n = true , |
| 13506 |
dashed .meta:n = |
| 13507 |
{ |
| 13508 |
tikz = nicematrix / dashed , |
| 13509 |
total-width = \pgflinewidth |
| 13510 |
} , |
| 13511 |
total-width .code:n = { } , |
| 13512 |
total-width .value_required:n = true , |
| 13513 |
sep-color .code:n = { } , |
| 13514 |
sep-color .value_required:n = true , |
| 13515 |
unknown .code:n = |
| 13516 |
\@@_unknown_key:nn |
| 13517 |
{ nicematrix / custom-line-bis } |
| 13518 |
{ Unknown~key~for~custom-line } |
| 13519 |
} |
| 13520 |
% \end{macrocode} |
| 13521 |
% |
| 13522 |
% The following keys will indicate whether the keys |dotted|, |tikz| and |color| |
| 13523 |
% are used in the use of a |custom-line|. |
| 13524 |
% \begin{macrocode} |
| 13525 |
\bool_new:N \l_@@_dotted_rule_bool |
| 13526 |
\bool_new:N \l_@@_tikz_rule_bool |
| 13527 |
\bool_new:N \l_@@_color_bool |
| 13528 |
% \end{macrocode} |
| 13529 |
% |
| 13530 |
% \bigskip |
| 13531 |
% The following keys are used to determine the total width of the line |
| 13532 |
% (including the spaces on both sides of the line). |
| 13533 |
% |
| 13534 |
% \begin{macrocode} |
| 13535 |
\keys_define:nn { nicematrix / custom-line-width } |
| 13536 |
{ |
| 13537 |
multiplicity .int_set:N = \l_@@_tmpc_int , |
| 13538 |
tikz .code:n = \bool_set_true:N \l_@@_tikz_rule_bool , |
| 13539 |
total-width .code:n = \dim_set:Nn \l_@@_rule_width_before_dim { #1 } |
| 13540 |
\bool_set_true:N \l_@@_total_width_bool , |
| 13541 |
total-width .value_required:n = true , |
| 13542 |
dotted .code:n = \bool_set_true:N \l_@@_dotted_rule_bool , |
| 13543 |
} |
| 13544 |
% \end{macrocode} |
| 13545 |
% |
| 13546 |
% \bigskip |
| 13547 |
% The following command will create the command that the final user will use in |
| 13548 |
% its array to draw an horizontal rule (hence the `|h|` in the name) with the |
| 13549 |
% full width of the array. |#1| is the whole set of keys to pass to the command |
| 13550 |
% |\@@_draw_hrule:n| (which is in the internal |\CodeAfter|). |
| 13551 |
% \begin{macrocode} |
| 13552 |
\cs_new_protected:Npn \@@_h_custom_line:n #1 |
| 13553 |
{ |
| 13554 |
% \end{macrocode} |
| 13555 |
% We use |\cs_set:cpn| and not |\cs_new:cpn| because we want a local definition. |
| 13556 |
% Moreover, the command must \emph{not} be protected since it begins with |
| 13557 |
% |\noalign| (which is in |\Hline|). |
| 13558 |
% \begin{macrocode} |
| 13559 |
\cs_set_nopar:cpn { nicematrix - \l_@@_command_str } { \Hline [ #1 ] } |
| 13560 |
\seq_put_left:No \l_@@_custom_line_commands_seq \l_@@_command_str |
| 13561 |
} |
| 13562 |
% \end{macrocode} |
| 13563 |
% |
| 13564 |
% \bigskip |
| 13565 |
% \bigskip |
| 13566 |
% The following command will create the command that the final user will use in |
| 13567 |
% its array to draw an horizontal rule on only some of the columns of the array |
| 13568 |
% (hence the letter |c| as in |\cline|). |#1| is the whole set of keys to pass |
| 13569 |
% to the command |\@@_draw_hrule:n| (which is in the internal |\CodeAfter|). |
| 13570 |
% |
| 13571 |
% \begin{macrocode} |
| 13572 |
\cs_new_protected:Npn \@@_c_custom_line:n #1 |
| 13573 |
{ |
| 13574 |
% \end{macrocode} |
| 13575 |
% Here, we need an expandable command since it begins with an |\noalign|. |
| 13576 |
% \begin{macrocode} |
| 13577 |
\exp_args:Nc \DeclareExpandableDocumentCommand |
| 13578 |
{ nicematrix - \l_@@_ccommand_str } |
| 13579 |
{ O { } m } |
| 13580 |
{ |
| 13581 |
\noalign |
| 13582 |
{ |
| 13583 |
\@@_compute_rule_width:n { #1 , ##1 } |
| 13584 |
\skip_vertical:n \l_@@_rule_width_before_dim |
| 13585 |
\clist_map_inline:nn |
| 13586 |
{ ##2 } |
| 13587 |
{ \@@_c_custom_line_i:nn { #1 , ##1 } { ####1 } } |
| 13588 |
} |
| 13589 |
} |
| 13590 |
\seq_put_left:No \l_@@_custom_line_commands_seq \l_@@_ccommand_str |
| 13591 |
} |
| 13592 |
% \end{macrocode} |
| 13593 |
% The first argument is the list of key-value pairs characteristic of the line. |
| 13594 |
% The second argument is the specification of columns for the |\cline| with the |
| 13595 |
% syntax $a$-$b$. |
| 13596 |
% \begin{macrocode} |
| 13597 |
\cs_new_protected:Npn \@@_c_custom_line_i:nn #1 #2 |
| 13598 |
{ |
| 13599 |
\tl_if_in:nnTF { #2 } { - } |
| 13600 |
{ \@@_cut_on_hyphen:w #2 \q_stop } |
| 13601 |
{ \@@_cut_on_hyphen:w #2 - #2 \q_stop } |
| 13602 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 13603 |
{ |
| 13604 |
\@@_draw_hrule:n |
| 13605 |
{ |
| 13606 |
#1 , |
| 13607 |
start = \l_tmpa_tl , |
| 13608 |
end = \l_tmpb_tl , |
| 13609 |
position = \int_eval:n { \c@iRow + 1 } , |
| 13610 |
total-width = \dim_use:N \l_@@_rule_width_before_dim |
| 13611 |
} |
| 13612 |
} |
| 13613 |
} |
| 13614 |
% \end{macrocode} |
| 13615 |
% |
| 13616 |
% \begin{macrocode} |
| 13617 |
\cs_new_protected:Npn \@@_compute_rule_width:n #1 |
| 13618 |
{ |
| 13619 |
\bool_set_false:N \l_@@_tikz_rule_bool |
| 13620 |
\bool_set_false:N \l_@@_total_width_bool |
| 13621 |
\bool_set_false:N \l_@@_dotted_rule_bool |
| 13622 |
\keys_set_known:nn { nicematrix / custom-line-width } { #1 } |
| 13623 |
\bool_if:NF \l_@@_total_width_bool |
| 13624 |
{ |
| 13625 |
\bool_if:NTF \l_@@_dotted_rule_bool |
| 13626 |
{ \dim_set:Nn \l_@@_rule_width_before_dim { 2 \l_@@_xdots_radius_dim } } |
| 13627 |
{ |
| 13628 |
\bool_if:NF \l_@@_tikz_rule_bool |
| 13629 |
{ |
| 13630 |
\dim_set:Nn \l_@@_rule_width_before_dim |
| 13631 |
{ |
| 13632 |
\arrayrulewidth * \l_@@_tmpc_int |
| 13633 |
+ \doublerulesep * ( \l_@@_tmpc_int - 1 ) |
| 13634 |
} |
| 13635 |
} |
| 13636 |
} |
| 13637 |
} |
| 13638 |
} |
| 13639 |
% \end{macrocode} |
| 13640 |
% |
| 13641 |
% The following constructions aims to allow cumulative blocks of options between |
| 13642 |
% square brackets such as in |I[color=blue][tikz=dashed]|. |
| 13643 |
% \begin{macrocode} |
| 13644 |
\cs_new_protected:Npn \@@_v_custom_line:nn #1 #2 |
| 13645 |
{ |
| 13646 |
\str_if_eq:nnTF { #2 } { [ } |
| 13647 |
{ \@@_v_custom_line_i:nw { #1 } [ } |
| 13648 |
{ \@@_v_custom_line_ii:nn { #2 } { #1 } } |
| 13649 |
} |
| 13650 |
\cs_new_protected:Npn \@@_v_custom_line_i:nw #1 [ #2 ] |
| 13651 |
{ \@@_v_custom_line:nn { #1 , #2 } } |
| 13652 |
% \end{macrocode} |
| 13653 |
% |
| 13654 |
% \begin{macrocode} |
| 13655 |
\cs_new_protected:Npn \@@_v_custom_line_ii:nn #1 #2 |
| 13656 |
{ |
| 13657 |
\@@_compute_rule_width:n { #2 } |
| 13658 |
% \end{macrocode} |
| 13659 |
% In the following line, the |\dim_use:N| is mandatory since we do an expansion. |
| 13660 |
% \begin{macrocode} |
| 13661 |
\tl_gput_right:Ne \g_@@_array_preamble_tl |
| 13662 |
{ |
| 13663 |
\exp_not:N ! |
| 13664 |
{ \skip_horizontal:n { \dim_use:N \l_@@_rule_width_before_dim } } |
| 13665 |
} |
| 13666 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 13667 |
{ |
| 13668 |
% \end{macrocode} |
| 13669 |
% |
| 13670 |
% Here is a version with the keys of |rules-after|. |
| 13671 |
% \begin{Verbatim} |
| 13672 |
% \@@_draw_vrule:n |
| 13673 |
% { |
| 13674 |
% #2 , |
| 13675 |
% position = \int_eval:n { \c@jCol + 1 } , |
| 13676 |
% total-width = \dim_use:N \l_@@_rule_width_before_dim |
| 13677 |
% } |
| 13678 |
% \end{Verbatim} |
| 13679 |
% However, you will use a slightly more efficient version. |
| 13680 |
% |
| 13681 |
% \begin{macrocode} |
| 13682 |
{ |
| 13683 |
\dim_set:Nn \l_@@_rule_width_after_dim |
| 13684 |
{ \dim_use:N \l_@@_rule_width_before_dim } |
| 13685 |
\int_set:Nn \l_@@_position_int { \int_eval:n { \c@jCol + 1 } } |
| 13686 |
\@@_draw_vrule:n { #2 } |
| 13687 |
} |
| 13688 |
} |
| 13689 |
\@@_rec_preamble:n #1 |
| 13690 |
} |
| 13691 |
% \end{macrocode} |
| 13692 |
% |
| 13693 |
% \begin{macrocode} |
| 13694 |
\@@_custom_line:n |
| 13695 |
{ letter = : , command = \hdottedline , ccommand = \cdottedline, dotted } |
| 13696 |
% \end{macrocode} |
| 13697 |
% |
| 13698 |
% |
| 13699 |
% \subsubsection*{The key default-line} |
| 13700 |
% |
| 13701 |
% \begin{macrocode} |
| 13702 |
\keys_define:nn { nicematrix / default-line } |
| 13703 |
{ |
| 13704 |
multiplicity .int_set:N = \l_@@_multiplicity_int , |
| 13705 |
color .code:n = \bool_set_true:N \l_@@_color_bool , |
| 13706 |
color .value_required:n = true , |
| 13707 |
dotted .code:n = \bool_set_true:N \l_@@_dotted_rule_bool , |
| 13708 |
dotted .value_forbidden:n = true , |
| 13709 |
total-width .code:n = { } , |
| 13710 |
total-width .value_required:n = true , |
| 13711 |
sep-color .code:n = { } , |
| 13712 |
sep-color .value_required:n = true , |
| 13713 |
unknown .code:n = |
| 13714 |
\@@_unknown_key:nn |
| 13715 |
{ nicematrix / default-line } |
| 13716 |
{ Unknown~key~for~default-line } |
| 13717 |
} |
| 13718 |
% \end{macrocode} |
| 13719 |
% |
| 13720 |
% \begin{macrocode} |
| 13721 |
\AtBeginDocument |
| 13722 |
{ |
| 13723 |
\IfPackageLoadedT { tikz } |
| 13724 |
{ |
| 13725 |
\keys_define:nn { nicematrix / default-line } |
| 13726 |
{ |
| 13727 |
tikz .code:n = |
| 13728 |
\bool_set_true:N \l_@@_tikz_rule_bool |
| 13729 |
\tl_set:Nn \l_@@_tikz_rule_tl { #1 } , |
| 13730 |
tikz .value_required:n = true , |
| 13731 |
dashed .meta:n = |
| 13732 |
{ |
| 13733 |
tikz = nicematrix / dashed , |
| 13734 |
total-width = \pgflinewidth |
| 13735 |
} |
| 13736 |
} |
| 13737 |
\@@_custom_line:n |
| 13738 |
{ |
| 13739 |
letter = ; , |
| 13740 |
command = \hdashedline , |
| 13741 |
ccommand = \cdashedline , |
| 13742 |
tikz = nicematrix / dashed , |
| 13743 |
total-width = \pgflinewidth |
| 13744 |
} |
| 13745 |
} |
| 13746 |
} |
| 13747 |
% \end{macrocode} |
| 13748 |
% |
| 13749 |
% \begin{macrocode} |
| 13750 |
\cs_new_protected:Npn \@@_default_line:n #1 |
| 13751 |
{ |
| 13752 |
\bool_set_false:N \l_@@_tikz_rule_bool |
| 13753 |
\bool_set_false:N \l_@@_dotted_rule_bool |
| 13754 |
\bool_set_false:N \l_@@_color_bool |
| 13755 |
\keys_set:nn { nicematrix / default-line } { #1 } |
| 13756 |
\bool_if:NT \l_@@_tikz_rule_bool |
| 13757 |
{ |
| 13758 |
\IfPackageLoadedF { tikz } |
| 13759 |
{ \@@_error:n { tikz~in~custom-line~without~tikz } } |
| 13760 |
\bool_if:NT \l_@@_color_bool |
| 13761 |
{ \@@_error:n { color~in~custom-line~with~tikz } } |
| 13762 |
} |
| 13763 |
\bool_if:NT \l_@@_dotted_rule_bool |
| 13764 |
{ |
| 13765 |
\int_compare:nNnT \l_@@_multiplicity_int > 1 |
| 13766 |
{ \@@_error:n { key~multiplicity~with~dotted } } |
| 13767 |
} |
| 13768 |
\bool_if:NTF \l_@@_tikz_rule_bool |
| 13769 |
{ |
| 13770 |
\socket_assign_plug:nn { nicematrix / vsegment } { tikz } |
| 13771 |
\socket_assign_plug:nn { nicematrix / hsegment } { tikz } |
| 13772 |
} |
| 13773 |
{ |
| 13774 |
\bool_if:NTF \l_@@_dotted_rule_bool |
| 13775 |
{ |
| 13776 |
\socket_assign_plug:nn { nicematrix / vsegment } { dotted } |
| 13777 |
\socket_assign_plug:nn { nicematrix / hsegment } { dotted } |
| 13778 |
} |
| 13779 |
{ |
| 13780 |
\bool_if:NTF \l_@@_multiple_rule_bool |
| 13781 |
{ |
| 13782 |
\socket_assign_plug:nn { nicematrix / vsegment } { multiple } |
| 13783 |
\socket_assign_plug:nn { nicematrix / hsegment } { multiple } |
| 13784 |
} |
| 13785 |
} |
| 13786 |
} |
| 13787 |
} |
| 13788 |
% \end{macrocode} |
| 13789 |
% |
| 13790 |
% \subsubsection*{The key hvlines} |
| 13791 |
% |
| 13792 |
% The following command tests whether the current position in the array (given by |
| 13793 |
% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the column) would provide an |
| 13794 |
% horizontal rule towards the right in the block delimited by the four arguments |
| 13795 |
% |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be |
| 13796 |
% drawn), the boolean |\g_tmpa_bool| is set to |false|. |
| 13797 |
% \begin{macrocode} |
| 13798 |
\cs_new_protected:Npn \@@_test_hline_in_block:nnnnn #1 #2 #3 #4 #5 |
| 13799 |
{ |
| 13800 |
\int_compare:nNnT \l_tmpa_tl > { #1 } |
| 13801 |
{ |
| 13802 |
\int_compare:nNnT \l_tmpa_tl < { #3 + 1 } |
| 13803 |
{ |
| 13804 |
\int_compare:nNnT \l_tmpb_tl > { #2 - 1 } |
| 13805 |
{ |
| 13806 |
\int_compare:nNnT \l_tmpb_tl < { #4 + 1 } |
| 13807 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13808 |
} |
| 13809 |
} |
| 13810 |
} |
| 13811 |
} |
| 13812 |
% \end{macrocode} |
| 13813 |
% |
| 13814 |
% The same for vertical rules. |
| 13815 |
% \begin{macrocode} |
| 13816 |
\cs_new_protected:Npn \@@_test_vline_in_block:nnnnn #1 #2 #3 #4 #5 |
| 13817 |
{ |
| 13818 |
\int_compare:nNnT \l_tmpa_tl > { #1 - 1 } |
| 13819 |
{ |
| 13820 |
\int_compare:nNnT \l_tmpa_tl < { #3 + 1 } |
| 13821 |
{ |
| 13822 |
\int_compare:nNnT \l_tmpb_tl > { #2 } |
| 13823 |
{ |
| 13824 |
\int_compare:nNnT \l_tmpb_tl < { #4 + 1 } |
| 13825 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13826 |
} |
| 13827 |
} |
| 13828 |
} |
| 13829 |
} |
| 13830 |
% \end{macrocode} |
| 13831 |
% |
| 13832 |
% \begin{macrocode} |
| 13833 |
\cs_new_protected:Npn \@@_test_hline_in_stroken_block:nnnn #1 #2 #3 #4 |
| 13834 |
{ |
| 13835 |
\int_compare:nNnT \l_tmpb_tl > { #2 - 1 } |
| 13836 |
{ |
| 13837 |
\int_compare:nNnT \l_tmpb_tl < { #4 + 1 } |
| 13838 |
{ |
| 13839 |
\int_compare:nNnTF \l_tmpa_tl = { #1 } |
| 13840 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13841 |
{ |
| 13842 |
\int_compare:nNnT \l_tmpa_tl = { #3 + 1 } |
| 13843 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13844 |
} |
| 13845 |
} |
| 13846 |
} |
| 13847 |
} |
| 13848 |
% \end{macrocode} |
| 13849 |
% |
| 13850 |
% \begin{macrocode} |
| 13851 |
\cs_new_protected:Npn \@@_test_vline_in_stroken_block:nnnn #1 #2 #3 #4 |
| 13852 |
{ |
| 13853 |
\int_compare:nNnT \l_tmpa_tl > { #1 - 1 } |
| 13854 |
{ |
| 13855 |
\int_compare:nNnT \l_tmpa_tl < { #3 + 1 } |
| 13856 |
{ |
| 13857 |
\int_compare:nNnTF \l_tmpb_tl = { #2 } |
| 13858 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13859 |
{ |
| 13860 |
\int_compare:nNnT \l_tmpb_tl = { #4 + 1 } |
| 13861 |
{ \bool_gset_false:N \g_tmpa_bool } |
| 13862 |
} |
| 13863 |
} |
| 13864 |
} |
| 13865 |
} |
| 13866 |
% \end{macrocode} |
| 13867 |
% |
| 13868 |
% \bigskip |
| 13869 |
% \section{The empty corners} |
| 13870 |
% |
| 13871 |
% When the key |corners| is raised, the rules are not drawn in the corners; they |
| 13872 |
% are not colored and |\TikzEveryCell| does not apply. Of course, we have to |
| 13873 |
% compute the corners before we begin to draw the rules. |
| 13874 |
% |
| 13875 |
% \begin{macrocode} |
| 13876 |
\cs_new_protected:Npn \@@_compute_corners: |
| 13877 |
{ |
| 13878 |
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq |
| 13879 |
{ \@@_mark_cells_of_block:nnnnn ##1 } |
| 13880 |
% \end{macrocode} |
| 13881 |
% The list |\l_@@_corners_cells_clist| will be the list of all the |
| 13882 |
% empty cells (and not in a block) considered in the corners of the array. We |
| 13883 |
% use a |clist| instead of a |seq| because we will frequently search in that |
| 13884 |
% list (and searching in a |clist| is faster than searching in a |seq|). |
| 13885 |
% \begin{macrocode} |
| 13886 |
\clist_clear:N \l_@@_corners_cells_clist |
| 13887 |
\clist_map_inline:Nn \l_@@_corners_clist |
| 13888 |
{ |
| 13889 |
\str_case:nnF { ##1 } |
| 13890 |
{ |
| 13891 |
{ NW } |
| 13892 |
{ \@@_compute_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol } |
| 13893 |
{ NE } |
| 13894 |
{ \@@_compute_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 } |
| 13895 |
{ SW } |
| 13896 |
{ \@@_compute_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol } |
| 13897 |
{ SE } |
| 13898 |
{ \@@_compute_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 } |
| 13899 |
} |
| 13900 |
{ \@@_error:nn { bad~corner } { ##1 } } |
| 13901 |
} |
| 13902 |
% \end{macrocode} |
| 13903 |
% Even if the user has used the key |corners| the list of cells in the corners |
| 13904 |
% may be empty. |
| 13905 |
% \begin{macrocode} |
| 13906 |
\clist_if_empty:NF \l_@@_corners_cells_clist |
| 13907 |
{ |
| 13908 |
% \end{macrocode} |
| 13909 |
% You write on the |aux| file the list of the cells which are in the (empty) |
| 13910 |
% corners because you need that information in the |\CodeBefore| since the |
| 13911 |
% commands which colors the |rows|, |columns| and |cells| must not color the |
| 13912 |
% cells in the corners. |
| 13913 |
% \begin{macrocode} |
| 13914 |
\tl_gput_right:Ne \g_@@_aux_tl |
| 13915 |
{ |
| 13916 |
\clist_set:Nn \exp_not:N \l_@@_corners_cells_clist |
| 13917 |
{ \l_@@_corners_cells_clist } |
| 13918 |
} |
| 13919 |
} |
| 13920 |
} |
| 13921 |
% \end{macrocode} |
| 13922 |
% |
| 13923 |
% \bigskip |
| 13924 |
% \begin{macrocode} |
| 13925 |
\cs_new_protected:Npn \@@_mark_cells_of_block:nnnnn #1 #2 #3 #4 #5 |
| 13926 |
{ |
| 13927 |
\int_step_inline:nnn { #1 } { #3 } |
| 13928 |
{ |
| 13929 |
\int_step_inline:nnn { #2 } { #4 } |
| 13930 |
{ \cs_set_nopar:cpn { @@ _ block _ ##1 - ####1 } { } } |
| 13931 |
} |
| 13932 |
} |
| 13933 |
% \end{macrocode} |
| 13934 |
% |
| 13935 |
% \bigskip |
| 13936 |
% \begin{macrocode} |
| 13937 |
\prg_new_conditional:Npnn \@@_if_in_block:nn #1 #2 { p } |
| 13938 |
{ |
| 13939 |
\cs_if_exist:cTF |
| 13940 |
{ @@ _ block _ \int_eval:n { #1 } - \int_eval:n { #2 } } |
| 13941 |
\prg_return_true: |
| 13942 |
\prg_return_false: |
| 13943 |
} |
| 13944 |
% \end{macrocode} |
| 13945 |
% |
| 13946 |
% \bigskip |
| 13947 |
% ``Computing a corner'' is determining all the empty cells (which are not in a |
| 13948 |
% block) that belong to that corner. These cells will be added to the sequence |
| 13949 |
% |\l_@@_corners_cells_clist|. |
| 13950 |
% |
| 13951 |
% \medskip |
| 13952 |
% The six arguments of |\@@_compute_corner:nnnnnn| are as follow: |
| 13953 |
% \begin{itemize} |
| 13954 |
% \item |#1| and |#2| are the number of row and column of the cell which is |
| 13955 |
% actually in the corner; |
| 13956 |
% \item |#3| and |#4| are the steps in rows and the step in columns when moving |
| 13957 |
% from the corner; |
| 13958 |
% \item |#5| is the number of the final row when scanning the rows from the |
| 13959 |
% corner; |
| 13960 |
% \item |#6| is the number of the final column when scanning the columns from |
| 13961 |
% the corner. |
| 13962 |
% \end{itemize} |
| 13963 |
% \begin{macrocode} |
| 13964 |
\cs_new_protected:Npn \@@_compute_corner:nnnnnn #1 #2 #3 #4 #5 #6 |
| 13965 |
{ |
| 13966 |
% \end{macrocode} |
| 13967 |
% For the explanations and the name of the variables, we consider that we are |
| 13968 |
% computing the left-upper corner. |
| 13969 |
% |
| 13970 |
% First, we try to determine which is the last empty cell (and not in a block: |
| 13971 |
% we won't add that precision any longer) in the column of number~$1$. The flag |
| 13972 |
% |\l_tmpa_bool| will be raised when a non-empty cell is found. |
| 13973 |
% \begin{macrocode} |
| 13974 |
\bool_set_false:N \l_tmpa_bool |
| 13975 |
\int_zero_new:N \l_@@_last_empty_row_int |
| 13976 |
\int_set:Nn \l_@@_last_empty_row_int { #1 } |
| 13977 |
\int_step_inline:nnnn { #1 } { #3 } { #5 } |
| 13978 |
{ |
| 13979 |
\bool_lazy_or:nnTF |
| 13980 |
{ |
| 13981 |
\cs_if_exist_p:c |
| 13982 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_eval:n { #2 } } |
| 13983 |
} |
| 13984 |
{ \@@_if_in_block_p:nn { ##1 } { #2 } } |
| 13985 |
{ \bool_set_true:N \l_tmpa_bool } |
| 13986 |
{ |
| 13987 |
\bool_if:NF \l_tmpa_bool |
| 13988 |
{ \int_set:Nn \l_@@_last_empty_row_int { ##1 } } |
| 13989 |
} |
| 13990 |
} |
| 13991 |
% \end{macrocode} |
| 13992 |
% Now, you determine the last empty cell in the row of number~$1$. |
| 13993 |
% \begin{macrocode} |
| 13994 |
\bool_set_false:N \l_tmpa_bool |
| 13995 |
\int_zero_new:N \l_@@_last_empty_column_int |
| 13996 |
\int_set:Nn \l_@@_last_empty_column_int { #2 } |
| 13997 |
\int_step_inline:nnnn { #2 } { #4 } { #6 } |
| 13998 |
{ |
| 13999 |
\bool_lazy_or:nnTF |
| 14000 |
{ |
| 14001 |
\cs_if_exist_p:c |
| 14002 |
{ pgf @ sh @ ns @ \@@_env: - \int_eval:n { #1 } - ##1 } |
| 14003 |
} |
| 14004 |
{ \@@_if_in_block_p:nn { #1 } { ##1 } } |
| 14005 |
{ \bool_set_true:N \l_tmpa_bool } |
| 14006 |
{ |
| 14007 |
\bool_if:NF \l_tmpa_bool |
| 14008 |
{ \int_set:Nn \l_@@_last_empty_column_int { ##1 } } |
| 14009 |
} |
| 14010 |
} |
| 14011 |
% \end{macrocode} |
| 14012 |
% Now, we loop over the rows. |
| 14013 |
% \begin{macrocode} |
| 14014 |
\int_step_inline:nnnn { #1 } { #3 } \l_@@_last_empty_row_int |
| 14015 |
{ |
| 14016 |
% \end{macrocode} |
| 14017 |
% We treat the row number |##1| with another loop. |
| 14018 |
% \begin{macrocode} |
| 14019 |
\bool_set_false:N \l_tmpa_bool |
| 14020 |
\int_step_inline:nnnn { #2 } { #4 } \l_@@_last_empty_column_int |
| 14021 |
{ |
| 14022 |
\bool_lazy_or:nnTF |
| 14023 |
{ \cs_if_exist_p:c { pgf @ sh @ ns @ \@@_env: - ##1 - ####1 } } |
| 14024 |
{ \@@_if_in_block_p:nn { ##1 } { ####1 } } |
| 14025 |
{ \bool_set_true:N \l_tmpa_bool } |
| 14026 |
{ |
| 14027 |
\bool_if:NF \l_tmpa_bool |
| 14028 |
{ |
| 14029 |
\int_set:Nn \l_@@_last_empty_column_int { ####1 } |
| 14030 |
\clist_put_right:Nn |
| 14031 |
\l_@@_corners_cells_clist |
| 14032 |
{ ##1 - ####1 } |
| 14033 |
\cs_set_nopar:cpn { @@ _ corner _ ##1 - ####1 } { } |
| 14034 |
} |
| 14035 |
} |
| 14036 |
} |
| 14037 |
} |
| 14038 |
} |
| 14039 |
% \end{macrocode} |
| 14040 |
% |
| 14041 |
% |
| 14042 |
% \bigskip |
| 14043 |
% Of course, instead of the following lines, we could have use |
| 14044 |
% |\prg_new_conditional:Npnn|. |
| 14045 |
% \begin{macrocode} |
| 14046 |
\cs_new:Npn \@@_if_in_corner:nT #1 { \cs_if_exist:cT { @@ _ corner _ #1 } } |
| 14047 |
\cs_new:Npn \@@_if_in_corner:nF #1 { \cs_if_exist:cF { @@ _ corner _ #1 } } |
| 14048 |
% \end{macrocode} |
| 14049 |
% |
| 14050 |
% Instead of the previous lines, we could have used |\l_@@_corners_cells_clist| |
| 14051 |
% but it's less efficient: |
| 14052 |
% |
| 14053 |
% \verb|\clist_if_in:NeT \l_@@_corners_cells_clist { #1 } ...| |
| 14054 |
% |
| 14055 |
% \bigskip |
| 14056 |
% \section{The environment \{NiceMatrixBlock\}} |
| 14057 |
% |
| 14058 |
% The following flag will be raised when all the columns of the environments of |
| 14059 |
% the block must have the same width in ``auto'' mode. |
| 14060 |
% \begin{macrocode} |
| 14061 |
\bool_new:N \l_@@_block_auto_columns_width_bool |
| 14062 |
% \end{macrocode} |
| 14063 |
% |
| 14064 |
% \bigskip |
| 14065 |
% Up to now, there is only one option available for the environment |
| 14066 |
% |{NiceMatrixBlock}|. |
| 14067 |
% \begin{macrocode} |
| 14068 |
\keys_define:nn { nicematrix / NiceMatrixBlock } |
| 14069 |
{ |
| 14070 |
auto-columns-width .code:n = |
| 14071 |
{ |
| 14072 |
\bool_set_true:N \l_@@_block_auto_columns_width_bool |
| 14073 |
\dim_gzero_new:N \g_@@_max_cell_width_dim |
| 14074 |
\bool_set_true:N \l_@@_auto_columns_width_bool |
| 14075 |
} |
| 14076 |
} |
| 14077 |
% \end{macrocode} |
| 14078 |
% |
| 14079 |
% \bigskip |
| 14080 |
% \begin{macrocode} |
| 14081 |
\NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } |
| 14082 |
{ |
| 14083 |
\int_gincr:N \g_@@_NiceMatrixBlock_int |
| 14084 |
\dim_zero:N \l_@@_columns_width_dim |
| 14085 |
\keys_set:nn { nicematrix / NiceMatrixBlock } { #1 } |
| 14086 |
\bool_if:NT \l_@@_block_auto_columns_width_bool |
| 14087 |
{ |
| 14088 |
\cs_if_exist:cT |
| 14089 |
{ @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int } |
| 14090 |
{ |
| 14091 |
\dim_set:Nn \l_@@_columns_width_dim |
| 14092 |
{ |
| 14093 |
\use:c |
| 14094 |
{ @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int } |
| 14095 |
} |
| 14096 |
} |
| 14097 |
} |
| 14098 |
} |
| 14099 |
% \end{macrocode} |
| 14100 |
% |
| 14101 |
% \medskip |
| 14102 |
% At the end of the environment |{NiceMatrixBlock}|, we write in the main |aux| |
| 14103 |
% file instructions for the column width of all the environments of the block |
| 14104 |
% (that's why we have stored the number of the first environment of the block in |
| 14105 |
% the counter |\l_@@_first_env_block_int|). |
| 14106 |
% \begin{macrocode} |
| 14107 |
{ |
| 14108 |
\legacy_if:nTF { measuring@ } |
| 14109 |
% \end{macrocode} |
| 14110 |
% If |{NiceMatrixBlock}| is used in an environment of \pkg{amsmath} such as |
| 14111 |
% |{align}|: cf. question 694957 on TeX StackExchange. The most important line |
| 14112 |
% in that case is the following one. |
| 14113 |
% \begin{macrocode} |
| 14114 |
{ \int_gdecr:N \g_@@_NiceMatrixBlock_int } |
| 14115 |
{ |
| 14116 |
\bool_if:NT \l_@@_block_auto_columns_width_bool |
| 14117 |
{ |
| 14118 |
\iow_shipout:Nn \@mainaux \ExplSyntaxOn |
| 14119 |
\iow_shipout:Ne \@mainaux |
| 14120 |
{ |
| 14121 |
\cs_gset:cpn |
| 14122 |
{ @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int } |
| 14123 |
% \end{macrocode} |
| 14124 |
% For technical reasons, we have to include the width of a potential rule on the |
| 14125 |
% right side of the cells. |
| 14126 |
% \begin{macrocode} |
| 14127 |
{ \dim_eval:n { \g_@@_max_cell_width_dim + \arrayrulewidth } } |
| 14128 |
} |
| 14129 |
\iow_shipout:Nn \@mainaux \ExplSyntaxOff |
| 14130 |
} |
| 14131 |
} |
| 14132 |
\ignorespacesafterend |
| 14133 |
} |
| 14134 |
% \end{macrocode} |
| 14135 |
% |
| 14136 |
% |
| 14137 |
% |
| 14138 |
% \section{The extra nodes} |
| 14139 |
% |
| 14140 |
% \bigskip |
| 14141 |
% The following command is called in |\@@_use_arraybox_with_notes_c:| just |
| 14142 |
% before the construction of the blocks (if the creation of medium nodes is |
| 14143 |
% required, medium nodes are also created for the blocks and that construction |
| 14144 |
% uses the standard medium nodes). |
| 14145 |
% \begin{macrocode} |
| 14146 |
\cs_new_protected:Npn \@@_create_extra_nodes: |
| 14147 |
{ |
| 14148 |
\bool_if:nTF \l_@@_medium_nodes_bool |
| 14149 |
{ |
| 14150 |
\bool_if:NTF \l_@@_no_cell_nodes_bool |
| 14151 |
{ \@@_error:n { extra-nodes~with~no-cell-nodes } } |
| 14152 |
{ |
| 14153 |
\bool_if:NTF \l_@@_large_nodes_bool |
| 14154 |
\@@_create_medium_and_large_nodes: |
| 14155 |
\@@_create_medium_nodes: |
| 14156 |
} |
| 14157 |
} |
| 14158 |
{ |
| 14159 |
\bool_if:NT \l_@@_large_nodes_bool |
| 14160 |
{ |
| 14161 |
\bool_if:NTF \l_@@_no_cell_nodes_bool |
| 14162 |
{ \@@_error:n { extra-nodes~with~no-cell-nodes } } |
| 14163 |
\@@_create_large_nodes: |
| 14164 |
} |
| 14165 |
} |
| 14166 |
} |
| 14167 |
% \end{macrocode} |
| 14168 |
% |
| 14169 |
% |
| 14170 |
% \bigskip |
| 14171 |
% We have three macros of creation of nodes: |\@@_create_medium_nodes:|, |
| 14172 |
% |\@@_create_large_nodes:| and |\@@_create_medium_and_large_nodes:|. |
| 14173 |
% |
| 14174 |
% |
| 14175 |
% \bigskip |
| 14176 |
% We have to compute the mathematical coordinates of the ``medium nodes''. These |
| 14177 |
% mathematical coordinates are also used to compute the mathematical coordinates |
| 14178 |
% of the ``large nodes''. That's why we write a command |
| 14179 |
% |\@@_computations_for_medium_nodes:| to do these computations. |
| 14180 |
% |
| 14181 |
% \bigskip |
| 14182 |
% The command |\@@_computations_for_medium_nodes:| must be used in a |
| 14183 |
% |{pgfpicture}|. |
| 14184 |
% |
| 14185 |
% \medskip |
| 14186 |
% For each row $i$, we compute two dimensions |
| 14187 |
% \texttt{l_@@_row_\textsl{i}_min_dim} and \texttt{l_@@_row_\textsl{i}_max_dim}. |
| 14188 |
% The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal |
| 14189 |
% $y$-value of all the cells of the row~$i$. The dimension |
| 14190 |
% \texttt{l_@@_row_\textsl{i}_max_dim} is the maximal $y$-value of all the cells |
| 14191 |
% of the row~$i$. |
| 14192 |
% |
| 14193 |
% Similarly, for each column $j$, we compute two dimensions |
| 14194 |
% \texttt{l_@@_column_\textsl{j}_min_dim} and |
| 14195 |
% \texttt{l_@@_column_\textsl{j}_max_dim}. The dimension |
| 14196 |
% \texttt{l_@@_column_\textsl{j}_min_dim} is the minimal $x$-value of all the |
| 14197 |
% cells of the column~$j$. The dimension \texttt{l_@@_column_\textsl{j}_max_dim} |
| 14198 |
% is the maximal $x$-value of all the cells of the column~$j$. |
| 14199 |
% |
| 14200 |
% Since these dimensions will be computed as maximum or minimum, we initialize |
| 14201 |
% them to |\c_max_dim| or |-\c_max_dim|. |
| 14202 |
% \begin{macrocode} |
| 14203 |
\cs_new_protected:Npn \@@_computations_for_medium_nodes: |
| 14204 |
{ |
| 14205 |
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: |
| 14206 |
{ |
| 14207 |
\dim_zero_new:c { l_@@_row_ \@@_i: _min_dim } |
| 14208 |
\dim_set_eq:cN { l_@@_row_ \@@_i: _min_dim } \c_max_dim |
| 14209 |
\dim_zero_new:c { l_@@_row_ \@@_i: _max_dim } |
| 14210 |
\dim_set:cn { l_@@_row_ \@@_i: _max_dim } { - \c_max_dim } |
| 14211 |
} |
| 14212 |
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: |
| 14213 |
{ |
| 14214 |
\dim_zero_new:c { l_@@_column_ \@@_j: _min_dim } |
| 14215 |
\dim_set_eq:cN { l_@@_column_ \@@_j: _min_dim } \c_max_dim |
| 14216 |
\dim_zero_new:c { l_@@_column_ \@@_j: _max_dim } |
| 14217 |
\dim_set:cn { l_@@_column_ \@@_j: _max_dim } { - \c_max_dim } |
| 14218 |
} |
| 14219 |
% \end{macrocode} |
| 14220 |
% We begin the two nested loops over the rows and the columns of the array. |
| 14221 |
% \begin{macrocode} |
| 14222 |
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: |
| 14223 |
{ |
| 14224 |
\int_step_variable:nnNn |
| 14225 |
\l_@@_first_col_int \g_@@_col_total_int \@@_j: |
| 14226 |
% \end{macrocode} |
| 14227 |
% If the cell ($i$-$j$) is empty or an implicit cell (that is to say a cell |
| 14228 |
% after implicit ampersands |&|) we don't update the dimensions we want to |
| 14229 |
% compute. |
| 14230 |
% \begin{macrocode} |
| 14231 |
{ |
| 14232 |
\cs_if_exist:cT |
| 14233 |
{ pgf @ sh @ ns @ \@@_env: - \@@_i: - \@@_j: } |
| 14234 |
% \end{macrocode} |
| 14235 |
% We retrieve the coordinates of the anchor |south west| of the (normal) node of |
| 14236 |
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. |
| 14237 |
% \begin{macrocode} |
| 14238 |
{ |
| 14239 |
\pgfpointanchor { \@@_env: - \@@_i: - \@@_j: } { south~west } |
| 14240 |
\dim_set:cn { l_@@_row_ \@@_i: _min_dim } |
| 14241 |
{ \dim_min:vn { l_@@_row _ \@@_i: _min_dim } \pgf@y } |
| 14242 |
\seq_if_in:NeF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } |
| 14243 |
{ |
| 14244 |
\dim_set:cn { l_@@_column _ \@@_j: _min_dim } |
| 14245 |
{ \dim_min:vn { l_@@_column _ \@@_j: _min_dim } \pgf@x } |
| 14246 |
} |
| 14247 |
% \end{macrocode} |
| 14248 |
% We retrieve the coordinates of the anchor |north east| of the (normal) node of |
| 14249 |
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. |
| 14250 |
% \begin{macrocode} |
| 14251 |
\pgfpointanchor { \@@_env: - \@@_i: - \@@_j: } { north~east } |
| 14252 |
\dim_set:cn { l_@@_row _ \@@_i: _ max_dim } |
| 14253 |
{ \dim_max:vn { l_@@_row _ \@@_i: _ max_dim } \pgf@y } |
| 14254 |
\seq_if_in:NeF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } |
| 14255 |
{ |
| 14256 |
\dim_set:cn { l_@@_column _ \@@_j: _ max_dim } |
| 14257 |
{ \dim_max:vn { l_@@_column _ \@@_j: _max_dim } \pgf@x } |
| 14258 |
} |
| 14259 |
} |
| 14260 |
} |
| 14261 |
} |
| 14262 |
% \end{macrocode} |
| 14263 |
% Now, we have to deal with empty rows or empty columns since we don't have |
| 14264 |
% created nodes in such rows and columns. |
| 14265 |
% \begin{macrocode} |
| 14266 |
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: |
| 14267 |
{ |
| 14268 |
\dim_compare:nNnT |
| 14269 |
{ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } } = \c_max_dim |
| 14270 |
{ |
| 14271 |
\@@_qpoint:n { row - \@@_i: - base } |
| 14272 |
\dim_set:cn { l_@@_row _ \@@_i: _ max _ dim } \pgf@y |
| 14273 |
\dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } \pgf@y |
| 14274 |
} |
| 14275 |
} |
| 14276 |
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: |
| 14277 |
{ |
| 14278 |
\dim_compare:nNnT |
| 14279 |
{ \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } } = \c_max_dim |
| 14280 |
{ |
| 14281 |
\@@_qpoint:n { col - \@@_j: } |
| 14282 |
\dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } \pgf@y |
| 14283 |
\dim_set:cn { l_@@_column _ \@@_j: _ min _ dim } \pgf@y |
| 14284 |
} |
| 14285 |
} |
| 14286 |
} |
| 14287 |
% \end{macrocode} |
| 14288 |
% |
| 14289 |
% |
| 14290 |
% \bigskip |
| 14291 |
% Here is the command |\@@_create_medium_nodes:|. When this command is used, the |
| 14292 |
% ``medium nodes'' are created. |
| 14293 |
% |
| 14294 |
% \begin{macrocode} |
| 14295 |
\cs_new_protected:Npn \@@_create_medium_nodes: |
| 14296 |
{ |
| 14297 |
\pgfpicture |
| 14298 |
\pgfrememberpicturepositiononpagetrue |
| 14299 |
\pgf@relevantforpicturesizefalse |
| 14300 |
\@@_computations_for_medium_nodes: |
| 14301 |
% \end{macrocode} |
| 14302 |
% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| |
| 14303 |
% because this command will also be used for the creation of the ``large nodes''. |
| 14304 |
% \begin{macrocode} |
| 14305 |
\tl_set:Nn \l_@@_suffix_tl { -medium } |
| 14306 |
\@@_create_nodes: |
| 14307 |
\endpgfpicture |
| 14308 |
} |
| 14309 |
% \end{macrocode} |
| 14310 |
% |
| 14311 |
% |
| 14312 |
% \medskip |
| 14313 |
% The command |\@@_create_large_nodes:| must be used when we want to create only |
| 14314 |
% the ``large nodes'' and not the medium ones\footnote{If we want to create |
| 14315 |
% both, we have to use |\@@_create_medium_and_large_nodes:|}. However, the |
| 14316 |
% computation of the mathematical coordinates of the ``large nodes'' needs the |
| 14317 |
% computation of the mathematical coordinates of the ``medium nodes''. Hence, we |
| 14318 |
% use first |\@@_computations_for_medium_nodes:| and then the command |
| 14319 |
% |\@@_computations_for_large_nodes:|. |
| 14320 |
% \begin{macrocode} |
| 14321 |
\cs_new_protected:Npn \@@_create_large_nodes: |
| 14322 |
{ |
| 14323 |
\pgfpicture |
| 14324 |
\pgfrememberpicturepositiononpagetrue |
| 14325 |
\pgf@relevantforpicturesizefalse |
| 14326 |
\@@_computations_for_medium_nodes: |
| 14327 |
\@@_computations_for_large_nodes: |
| 14328 |
\tl_set:Nn \l_@@_suffix_tl { - large } |
| 14329 |
\@@_create_nodes: |
| 14330 |
\endpgfpicture |
| 14331 |
} |
| 14332 |
% \end{macrocode} |
| 14333 |
% |
| 14334 |
% \begin{macrocode} |
| 14335 |
\cs_new_protected:Npn \@@_create_medium_and_large_nodes: |
| 14336 |
{ |
| 14337 |
\pgfpicture |
| 14338 |
\pgfrememberpicturepositiononpagetrue |
| 14339 |
\pgf@relevantforpicturesizefalse |
| 14340 |
\@@_computations_for_medium_nodes: |
| 14341 |
% \end{macrocode} |
| 14342 |
% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| |
| 14343 |
% because this command will also be used for the creation of the ``large nodes''. |
| 14344 |
% \begin{macrocode} |
| 14345 |
\tl_set:Nn \l_@@_suffix_tl { - medium } |
| 14346 |
\@@_create_nodes: |
| 14347 |
\@@_computations_for_large_nodes: |
| 14348 |
\tl_set:Nn \l_@@_suffix_tl { - large } |
| 14349 |
\@@_create_nodes: |
| 14350 |
\endpgfpicture |
| 14351 |
} |
| 14352 |
% \end{macrocode} |
| 14353 |
% |
| 14354 |
% |
| 14355 |
% \bigskip |
| 14356 |
% For ``large nodes'', the exterior rows and columns don't interfere. That's why |
| 14357 |
% the loop over the columns will start at 1 and stop at $|\c@jCol|$ (and not |
| 14358 |
% |\g_@@_col_total_int|). Idem for the rows. |
| 14359 |
% \begin{macrocode} |
| 14360 |
\cs_new_protected:Npn \@@_computations_for_large_nodes: |
| 14361 |
{ |
| 14362 |
\int_set:Nn \l_@@_first_row_int 1 |
| 14363 |
\int_set:Nn \l_@@_first_col_int 1 |
| 14364 |
% \end{macrocode} |
| 14365 |
% We have to change the values of all the dimensions |
| 14366 |
% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, |
| 14367 |
% \texttt{l_@@_column_\textsl{j}_min_dim} and |
| 14368 |
% \texttt{l_@@_column_\textsl{j}_max_dim}. |
| 14369 |
% \begin{macrocode} |
| 14370 |
\int_step_variable:nNn { \c@iRow - 1 } \@@_i: |
| 14371 |
{ |
| 14372 |
\dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } |
| 14373 |
{ |
| 14374 |
( |
| 14375 |
\dim_use:c { l_@@_row _ \@@_i: _ min _ dim } + |
| 14376 |
\dim_use:c { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } |
| 14377 |
) |
| 14378 |
/ 2 |
| 14379 |
} |
| 14380 |
\dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } |
| 14381 |
{ l_@@_row_ \@@_i: _min_dim } |
| 14382 |
} |
| 14383 |
\int_step_variable:nNn { \c@jCol - 1 } \@@_j: |
| 14384 |
{ |
| 14385 |
\dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } |
| 14386 |
{ |
| 14387 |
( |
| 14388 |
\dim_use:c { l_@@_column _ \@@_j: _ max _ dim } + |
| 14389 |
\dim_use:c |
| 14390 |
{ l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } |
| 14391 |
) |
| 14392 |
/ 2 |
| 14393 |
} |
| 14394 |
\dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } |
| 14395 |
{ l_@@_column _ \@@_j: _ max _ dim } |
| 14396 |
} |
| 14397 |
% \end{macrocode} |
| 14398 |
% Here, we have to use |\dim_sub:cn| because of the number 1 in the name. |
| 14399 |
% \begin{macrocode} |
| 14400 |
\dim_sub:cn |
| 14401 |
{ l_@@_column _ 1 _ min _ dim } |
| 14402 |
\l_@@_left_margin_dim |
| 14403 |
\dim_add:cn |
| 14404 |
{ l_@@_column _ \int_use:N \c@jCol _ max _ dim } |
| 14405 |
\l_@@_right_margin_dim |
| 14406 |
} |
| 14407 |
% \end{macrocode} |
| 14408 |
% |
| 14409 |
% |
| 14410 |
% |
| 14411 |
% \bigskip |
| 14412 |
% The command |\@@_create_nodes:| is used twice: for the construction |
| 14413 |
% of the ``medium nodes'' and for the construction of the ``large nodes''. The |
| 14414 |
% nodes are constructed with the value of all the dimensions |
| 14415 |
% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, |
| 14416 |
% \texttt{l_@@_column_\textsl{j}_min_dim} and |
| 14417 |
% \texttt{l_@@_column_\textsl{j}_max_dim}. Between the construction of the |
| 14418 |
% ``medium nodes'' and the ``large nodes'', the values of these dimensions are |
| 14419 |
% changed. |
| 14420 |
% |
| 14421 |
% The function also uses |\l_@@_suffix_tl| (|-medium| or |-large|). |
| 14422 |
% \begin{macrocode} |
| 14423 |
\cs_new_protected:Npn \@@_create_nodes: |
| 14424 |
{ |
| 14425 |
\int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: |
| 14426 |
{ |
| 14427 |
\int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: |
| 14428 |
{ |
| 14429 |
% \end{macrocode} |
| 14430 |
% We draw the rectangular node for the cell (|\@@_i|-|\@@_j|). |
| 14431 |
% \begin{macrocode} |
| 14432 |
\@@_pgf_rect_node:nnnnn |
| 14433 |
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14434 |
{ \dim_use:c { l_@@_column_ \@@_j: _min_dim } } |
| 14435 |
{ \dim_use:c { l_@@_row_ \@@_i: _min_dim } } |
| 14436 |
{ \dim_use:c { l_@@_column_ \@@_j: _max_dim } } |
| 14437 |
{ \dim_use:c { l_@@_row_ \@@_i: _max_dim } } |
| 14438 |
\str_if_empty:NF \l_@@_name_str |
| 14439 |
{ |
| 14440 |
\pgfnodealias |
| 14441 |
{ \l_@@_name_str - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14442 |
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14443 |
} |
| 14444 |
} |
| 14445 |
} |
| 14446 |
\int_step_inline:nn \c@iRow |
| 14447 |
{ |
| 14448 |
\pgfnodealias |
| 14449 |
{ \@@_env: - ##1 - last \l_@@_suffix_tl } |
| 14450 |
{ \@@_env: - ##1 - \int_use:N \c@jCol \l_@@_suffix_tl } |
| 14451 |
} |
| 14452 |
\int_step_inline:nn \c@jCol |
| 14453 |
{ |
| 14454 |
\pgfnodealias |
| 14455 |
{ \@@_env: - last - ##1 \l_@@_suffix_tl } |
| 14456 |
{ \@@_env: - \int_use:N \c@iRow - ##1 \l_@@_suffix_tl } |
| 14457 |
} |
| 14458 |
\pgfnodealias |
| 14459 |
{ \@@_env: - last - last \l_@@_suffix_tl } |
| 14460 |
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol \l_@@_suffix_tl } |
| 14461 |
% \end{macrocode} |
| 14462 |
% Now, we create the nodes for the cells of the |\multicolumn|. We recall that |
| 14463 |
% we have stored in |\g_@@_multicolumn_cells_seq| the list of the cells where a |
| 14464 |
% |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in |
| 14465 |
% |\g_@@_multicolumn_sizes_seq| the correspondent values of $n$. |
| 14466 |
% \begin{macrocode} |
| 14467 |
\seq_map_pairwise_function:NNN |
| 14468 |
\g_@@_multicolumn_cells_seq |
| 14469 |
\g_@@_multicolumn_sizes_seq |
| 14470 |
\@@_node_for_multicolumn:nn |
| 14471 |
} |
| 14472 |
% \end{macrocode} |
| 14473 |
% |
| 14474 |
% |
| 14475 |
% \bigskip |
| 14476 |
% \begin{macrocode} |
| 14477 |
\cs_new_protected:Npn \@@_extract_coords_values: #1 - #2 \q_stop |
| 14478 |
{ |
| 14479 |
\cs_set_nopar:Npn \@@_i: { #1 } |
| 14480 |
\cs_set_nopar:Npn \@@_j: { #2 } |
| 14481 |
} |
| 14482 |
% \end{macrocode} |
| 14483 |
% |
| 14484 |
% The command |\@@_node_for_multicolumn:nn| takes two arguments. The first is |
| 14485 |
% the position of the cell where the command |\multicolumn{|$n$|}{...}{...}| was |
| 14486 |
% issued in the format $i$|-|$j$ and the second is the value of~$n$ (the length |
| 14487 |
% of the ``multi-cell''). |
| 14488 |
% \begin{macrocode} |
| 14489 |
\cs_new_protected:Npn \@@_node_for_multicolumn:nn #1 #2 |
| 14490 |
{ |
| 14491 |
\@@_extract_coords_values: #1 \q_stop |
| 14492 |
\@@_pgf_rect_node:nnnnn |
| 14493 |
{ \@@_env: - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14494 |
{ \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } } |
| 14495 |
{ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } } |
| 14496 |
{ \dim_use:c { l_@@_column _ \int_eval:n { \@@_j: +#2-1 } _ max _ dim } } |
| 14497 |
{ \dim_use:c { l_@@_row _ \@@_i: _ max _ dim } } |
| 14498 |
\str_if_empty:NF \l_@@_name_str |
| 14499 |
{ |
| 14500 |
\pgfnodealias |
| 14501 |
{ \l_@@_name_str - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14502 |
{ \int_use:N \g_@@_env_int - \@@_i: - \@@_j: \l_@@_suffix_tl } |
| 14503 |
} |
| 14504 |
} |
| 14505 |
% \end{macrocode} |
| 14506 |
% |
| 14507 |
% \bigskip |
| 14508 |
% \section{The blocks} |
| 14509 |
% |
| 14510 |
% The following code deals with the command |\Block|. This command has no direct |
| 14511 |
% link with the environment |{NiceMatrixBlock}|. |
| 14512 |
% |
| 14513 |
% \bigskip |
| 14514 |
% The options of the command |\Block| will be analyzed first in the cell of the |
| 14515 |
% array (and once again when the block will be put in the array). |
| 14516 |
% Here is the set of keys for the first pass (in the cell of the array). |
| 14517 |
% \begin{macrocode} |
| 14518 |
\keys_define:nn { nicematrix / BlockFirstPass } |
| 14519 |
{ |
| 14520 |
j .code:n = \str_set:Nn \l_@@_hpos_block_str j |
| 14521 |
\bool_set_true:N \l_@@_p_block_bool , |
| 14522 |
j .value_forbidden:n = true , |
| 14523 |
l .code:n = \str_set:Nn \l_@@_hpos_block_str l , |
| 14524 |
l .value_forbidden:n = true , |
| 14525 |
r .code:n = \str_set:Nn \l_@@_hpos_block_str r , |
| 14526 |
r .value_forbidden:n = true , |
| 14527 |
c .code:n = \str_set:Nn \l_@@_hpos_block_str c , |
| 14528 |
c .value_forbidden:n = true , |
| 14529 |
L .code:n = \str_set:Nn \l_@@_hpos_block_str l , |
| 14530 |
L .value_forbidden:n = true , |
| 14531 |
R .code:n = \str_set:Nn \l_@@_hpos_block_str r , |
| 14532 |
R .value_forbidden:n = true , |
| 14533 |
C .code:n = \str_set:Nn \l_@@_hpos_block_str c , |
| 14534 |
C .value_forbidden:n = true , |
| 14535 |
t .code:n = \str_set:Nn \l_@@_vpos_block_str t , |
| 14536 |
t .value_forbidden:n = true , |
| 14537 |
T .code:n = \str_set:Nn \l_@@_vpos_block_str T , |
| 14538 |
T .value_forbidden:n = true , |
| 14539 |
b .code:n = \str_set:Nn \l_@@_vpos_block_str b , |
| 14540 |
b .value_forbidden:n = true , |
| 14541 |
B .code:n = \str_set:Nn \l_@@_vpos_block_str B , |
| 14542 |
B .value_forbidden:n = true , |
| 14543 |
m .code:n = \str_set:Nn \l_@@_vpos_block_str c , |
| 14544 |
m .value_forbidden:n = true , |
| 14545 |
v-center .meta:n = m , |
| 14546 |
p .code:n = \bool_set_true:N \l_@@_p_block_bool , |
| 14547 |
p .value_forbidden:n = true , |
| 14548 |
respect-arraystretch .code:n = |
| 14549 |
\cs_set_eq:NN \@@_reset_arraystretch: \prg_do_nothing: , |
| 14550 |
respect-arraystretch .value_forbidden:n = true , |
| 14551 |
% \end{macrocode} |
| 14552 |
% The following key is no longer documented in |nicematrix.tex| and |
| 14553 |
% |nicematrix-french.tex|. It should be considered as deprecated. |
| 14554 |
% \begin{macrocode} |
| 14555 |
color .code:n = |
| 14556 |
\@@_color:n { #1 } |
| 14557 |
\tl_set_rescan:Nnn |
| 14558 |
\l_@@_draw_tl |
| 14559 |
{ \char_set_catcode_other:N ! } |
| 14560 |
{ #1 } , |
| 14561 |
color .value_required:n = true , |
| 14562 |
} |
| 14563 |
% \end{macrocode} |
| 14564 |
% |
| 14565 |
% |
| 14566 |
% |
| 14567 |
% The following command |\@@_Block:| will be linked to |\Block| in the |
| 14568 |
% environments of \pkg{nicematrix}. We define it with |
| 14569 |
% |\NewExpandableDocumentCommand| because it has an optional argument between~ |
| 14570 |
% |<| and~|>|. It's mandatory to use an expandable command. |
| 14571 |
% |
| 14572 |
% \begin{macrocode} |
| 14573 |
\cs_new_protected:Npn \@@_Block: { \@@_collect_options:n { \@@_Block_i: } } |
| 14574 |
% \end{macrocode} |
| 14575 |
% |
| 14576 |
% \bigskip |
| 14577 |
% \begin{macrocode} |
| 14578 |
\NewExpandableDocumentCommand \@@_Block_i: { m m D < > { } +m } |
| 14579 |
{ |
| 14580 |
% \end{macrocode} |
| 14581 |
% If the first mandatory argument of the command (which is the size of the block |
| 14582 |
% with the syntax $i$|-|$j$) has not been provided by the user, you use |1-1| |
| 14583 |
% (that is to say a block of only one cell). |
| 14584 |
% \begin{macrocode} |
| 14585 |
\tl_if_blank:nTF { #2 } |
| 14586 |
{ \@@_Block_ii:nnnnn 1 1 } |
| 14587 |
{ |
| 14588 |
\tl_if_in:nnTF { #2 } { - } |
| 14589 |
{ |
| 14590 |
\int_compare:nNnTF { \char_value_catcode:n { 45 } } = { 13 } |
| 14591 |
\@@_Block_i_czech:w \@@_Block_i:w |
| 14592 |
#2 \q_stop |
| 14593 |
} |
| 14594 |
{ |
| 14595 |
\@@_error:nn { Bad~argument~for~Block } { #2 } |
| 14596 |
\@@_Block_ii:nnnnn 1 1 |
| 14597 |
} |
| 14598 |
} |
| 14599 |
{ #1 } { #3 } { #4 } |
| 14600 |
\ignorespaces |
| 14601 |
} |
| 14602 |
% \end{macrocode} |
| 14603 |
% |
| 14604 |
% \medskip |
| 14605 |
% With the following construction, we extract the values of $i$ and $j$ in the |
| 14606 |
% first mandatory argument of the command. |
| 14607 |
% \begin{macrocode} |
| 14608 |
\cs_new:Npn \@@_Block_i:w #1-#2 \q_stop { \@@_Block_ii:nnnnn { #1 } { #2 } } |
| 14609 |
% \end{macrocode} |
| 14610 |
% |
| 14611 |
% With \pkg{babel} with the key |czech|, the character |-| (hyphen) is active. |
| 14612 |
% That's why we need a special version. Remark that we could not use a |
| 14613 |
% preprocessor in the command |\@@_Block:| to do the job because the command |
| 14614 |
% |\@@_Block:| is defined with the command |\NewExpandableDocumentCommand|. |
| 14615 |
% \begin{macrocode} |
| 14616 |
{ |
| 14617 |
\char_set_catcode_active:N - |
| 14618 |
\cs_new:Npn \@@_Block_i_czech:w #1-#2 \q_stop { \@@_Block_ii:nnnnn { #1 } { #2 } } |
| 14619 |
} |
| 14620 |
% \end{macrocode} |
| 14621 |
% |
| 14622 |
% \medskip |
| 14623 |
% Now, the arguments have been extracted: |
| 14624 |
% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of |
| 14625 |
% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are |
| 14626 |
% the tokens to put before the math mode and before the composition of the block |
| 14627 |
% and |#5| is the label (=content) of the block. |
| 14628 |
% \begin{macrocode} |
| 14629 |
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5 |
| 14630 |
{ |
| 14631 |
% \end{macrocode} |
| 14632 |
% |
| 14633 |
% \medskip |
| 14634 |
% We recall that |#1| and |#2| have been extracted from the first mandatory |
| 14635 |
% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is |
| 14636 |
% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a |
| 14637 |
% missing value by 100 (it's a convention: when the block will actually be drawn |
| 14638 |
% these values will be detected and interpreted as \emph{maximal possible |
| 14639 |
% value} according to the actual size of the array). |
| 14640 |
% \begin{macrocode} |
| 14641 |
\bool_lazy_or:nnTF |
| 14642 |
{ \tl_if_blank_p:n { #1 } } |
| 14643 |
{ \str_if_eq_p:ee { * } { #1 } } |
| 14644 |
{ \int_set:Nn \l_tmpa_int { 100 } } |
| 14645 |
{ \int_set:Nn \l_tmpa_int { #1 } } |
| 14646 |
\bool_lazy_or:nnTF |
| 14647 |
{ \tl_if_blank_p:n { #2 } } |
| 14648 |
{ \str_if_eq_p:ee { * } { #2 } } |
| 14649 |
{ \int_set:Nn \l_tmpb_int { 100 } } |
| 14650 |
{ \int_set:Nn \l_tmpb_int { #2 } } |
| 14651 |
% \end{macrocode} |
| 14652 |
% |
| 14653 |
% \medskip |
| 14654 |
% If the block is mono-column. |
| 14655 |
% \begin{macrocode} |
| 14656 |
\int_compare:nNnTF \l_tmpb_int = 1 |
| 14657 |
{ |
| 14658 |
\tl_if_empty:NTF \l_@@_hpos_cell_tl |
| 14659 |
{ \str_set_eq:NN \l_@@_hpos_block_str \c_@@_c_str } |
| 14660 |
{ \str_set:No \l_@@_hpos_block_str \l_@@_hpos_cell_tl } |
| 14661 |
} |
| 14662 |
{ \str_set_eq:NN \l_@@_hpos_block_str \c_@@_c_str } |
| 14663 |
% \end{macrocode} |
| 14664 |
% The value of |\l_@@_hpos_block_str| may be modified by the keys of the |
| 14665 |
% command |\Block| that we will analyze now. |
| 14666 |
% |
| 14667 |
% \medskip |
| 14668 |
% \begin{macrocode} |
| 14669 |
\keys_set_known:nn { nicematrix / BlockFirstPass } { #3 } |
| 14670 |
% \end{macrocode} |
| 14671 |
% |
| 14672 |
% \begin{macrocode} |
| 14673 |
\tl_set:Ne \l_tmpa_tl |
| 14674 |
{ |
| 14675 |
{ \int_use:N \c@iRow } |
| 14676 |
{ \int_use:N \c@jCol } |
| 14677 |
{ \int_eval:n { \c@iRow + \l_tmpa_int - 1 } } |
| 14678 |
{ \int_eval:n { \c@jCol + \l_tmpb_int - 1 } } |
| 14679 |
} |
| 14680 |
% \end{macrocode} |
| 14681 |
% Now, |\l_tmpa_tl| contains an ``object'' corresponding to the position of the |
| 14682 |
% block with four components, each of them surrounded by curly brackets: |
| 14683 |
% |
| 14684 |
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|. |
| 14685 |
% |
| 14686 |
% |
| 14687 |
% \medskip |
| 14688 |
% We have different treatments when the key |p| is used and when the block is |
| 14689 |
% mono-column or mono-row, etc. That's why we have several macros: |
| 14690 |
% |\@@_Block_iv:nnnnn|, |\@@_Block_v:nnnnn|, |\@@_Block_vi:nnnn|, etc. (the five |
| 14691 |
% arguments of those macros are provided by curryfication). |
| 14692 |
% \begin{macrocode} |
| 14693 |
\bool_set_false:N \l_tmpa_bool |
| 14694 |
\bool_if:NT \l_@@_amp_in_blocks_bool |
| 14695 |
% \end{macrocode} |
| 14696 |
% |\tl_if_in:nnT| is slightly faster than |\str_if_in:nnT|. |
| 14697 |
% \begin{macrocode} |
| 14698 |
{ \tl_if_in:nnT { #5 } { & } { \bool_set_true:N \l_tmpa_bool } } |
| 14699 |
\bool_case:nF |
| 14700 |
{ |
| 14701 |
\l_tmpa_bool { \@@_Block_vii:eennn } |
| 14702 |
\l_@@_p_block_bool { \@@_Block_vi:eennn } |
| 14703 |
% \end{macrocode} |
| 14704 |
% For the blocks mono-column, we will compose right away in a box in order to |
| 14705 |
% compute its width and take that width into account for the width of the |
| 14706 |
% column. However, if the column is a |X| column, we should not do that since |
| 14707 |
% the width is determined by another way. This should be the same for the |p|, |
| 14708 |
% |m| and |b| columns and we should modify that point. However, for the |X| |
| 14709 |
% column, it's imperative. Otherwise, the process for the determination of the |
| 14710 |
% widths of the columns will be wrong. |
| 14711 |
% \begin{macrocode} |
| 14712 |
\l_@@_X_bool { \@@_Block_v:eennn } |
| 14713 |
{ \tl_if_empty_p:n { #5 } } { \@@_Block_v:eennn } |
| 14714 |
{ \int_compare_p:nNn \l_tmpa_int = \c_one_int } { \@@_Block_iv:eennn } |
| 14715 |
{ \int_compare_p:nNn \l_tmpb_int = \c_one_int } { \@@_Block_iv:eennn } |
| 14716 |
} |
| 14717 |
{ \@@_Block_v:eennn } |
| 14718 |
{ \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 } |
| 14719 |
} |
| 14720 |
% \end{macrocode} |
| 14721 |
% |
| 14722 |
% |
| 14723 |
% \bigskip |
| 14724 |
% The following macro is for the case of a |\Block| which is mono-row or |
| 14725 |
% mono-column (or both) and don't use the key~|p|. In that case, the content of |
| 14726 |
% the block is composed right away in a box (because we have to take into account |
| 14727 |
% the dimensions of that box for the width of the current column or the height |
| 14728 |
% and the depth of the current row). However, that box will be put in the array |
| 14729 |
% \emph{after the construction of the array} (by using \textsc{pgf}) with |
| 14730 |
% |\@@_draw_blocks:| and above all |\@@_Block_v:nnnnnn| which will do the main |
| 14731 |
% job. |
| 14732 |
% |
| 14733 |
% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of |
| 14734 |
% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are |
| 14735 |
% the tokens to put before the potential math mode and before the composition of |
| 14736 |
% the block and |#5| is the label (=content) of the block. |
| 14737 |
% \begin{macrocode} |
| 14738 |
\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5 |
| 14739 |
{ |
| 14740 |
\int_gincr:N \g_@@_block_box_int |
| 14741 |
\cs_set_eq:NN \cellcolor \@@_cellcolor_error |
| 14742 |
\cs_set_eq:NN \rowcolor \@@_rowcolor_error |
| 14743 |
\cs_set_protected_nopar:Npn \diagbox ##1 ##2 |
| 14744 |
{ |
| 14745 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 14746 |
{ |
| 14747 |
\@@_draw_diagbox:nnnnnn |
| 14748 |
{ \int_use:N \c@iRow } |
| 14749 |
{ \int_use:N \c@jCol } |
| 14750 |
{ \int_eval:n { \c@iRow + #1 - 1 } } |
| 14751 |
{ \int_eval:n { \c@jCol + #2 - 1 } } |
| 14752 |
{ \g_@@_row_style_tl \exp_not:n { ##1 } } |
| 14753 |
{ \g_@@_row_style_tl \exp_not:n { ##2 } } |
| 14754 |
} |
| 14755 |
} |
| 14756 |
\box_gclear_new:c |
| 14757 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 14758 |
% \end{macrocode} |
| 14759 |
% Now, we will actually compose the content of the |\Block| in a TeX box. |
| 14760 |
% \emph{Be careful}: if after the construction of the box, the boolean |
| 14761 |
% |\g_@@_rotate_bool| is raised (which means that the command |\rotate| was |
| 14762 |
% present in the content of the |\Block|) we will rotate the box but also, |
| 14763 |
% maybe, change the position of the baseline! |
| 14764 |
% \begin{macrocode} |
| 14765 |
\hbox_gset:cn |
| 14766 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 14767 |
{ |
| 14768 |
% \end{macrocode} |
| 14769 |
% For a mono-column block, if the user has specified a color for the column in |
| 14770 |
% the preamble of the array, we want to fix that color in the box we construct. |
| 14771 |
% We do that with |\set@color| and not |\color_ensure_current:| (in order to use |
| 14772 |
% |\color_ensure_current:| safely, you should load \pkg{l3backend} before the |
| 14773 |
% |\documentclass|). |
| 14774 |
% \begin{macrocode} |
| 14775 |
\tl_if_empty:NTF \l_@@_color_tl |
| 14776 |
{ \int_compare:nNnT { #2 } = 1 \set@color } |
| 14777 |
{ \@@_color:o \l_@@_color_tl } |
| 14778 |
% \end{macrocode} |
| 14779 |
% If the block is mono-row, we use |\g_@@_row_style_tl| even if it has yet been |
| 14780 |
% used in the beginning of the cell where the command |\Block| has been issued |
| 14781 |
% because we want to be able to take into account a potential instruction of |
| 14782 |
% color of the font in |\g_@@_row_style_tl|. |
| 14783 |
% \begin{macrocode} |
| 14784 |
\int_compare:nNnT { #1 } = 1 |
| 14785 |
{ |
| 14786 |
\int_if_zero:nTF \c@iRow |
| 14787 |
{ |
| 14788 |
% \end{macrocode} |
| 14789 |
% |
| 14790 |
% \bigskip |
| 14791 |
% In the following code, the value of |code-for-first-row| contains a |\Block| |
| 14792 |
% (in order to have the ``first row'' centered). But, that block will be |
| 14793 |
% executed, since it is entirely contained in the first row, the value of |
| 14794 |
% |code-for-first-row| will be inserted once again... with the same command |
| 14795 |
% |\Block|. That's why we have to nullify the command |\Block.| |
| 14796 |
% \begin{Verbatim} |
| 14797 |
% $\begin{bNiceMatrix}% |
| 14798 |
% [ |
| 14799 |
% r, |
| 14800 |
% first-row, |
| 14801 |
% last-col, |
| 14802 |
% code-for-first-row = \Block{}{\scriptstyle\color{blue} \arabic{jCol}}, |
| 14803 |
% code-for-last-col = \scriptstyle \color{blue} \arabic{iRow} |
| 14804 |
% ] |
| 14805 |
% & & & & \\ |
| 14806 |
% -2 & 3 & -4 & 5 & \\ |
| 14807 |
% 3 & -4 & 5 & -6 & \\ |
| 14808 |
% -4 & 5 & -6 & 7 & \\ |
| 14809 |
% 5 & -6 & 7 & -8 & \\ |
| 14810 |
% \end{bNiceMatrix}$ |
| 14811 |
% \end{Verbatim} |
| 14812 |
% |
| 14813 |
% \begin{macrocode} |
| 14814 |
\cs_set_eq:NN \Block \@@_NullBlock: |
| 14815 |
\l_@@_code_for_first_row_tl |
| 14816 |
} |
| 14817 |
{ |
| 14818 |
\int_compare:nNnT \c@iRow = \l_@@_last_row_int |
| 14819 |
{ |
| 14820 |
\cs_set_eq:NN \Block \@@_NullBlock: |
| 14821 |
\l_@@_code_for_last_row_tl |
| 14822 |
} |
| 14823 |
} |
| 14824 |
\g_@@_row_style_tl |
| 14825 |
} |
| 14826 |
% \end{macrocode} |
| 14827 |
% The following command will be no-op when |respect-arraystretch| is in force. |
| 14828 |
% \begin{macrocode} |
| 14829 |
\@@_reset_arraystretch: |
| 14830 |
\dim_zero:N \extrarowheight |
| 14831 |
% \end{macrocode} |
| 14832 |
% |#4| is the optional argument of the command |\Block|, provided with the |
| 14833 |
% syntax |<...>|. |
| 14834 |
% \begin{macrocode} |
| 14835 |
#4 |
| 14836 |
% \end{macrocode} |
| 14837 |
% We adjust |\l_@@_hpos_block_str| when |\rotate| has been used (in the cell |
| 14838 |
% where the command |\Block| is used but maybe in |#4|, |\RowStyle|, |
| 14839 |
% |code-for-first-row|, etc.). |
| 14840 |
% \begin{macrocode} |
| 14841 |
\@@_adjust_hpos_rotate: |
| 14842 |
% \end{macrocode} |
| 14843 |
% The boolean |\g_@@_rotate_bool| will be also considered \emph{after the composition |
| 14844 |
% of the box} (in order to rotate the box). |
| 14845 |
% |
| 14846 |
% \medskip |
| 14847 |
% Remind that we are in the command of composition of the box of the block. |
| 14848 |
% Previously, we have only done some tuning. Now, we will actually compose the |
| 14849 |
% content with a |{tabular}|, an |{array}| or a |{minipage}|. |
| 14850 |
% \begin{macrocode} |
| 14851 |
\bool_if:NTF \l_@@_tabular_bool |
| 14852 |
{ |
| 14853 |
\bool_lazy_all:nTF |
| 14854 |
{ |
| 14855 |
{ \int_compare_p:nNn { #2 } = 1 } |
| 14856 |
% \end{macrocode} |
| 14857 |
% Remind that, when the column has not a fixed width, the dimension |
| 14858 |
% |\l_@@_col_width_dim| has the conventional value of $-1$~cm. |
| 14859 |
% \begin{macrocode} |
| 14860 |
{ ! \dim_compare_p:nNn \l_@@_col_width_dim < \c_zero_dim } |
| 14861 |
{ ! \g_@@_rotate_bool } |
| 14862 |
} |
| 14863 |
% \end{macrocode} |
| 14864 |
% When the block is mono-column in a column with a fixed width (e.g. |p{3cm}|), we |
| 14865 |
% use a |{minipage}|. |
| 14866 |
% \begin{macrocode} |
| 14867 |
{ |
| 14868 |
\use:e |
| 14869 |
{ |
| 14870 |
% \end{macrocode} |
| 14871 |
% Curiously, |\exp_not:N| is still mandatory when |tagging=on|. |
| 14872 |
% \begin{macrocode} |
| 14873 |
\exp_not:N \begin { minipage } |
| 14874 |
[ \str_lowercase:f \l_@@_vpos_block_str ] |
| 14875 |
{ \l_@@_col_width_dim } |
| 14876 |
\str_case:on \l_@@_hpos_block_str |
| 14877 |
{ c \centering r \raggedleft l \raggedright } |
| 14878 |
} |
| 14879 |
#5 |
| 14880 |
\end { minipage } |
| 14881 |
} |
| 14882 |
% \end{macrocode} |
| 14883 |
% In the other cases, we use a |{tabular}|. |
| 14884 |
% \begin{macrocode} |
| 14885 |
{ |
| 14886 |
\use:e |
| 14887 |
{ |
| 14888 |
% \end{macrocode} |
| 14889 |
% Curiously, |\exp_not:N| is still mandatory when |tagging=on|. |
| 14890 |
% \begin{macrocode} |
| 14891 |
\exp_not:N \begin { tabular } |
| 14892 |
[ \str_lowercase:f \l_@@_vpos_block_str ] |
| 14893 |
{ @ { } \l_@@_hpos_block_str @ { } } |
| 14894 |
} |
| 14895 |
#5 |
| 14896 |
\end { tabular } |
| 14897 |
} |
| 14898 |
} |
| 14899 |
% \end{macrocode} |
| 14900 |
% If we are in a mathematical array (|\l_@@_tabular_bool| is |false|). The |
| 14901 |
% composition is always done with an |{array}| (never with a |{minipage}|). |
| 14902 |
% \begin{macrocode} |
| 14903 |
{ |
| 14904 |
$ % $ |
| 14905 |
\bool_if:NT \l_@@_small_bool % 2026/04/05 |
| 14906 |
{ |
| 14907 |
\def \arraystretch { 0.47 } |
| 14908 |
\dim_set:Nn \arraycolsep { 1.45 pt } |
| 14909 |
} |
| 14910 |
\use:e |
| 14911 |
{ |
| 14912 |
% \end{macrocode} |
| 14913 |
% Curiously, |\exp_not:N| is still mandatory when |tagging=on|. |
| 14914 |
% \begin{macrocode} |
| 14915 |
\exp_not:N \begin { array } |
| 14916 |
[ \str_lowercase:f \l_@@_vpos_block_str ] |
| 14917 |
{ @ { } \l_@@_hpos_block_str @ { } } |
| 14918 |
} |
| 14919 |
\@@_tuning_key_small: % 2026/04/05 |
| 14920 |
#5 |
| 14921 |
\end { array } |
| 14922 |
$ % $ |
| 14923 |
} |
| 14924 |
} |
| 14925 |
% \end{macrocode} |
| 14926 |
% The box which will contain the content of the block has now been composed. |
| 14927 |
% |
| 14928 |
% \bigskip |
| 14929 |
% If there were |\rotate| (which raises |\g_@@_rotate_bool|) in the content of |
| 14930 |
% the |\Block|, we do a rotation of the box (and we also adjust the |
| 14931 |
% baseline of the rotated box). |
| 14932 |
% \begin{macrocode} |
| 14933 |
\bool_if:NT \g_@@_rotate_bool \@@_rotate_box_of_block: |
| 14934 |
% \end{macrocode} |
| 14935 |
% |
| 14936 |
% If we are in a mono-column block, we take into account the width of that block |
| 14937 |
% for the width of the column. |
| 14938 |
% \begin{macrocode} |
| 14939 |
\int_compare:nNnT { #2 } = 1 |
| 14940 |
{ |
| 14941 |
\dim_gset:Nn \g_@@_blocks_wd_dim |
| 14942 |
{ |
| 14943 |
\dim_max:nn |
| 14944 |
\g_@@_blocks_wd_dim |
| 14945 |
{ |
| 14946 |
\box_wd:c |
| 14947 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 14948 |
} |
| 14949 |
} |
| 14950 |
} |
| 14951 |
% \end{macrocode} |
| 14952 |
% If we are in a mono-row block we take into account the height and the depth of |
| 14953 |
% that block for the height and the depth of the row, excepted when the block |
| 14954 |
% uses explicitely an option of vertical position |T| or |B|. |
| 14955 |
% Remind that if the user has not used a key for the vertical position of the block, |
| 14956 |
% then |\l_@@_vpos_block_str| remains empty. |
| 14957 |
% \begin{macrocode} |
| 14958 |
\int_compare:nNnT { #1 } = 1 |
| 14959 |
{ |
| 14960 |
\bool_lazy_any:nT |
| 14961 |
{ |
| 14962 |
{ \str_if_empty_p:N \l_@@_vpos_block_str } |
| 14963 |
{ \str_if_eq_p:ee t \l_@@_vpos_block_str } |
| 14964 |
{ \str_if_eq_p:ee b \l_@@_vpos_block_str } |
| 14965 |
} |
| 14966 |
\@@_adjust_blocks_ht_dp: |
| 14967 |
} |
| 14968 |
\seq_gput_right:Ne \g_@@_blocks_seq |
| 14969 |
{ |
| 14970 |
\l_tmpa_tl |
| 14971 |
% \end{macrocode} |
| 14972 |
% In the list of options |#3|, maybe there is a key for the horizontal alignment |
| 14973 |
% (|l|, |r| or |c|). In that case, that key has been read and stored in |
| 14974 |
% |\l_@@_hpos_block_str|. However, maybe there were no key of the horizontal |
| 14975 |
% alignment and that's why we put a key corresponding to the value of |
| 14976 |
% |\l_@@_hpos_block_str|, which is fixed by the type of current column. |
| 14977 |
% \begin{macrocode} |
| 14978 |
{ |
| 14979 |
\exp_not:n { #3 } , |
| 14980 |
\l_@@_hpos_block_str , |
| 14981 |
% \end{macrocode} |
| 14982 |
% Now, we put a key for the vertical alignment. |
| 14983 |
% \begin{macrocode} |
| 14984 |
\bool_if:NT \g_@@_rotate_bool |
| 14985 |
{ |
| 14986 |
\bool_if:NTF \g_@@_rotate_c_bool |
| 14987 |
{ m } |
| 14988 |
{ |
| 14989 |
\int_compare:nNnT \c@iRow = \l_@@_last_row_int |
| 14990 |
{ T } |
| 14991 |
} |
| 14992 |
} |
| 14993 |
} |
| 14994 |
{ |
| 14995 |
\box_use_drop:c |
| 14996 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 14997 |
} |
| 14998 |
} |
| 14999 |
\bool_set_false:N \g_@@_rotate_c_bool |
| 15000 |
} |
| 15001 |
% \end{macrocode} |
| 15002 |
% |
| 15003 |
% |
| 15004 |
% \begin{macrocode} |
| 15005 |
\cs_new_protected:Npn \@@_adjust_blocks_ht_dp: |
| 15006 |
{ |
| 15007 |
\dim_gset:Nn \g_@@_blocks_ht_dim |
| 15008 |
{ |
| 15009 |
\dim_max:nn |
| 15010 |
\g_@@_blocks_ht_dim |
| 15011 |
{ |
| 15012 |
\box_ht:c |
| 15013 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15014 |
} |
| 15015 |
} |
| 15016 |
\dim_gset:Nn \g_@@_blocks_dp_dim |
| 15017 |
{ |
| 15018 |
\dim_max:nn |
| 15019 |
\g_@@_blocks_dp_dim |
| 15020 |
{ |
| 15021 |
\box_dp:c |
| 15022 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15023 |
} |
| 15024 |
} |
| 15025 |
} |
| 15026 |
% \end{macrocode} |
| 15027 |
% |
| 15028 |
% \bigskip |
| 15029 |
% \begin{macrocode} |
| 15030 |
\cs_new:Npn \@@_adjust_hpos_rotate: |
| 15031 |
{ |
| 15032 |
\bool_if:NT \g_@@_rotate_bool |
| 15033 |
{ |
| 15034 |
\str_set:Ne \l_@@_hpos_block_str |
| 15035 |
{ |
| 15036 |
\bool_if:NTF \g_@@_rotate_c_bool |
| 15037 |
c |
| 15038 |
{ |
| 15039 |
\str_case:onF \l_@@_vpos_block_str |
| 15040 |
{ b l B l t r T r } |
| 15041 |
{ |
| 15042 |
\int_compare:nNnTF \c@iRow = \l_@@_last_row_int |
| 15043 |
r |
| 15044 |
l |
| 15045 |
} |
| 15046 |
} |
| 15047 |
} |
| 15048 |
} |
| 15049 |
} |
| 15050 |
\cs_generate_variant:Nn \@@_Block_iv:nnnnn { e e } |
| 15051 |
% \end{macrocode} |
| 15052 |
% |
| 15053 |
% \bigskip |
| 15054 |
% Despite its name the following command rotates the box of the block \emph{but |
| 15055 |
% also does vertical adjustment of the baseline of the block}. |
| 15056 |
% \begin{macrocode} |
| 15057 |
\cs_new_protected:Npn \@@_rotate_box_of_block: |
| 15058 |
{ |
| 15059 |
\box_grotate:cn |
| 15060 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15061 |
{ \bool_if:NTF \g_@@_rotate_minus_bool { -90 } { 90 } } |
| 15062 |
\int_compare:nNnT \c@iRow = \l_@@_last_row_int |
| 15063 |
{ |
| 15064 |
\vbox_gset_top:cn |
| 15065 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15066 |
{ |
| 15067 |
\skip_vertical:n { 0.8 ex } |
| 15068 |
\box_use:c |
| 15069 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15070 |
} |
| 15071 |
} |
| 15072 |
\bool_if:NT \g_@@_rotate_c_bool |
| 15073 |
{ |
| 15074 |
\hbox_gset:cn |
| 15075 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15076 |
{ |
| 15077 |
\IfFormatAtLeastTF { 2026-04-01} |
| 15078 |
{ |
| 15079 |
\vbox_center:n |
| 15080 |
{ |
| 15081 |
\box_use:c |
| 15082 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15083 |
} |
| 15084 |
} |
| 15085 |
{ |
| 15086 |
$ % $ |
| 15087 |
\vcenter |
| 15088 |
{ |
| 15089 |
\box_use:c |
| 15090 |
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } |
| 15091 |
} |
| 15092 |
$ % $ |
| 15093 |
} |
| 15094 |
} |
| 15095 |
} |
| 15096 |
} |
| 15097 |
% \end{macrocode} |
| 15098 |
% |
| 15099 |
% \bigskip |
| 15100 |
% The following macro is for the standard case, where the block is not mono-row |
| 15101 |
% and not mono-column and does not use the key |p|). In that case, the content of |
| 15102 |
% the block is \emph{not} composed right away in a box. The composition in a box |
| 15103 |
% will be done further, just after the construction of the array (cf. |
| 15104 |
% |\@@_draw_blocks:| and above all |\@@_Block_v:nnnnnn|). |
| 15105 |
% |
| 15106 |
% |#1| is $i$ (the number of rows of the block), |#2| is $j$ (the number of |
| 15107 |
% columns of the block), |#3| is the list of \textsl{key=values} pairs, |#4| are |
| 15108 |
% the tokens to put before the math mode and before the composition of the block |
| 15109 |
% and |#5| is the label (=content) of the block. |
| 15110 |
% \begin{macrocode} |
| 15111 |
\cs_new_protected:Npn \@@_Block_v:nnnnn #1 #2 #3 #4 #5 |
| 15112 |
{ |
| 15113 |
\seq_gput_right:Ne \g_@@_blocks_seq |
| 15114 |
{ |
| 15115 |
\l_tmpa_tl |
| 15116 |
{ \exp_not:n { #3 } } |
| 15117 |
{ |
| 15118 |
\bool_if:NTF \l_@@_tabular_bool |
| 15119 |
{ |
| 15120 |
{ |
| 15121 |
% \end{macrocode} |
| 15122 |
% The following command will be no-op when |respect-arraystretch| is in force. |
| 15123 |
% \begin{macrocode} |
| 15124 |
\@@_reset_arraystretch: |
| 15125 |
\exp_not:n |
| 15126 |
{ |
| 15127 |
\dim_zero:N \extrarowheight |
| 15128 |
#4 |
| 15129 |
% \end{macrocode} |
| 15130 |
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the |
| 15131 |
% tabular used for the content of the cell will be constructed with a format |
| 15132 |
% |c|. In the other cases, the tabular will be constructed with a format equal |
| 15133 |
% to the key of position of the box. In other words: the alignment internal to |
| 15134 |
% the tabular is the same as the external alignment of the tabular (that is to |
| 15135 |
% say the position of the block in its zone of merged cells). |
| 15136 |
% \begin{macrocode} |
| 15137 |
\tag_if_active:T { \tag_stop:n { table } } |
| 15138 |
\use:e |
| 15139 |
{ |
| 15140 |
\exp_not:N \begin { tabular } [ \l_@@_vpos_block_str ] |
| 15141 |
{ @ { } \l_@@_hpos_block_str @ { } } |
| 15142 |
} |
| 15143 |
#5 |
| 15144 |
\end { tabular } |
| 15145 |
} |
| 15146 |
} |
| 15147 |
} |
| 15148 |
% \end{macrocode} |
| 15149 |
% When we are \emph{not} in an environment |{NiceTabular}| (or similar). |
| 15150 |
% \begin{macrocode} |
| 15151 |
{ |
| 15152 |
{ |
| 15153 |
% \end{macrocode} |
| 15154 |
% The following will be no-op when |respect-arraystretch| is in force. |
| 15155 |
% \begin{macrocode} |
| 15156 |
\@@_reset_arraystretch: |
| 15157 |
\exp_not:n |
| 15158 |
{ |
| 15159 |
\dim_zero:N \extrarowheight |
| 15160 |
#4 |
| 15161 |
$ % $ |
| 15162 |
\use:e |
| 15163 |
{ |
| 15164 |
\exp_not:N \begin { array } [ \l_@@_vpos_block_str ] |
| 15165 |
{ @ { } \l_@@_hpos_block_str @ { } } |
| 15166 |
} |
| 15167 |
\@@_tuning_key_small: % 2026/05/04 |
| 15168 |
#5 |
| 15169 |
\end { array } |
| 15170 |
$ % $ |
| 15171 |
} |
| 15172 |
} |
| 15173 |
} |
| 15174 |
} |
| 15175 |
} |
| 15176 |
} |
| 15177 |
\cs_generate_variant:Nn \@@_Block_v:nnnnn { e e } |
| 15178 |
% \end{macrocode} |
| 15179 |
% |
| 15180 |
% \bigskip |
| 15181 |
% The following macro is for the case of a |\Block| which uses the key~|p|. |
| 15182 |
% \begin{macrocode} |
| 15183 |
\cs_new_protected:Npn \@@_Block_vi:nnnnn #1 #2 #3 #4 #5 |
| 15184 |
{ |
| 15185 |
\seq_gput_right:Ne \g_@@_blocks_seq |
| 15186 |
{ |
| 15187 |
\l_tmpa_tl |
| 15188 |
{ \exp_not:n { #3 } } |
| 15189 |
% \end{macrocode} |
| 15190 |
% Here, the curly braces for the group are mandatory. |
| 15191 |
% \begin{macrocode} |
| 15192 |
{ { \exp_not:n { #4 #5 } } } |
| 15193 |
} |
| 15194 |
} |
| 15195 |
\cs_generate_variant:Nn \@@_Block_vi:nnnnn { e e } |
| 15196 |
% \end{macrocode} |
| 15197 |
% |
| 15198 |
% |
| 15199 |
% \bigskip |
| 15200 |
% The following macro is also for the case of a |\Block| which uses the key~|p|. |
| 15201 |
% \begin{macrocode} |
| 15202 |
\cs_new_protected:Npn \@@_Block_vii:nnnnn #1 #2 #3 #4 #5 |
| 15203 |
{ |
| 15204 |
\seq_gput_right:Ne \g_@@_blocks_seq |
| 15205 |
{ |
| 15206 |
\l_tmpa_tl |
| 15207 |
{ \exp_not:n { #3 } } |
| 15208 |
{ \exp_not:n { #4 #5 } } |
| 15209 |
} |
| 15210 |
} |
| 15211 |
\cs_generate_variant:Nn \@@_Block_vii:nnnnn { e e } |
| 15212 |
% \end{macrocode} |
| 15213 |
% |
| 15214 |
% |
| 15215 |
% \bigskip |
| 15216 |
% We recall that the options of the command |\Block| are analyzed twice: first |
| 15217 |
% in the cell of the array and once again when the block will be put in the |
| 15218 |
% array \emph{after the construction of the array} (by using \textsc{pgf}). |
| 15219 |
% |
| 15220 |
% \medskip |
| 15221 |
% \begin{macrocode} |
| 15222 |
\keys_define:nn { nicematrix / Block } |
| 15223 |
{ |
| 15224 |
ampersand-in-blocks .bool_set:N = \l_@@_amp_in_blocks_bool , |
| 15225 |
&-in-blocks .meta:n = ampersand-in-blocks , |
| 15226 |
% \end{macrocode} |
| 15227 |
% The sequence |\l_@@_tikz_seq| will contain a sequence of comma-separated lists |
| 15228 |
% of keys. |
| 15229 |
% \begin{macrocode} |
| 15230 |
tikz .code:n = |
| 15231 |
\IfPackageLoadedTF { tikz } |
| 15232 |
{ \seq_put_right:Nn \l_@@_tikz_seq { { #1 } } } |
| 15233 |
{ \@@_error:n { tikz~key~without~tikz } } , |
| 15234 |
tikz .value_required:n = true , |
| 15235 |
fill .code:n = |
| 15236 |
\tl_set_rescan:Nnn |
| 15237 |
\l_@@_fill_tl |
| 15238 |
{ \char_set_catcode_other:N ! } |
| 15239 |
{ #1 } , |
| 15240 |
fill .value_required:n = true , |
| 15241 |
% \end{macrocode} |
| 15242 |
% \emph{In fine}, the opacity will be applied by |\pgfsetfillopacity|. |
| 15243 |
% \begin{macrocode} |
| 15244 |
opacity .tl_set:N = \l_@@_opacity_tl , |
| 15245 |
opacity .value_required:n = true , |
| 15246 |
draw .code:n = |
| 15247 |
\tl_set_rescan:Nnn |
| 15248 |
\l_@@_draw_tl |
| 15249 |
{ \char_set_catcode_other:N ! } |
| 15250 |
{ #1 } , |
| 15251 |
draw .default:n = default , |
| 15252 |
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , |
| 15253 |
rounded-corners .default:n = 4 pt , |
| 15254 |
color .code:n = |
| 15255 |
\@@_color:n { #1 } |
| 15256 |
\tl_set_rescan:Nnn |
| 15257 |
\l_@@_draw_tl |
| 15258 |
{ \char_set_catcode_other:N ! } |
| 15259 |
{ #1 } , |
| 15260 |
borders .clist_set:N = \l_@@_borders_clist , |
| 15261 |
borders .default:n = all , % added 2026/05/08 |
| 15262 |
hvlines .meta:n = { vlines , hlines } , |
| 15263 |
vlines .bool_set:N = \l_@@_vlines_block_bool, |
| 15264 |
hlines .bool_set:N = \l_@@_hlines_block_bool, |
| 15265 |
rules/width .dim_set:N = \arrayrulewidth , |
| 15266 |
rules/color .tl_set:N = \l_@@_rules_color_tl , |
| 15267 |
rules .code:n = \keys_set:nn { nicematrix / rules } { #1 } , |
| 15268 |
% \end{macrocode} |
| 15269 |
% The key |line-width| is now deprecated (replaced by |rules/width|). |
| 15270 |
% \begin{macrocode} |
| 15271 |
line-width .dim_set:N = \arrayrulewidth , % deprecated |
| 15272 |
% \end{macrocode} |
| 15273 |
% Some keys have not a property |.value_required:n| (or similar) because they |
| 15274 |
% are in |BlockFirstPass|. |
| 15275 |
% \begin{macrocode} |
| 15276 |
j .code:n = \str_set:Nn \l_@@_hpos_block_str j |
| 15277 |
\bool_set_true:N \l_@@_p_block_bool , |
| 15278 |
l .code:n = \str_set:Nn \l_@@_hpos_block_str l , |
| 15279 |
r .code:n = \str_set:Nn \l_@@_hpos_block_str r , |
| 15280 |
c .code:n = \str_set:Nn \l_@@_hpos_block_str c , |
| 15281 |
L .code:n = \str_set:Nn \l_@@_hpos_block_str l |
| 15282 |
\bool_set_true:N \l_@@_hpos_of_block_cap_bool , |
| 15283 |
R .code:n = \str_set:Nn \l_@@_hpos_block_str r |
| 15284 |
\bool_set_true:N \l_@@_hpos_of_block_cap_bool , |
| 15285 |
C .code:n = \str_set:Nn \l_@@_hpos_block_str c |
| 15286 |
\bool_set_true:N \l_@@_hpos_of_block_cap_bool , |
| 15287 |
t .code:n = \str_set:Nn \l_@@_vpos_block_str t , |
| 15288 |
T .code:n = \str_set:Nn \l_@@_vpos_block_str T , |
| 15289 |
b .code:n = \str_set:Nn \l_@@_vpos_block_str b , |
| 15290 |
B .code:n = \str_set:Nn \l_@@_vpos_block_str B , |
| 15291 |
m .code:n = \str_set:Nn \l_@@_vpos_block_str c , |
| 15292 |
m .value_forbidden:n = true , |
| 15293 |
v-center .meta:n = m , |
| 15294 |
p .code:n = \bool_set_true:N \l_@@_p_block_bool , |
| 15295 |
p .value_forbidden:n = true , |
| 15296 |
name .str_set:N = \l_@@_block_name_str , |
| 15297 |
name .value_required:n = true , |
| 15298 |
respect-arraystretch .code:n = |
| 15299 |
\cs_set_eq:NN \@@_reset_arraystretch: \prg_do_nothing: , |
| 15300 |
respect-arraystretch .value_forbidden:n = true , |
| 15301 |
transparent .bool_set:N = \l_@@_transparent_bool , |
| 15302 |
unknown .code:n = |
| 15303 |
\@@_unknown_key:nn |
| 15304 |
{ nicematrix / Block } |
| 15305 |
{ Unknown~key~for~Block } |
| 15306 |
} |
| 15307 |
% \end{macrocode} |
| 15308 |
% |
| 15309 |
% |
| 15310 |
% \bigskip |
| 15311 |
% The command |\@@_draw_blocks:| will draw all the blocks. This command is used |
| 15312 |
% after the construction of the array. We have to revert to a clean version of |
| 15313 |
% |\ialign| because there may be tabulars in the |\Block| instructions that will |
| 15314 |
% be composed now. |
| 15315 |
% \begin{macrocode} |
| 15316 |
\cs_new_protected:Npn \@@_draw_blocks: |
| 15317 |
{ |
| 15318 |
\cs_set_eq:NN \ar@ialign \@@_old_ar@ialign: |
| 15319 |
\seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iv:nnnnnn ##1 } |
| 15320 |
} |
| 15321 |
% \end{macrocode} |
| 15322 |
% |
| 15323 |
% \begin{macrocode} |
| 15324 |
\cs_new_protected:Npn \@@_Block_iv:nnnnnn #1 #2 #3 #4 #5 #6 |
| 15325 |
{ |
| 15326 |
% \end{macrocode} |
| 15327 |
% The integer |\l_@@_last_row_int| will be the last row of the block and |
| 15328 |
% |\l_@@_last_col_int| its last column. |
| 15329 |
% \begin{macrocode} |
| 15330 |
\int_zero:N \l_@@_last_row_int |
| 15331 |
\int_zero:N \l_@@_last_col_int |
| 15332 |
% \end{macrocode} |
| 15333 |
% |
| 15334 |
% We remind that the first mandatory argument of the command |\Block| is the |
| 15335 |
% size of the block with the special format $i$|-|$j$. However, the user is |
| 15336 |
% allowed to omit $i$ or $j$ (or both). This will be interpreted as follows: the |
| 15337 |
% last row (resp. column) of the block will be the last row (resp. column) of |
| 15338 |
% the block (without the potential exterior row---resp. column---of the array). |
| 15339 |
% By convention, this is stored in |\g_@@_blocks_seq| as a number of rows (resp. |
| 15340 |
% columns) for the block equal to 100. That's what we detect now (we write 98 |
| 15341 |
% for the case the the command |\Block| has been issued in the ``first row''). |
| 15342 |
% \begin{macrocode} |
| 15343 |
\int_compare:nNnTF { #3 } > { 98 } |
| 15344 |
{ \int_set_eq:NN \l_@@_last_row_int \c@iRow } |
| 15345 |
{ \int_set:Nn \l_@@_last_row_int { #3 } } |
| 15346 |
\int_compare:nNnTF { #4 } > { 98 } |
| 15347 |
{ \int_set_eq:NN \l_@@_last_col_int \c@jCol } |
| 15348 |
{ \int_set:Nn \l_@@_last_col_int { #4 } } |
| 15349 |
% \end{macrocode} |
| 15350 |
% |
| 15351 |
% \begin{macrocode} |
| 15352 |
\int_compare:nNnTF \l_@@_last_col_int > \g_@@_col_total_int |
| 15353 |
{ |
| 15354 |
\bool_lazy_and:nnTF |
| 15355 |
\l_@@_preamble_bool |
| 15356 |
{ |
| 15357 |
\int_compare_p:n |
| 15358 |
{ \l_@@_last_col_int <= \g_@@_static_num_of_col_int } |
| 15359 |
} |
| 15360 |
{ |
| 15361 |
\msg_error:nnnn { nicematrix } { Block~too~large~2 } { #1 } { #2 } |
| 15362 |
\@@_msg_redirect_name:nn { Block~too~large~2 } { none } |
| 15363 |
\@@_msg_redirect_name:nn { columns~not~used } { none } |
| 15364 |
} |
| 15365 |
{ \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } |
| 15366 |
} |
| 15367 |
{ |
| 15368 |
\int_compare:nNnTF \l_@@_last_row_int > \g_@@_row_total_int |
| 15369 |
{ \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } |
| 15370 |
{ |
| 15371 |
% \end{macrocode} |
| 15372 |
% We expand the four first arguments of |\@@_Block_v:nnnnnn|. |
| 15373 |
% \begin{macrocode} |
| 15374 |
\use:e |
| 15375 |
{ |
| 15376 |
\@@_Block_v:nnnnnn |
| 15377 |
{ #1 } |
| 15378 |
{ #2 } |
| 15379 |
{ \int_use:N \l_@@_last_row_int } |
| 15380 |
{ \int_use:N \l_@@_last_col_int } |
| 15381 |
} |
| 15382 |
{ #5 } |
| 15383 |
{ #6 } |
| 15384 |
} |
| 15385 |
} |
| 15386 |
} |
| 15387 |
% \end{macrocode} |
| 15388 |
% |
| 15389 |
% |
| 15390 |
% \medskip |
| 15391 |
% The following command |\@@_Block_v:nnnnnn| will actually draw the block. |
| 15392 |
% |#1| is the first row of the block; |
| 15393 |
% |#2| is the first column of the block; |
| 15394 |
% |#3| is the last row of the block; |
| 15395 |
% |#4| is the last column of the block; |
| 15396 |
% |#5| is a list of \textsl{key=value} options; |
| 15397 |
% |#6| is the label (content) of the block. |
| 15398 |
% \begin{macrocode} |
| 15399 |
\cs_new_protected:Npn \@@_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 |
| 15400 |
{ |
| 15401 |
% \end{macrocode} |
| 15402 |
% The group is for the keys. |
| 15403 |
% \begin{macrocode} |
| 15404 |
\group_begin: |
| 15405 |
\int_compare:nNnT { #1 } = { #3 } |
| 15406 |
{ \str_set:Nn \l_@@_vpos_block_str { t } } |
| 15407 |
\keys_set:nn { nicematrix / Block } { #5 } |
| 15408 |
% \end{macrocode} |
| 15409 |
% |
| 15410 |
% |
| 15411 |
% If the content of the block contains |&|, we will have a special treatment |
| 15412 |
% (since the cell must be divided in several sub-cells). Remark that |
| 15413 |
% |\tl_if_in:nnT| is faster then |\str_if_in:nnT|. |
| 15414 |
% \begin{macrocode} |
| 15415 |
\bool_if:NT \l_@@_amp_in_blocks_bool |
| 15416 |
{ \tl_if_in:nnT { #6 } { & } { \bool_set_true:N \l_@@_ampersand_bool } } |
| 15417 |
% \end{macrocode} |
| 15418 |
% |
| 15419 |
% \begin{macrocode} |
| 15420 |
\bool_lazy_and:nnT |
| 15421 |
\l_@@_vlines_block_bool |
| 15422 |
{ ! \l_@@_ampersand_bool } |
| 15423 |
{ |
| 15424 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 15425 |
{ |
| 15426 |
\@@_vlines_block:nnnnnn |
| 15427 |
{ \dim_use:N \arrayrulewidth } |
| 15428 |
{ \l_@@_rules_color_tl } |
| 15429 |
{ #1 } { #2 } { #3 } { #4 } |
| 15430 |
} |
| 15431 |
} |
| 15432 |
\bool_if:NT \l_@@_hlines_block_bool |
| 15433 |
{ |
| 15434 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 15435 |
{ |
| 15436 |
\@@_hlines_block:nnnnnn |
| 15437 |
{ \dim_use:N \arrayrulewidth } |
| 15438 |
{ \l_@@_rules_color_tl } |
| 15439 |
{ #1 } { #2 } { #3 } { #4 } |
| 15440 |
} |
| 15441 |
} |
| 15442 |
% \end{macrocode} |
| 15443 |
% The sequence of the positions of the blocks (excepted the blocks with the key |
| 15444 |
% |hvlines|) will be used when drawing the rules (in fact, there is also the |
| 15445 |
% |\multicolumn| and the |\diagbox| in that sequence). |
| 15446 |
% \begin{macrocode} |
| 15447 |
\bool_if:NF \l_@@_transparent_bool |
| 15448 |
{ |
| 15449 |
\seq_gput_right:Ne \g_@@_pos_of_blocks_seq |
| 15450 |
{ { #1 } { #2 } { #3 } { #4 } { \l_@@_block_name_str } } |
| 15451 |
} |
| 15452 |
% \end{macrocode} |
| 15453 |
% |
| 15454 |
% \bigskip |
| 15455 |
% \begin{macrocode} |
| 15456 |
\tl_if_empty:NF \l_@@_draw_tl |
| 15457 |
{ |
| 15458 |
\tl_gput_right:Nn \g_@@_rules_tl |
| 15459 |
{ |
| 15460 |
\@@_stroke_block:nnnnn |
| 15461 |
% \end{macrocode} |
| 15462 |
% |#5| are the options |
| 15463 |
% \begin{macrocode} |
| 15464 |
{ #5 } { #1 } { #2 } { #3 } { #4 } |
| 15465 |
} |
| 15466 |
\seq_gput_right:Nn \g_@@_pos_of_stroken_blocks_seq |
| 15467 |
{ { #1 } { #2 } { #3 } { #4 } } |
| 15468 |
} |
| 15469 |
% \end{macrocode} |
| 15470 |
% |
| 15471 |
% \begin{macrocode} |
| 15472 |
\clist_if_empty:NF \l_@@_borders_clist |
| 15473 |
{ |
| 15474 |
\tl_gput_right:Nn \g_nicematrix_code_after_tl |
| 15475 |
{ |
| 15476 |
\@@_stroke_borders_block:nnnnn |
| 15477 |
{ #5 } { #1 } { #2 } { #3 } { #4 } |
| 15478 |
} |
| 15479 |
} |
| 15480 |
% \end{macrocode} |
| 15481 |
% |
| 15482 |
% \begin{macrocode} |
| 15483 |
\tl_if_empty:NF \l_@@_fill_tl |
| 15484 |
{ |
| 15485 |
\@@_add_opacity_to_fill: |
| 15486 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 15487 |
{ |
| 15488 |
\@@_exp_color_arg:No \@@_roundedrectanglecolor \l_@@_fill_tl |
| 15489 |
{ #1 - #2 } |
| 15490 |
{ #3 - #4 } |
| 15491 |
{ \dim_use:N \l_@@_rounded_corners_dim } |
| 15492 |
} |
| 15493 |
} |
| 15494 |
% \end{macrocode} |
| 15495 |
% |
| 15496 |
% \begin{macrocode} |
| 15497 |
\seq_if_empty:NF \l_@@_tikz_seq |
| 15498 |
{ |
| 15499 |
\tl_gput_right:Ne \g_nicematrix_code_before_tl |
| 15500 |
{ |
| 15501 |
\@@_block_tikz:nnnnn |
| 15502 |
{ \seq_use:Nn \l_@@_tikz_seq { , } } |
| 15503 |
{ #1 } { #2 } { #3 } { #4 } |
| 15504 |
% \end{macrocode} |
| 15505 |
% We will have in that last field a list of lists of TikZ keys. |
| 15506 |
% \begin{macrocode} |
| 15507 |
} |
| 15508 |
} |
| 15509 |
% \end{macrocode} |
| 15510 |
% |
| 15511 |
% \medskip |
| 15512 |
% \begin{macrocode} |
| 15513 |
\cs_set_protected_nopar:Npn \diagbox ##1 ##2 |
| 15514 |
{ |
| 15515 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 15516 |
{ |
| 15517 |
\@@_draw_diagbox:nnnnnn |
| 15518 |
{ #1 } { #2 } { #3 } { #4 } |
| 15519 |
{ \exp_not:n { ##1 } } |
| 15520 |
{ \exp_not:n { ##2 } } |
| 15521 |
} |
| 15522 |
} |
| 15523 |
% \end{macrocode} |
| 15524 |
% |
| 15525 |
% |
| 15526 |
% \bigskip |
| 15527 |
% Let's consider the following |{NiceTabular}|. Because of the instruction |
| 15528 |
% |!{\hspace{1cm}}| in the preamble which increases the space between the |
| 15529 |
% columns (by adding, in fact, that space to the previous column, that is to say |
| 15530 |
% the second column of the tabular), we will create \emph{two} nodes relative to |
| 15531 |
% the block: the node |1-1-block| and the node |1-1-block-short|. |
| 15532 |
% |
| 15533 |
% \begin{Verbatim} |
| 15534 |
% \begin{NiceTabular}{cc!{\hspace{1cm}}c} |
| 15535 |
% \Block{2-2}{our block} & & one \\ |
| 15536 |
% & & two \\ |
| 15537 |
% three & four & five \\ |
| 15538 |
% six & seven & eight \\ |
| 15539 |
% \end{NiceTabular} |
| 15540 |
% \end{Verbatim} |
| 15541 |
% |
| 15542 |
% \tikzset{highlight/.style={rectangle, |
| 15543 |
% fill=red!15, |
| 15544 |
% blend mode = multiply, |
| 15545 |
% rounded corners = 0pt, |
| 15546 |
% inner sep=0pt, |
| 15547 |
% fit = #1}} |
| 15548 |
% |
| 15549 |
% \begin{tabular}{c@{\hspace{1cm}}c} |
| 15550 |
% We highlight the node |1-1-block| |
| 15551 |
% & |
| 15552 |
% We highlight the node |1-1-block-short| \\[2mm] |
| 15553 |
% \begin{NiceTabular}{cc!{\hspace{1cm}}c} |
| 15554 |
% \Block{2-2}{our block} & & one \\ |
| 15555 |
% & & two \\ |
| 15556 |
% three & four & five \\ |
| 15557 |
% six & seven & eight \\ |
| 15558 |
% \CodeAfter |
| 15559 |
% \tikz \node [highlight = (1-1-block)] { } ; |
| 15560 |
% \end{NiceTabular} |
| 15561 |
% & |
| 15562 |
% \begin{NiceTabular}{cc!{\hspace{1cm}}c} |
| 15563 |
% \Block{2-2}{our block} & & one \\ |
| 15564 |
% & & two \\ |
| 15565 |
% three & four & five \\ |
| 15566 |
% six & seven & eight \\ |
| 15567 |
% \CodeAfter |
| 15568 |
% \tikz \node [highlight = (1-1-block-short)] { } ; |
| 15569 |
% \end{NiceTabular} |
| 15570 |
% \end{tabular} |
| 15571 |
% |
| 15572 |
% |
| 15573 |
% \bigskip |
| 15574 |
% The construction of the node corresponding to the merged cells. |
| 15575 |
% \begin{macrocode} |
| 15576 |
\pgfpicture |
| 15577 |
\pgfrememberpicturepositiononpagetrue |
| 15578 |
\pgf@relevantforpicturesizefalse |
| 15579 |
\@@_qpoint:n { row - #1 } |
| 15580 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 15581 |
\@@_qpoint:n { col - #2 } |
| 15582 |
\dim_set_eq:NN \l_tmpb_dim \pgf@x |
| 15583 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_last_row_int + 1 } } |
| 15584 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 15585 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_col_int + 1 } } |
| 15586 |
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x |
| 15587 |
% \end{macrocode} |
| 15588 |
% |
| 15589 |
% |
| 15590 |
% |
| 15591 |
% We construct the node for the block with the name |(#1-#2-block)|. |
| 15592 |
% |
| 15593 |
% The function |\@@_pgf_rect_node:nnnnn| takes in as arguments the name of the node |
| 15594 |
% and the four coordinates of two opposite corner points of the rectangle. |
| 15595 |
% \begin{macrocode} |
| 15596 |
\@@_pgf_rect_node:nnnnn |
| 15597 |
{ \@@_env: - #1 - #2 - block } |
| 15598 |
\l_tmpb_dim \l_tmpa_dim \l_@@_tmpd_dim \l_@@_tmpc_dim |
| 15599 |
\str_if_empty:NF \l_@@_block_name_str |
| 15600 |
{ |
| 15601 |
\pgfnodealias |
| 15602 |
{ \@@_env: - \l_@@_block_name_str } |
| 15603 |
{ \@@_env: - #1 - #2 - block } |
| 15604 |
\str_if_empty:NF \l_@@_name_str |
| 15605 |
{ |
| 15606 |
\pgfnodealias |
| 15607 |
{ \l_@@_name_str - \l_@@_block_name_str } |
| 15608 |
{ \@@_env: - #1 - #2 - block } |
| 15609 |
} |
| 15610 |
} |
| 15611 |
% \end{macrocode} |
| 15612 |
% |
| 15613 |
% \medskip |
| 15614 |
% Now, we create the ``short node'' which, in general, will be used to put the |
| 15615 |
% label (that is to say the content of the node). However, if one the keys |L|, |C| or |
| 15616 |
% |R| is used (that information is provided by the boolean |
| 15617 |
% |\l_@@_hpos_of_block_cap_bool|), we don't need to create that node since the |
| 15618 |
% normal node is used to put the label. |
| 15619 |
% |
| 15620 |
% \begin{macrocode} |
| 15621 |
\bool_if:NF \l_@@_hpos_of_block_cap_bool |
| 15622 |
{ |
| 15623 |
\dim_set_eq:NN \l_tmpb_dim \c_max_dim |
| 15624 |
% \end{macrocode} |
| 15625 |
% The short node is constructed by taking into account the \emph{contents} of |
| 15626 |
% the columns involved in at least one cell of the block. That's why we have to |
| 15627 |
% do a loop over the rows of the array. |
| 15628 |
% \begin{macrocode} |
| 15629 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 15630 |
{ |
| 15631 |
% \end{macrocode} |
| 15632 |
% We recall that, when a cell is empty, no (normal) node is created in that |
| 15633 |
% cell. That's why we test the existence of the node before using it. |
| 15634 |
% \begin{macrocode} |
| 15635 |
\cs_if_exist:cT |
| 15636 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - #2 } |
| 15637 |
{ |
| 15638 |
\seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } |
| 15639 |
{ |
| 15640 |
\pgfpointanchor { \@@_env: - ##1 - #2 } { west } |
| 15641 |
\dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x } |
| 15642 |
} |
| 15643 |
} |
| 15644 |
} |
| 15645 |
% \end{macrocode} |
| 15646 |
% If all the cells of the column were empty, |\l_tmpb_dim| has still the same |
| 15647 |
% value |\c_max_dim|. In that case, you use for |\l_tmpb_dim| the value of the |
| 15648 |
% position of the vertical rule. |
| 15649 |
% \begin{macrocode} |
| 15650 |
\dim_compare:nNnT \l_tmpb_dim = \c_max_dim |
| 15651 |
{ |
| 15652 |
\@@_qpoint:n { col - #2 } |
| 15653 |
\dim_set_eq:NN \l_tmpb_dim \pgf@x |
| 15654 |
} |
| 15655 |
\dim_set:Nn \l_@@_tmpd_dim { - \c_max_dim } |
| 15656 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 15657 |
{ |
| 15658 |
\cs_if_exist:cT |
| 15659 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } |
| 15660 |
{ |
| 15661 |
\seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 } |
| 15662 |
{ |
| 15663 |
\pgfpointanchor |
| 15664 |
{ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int } |
| 15665 |
{ east } |
| 15666 |
\dim_set:Nn \l_@@_tmpd_dim |
| 15667 |
{ \dim_max:nn \l_@@_tmpd_dim \pgf@x } |
| 15668 |
} |
| 15669 |
} |
| 15670 |
} |
| 15671 |
\dim_compare:nNnT \l_@@_tmpd_dim = { - \c_max_dim } |
| 15672 |
{ |
| 15673 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_col_int + 1 } } |
| 15674 |
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x |
| 15675 |
} |
| 15676 |
\@@_pgf_rect_node:nnnnn |
| 15677 |
{ \@@_env: - #1 - #2 - block - short } |
| 15678 |
\l_tmpb_dim \l_tmpa_dim \l_@@_tmpd_dim \l_@@_tmpc_dim |
| 15679 |
} |
| 15680 |
% \end{macrocode} |
| 15681 |
% |
| 15682 |
% \medskip |
| 15683 |
% If the creation of the ``medium nodes'' is required, we create a ``medium |
| 15684 |
% node'' for the block. The function |\@@_pgf_rect_node:nnn| takes in as |
| 15685 |
% arguments the name of the node and two \textsc{pgf} points. |
| 15686 |
% \begin{macrocode} |
| 15687 |
\bool_if:NT \l_@@_medium_nodes_bool |
| 15688 |
{ |
| 15689 |
\@@_pgf_rect_node:nnn |
| 15690 |
{ \@@_env: - #1 - #2 - block - medium } |
| 15691 |
{ \pgfpointanchor { \@@_env: - #1 - #2 - medium } { north~west } } |
| 15692 |
{ |
| 15693 |
\pgfpointanchor |
| 15694 |
{ \@@_env: |
| 15695 |
- \int_use:N \l_@@_last_row_int |
| 15696 |
- \int_use:N \l_@@_last_col_int - medium |
| 15697 |
} |
| 15698 |
{ south~east } |
| 15699 |
} |
| 15700 |
} |
| 15701 |
\endpgfpicture |
| 15702 |
|
| 15703 |
% \end{macrocode} |
| 15704 |
% |
| 15705 |
% \bigskip |
| 15706 |
% |\l_@@_ampersand_bool| is raised when the content of the block actually |
| 15707 |
% \emph{contents} an ampersand~|&|. |
| 15708 |
% \begin{macrocode} |
| 15709 |
\bool_if:NTF \l_@@_ampersand_bool |
| 15710 |
{ |
| 15711 |
\seq_set_split:Nnn \l_tmpa_seq { & } { #6 } |
| 15712 |
\int_zero_new:N \l_@@_split_int |
| 15713 |
\int_set:Nn \l_@@_split_int { \seq_count:N \l_tmpa_seq } |
| 15714 |
% \end{macrocode} |
| 15715 |
% The following counters will be used to send information to |\cellcolor| |
| 15716 |
% if the user uses that command in a subcell. We use locally counters |
| 15717 |
% that have another signification in the main environment (maybe we should change that). |
| 15718 |
% \begin{macrocode} |
| 15719 |
\int_set:Nn \l_@@_first_row_int { #1 } |
| 15720 |
\int_set:Nn \l_@@_first_col_int { #2 } |
| 15721 |
\int_set:Nn \l_@@_last_row_int { #3 } |
| 15722 |
\int_set:Nn \l_@@_last_col_int { #4 } |
| 15723 |
% \end{macrocode} |
| 15724 |
% |
| 15725 |
% \begin{macrocode} |
| 15726 |
\pgfpicture |
| 15727 |
\pgfrememberpicturepositiononpagetrue |
| 15728 |
\pgf@relevantforpicturesizefalse |
| 15729 |
\@@_qpoint:n { row - #1 } |
| 15730 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 15731 |
\@@_qpoint:n { row - \int_eval:n { #3 + 1 } } |
| 15732 |
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@y |
| 15733 |
\@@_qpoint:n { col - #2 } |
| 15734 |
\dim_set_eq:NN \l_tmpa_dim \pgf@x |
| 15735 |
\@@_qpoint:n { col - \int_eval:n { #4 + 1 } } |
| 15736 |
\dim_set:Nn \l_tmpb_dim |
| 15737 |
{ ( \pgf@x - \l_tmpa_dim ) / \int_use:N \l_@@_split_int } |
| 15738 |
\bool_lazy_or:nnT |
| 15739 |
\l_@@_vlines_block_bool |
| 15740 |
{ \str_if_eq_p:ee \l_@@_vlines_clist { all } } |
| 15741 |
{ |
| 15742 |
\int_step_inline:nn { \l_@@_split_int - 1 } |
| 15743 |
{ |
| 15744 |
\pgfpathmoveto |
| 15745 |
{ |
| 15746 |
\pgfpoint |
| 15747 |
{ \l_tmpa_dim + ##1 \l_tmpb_dim } |
| 15748 |
\l_@@_tmpc_dim |
| 15749 |
} |
| 15750 |
\pgfpathlineto |
| 15751 |
{ |
| 15752 |
\pgfpoint |
| 15753 |
{ \l_tmpa_dim + ##1 \l_tmpb_dim } |
| 15754 |
\l_@@_tmpd_dim |
| 15755 |
} |
| 15756 |
\CT@arc@ |
| 15757 |
\pgfsetlinewidth { 1.1 \arrayrulewidth } |
| 15758 |
\pgfsetrectcap |
| 15759 |
\pgfusepathqstroke |
| 15760 |
} |
| 15761 |
} |
| 15762 |
\cs_set_eq:NN \cellcolor \@@_subcellcolor |
| 15763 |
\int_zero_new:N \l_@@_split_i_int |
| 15764 |
% \end{macrocode} |
| 15765 |
% |
| 15766 |
% \begin{macrocode} |
| 15767 |
\str_if_eq:eeTF \l_@@_vpos_block_str T |
| 15768 |
{ |
| 15769 |
\pgfpointanchor { \@@_env: - #1 - #2 - block } { north } |
| 15770 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 15771 |
} |
| 15772 |
{ |
| 15773 |
\str_if_eq:eeTF \l_@@_vpos_block_str B |
| 15774 |
{ |
| 15775 |
\pgfpointanchor { \@@_env: - #1 - #2 - block } { south } |
| 15776 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 15777 |
} |
| 15778 |
{ |
| 15779 |
\bool_lazy_or:nnTF |
| 15780 |
{ \int_compare_p:nNn { #1 } = { #3 } } |
| 15781 |
{ \str_if_eq_p:ee \l_@@_vpos_block_str t } |
| 15782 |
{ |
| 15783 |
\@@_qpoint:n { row - #1 - base } |
| 15784 |
\dim_set:Nn \l_@@_tmpc_dim { \pgf@y - 0.5 \arrayrulewidth } |
| 15785 |
} |
| 15786 |
{ |
| 15787 |
\str_if_eq:eeTF \l_@@_vpos_block_str b |
| 15788 |
{ |
| 15789 |
\@@_qpoint:n { row - #3 - base } |
| 15790 |
\dim_set:Nn \l_@@_tmpc_dim { \pgf@y - 0.5 \arrayrulewidth } |
| 15791 |
} |
| 15792 |
{ |
| 15793 |
\@@_qpoint:n { #1 - #2 - block } |
| 15794 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 15795 |
} |
| 15796 |
} |
| 15797 |
} |
| 15798 |
} |
| 15799 |
\int_step_inline:nn \l_@@_split_int |
| 15800 |
{ |
| 15801 |
\group_begin: |
| 15802 |
% \end{macrocode} |
| 15803 |
% The counter |\l_@@_split_i_int| is only for the command |\@@_subcellcolor|. |
| 15804 |
% \begin{macrocode} |
| 15805 |
\int_set:Nn \l_@@_split_i_int { ##1 } |
| 15806 |
\dim_set:Nn \col@sep |
| 15807 |
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep } |
| 15808 |
\pgftransformshift |
| 15809 |
{ |
| 15810 |
\pgfpoint |
| 15811 |
{ |
| 15812 |
\l_tmpa_dim + ##1 \l_tmpb_dim - |
| 15813 |
\str_case:on \l_@@_hpos_block_str |
| 15814 |
{ |
| 15815 |
l { \l_tmpb_dim + \col@sep} |
| 15816 |
c { 0.5 \l_tmpb_dim } |
| 15817 |
r { \col@sep } |
| 15818 |
} |
| 15819 |
} |
| 15820 |
{ \l_@@_tmpc_dim } |
| 15821 |
} |
| 15822 |
\pgfset { inner~sep = \c_zero_dim } |
| 15823 |
\pgfnode |
| 15824 |
{ rectangle } |
| 15825 |
{ |
| 15826 |
\str_if_eq:eeTF T \l_@@_vpos_block_str |
| 15827 |
{ |
| 15828 |
\str_case:on \l_@@_hpos_block_str |
| 15829 |
{ |
| 15830 |
l { north~west } |
| 15831 |
c { north } |
| 15832 |
r { north~east } |
| 15833 |
} |
| 15834 |
} |
| 15835 |
{ |
| 15836 |
\str_if_eq:eeTF B \l_@@_vpos_block_str |
| 15837 |
{ |
| 15838 |
\str_case:on \l_@@_hpos_block_str |
| 15839 |
{ |
| 15840 |
l { south~west } |
| 15841 |
c { south } |
| 15842 |
r { south~east } |
| 15843 |
} |
| 15844 |
} |
| 15845 |
{ |
| 15846 |
\bool_lazy_any:nTF |
| 15847 |
{ |
| 15848 |
{ \int_compare_p:nNn { #1 } = { #3 } } |
| 15849 |
{ \str_if_eq_p:ee t \l_@@_vpos_block_str } |
| 15850 |
{ \str_if_eq_p:ee b \l_@@_vpos_block_str } |
| 15851 |
} |
| 15852 |
{ |
| 15853 |
\str_case:on \l_@@_hpos_block_str |
| 15854 |
{ |
| 15855 |
l { base~west } |
| 15856 |
c { base } |
| 15857 |
r { base~east } |
| 15858 |
} |
| 15859 |
} |
| 15860 |
{ |
| 15861 |
\str_case:on \l_@@_hpos_block_str |
| 15862 |
{ |
| 15863 |
l { west } |
| 15864 |
c { center } |
| 15865 |
r { east } |
| 15866 |
} |
| 15867 |
} |
| 15868 |
} |
| 15869 |
} |
| 15870 |
} |
| 15871 |
{ \seq_item:Nn \l_tmpa_seq { ##1 } } { } { } |
| 15872 |
\group_end: |
| 15873 |
} |
| 15874 |
\endpgfpicture |
| 15875 |
} |
| 15876 |
% \end{macrocode} |
| 15877 |
% Now the case where there is no ampersand |&| in the content of the block. |
| 15878 |
% \begin{macrocode} |
| 15879 |
{ |
| 15880 |
\bool_if:NTF \l_@@_p_block_bool |
| 15881 |
{ |
| 15882 |
% \end{macrocode} |
| 15883 |
% When the final user has used the key~|p|, we have to compute the width. |
| 15884 |
% \begin{macrocode} |
| 15885 |
\pgfpicture |
| 15886 |
\pgfrememberpicturepositiononpagetrue |
| 15887 |
\pgf@relevantforpicturesizefalse |
| 15888 |
\bool_if:NTF \l_@@_hpos_of_block_cap_bool |
| 15889 |
{ |
| 15890 |
\@@_qpoint:n { col - #2 } |
| 15891 |
\dim_gset_eq:NN \g_tmpa_dim \pgf@x |
| 15892 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_col_int + 1 } } |
| 15893 |
} |
| 15894 |
{ |
| 15895 |
\pgfpointanchor { \@@_env: - #1 - #2 - block - short } { west } |
| 15896 |
\dim_gset_eq:NN \g_tmpa_dim \pgf@x |
| 15897 |
\pgfpointanchor { \@@_env: - #1 - #2 - block - short } { east } |
| 15898 |
} |
| 15899 |
\dim_gset:Nn \g_tmpb_dim { \pgf@x - \g_tmpa_dim } |
| 15900 |
\endpgfpicture |
| 15901 |
\hbox_set:Nn \l_@@_cell_box |
| 15902 |
{ |
| 15903 |
\begin { minipage } [ \str_lowercase:f \l_@@_vpos_block_str ] |
| 15904 |
{ \g_tmpb_dim } |
| 15905 |
\str_case:on \l_@@_hpos_block_str |
| 15906 |
{ c \centering r \raggedleft l \raggedright j { } } |
| 15907 |
\cs_set_eq:NN \cellcolor \@@_cellcolor_error |
| 15908 |
#6 |
| 15909 |
\end { minipage } |
| 15910 |
} |
| 15911 |
} |
| 15912 |
{ |
| 15913 |
\hbox_set:Nn \l_@@_cell_box |
| 15914 |
{ |
| 15915 |
\set@color |
| 15916 |
\cs_set_eq:NN \cellcolor \@@_cellcolor_error |
| 15917 |
#6 |
| 15918 |
} |
| 15919 |
} |
| 15920 |
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: |
| 15921 |
% \end{macrocode} |
| 15922 |
% |
| 15923 |
% \bigskip |
| 15924 |
% Now, we will put the label of the block. We recall that |\l_@@_vpos_block_str| |
| 15925 |
% is empty when the user has not used a key for the vertical position of the block. |
| 15926 |
% \begin{macrocode} |
| 15927 |
\pgfpicture |
| 15928 |
\pgfrememberpicturepositiononpagetrue |
| 15929 |
\pgf@relevantforpicturesizefalse |
| 15930 |
\bool_lazy_any:nTF |
| 15931 |
{ |
| 15932 |
{ \str_if_empty_p:N \l_@@_vpos_block_str } |
| 15933 |
{ \str_if_eq_p:ee c \l_@@_vpos_block_str } |
| 15934 |
{ \str_if_eq_p:ee T \l_@@_vpos_block_str } |
| 15935 |
{ \str_if_eq_p:ee B \l_@@_vpos_block_str } |
| 15936 |
} |
| 15937 |
% \end{macrocode} |
| 15938 |
% \medskip |
| 15939 |
% \begin{macrocode} |
| 15940 |
{ |
| 15941 |
% \end{macrocode} |
| 15942 |
% If we are in the ``first column'', we must put the block as if it was with the key~|r|. |
| 15943 |
% \begin{macrocode} |
| 15944 |
\int_if_zero:nT { #2 } { \str_set_eq:NN \l_@@_hpos_block_str \c_@@_r_str } |
| 15945 |
% \end{macrocode} |
| 15946 |
% If we are in the ``last column'', we must put the block as if it was with the key~|l|. |
| 15947 |
% \begin{macrocode} |
| 15948 |
\bool_if:nT \g_@@_last_col_found_bool |
| 15949 |
{ |
| 15950 |
\int_compare:nNnT { #2 } = \g_@@_col_total_int |
| 15951 |
{ \str_set_eq:NN \l_@@_hpos_block_str \c_@@_l_str } |
| 15952 |
} |
| 15953 |
% \end{macrocode} |
| 15954 |
% |\l_tmpa_tl| will contain the anchor of the \textsc{pgf} node which will be used. |
| 15955 |
% \begin{macrocode} |
| 15956 |
\tl_set:Ne \l_tmpa_tl |
| 15957 |
{ |
| 15958 |
\str_case:on \l_@@_vpos_block_str |
| 15959 |
{ |
| 15960 |
% \end{macrocode} |
| 15961 |
% We recall that |\l_@@_vpos_block_str| is empty when the user has not used a key |
| 15962 |
% for the vertical position of the block. |
| 15963 |
% \begin{macrocode} |
| 15964 |
{ } { |
| 15965 |
\str_case:on \l_@@_hpos_block_str |
| 15966 |
{ |
| 15967 |
c { center } |
| 15968 |
l { west } |
| 15969 |
r { east } |
| 15970 |
j { center } |
| 15971 |
} |
| 15972 |
} |
| 15973 |
c { |
| 15974 |
\str_case:on \l_@@_hpos_block_str |
| 15975 |
{ |
| 15976 |
c { center } |
| 15977 |
l { west } |
| 15978 |
r { east } |
| 15979 |
j { center } |
| 15980 |
} |
| 15981 |
|
| 15982 |
} |
| 15983 |
T { |
| 15984 |
\str_case:on \l_@@_hpos_block_str |
| 15985 |
{ |
| 15986 |
c { north } |
| 15987 |
l { north~west } |
| 15988 |
r { north~east } |
| 15989 |
j { north } |
| 15990 |
} |
| 15991 |
|
| 15992 |
} |
| 15993 |
B { |
| 15994 |
\str_case:on \l_@@_hpos_block_str |
| 15995 |
{ |
| 15996 |
c { south } |
| 15997 |
l { south~west } |
| 15998 |
r { south~east } |
| 15999 |
j { south } |
| 16000 |
} |
| 16001 |
|
| 16002 |
} |
| 16003 |
} |
| 16004 |
} |
| 16005 |
% \end{macrocode} |
| 16006 |
% |
| 16007 |
% \begin{macrocode} |
| 16008 |
\pgftransformshift |
| 16009 |
{ |
| 16010 |
\pgfpointanchor |
| 16011 |
{ |
| 16012 |
\@@_env: - #1 - #2 - block |
| 16013 |
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short } |
| 16014 |
} |
| 16015 |
\l_tmpa_tl |
| 16016 |
} |
| 16017 |
\pgfset { inner~sep = \c_zero_dim } |
| 16018 |
\pgfnode |
| 16019 |
{ rectangle } |
| 16020 |
\l_tmpa_tl |
| 16021 |
{ \box_use_drop:N \l_@@_cell_box } { } { } |
| 16022 |
} |
| 16023 |
% \end{macrocode} |
| 16024 |
% End of the case when |\l_@@_vpos_block_str| is equal to |c|, |T| or |B|. |
| 16025 |
% Now, the other cases. |
| 16026 |
% \begin{macrocode} |
| 16027 |
{ |
| 16028 |
% \end{macrocode} |
| 16029 |
% |
| 16030 |
% \begin{macrocode} |
| 16031 |
\pgfextracty \l_tmpa_dim |
| 16032 |
{ |
| 16033 |
\@@_qpoint:n |
| 16034 |
{ |
| 16035 |
row - \str_if_eq:eeTF b \l_@@_vpos_block_str { #3 } { #1 } |
| 16036 |
- base |
| 16037 |
} |
| 16038 |
} |
| 16039 |
\dim_sub:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } |
| 16040 |
% \end{macrocode} |
| 16041 |
% We retrieve (in |\pgf@x|) the $x$-value of the center of the block. |
| 16042 |
% \begin{macrocode} |
| 16043 |
\pgfpointanchor |
| 16044 |
{ |
| 16045 |
\@@_env: - #1 - #2 - block |
| 16046 |
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short } |
| 16047 |
} |
| 16048 |
{ |
| 16049 |
\str_case:on \l_@@_hpos_block_str |
| 16050 |
{ |
| 16051 |
c { center } |
| 16052 |
l { west } |
| 16053 |
r { east } |
| 16054 |
j { center } |
| 16055 |
} |
| 16056 |
} |
| 16057 |
% \end{macrocode} |
| 16058 |
% We put the label of the block which has been composed in |\l_@@_cell_box|. |
| 16059 |
% \begin{macrocode} |
| 16060 |
\pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim } |
| 16061 |
\pgfset { inner~sep = \c_zero_dim } |
| 16062 |
\pgfnode |
| 16063 |
{ rectangle } |
| 16064 |
{ |
| 16065 |
\str_case:on \l_@@_hpos_block_str |
| 16066 |
{ |
| 16067 |
c { base } |
| 16068 |
l { base~west } |
| 16069 |
r { base~east } |
| 16070 |
j { base } |
| 16071 |
} |
| 16072 |
} |
| 16073 |
{ \box_use_drop:N \l_@@_cell_box } { } { } |
| 16074 |
} |
| 16075 |
% \end{macrocode} |
| 16076 |
% |
| 16077 |
% \begin{macrocode} |
| 16078 |
\endpgfpicture |
| 16079 |
} |
| 16080 |
\group_end: |
| 16081 |
} |
| 16082 |
\cs_generate_variant:Nn \@@_Block_v:nnnnnn { n n e e } |
| 16083 |
% \end{macrocode} |
| 16084 |
% |
| 16085 |
% |
| 16086 |
% \bigskip |
| 16087 |
% The following command adds the value of |\l_@@_opacity_tl| (if not empty) to |
| 16088 |
% the specification of color set in |\l_@@_fill_tl| (the information of opacity |
| 16089 |
% is added in between square brackets before the color itself). |
| 16090 |
% \begin{macrocode} |
| 16091 |
\cs_new_protected:Npn \@@_add_opacity_to_fill: |
| 16092 |
{ |
| 16093 |
\tl_if_empty:NF \l_@@_opacity_tl |
| 16094 |
{ |
| 16095 |
\tl_if_head_eq_meaning:oNTF \l_@@_fill_tl [ |
| 16096 |
{ |
| 16097 |
\tl_set:Ne \l_@@_fill_tl |
| 16098 |
{ |
| 16099 |
[ opacity = \l_@@_opacity_tl , |
| 16100 |
\tl_tail:o \l_@@_fill_tl |
| 16101 |
} |
| 16102 |
} |
| 16103 |
{ |
| 16104 |
\tl_set:Ne \l_@@_fill_tl |
| 16105 |
{ [ opacity = \l_@@_opacity_tl ] { \exp_not:o \l_@@_fill_tl } } |
| 16106 |
} |
| 16107 |
} |
| 16108 |
} |
| 16109 |
% \end{macrocode} |
| 16110 |
% |
| 16111 |
% \bigskip |
| 16112 |
% The first argument of |\@@_stroke_block:nnn| is a list of options for the |
| 16113 |
% rectangle that you will stroke. The other arguments are the position of the block: |
| 16114 |
% \textsl{imin}, \textsl{jmin}, \textsl{imax} and \textsl{jmax}. |
| 16115 |
% \begin{macrocode} |
| 16116 |
\cs_new_protected:Npn \@@_stroke_block:nnnnn #1 #2 #3 #4 #5 |
| 16117 |
{ |
| 16118 |
\group_begin: |
| 16119 |
\tl_clear:N \l_@@_draw_tl |
| 16120 |
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth |
| 16121 |
\keys_set_known:nn { nicematrix / BlockStroke } { #1 } |
| 16122 |
\tl_if_empty:NF \l_@@_draw_tl |
| 16123 |
{ |
| 16124 |
% \end{macrocode} |
| 16125 |
% If the user has used the key |color| of the command |\Block| without value, |
| 16126 |
% the color fixed by |\arrayrulecolor| is used. |
| 16127 |
% \begin{macrocode} |
| 16128 |
\tl_if_eq:NnTF \l_@@_draw_tl { default } |
| 16129 |
\CT@arc@ |
| 16130 |
{ \@@_color:o \l_@@_draw_tl } |
| 16131 |
} |
| 16132 |
% \end{macrocode} |
| 16133 |
% The following code can't be put just before the |\pgfusepath { stroke }| (it's |
| 16134 |
% too late). |
| 16135 |
% \begin{macrocode} |
| 16136 |
\pgfsetcornersarced |
| 16137 |
{ \pgfpoint \l_@@_rounded_corners_dim \l_@@_rounded_corners_dim } |
| 16138 |
\int_compare:nNnF { #2 } > \c@iRow |
| 16139 |
{ |
| 16140 |
\int_compare:nNnF { #3 } > \c@jCol |
| 16141 |
{ |
| 16142 |
\@@_qpoint:n { row - #2 } |
| 16143 |
\dim_set_eq:NN \l_tmpb_dim \pgf@y |
| 16144 |
\@@_qpoint:n { col - #3 } |
| 16145 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x |
| 16146 |
\@@_qpoint:n |
| 16147 |
{ row - \int_eval:n { 1 + \int_min:nn \c@iRow { #4 } } } |
| 16148 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 16149 |
\@@_qpoint:n |
| 16150 |
{ col - \int_eval:n { 1 + \int_min:nn \c@jCol { #5 } } } |
| 16151 |
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim } |
| 16152 |
\pgfpathrectanglecorners |
| 16153 |
{ \pgfpoint \l_@@_tmpc_dim \l_tmpb_dim } |
| 16154 |
{ \pgfpoint \pgf@x \l_tmpa_dim } |
| 16155 |
\dim_compare:nNnTF \l_@@_rounded_corners_dim = \c_zero_dim |
| 16156 |
\pgfusepathqstroke |
| 16157 |
{ \pgfusepath { stroke } } |
| 16158 |
} |
| 16159 |
} |
| 16160 |
\group_end: |
| 16161 |
} |
| 16162 |
% \end{macrocode} |
| 16163 |
% |
| 16164 |
% Here is the set of keys for the command |\@@_stroke_block:nnnnn|. |
| 16165 |
% \begin{macrocode} |
| 16166 |
\keys_define:nn { nicematrix / BlockStroke } |
| 16167 |
{ |
| 16168 |
color .tl_set:N = \l_@@_draw_tl , |
| 16169 |
draw .code:n = |
| 16170 |
\tl_if_empty:eF { #1 } { \tl_set:Nn \l_@@_draw_tl { #1 } } , |
| 16171 |
draw .default:n = default , |
| 16172 |
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , |
| 16173 |
rounded-corners .default:n = 4 pt , |
| 16174 |
rules/width .dim_set:N = \l_@@_line_width_dim , |
| 16175 |
% \end{macrocode} |
| 16176 |
% The key |line-width| is now deprecated. |
| 16177 |
% \begin{macrocode} |
| 16178 |
line-width .dim_set:N = \l_@@_line_width_dim % deprecated |
| 16179 |
} |
| 16180 |
% \end{macrocode} |
| 16181 |
% |
| 16182 |
% |
| 16183 |
% \bigskip |
| 16184 |
% The command |\@@_vlines_block:nnnnn| is used only once: in |\@@_Block_v:nnnnnn| |
| 16185 |
% which actually draw the block. |
| 16186 |
% |
| 16187 |
% \medskip |
| 16188 |
% The first argument of |\@@_vlines_block:nnn| is the width of the |
| 16189 |
% rules that we will draw. The second is th color. |
| 16190 |
% The other arguments are the position of the block: |
| 16191 |
% \textsl{imin}, \textsl{jmin}, \textsl{imax} and \textsl{jmax}. |
| 16192 |
% \begin{macrocode} |
| 16193 |
\cs_new_protected:Npn \@@_vlines_block:nnnnnn #1 #2 #3 #4 #5 #6 |
| 16194 |
{ |
| 16195 |
\group_begin: |
| 16196 |
% \end{macrocode} |
| 16197 |
% We are actually during the execution of the |\g_nicematrix_code_after_tl|. |
| 16198 |
% In that context |\arrayrulewidth| is the width of standard lines (we are drawing |
| 16199 |
% standard rules because, up to now, there is no way to draw the internal lines of a Block |
| 16200 |
% with a style of TikZ). |
| 16201 |
% \begin{macrocode} |
| 16202 |
\dim_set:Nn \arrayrulewidth { #1 } |
| 16203 |
\pgfsetlinewidth \arrayrulewidth % added 2026-03-28 |
| 16204 |
\@@_set_CTarc:n { #2 } |
| 16205 |
\CT@arc@ |
| 16206 |
% \end{macrocode} |
| 16207 |
% |
| 16208 |
% \medskip |
| 16209 |
% We filter the list of blocks |\g_@@_pos_of_blocks_seq| in order to discard the blocks |
| 16210 |
% which encompass the current block (elsewhere, of course, the rules would not be drawn). |
| 16211 |
% \begin{macrocode} |
| 16212 |
\seq_set_filter:NNn \g_@@_pos_of_blocks_seq \g_@@_pos_of_blocks_seq % noqa: E420 |
| 16213 |
{ |
| 16214 |
\int_compare_p:nNn { \use_i:nnnnn ##1 } > { #3 } |
| 16215 |
|| |
| 16216 |
\int_compare_p:nNn { \use_ii:nnnnn ##1 } > { #4 } |
| 16217 |
|| |
| 16218 |
\int_compare_p:nNn { \use_iii:nnnnn ##1 } < { #5 } |
| 16219 |
|| |
| 16220 |
\int_compare_p:nNn { \use_iv:nnnnn ##1 } < { #6 } |
| 16221 |
} |
| 16222 |
% \end{macrocode} |
| 16223 |
% |
| 16224 |
% \begin{macrocode} |
| 16225 |
\bool_if:NT \l_@@_fix_vertex_bool |
| 16226 |
{ |
| 16227 |
\int_compare:nNnT { #4 } > 1 |
| 16228 |
{ |
| 16229 |
\seq_put_right:Ne \g_@@_pos_of_blocks_seq |
| 16230 |
{ |
| 16231 |
{ 1 } |
| 16232 |
{ 1 } |
| 16233 |
{ \int_use:N \c@iRow } |
| 16234 |
{ \int_eval:n { #4 -1 } } |
| 16235 |
{ } |
| 16236 |
} |
| 16237 |
} |
| 16238 |
\int_compare:nNnT { #6 } < \c@jCol |
| 16239 |
{ |
| 16240 |
\seq_put_right:Ne \g_@@_pos_of_blocks_seq |
| 16241 |
{ |
| 16242 |
{ 1 } |
| 16243 |
{ \int_eval:n { #6 + 1 } } |
| 16244 |
{ \int_use:N \c@iRow } |
| 16245 |
{ \int_use:N \c@jCol } |
| 16246 |
{ } |
| 16247 |
} |
| 16248 |
} |
| 16249 |
} |
| 16250 |
% \end{macrocode} |
| 16251 |
% |
| 16252 |
% \begin{macrocode} |
| 16253 |
\int_set:Nn \l_@@_start_int { #3 } |
| 16254 |
\int_set:Nn \l_@@_end_int { #5 } |
| 16255 |
\int_step_inline:nnn { #4 } { #6 + 1 } |
| 16256 |
{ |
| 16257 |
\int_set:Nn \l_@@_position_int { ##1 } |
| 16258 |
\socket_use:n { nicematrix / draw-vrule } |
| 16259 |
} |
| 16260 |
\group_end: |
| 16261 |
} |
| 16262 |
% \end{macrocode} |
| 16263 |
% |
| 16264 |
% \bigskip |
| 16265 |
% The command |\@@_hlines_block:nnnnnn| is used only once: in |\@@_Block_v:nnnnnn| |
| 16266 |
% which actually draws the block. |
| 16267 |
% |
| 16268 |
% \begin{macrocode} |
| 16269 |
\cs_new_protected:Npn \@@_hlines_block:nnnnnn #1 #2 #3 #4 #5 #6 |
| 16270 |
{ |
| 16271 |
\group_begin: |
| 16272 |
% \end{macrocode} |
| 16273 |
% We are actually during the execution of the |\g_nicematrix_code_after_tl|. |
| 16274 |
% In that context |\arrayrulewidth| is the widht of standard lines (we are drawing |
| 16275 |
% standard rules becuase, up to now, there is no way to draw the internal lines of a Block |
| 16276 |
% with a style of TikZ). |
| 16277 |
% \begin{macrocode} |
| 16278 |
\dim_set:Nn \arrayrulewidth { #1 } |
| 16279 |
\pgfsetlinewidth \arrayrulewidth % added 2026/03/28 |
| 16280 |
\@@_set_CTarc:n { #2 } |
| 16281 |
\CT@arc@ |
| 16282 |
% \end{macrocode} |
| 16283 |
% \medskip |
| 16284 |
% We filter the list of blocks |\g_@@_pos_of_blocks_seq| in order to discard the blocks |
| 16285 |
% which encompass the current block (elsewhere, of course, the rules would not be drawn). |
| 16286 |
% \begin{macrocode} |
| 16287 |
\seq_set_filter:NNn \g_@@_pos_of_blocks_seq \g_@@_pos_of_blocks_seq % noqa: E420 |
| 16288 |
{ |
| 16289 |
\int_compare_p:nNn { \use_i:nnnnn ##1 } > { #3 } |
| 16290 |
|| |
| 16291 |
\int_compare_p:nNn { \use_ii:nnnnn ##1 } > { #4 } |
| 16292 |
|| |
| 16293 |
\int_compare_p:nNn { \use_iii:nnnnn ##1 } < { #5 } |
| 16294 |
|| |
| 16295 |
\int_compare_p:nNn { \use_iv:nnnnn ##1 } < { #6 } |
| 16296 |
} |
| 16297 |
% \end{macrocode} |
| 16298 |
% |
| 16299 |
% \begin{macrocode} |
| 16300 |
\bool_if:NT \l_@@_fix_vertex_bool |
| 16301 |
{ |
| 16302 |
\int_compare:nNnT { #3 } > 1 |
| 16303 |
{ |
| 16304 |
\seq_put_right:Ne \g_@@_pos_of_blocks_seq |
| 16305 |
{ |
| 16306 |
{ 1 } |
| 16307 |
{ 1 } |
| 16308 |
{ \int_eval:n { #3 - 1 } } |
| 16309 |
{ \int_use:N \c@jCol } |
| 16310 |
{ } |
| 16311 |
} |
| 16312 |
} |
| 16313 |
\int_compare:nNnT { #5 } < \c@iRow |
| 16314 |
{ |
| 16315 |
\seq_put_right:Ne \g_@@_pos_of_blocks_seq |
| 16316 |
{ |
| 16317 |
{ \int_eval:n { #5 + 1 } } |
| 16318 |
{ 1 } |
| 16319 |
{ \int_use:N \c@iRow } |
| 16320 |
{ \int_use:N \c@jCol } |
| 16321 |
{ } |
| 16322 |
} |
| 16323 |
} |
| 16324 |
} |
| 16325 |
% \end{macrocode} |
| 16326 |
% |
| 16327 |
% \begin{macrocode} |
| 16328 |
\int_set:Nn \l_@@_start_int { #4 } |
| 16329 |
\int_set:Nn \l_@@_end_int { #6 } |
| 16330 |
\int_step_inline:nnn { #3 } { #5 + 1 } |
| 16331 |
{ |
| 16332 |
\int_set:Nn \l_@@_position_int { ##1 } |
| 16333 |
\socket_use:n { nicematrix / draw-hrule } |
| 16334 |
} |
| 16335 |
\group_end: |
| 16336 |
} |
| 16337 |
% \end{macrocode} |
| 16338 |
% |
| 16339 |
% \bigskip |
| 16340 |
% The first argument of |\@@_stroke_borders_block:nnn| is a list of options for |
| 16341 |
% the borders that you will stroke. |
| 16342 |
% \begin{macrocode} |
| 16343 |
\cs_new_protected:Npn \@@_stroke_borders_block:nnnnn #1 #2 #3 #4 #5 |
| 16344 |
{ |
| 16345 |
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth |
| 16346 |
\keys_set_known:nn { nicematrix / BlockBorders } { #1 } |
| 16347 |
\dim_compare:nNnTF \l_@@_rounded_corners_dim > \c_zero_dim |
| 16348 |
{ \@@_error:n { borders~forbidden } } |
| 16349 |
{ |
| 16350 |
\tl_clear_new:N \l_@@_borders_tikz_tl |
| 16351 |
\keys_set:no { nicematrix / OnlyForTikzInBorders } \l_@@_borders_clist |
| 16352 |
\tl_set:Nn \l_@@_tmpc_tl { #2 } |
| 16353 |
\tl_set:Nn \l_@@_tmpd_tl { #3 } |
| 16354 |
\tl_set:Ne \l_tmpa_tl { \int_eval:n { #4 + 1 } } |
| 16355 |
\tl_set:Ne \l_tmpb_tl { \int_eval:n { #5 + 1 } } |
| 16356 |
\@@_stroke_borders_block_i: |
| 16357 |
} |
| 16358 |
} |
| 16359 |
% \end{macrocode} |
| 16360 |
% |
| 16361 |
% \begin{macrocode} |
| 16362 |
\AtBeginDocument |
| 16363 |
{ |
| 16364 |
\cs_new_protected:Npe \@@_stroke_borders_block_i: |
| 16365 |
{ |
| 16366 |
\c_@@_pgfortikzpicture_tl |
| 16367 |
\@@_stroke_borders_block_ii: |
| 16368 |
\c_@@_endpgfortikzpicture_tl |
| 16369 |
} |
| 16370 |
} |
| 16371 |
% \end{macrocode} |
| 16372 |
% |
| 16373 |
% \begin{macrocode} |
| 16374 |
\cs_new_protected:Npn \@@_stroke_borders_block_ii: |
| 16375 |
{ |
| 16376 |
\pgfrememberpicturepositiononpagetrue |
| 16377 |
\pgf@relevantforpicturesizefalse |
| 16378 |
\CT@arc@ |
| 16379 |
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim } |
| 16380 |
\clist_if_in:NnTF \l_@@_borders_clist { all } |
| 16381 |
{ |
| 16382 |
\@@_stroke_vertical:n \l_tmpb_tl |
| 16383 |
\@@_stroke_vertical:n \l_@@_tmpd_tl |
| 16384 |
\@@_stroke_horizontal:n \l_tmpa_tl |
| 16385 |
\@@_stroke_horizontal:n \l_@@_tmpc_tl |
| 16386 |
} |
| 16387 |
{ |
| 16388 |
\clist_if_in:NnT \l_@@_borders_clist { right } |
| 16389 |
{ \@@_stroke_vertical:n \l_tmpb_tl } |
| 16390 |
\clist_if_in:NnT \l_@@_borders_clist { left } |
| 16391 |
{ \@@_stroke_vertical:n \l_@@_tmpd_tl } |
| 16392 |
\clist_if_in:NnT \l_@@_borders_clist { bottom } |
| 16393 |
{ \@@_stroke_horizontal:n \l_tmpa_tl } |
| 16394 |
\clist_if_in:NnT \l_@@_borders_clist { top } |
| 16395 |
{ \@@_stroke_horizontal:n \l_@@_tmpc_tl } |
| 16396 |
} |
| 16397 |
} |
| 16398 |
% \end{macrocode} |
| 16399 |
% |
| 16400 |
% \begin{macrocode} |
| 16401 |
\keys_define:nn { nicematrix / OnlyForTikzInBorders } |
| 16402 |
{ |
| 16403 |
tikz .code:n = |
| 16404 |
\cs_if_exist:NTF \tikzpicture |
| 16405 |
{ \tl_set:Nn \l_@@_borders_tikz_tl { #1 } } |
| 16406 |
{ \@@_error:n { tikz~in~borders~without~tikz } } , |
| 16407 |
tikz .value_required:n = true , |
| 16408 |
top .code:n = , |
| 16409 |
bottom .code:n = , |
| 16410 |
left .code:n = , |
| 16411 |
right .code:n = , |
| 16412 |
all .code:n = , |
| 16413 |
unknown .code:n = \@@_error:n { bad~border } |
| 16414 |
} |
| 16415 |
% \end{macrocode} |
| 16416 |
% |
| 16417 |
% |
| 16418 |
% \medskip |
| 16419 |
% The following command is used to stroke the left border and the right border. |
| 16420 |
% The argument |#1| is the number of column (in the sense of the |col| node). |
| 16421 |
% \begin{macrocode} |
| 16422 |
\cs_new_protected:Npn \@@_stroke_vertical:n #1 |
| 16423 |
{ |
| 16424 |
\@@_qpoint:n \l_@@_tmpc_tl |
| 16425 |
\dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l_@@_line_width_dim } |
| 16426 |
\@@_qpoint:n \l_tmpa_tl |
| 16427 |
\dim_set:Nn \l_@@_tmpc_dim { \pgf@y + 0.5 \l_@@_line_width_dim } |
| 16428 |
\@@_qpoint:n { #1 } |
| 16429 |
\tl_if_empty:NTF \l_@@_borders_tikz_tl |
| 16430 |
{ |
| 16431 |
\pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim } |
| 16432 |
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_tmpc_dim } |
| 16433 |
\pgfusepathqstroke |
| 16434 |
} |
| 16435 |
{ |
| 16436 |
\use:e { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] } |
| 16437 |
( \pgf@x , \l_tmpb_dim ) -- ( \pgf@x , \l_@@_tmpc_dim ) ; |
| 16438 |
} |
| 16439 |
} |
| 16440 |
% \end{macrocode} |
| 16441 |
% |
| 16442 |
% \medskip |
| 16443 |
% The following command is used to stroke the top border and the bottom border. |
| 16444 |
% The argument |#1| is the number of row (in the sense of the |row| node). |
| 16445 |
% \begin{macrocode} |
| 16446 |
\cs_new_protected:Npn \@@_stroke_horizontal:n #1 |
| 16447 |
{ |
| 16448 |
\@@_qpoint:n \l_@@_tmpd_tl |
| 16449 |
\clist_if_in:NnTF \l_@@_borders_clist { left } |
| 16450 |
{ \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l_@@_line_width_dim } } |
| 16451 |
{ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l_@@_line_width_dim } } |
| 16452 |
\@@_qpoint:n \l_tmpb_tl |
| 16453 |
\dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l_@@_line_width_dim } |
| 16454 |
\@@_qpoint:n { #1 } |
| 16455 |
\tl_if_empty:NTF \l_@@_borders_tikz_tl |
| 16456 |
{ |
| 16457 |
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } |
| 16458 |
\pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } |
| 16459 |
\pgfusepathqstroke |
| 16460 |
} |
| 16461 |
{ |
| 16462 |
\use:e { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] } |
| 16463 |
( \l_tmpa_dim , \pgf@y ) -- ( \l_tmpb_dim , \pgf@y ) ; |
| 16464 |
} |
| 16465 |
} |
| 16466 |
% \end{macrocode} |
| 16467 |
% |
| 16468 |
% \bigskip |
| 16469 |
% Here is the set of keys for the command |\@@_stroke_borders_block:nnn|. |
| 16470 |
% \begin{macrocode} |
| 16471 |
\keys_define:nn { nicematrix / BlockBorders } |
| 16472 |
{ |
| 16473 |
borders .clist_set:N = \l_@@_borders_clist , |
| 16474 |
borders .default:n = all , % 2026/08/05 |
| 16475 |
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , |
| 16476 |
rounded-corners .default:n = 4 pt , |
| 16477 |
rules/width .dim_set:N = \l_@@_line_width_dim , |
| 16478 |
% \end{macrocode} |
| 16479 |
% The following key is deprecated. |
| 16480 |
% \begin{macrocode} |
| 16481 |
line-width .dim_set:N = \l_@@_line_width_dim % deprecated |
| 16482 |
} |
| 16483 |
% \end{macrocode} |
| 16484 |
% |
| 16485 |
% \bigskip |
| 16486 |
% The following command will be used if the key |tikz| has been used for the |
| 16487 |
% command |\Block|. |
| 16488 |
|
| 16489 |
% |#1| is a \emph{list of lists} of TikZ keys used with the path. |
| 16490 |
% |
| 16491 |
% \emph{Example}: |{{offset=1pt,draw,red},{offset=2pt,draw,blue}}| |
| 16492 |
% |
| 16493 |
% which arises from a command such as : |
| 16494 |
% |
| 16495 |
% |\Block[tikz={offset=1pt,draw,red},tikz={offset=2pt,draw,blue}]{2-2}{}| |
| 16496 |
% |
| 16497 |
% The arguments |#2| and |#3| are the coordinates of the first |
| 16498 |
% cell and |#4| and |#5| the coordinates of the last cell of the block. |
| 16499 |
% |
| 16500 |
% \begin{macrocode} |
| 16501 |
\cs_new_protected:Npn \@@_block_tikz:nnnnn #1 #2 #3 #4 #5 |
| 16502 |
{ |
| 16503 |
\begin { tikzpicture } |
| 16504 |
\@@_clip_with_rounded_corners: |
| 16505 |
% \end{macrocode} |
| 16506 |
% We use |clist_map_inline:nn| because |#5| is a list of lists. |
| 16507 |
% \begin{macrocode} |
| 16508 |
\clist_map_inline:nn { #1 } |
| 16509 |
{ |
| 16510 |
% \end{macrocode} |
| 16511 |
% We extract the key |offset| which is \emph{not} a key of TikZ but a key added |
| 16512 |
% by \pkg{nicematrix}. |
| 16513 |
% \begin{macrocode} |
| 16514 |
\keys_set_known:nnN { nicematrix / SpecialOffset } { ##1 } \l_tmpa_tl |
| 16515 |
\use:e { \exp_not:N \path [ \l_tmpa_tl ] } |
| 16516 |
( |
| 16517 |
[ |
| 16518 |
xshift = \dim_use:N \l_@@_offset_dim , |
| 16519 |
yshift = - \dim_use:N \l_@@_offset_dim |
| 16520 |
] |
| 16521 |
#2 -| #3 |
| 16522 |
) |
| 16523 |
rectangle |
| 16524 |
( |
| 16525 |
[ |
| 16526 |
xshift = - \dim_use:N \l_@@_offset_dim , |
| 16527 |
yshift = \dim_use:N \l_@@_offset_dim |
| 16528 |
] |
| 16529 |
\int_eval:n { #4 + 1 } -| \int_eval:n { #5 + 1 } |
| 16530 |
) ; |
| 16531 |
} |
| 16532 |
\end { tikzpicture } |
| 16533 |
} |
| 16534 |
\cs_generate_variant:Nn \@@_block_tikz:nnnnn { o } |
| 16535 |
% \end{macrocode} |
| 16536 |
% |
| 16537 |
% \medskip |
| 16538 |
|
| 16539 |
% \begin{macrocode} |
| 16540 |
\keys_define:nn { nicematrix / SpecialOffset } |
| 16541 |
{ |
| 16542 |
offset .dim_set:N = \l_@@_offset_dim , |
| 16543 |
} |
| 16544 |
% \end{macrocode} |
| 16545 |
% |
| 16546 |
% \bigskip |
| 16547 |
% In some circonstancies, we want to nullify the command |\Block|. In order to |
| 16548 |
% reach that goal, we will link the command |\Block| to the following command |
| 16549 |
% |\@@_NullBlock:| which has the same syntax as the standard command |\Block| |
| 16550 |
% but which is no-op. |
| 16551 |
% \begin{macrocode} |
| 16552 |
\cs_new_protected:Npn \@@_NullBlock: |
| 16553 |
{ \@@_collect_options:n { \@@_NullBlock_i: } } |
| 16554 |
\NewExpandableDocumentCommand \@@_NullBlock_i: { m m D < > { } +m } |
| 16555 |
{ } |
| 16556 |
% \end{macrocode} |
| 16557 |
% |
| 16558 |
% \bigskip |
| 16559 |
% The following command will be linked to |\cellcolor| in the sub-cells of |
| 16560 |
% a block which contains ampersands (|&|). Of course, |&-in-blocks| must be in force. |
| 16561 |
% \begin{macrocode} |
| 16562 |
\NewDocumentCommand \@@_subcellcolor { O { } m } |
| 16563 |
{ |
| 16564 |
\tl_gput_right:Ne \g_@@_pre_code_before_tl |
| 16565 |
{ |
| 16566 |
% \end{macrocode} |
| 16567 |
% We must not expand the color (|#2|) because the color may contain the token |
| 16568 |
% |!| which may be activated by some packages (ex.: \pkg{babel} with the option |
| 16569 |
% |french| on latex and pdflatex). |
| 16570 |
% \begin{macrocode} |
| 16571 |
\@@_subcellcolor:nnnnnnn |
| 16572 |
{ |
| 16573 |
\tl_if_blank:nTF { #1 } |
| 16574 |
{ { \exp_not:n { #2 } } } |
| 16575 |
{ [ #1 ] { \exp_not:n { #2 } } } |
| 16576 |
} |
| 16577 |
{ \int_use:N \l_@@_first_row_int } % first row of the block |
| 16578 |
{ \int_use:N \l_@@_first_col_int } % first column of the block |
| 16579 |
{ \int_use:N \l_@@_last_row_int } % last row of the block |
| 16580 |
{ \int_use:N \l_@@_last_col_int } % last column of the block |
| 16581 |
{ \int_use:N \l_@@_split_int } |
| 16582 |
{ \int_use:N \l_@@_split_i_int } |
| 16583 |
} |
| 16584 |
\ignorespaces |
| 16585 |
} |
| 16586 |
% \end{macrocode} |
| 16587 |
% |
| 16588 |
% |
| 16589 |
% \begin{macrocode} |
| 16590 |
\cs_new_protected:Npn \@@_subcellcolor:nnnnnnn #1 #2 #3 #4 #5 #6 #7 |
| 16591 |
{ |
| 16592 |
\@@_color_opacity: #1 |
| 16593 |
\pgfpicture |
| 16594 |
\pgf@relevantforpicturesizefalse |
| 16595 |
\@@_qpoint:n { col - #3 } |
| 16596 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x |
| 16597 |
\@@_qpoint:n { col - \int_eval:n { #5 + 1 } } |
| 16598 |
\dim_set:Nn \l_tmpa_dim { ( \pgf@x - \l_@@_tmpc_dim ) / #6 } |
| 16599 |
\dim_set:Nn \l_tmpb_dim { \l_@@_tmpc_dim + #7 \l_tmpa_dim } |
| 16600 |
\@@_qpoint:n { row - \int_eval:n { #4 + 1 } } |
| 16601 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 16602 |
\@@_qpoint:n { row - #2 } |
| 16603 |
\pgfpathrectanglecorners |
| 16604 |
{ \pgfpoint { \l_tmpb_dim - \l_tmpa_dim } \l_@@_tmpc_dim } |
| 16605 |
{ \pgfpoint \l_tmpb_dim \pgf@y } |
| 16606 |
\pgfusepathqfill |
| 16607 |
\endpgfpicture |
| 16608 |
} |
| 16609 |
% \end{macrocode} |
| 16610 |
% |
| 16611 |
% |
| 16612 |
% \bigskip |
| 16613 |
% \section{Automatic arrays} |
| 16614 |
% |
| 16615 |
% We will extract some keys and pass the other keys to the environment |
| 16616 |
% |{NiceArrayWithDelims}|. |
| 16617 |
% \begin{macrocode} |
| 16618 |
\keys_define:nn { nicematrix / Auto } |
| 16619 |
{ |
| 16620 |
columns-type .tl_set:N = \l_@@_columns_type_tl , |
| 16621 |
columns-type .value_required:n = true , |
| 16622 |
l .meta:n = { columns-type = l } , |
| 16623 |
r .meta:n = { columns-type = r } , |
| 16624 |
c .meta:n = { columns-type = c } , |
| 16625 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 16626 |
delimiters / color .value_required:n = true , |
| 16627 |
delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool , |
| 16628 |
delimiters .code:n = \keys_set:nn { nicematrix / delimiters } { #1 } , |
| 16629 |
delimiters .value_required:n = true , |
| 16630 |
rounded-corners .dim_set:N = \l_@@_tab_rounded_corners_dim , |
| 16631 |
rounded-corners .default:n = 4 pt |
| 16632 |
} |
| 16633 |
% \end{macrocode} |
| 16634 |
% |
| 16635 |
% \begin{macrocode} |
| 16636 |
\NewDocumentCommand \AutoNiceMatrixWithDelims |
| 16637 |
{ m m O { } > { \SplitArgument { 1 } { - } } m O { } m ! O { } } |
| 16638 |
{ \@@_auto_nice_matrix:nnnnnn { #1 } { #2 } #4 { #6 } { #3 , #5 , #7 } } |
| 16639 |
% \end{macrocode} |
| 16640 |
% |
| 16641 |
% |
| 16642 |
% \begin{macrocode} |
| 16643 |
\cs_new_protected:Npn \@@_auto_nice_matrix:nnnnnn #1 #2 #3 #4 #5 #6 |
| 16644 |
{ |
| 16645 |
% \end{macrocode} |
| 16646 |
% The group is for the protection of the keys. |
| 16647 |
% \begin{macrocode} |
| 16648 |
\group_begin: |
| 16649 |
\keys_set_known:nnN { nicematrix / Auto } { #6 } \l_tmpa_tl |
| 16650 |
\use:e |
| 16651 |
{ |
| 16652 |
\exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 } |
| 16653 |
{ * { #4 } { \exp_not:o \l_@@_columns_type_tl } } |
| 16654 |
[ \exp_not:o \l_tmpa_tl ] |
| 16655 |
} |
| 16656 |
\int_if_zero:nT \l_@@_first_row_int |
| 16657 |
{ |
| 16658 |
\int_if_zero:nT \l_@@_first_col_int { & } |
| 16659 |
\prg_replicate:nn { #4 - 1 } { & } |
| 16660 |
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\ |
| 16661 |
} |
| 16662 |
\prg_replicate:nn { #3 } |
| 16663 |
{ |
| 16664 |
\int_if_zero:nT \l_@@_first_col_int { & } |
| 16665 |
% \end{macrocode} |
| 16666 |
% We put |{ }| before |#6| to avoid a hasty expansion of a potential |
| 16667 |
% |\arabic{iRow}| at the beginning of the row which would result in an incorrect |
| 16668 |
% value of that |iRow| (since |iRow| is incremented in the first cell of the row |
| 16669 |
% of the |\halign|). |
| 16670 |
% \begin{macrocode} |
| 16671 |
\prg_replicate:nn { #4 - 1 } { { } #5 & } #5 |
| 16672 |
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\ |
| 16673 |
} |
| 16674 |
\int_compare:nNnT \l_@@_last_row_int > { -2 } |
| 16675 |
{ |
| 16676 |
\int_if_zero:nT \l_@@_first_col_int { & } |
| 16677 |
\prg_replicate:nn { #4 - 1 } { & } |
| 16678 |
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\ |
| 16679 |
} |
| 16680 |
\end { NiceArrayWithDelims } |
| 16681 |
\group_end: |
| 16682 |
} |
| 16683 |
% \end{macrocode} |
| 16684 |
% |
| 16685 |
% \begin{macrocode} |
| 16686 |
\cs_set_protected:Npn \@@_define_com:NNN #1 #2 #3 |
| 16687 |
{ |
| 16688 |
\cs_set_protected:cpn { #1 AutoNiceMatrix } |
| 16689 |
{ |
| 16690 |
\bool_gset_true:N \g_@@_delims_bool |
| 16691 |
\str_gset:Ne \g_@@_name_env_str { #1 AutoNiceMatrix } |
| 16692 |
\AutoNiceMatrixWithDelims { #2 } { #3 } |
| 16693 |
} |
| 16694 |
} |
| 16695 |
% \end{macrocode} |
| 16696 |
% |
| 16697 |
% |
| 16698 |
% \bigskip |
| 16699 |
% We define also a command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|. |
| 16700 |
% \begin{macrocode} |
| 16701 |
\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } |
| 16702 |
{ |
| 16703 |
\group_begin: |
| 16704 |
\bool_gset_false:N \g_@@_delims_bool |
| 16705 |
\AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] |
| 16706 |
\group_end: |
| 16707 |
} |
| 16708 |
% \end{macrocode} |
| 16709 |
% |
| 16710 |
% |
| 16711 |
% \bigskip |
| 16712 |
% \section{The redefinition of the command \textbackslash dotfill } |
| 16713 |
% |
| 16714 |
% \begin{macrocode} |
| 16715 |
\cs_set_eq:NN \@@_old_dotfill: \dotfill |
| 16716 |
\cs_new_protected:Npn \@@_dotfill: |
| 16717 |
{ |
| 16718 |
% \end{macrocode} |
| 16719 |
% First, we insert |\@@_dotfill| (which is the saved version of |\dotfill|) in |
| 16720 |
% case of use of |\dotfill| ``internally'' in the cell (e.g. |\hbox to 1cm {\dotfill}|). |
| 16721 |
% \begin{macrocode} |
| 16722 |
\@@_old_dotfill: |
| 16723 |
\tl_gput_right:Nn \g_@@_cell_after_hook_tl \@@_dotfill_i: |
| 16724 |
} |
| 16725 |
% \end{macrocode} |
| 16726 |
% Now, if the box if not empty (unfornately, we can't actually test whether the |
| 16727 |
% box is empty and that's why we only consider it's width), we insert |
| 16728 |
% |\@@_dotfill| (which is the saved version of |\dotfill|) in the cell of the |
| 16729 |
% array, and it will extend, since it is no longer in |\l_@@_cell_box|. |
| 16730 |
% \begin{macrocode} |
| 16731 |
\cs_new_protected:Npn \@@_dotfill_i: |
| 16732 |
{ |
| 16733 |
\dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim |
| 16734 |
{ \@@_old_dotfill: } |
| 16735 |
} |
| 16736 |
% \end{macrocode} |
| 16737 |
% |
| 16738 |
% \bigskip |
| 16739 |
% \section{The command \textbackslash diagbox} |
| 16740 |
% |
| 16741 |
% The command |\diagbox| will be linked to |\diagbox:nn| in the environments of |
| 16742 |
% \pkg{nicematrix}. However, there are also redefinitions of |\diagbox| in other |
| 16743 |
% circonstancies. |
| 16744 |
% |
| 16745 |
% \begin{macrocode} |
| 16746 |
\cs_new_protected:Npn \@@_diagbox:nn #1 #2 |
| 16747 |
{ |
| 16748 |
\tl_gput_right:Ne \g_@@_rules_tl |
| 16749 |
{ |
| 16750 |
\@@_draw_diagbox:nnnnnn |
| 16751 |
{ \int_use:N \c@iRow } |
| 16752 |
{ \int_use:N \c@jCol } |
| 16753 |
{ \int_use:N \c@iRow } |
| 16754 |
{ \int_use:N \c@jCol } |
| 16755 |
% \end{macrocode} |
| 16756 |
% The expansion done on |\g_@@_row_style_tl| will result in the fact that you |
| 16757 |
% take into account the current number of row and number of column. |
| 16758 |
% \begin{macrocode} |
| 16759 |
{ \g_@@_row_style_tl \exp_not:n { #1 } } |
| 16760 |
{ \g_@@_row_style_tl \exp_not:n { #2 } } |
| 16761 |
} |
| 16762 |
% \end{macrocode} |
| 16763 |
% We put the cell with |\diagbox| in the sequence |\g_@@_pos_of_blocks_seq| |
| 16764 |
% because a cell with |\diagbox| must be considered as non empty by the key |
| 16765 |
% |corners|. |
| 16766 |
% \begin{macrocode} |
| 16767 |
\seq_gput_right:Ne \g_@@_pos_of_blocks_seq |
| 16768 |
{ |
| 16769 |
{ \int_use:N \c@iRow } |
| 16770 |
{ \int_use:N \c@jCol } |
| 16771 |
{ \int_use:N \c@iRow } |
| 16772 |
{ \int_use:N \c@jCol } |
| 16773 |
% \end{macrocode} |
| 16774 |
% The last argument is for the name of the block. |
| 16775 |
% \begin{macrocode} |
| 16776 |
{ } |
| 16777 |
} |
| 16778 |
} |
| 16779 |
% \end{macrocode} |
| 16780 |
% |
| 16781 |
% \medskip |
| 16782 |
% The command |\diagbox| is also redefined locally when we draw a block. |
| 16783 |
% |
| 16784 |
% \medskip |
| 16785 |
% The first four arguments of |\@@_draw_diagbox:nnnnnn| correspond to the |
| 16786 |
% rectangle (=block) to slash (we recall that it's possible to use |\diagbox| in |
| 16787 |
% a |\Block|). The other two are the elements to draw below and above the |
| 16788 |
% diagonal line. |
| 16789 |
% \begin{macrocode} |
| 16790 |
\cs_new_protected:Npn \@@_draw_diagbox:nnnnnn #1 #2 #3 #4 #5 #6 |
| 16791 |
{ |
| 16792 |
% \end{macrocode} |
| 16793 |
% We \emph{must} us an environment |{pgfscope}| and not a simple group of TeX. |
| 16794 |
% \begin{macrocode} |
| 16795 |
\begin { pgfscope } |
| 16796 |
\@@_qpoint:n { row - #1 } |
| 16797 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 16798 |
\@@_qpoint:n { col - #2 } |
| 16799 |
\dim_set_eq:NN \l_tmpb_dim \pgf@x |
| 16800 |
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } |
| 16801 |
\@@_qpoint:n { row - \int_eval:n { #3 + 1 } } |
| 16802 |
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y |
| 16803 |
\@@_qpoint:n { col - \int_eval:n { #4 + 1 } } |
| 16804 |
\dim_set_eq:NN \l_@@_tmpd_dim \pgf@x |
| 16805 |
\pgfpathlineto { \pgfpoint \l_@@_tmpd_dim \l_@@_tmpc_dim } |
| 16806 |
{ |
| 16807 |
% \end{macrocode} |
| 16808 |
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of |
| 16809 |
% the rules in the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not |
| 16810 |
% loaded. |
| 16811 |
% \begin{macrocode} |
| 16812 |
\CT@arc@ |
| 16813 |
\pgfsetroundcap |
| 16814 |
\pgfusepathqstroke |
| 16815 |
} |
| 16816 |
\pgfset { inner~sep = 1 pt } |
| 16817 |
\pgfscope |
| 16818 |
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_@@_tmpc_dim } |
| 16819 |
\pgfnode { rectangle } { south~west } |
| 16820 |
{ |
| 16821 |
\begin { minipage } { 20 cm } |
| 16822 |
% \end{macrocode} |
| 16823 |
% The |\scan_stop:| avoids an error in math mode when the argument |#5| is empty. |
| 16824 |
% \begin{macrocode} |
| 16825 |
\@@_math_toggle: \scan_stop: #5 \@@_math_toggle: |
| 16826 |
\end { minipage } |
| 16827 |
} |
| 16828 |
{ } |
| 16829 |
{ } |
| 16830 |
\endpgfscope |
| 16831 |
\pgftransformshift { \pgfpoint \l_@@_tmpd_dim \l_tmpa_dim } |
| 16832 |
\pgfnode { rectangle } { north~east } |
| 16833 |
{ |
| 16834 |
\begin { minipage } { 20 cm } |
| 16835 |
\raggedleft |
| 16836 |
\@@_math_toggle: \scan_stop: #6 \@@_math_toggle: |
| 16837 |
\end { minipage } |
| 16838 |
} |
| 16839 |
{ } |
| 16840 |
{ } |
| 16841 |
\end { pgfscope } |
| 16842 |
} |
| 16843 |
% \end{macrocode} |
| 16844 |
% |
| 16845 |
% |
| 16846 |
% |
| 16847 |
% |
| 16848 |
% \bigskip |
| 16849 |
% \section{The keyword \textbackslash CodeAfter} |
| 16850 |
% |
| 16851 |
% |
| 16852 |
% |
| 16853 |
% \medskip |
| 16854 |
% In fact, in this subsection, we define the user command |\CodeAfter| for the |
| 16855 |
% case of the ``normal syntax''. For the case of ``light-syntax'', see the |
| 16856 |
% definition of the environment |{@@-light-syntax}| on |
| 16857 |
% p.~\pageref{code-light-syntax}. |
| 16858 |
% |
| 16859 |
% |
| 16860 |
% \medskip |
| 16861 |
% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to |
| 16862 |
% |\@@_CodeAfter:|. That macro must \emph{not} be protected since it begins with |
| 16863 |
% |\omit|. |
| 16864 |
% \begin{macrocode} |
| 16865 |
\cs_new:Npn \@@_CodeAfter: { \omit \@@_CodeAfter_ii:n } |
| 16866 |
% \end{macrocode} |
| 16867 |
% |
| 16868 |
% \medskip |
| 16869 |
% However, in each cell of the environment, the command |\CodeAfter| will be |
| 16870 |
% linked to the following command |\@@_CodeAfter_ii:n| which begins |
| 16871 |
% with |\\|. |
| 16872 |
% |
| 16873 |
% \begin{macrocode} |
| 16874 |
\cs_new_protected:Npn \@@_CodeAfter_i: { \\ \omit \@@_CodeAfter_ii:n } |
| 16875 |
% \end{macrocode} |
| 16876 |
% |
| 16877 |
% \smallskip |
| 16878 |
% We have to catch everything until the end of the current environment (of |
| 16879 |
% \pkg{nicematrix}). First, we go until the next command |\end|. |
| 16880 |
% \begin{macrocode} |
| 16881 |
\cs_new_protected:Npn \@@_CodeAfter_ii:n #1 \end |
| 16882 |
{ |
| 16883 |
\tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 } |
| 16884 |
\@@_CodeAfter_iv:n |
| 16885 |
} |
| 16886 |
% \end{macrocode} |
| 16887 |
% |
| 16888 |
% We catch the argument of the command |\end| (in |#1|). |
| 16889 |
% \begin{macrocode} |
| 16890 |
\cs_new_protected:Npn \@@_CodeAfter_iv:n #1 |
| 16891 |
{ |
| 16892 |
% \end{macrocode} |
| 16893 |
% If this is really the end of the current environment (of \pkg{nicematrix}), we |
| 16894 |
% put back the command |\end| and its argument in the TeX flow. |
| 16895 |
% \begin{macrocode} |
| 16896 |
\str_if_eq:eeTF \@currenvir { #1 } |
| 16897 |
{ \end { #1 } } |
| 16898 |
% \end{macrocode} |
| 16899 |
% If this is not the |\end| we are looking for, we put those tokens in |
| 16900 |
% |\g_nicematrix_code_after_tl| and we go on searching for the next command |
| 16901 |
% |\end| with a recursive call to the command |\@@_CodeAfter:n|. |
| 16902 |
% \begin{macrocode} |
| 16903 |
{ |
| 16904 |
\tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } } |
| 16905 |
\@@_CodeAfter_ii:n |
| 16906 |
} |
| 16907 |
} |
| 16908 |
% \end{macrocode} |
| 16909 |
% |
| 16910 |
% |
| 16911 |
% |
| 16912 |
% \section{The delimiters in the preamble} |
| 16913 |
% |
| 16914 |
% The command |\@@_delimiter:nnn| will be used to draw delimiters inside the |
| 16915 |
% matrix when delimiters are specified in the preamble of the array. It does |
| 16916 |
% \emph{not} concern the exterior delimiters added by |{NiceArrayWithDelims}| |
| 16917 |
% (and |{pNiceArray}|, |{pNiceMatrix}|, etc.). |
| 16918 |
% |
| 16919 |
% A delimiter in the preamble of the array will write an instruction |
| 16920 |
% |\@@_delimiter:nnn| in the |\g_@@_pre_code_after_tl| (and also |
| 16921 |
% potentially add instructions in the preamble provided to |\array| in order to |
| 16922 |
% add space between columns). |
| 16923 |
% |
| 16924 |
% \smallskip |
| 16925 |
% The first argument is the type of delimiter (|(|, |[|, |\{|, |)|, |]| or |
| 16926 |
% |\}|). The second argument is the number of column. The third argument is a |
| 16927 |
% boolean equal to |\c_true_bool| (resp. |\c_false_true|) when the delimiter |
| 16928 |
% must be put on the left (resp. right) side. |
| 16929 |
% |
| 16930 |
% \begin{macrocode} |
| 16931 |
\cs_new_protected:Npn \@@_delimiter:nnn #1 #2 #3 |
| 16932 |
{ |
| 16933 |
\pgfpicture |
| 16934 |
\pgfrememberpicturepositiononpagetrue |
| 16935 |
\pgf@relevantforpicturesizefalse |
| 16936 |
% \end{macrocode} |
| 16937 |
% |
| 16938 |
% \medskip |
| 16939 |
% |\l_@@_y_initial_dim| and |\l_@@_y_final_dim| will be the $y$-values of the |
| 16940 |
% extremities of the delimiter we will have to construct. |
| 16941 |
% \begin{macrocode} |
| 16942 |
\@@_qpoint:n { row - 1 } |
| 16943 |
\dim_set_eq:NN \l_@@_y_initial_dim \pgf@y |
| 16944 |
\@@_qpoint:n { row - \int_eval:n { \c@iRow + 1 } } |
| 16945 |
\dim_set_eq:NN \l_@@_y_final_dim \pgf@y |
| 16946 |
% \end{macrocode} |
| 16947 |
% |
| 16948 |
% \medskip |
| 16949 |
% We will compute in |\l_tmpa_dim| the $x$-value where we will have to put our |
| 16950 |
% delimiter (on the left side or on the right side). |
| 16951 |
% \begin{macrocode} |
| 16952 |
\bool_if:nTF { #3 } |
| 16953 |
{ \dim_set_eq:NN \l_tmpa_dim \c_max_dim } |
| 16954 |
{ \dim_set:Nn \l_tmpa_dim { - \c_max_dim } } |
| 16955 |
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int |
| 16956 |
{ |
| 16957 |
\cs_if_exist:cT |
| 16958 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - #2 } |
| 16959 |
{ |
| 16960 |
\pgfpointanchor |
| 16961 |
{ \@@_env: - ##1 - #2 } |
| 16962 |
{ \bool_if:nTF { #3 } { west } { east } } |
| 16963 |
\dim_set:Nn \l_tmpa_dim |
| 16964 |
{ |
| 16965 |
\bool_if:nTF { #3 } |
| 16966 |
\dim_min:nn |
| 16967 |
\dim_max:nn |
| 16968 |
\l_tmpa_dim |
| 16969 |
\pgf@x |
| 16970 |
} |
| 16971 |
} |
| 16972 |
} |
| 16973 |
% \end{macrocode} |
| 16974 |
% |
| 16975 |
% |
| 16976 |
% Now we can put the delimiter with a node of \textsc{pgf}. |
| 16977 |
% \begin{macrocode} |
| 16978 |
\pgfset { inner~sep = \c_zero_dim } |
| 16979 |
\dim_zero:N \nulldelimiterspace |
| 16980 |
\pgftransformshift |
| 16981 |
{ |
| 16982 |
\pgfpoint |
| 16983 |
\l_tmpa_dim |
| 16984 |
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim + \arrayrulewidth ) / 2 } |
| 16985 |
} |
| 16986 |
\pgfnode |
| 16987 |
{ rectangle } |
| 16988 |
{ \bool_if:nTF { #3 } { east } { west } } |
| 16989 |
{ |
| 16990 |
% \end{macrocode} |
| 16991 |
% Here is the content of the \textsc{pgf} node, that is to say the delimiter, |
| 16992 |
% constructed with its right size. |
| 16993 |
% \begin{macrocode} |
| 16994 |
\nullfont |
| 16995 |
$ % $ |
| 16996 |
\@@_color:o \l_@@_delimiters_color_tl |
| 16997 |
\bool_if:nTF { #3 } { \left #1 } { \left . } |
| 16998 |
\vcenter |
| 16999 |
{ |
| 17000 |
\nullfont |
| 17001 |
\hrule \@height |
| 17002 |
\dim_eval:n { \l_@@_y_initial_dim - \l_@@_y_final_dim } |
| 17003 |
\@depth \c_zero_dim |
| 17004 |
\@width \c_zero_dim |
| 17005 |
} |
| 17006 |
\bool_if:nTF { #3 } { \right . } { \right #1 } |
| 17007 |
$ % $ |
| 17008 |
} |
| 17009 |
{ } |
| 17010 |
{ } |
| 17011 |
\endpgfpicture |
| 17012 |
} |
| 17013 |
% \end{macrocode} |
| 17014 |
% |
| 17015 |
% \section{The command \textbackslash SubMatrix} |
| 17016 |
% |
| 17017 |
% |
| 17018 |
% \begin{macrocode} |
| 17019 |
\keys_define:nn { nicematrix / sub-matrix } |
| 17020 |
{ |
| 17021 |
extra-height .dim_set:N = \l_@@_submatrix_extra_height_dim , |
| 17022 |
left-xshift .dim_set:N = \l_@@_submatrix_left_xshift_dim , |
| 17023 |
right-xshift .dim_set:N = \l_@@_submatrix_right_xshift_dim , |
| 17024 |
xshift .meta:n = { left-xshift = #1, right-xshift = #1 } , |
| 17025 |
xshift .value_required:n = true , |
| 17026 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 17027 |
delimiters / color .value_required:n = true , |
| 17028 |
slim .bool_set:N = \l_@@_submatrix_slim_bool , |
| 17029 |
hlines .clist_set:N = \l_@@_submatrix_hlines_clist , |
| 17030 |
hlines .default:n = all , |
| 17031 |
vlines .clist_set:N = \l_@@_submatrix_vlines_clist , |
| 17032 |
vlines .default:n = all , |
| 17033 |
hvlines .meta:n = { hlines, vlines } , |
| 17034 |
hvlines .value_forbidden:n = true |
| 17035 |
} |
| 17036 |
\keys_define:nn { nicematrix } |
| 17037 |
{ |
| 17038 |
SubMatrix .inherit:n = nicematrix / sub-matrix , |
| 17039 |
NiceArray / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 17040 |
pNiceArray / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 17041 |
NiceMatrixOptions / sub-matrix .inherit:n = nicematrix / sub-matrix , |
| 17042 |
} |
| 17043 |
% \end{macrocode} |
| 17044 |
% |
| 17045 |
% \medskip |
| 17046 |
% The following keys set is for the command |\SubMatrix| itself (not the tuning |
| 17047 |
% of |\SubMatrix| that can be done elsewhere). |
| 17048 |
% \begin{macrocode} |
| 17049 |
\keys_define:nn { nicematrix / SubMatrix } |
| 17050 |
{ |
| 17051 |
delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , |
| 17052 |
delimiters / color .value_required:n = true , |
| 17053 |
hlines .clist_set:N = \l_@@_submatrix_hlines_clist , |
| 17054 |
hlines .default:n = all , |
| 17055 |
vlines .clist_set:N = \l_@@_submatrix_vlines_clist , |
| 17056 |
vlines .default:n = all , |
| 17057 |
hvlines .meta:n = { hlines, vlines } , |
| 17058 |
hvlines .value_forbidden:n = true , |
| 17059 |
name .code:n = |
| 17060 |
\tl_if_empty:nTF { #1 } |
| 17061 |
{ \@@_error:n { Invalid~name } } |
| 17062 |
{ |
| 17063 |
\regex_if_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 } |
| 17064 |
{ |
| 17065 |
\seq_if_in:NnTF \g_@@_submatrix_names_seq { #1 } |
| 17066 |
{ \@@_error:nn { Duplicate~name~for~SubMatrix } { #1 } } |
| 17067 |
{ |
| 17068 |
\str_set:Nn \l_@@_submatrix_name_str { #1 } |
| 17069 |
\seq_gput_right:Nn \g_@@_submatrix_names_seq { #1 } |
| 17070 |
} |
| 17071 |
} |
| 17072 |
{ \@@_error:n { Invalid~name } } |
| 17073 |
} , |
| 17074 |
name .value_required:n = true , |
| 17075 |
rules .code:n = \keys_set:nn { nicematrix / rules } { #1 } , |
| 17076 |
rules .value_required:n = true , |
| 17077 |
code .tl_set:N = \l_@@_code_tl , |
| 17078 |
code .value_required:n = true , |
| 17079 |
unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix } |
| 17080 |
} |
| 17081 |
% \end{macrocode} |
| 17082 |
% |
| 17083 |
% |
| 17084 |
% |
| 17085 |
% \bigskip |
| 17086 |
% \begin{macrocode} |
| 17087 |
\NewDocumentCommand \@@_SubMatrix_in_code_before { m m m m ! O { } } |
| 17088 |
{ |
| 17089 |
\tl_gput_right:Ne \g_@@_pre_code_after_tl |
| 17090 |
{ |
| 17091 |
\SubMatrix { #1 } { #2 } { #3 } { #4 } |
| 17092 |
[ |
| 17093 |
delimiters / color = \l_@@_delimiters_color_tl , |
| 17094 |
hlines = \l_@@_submatrix_hlines_clist , |
| 17095 |
vlines = \l_@@_submatrix_vlines_clist , |
| 17096 |
extra-height = \dim_use:N \l_@@_submatrix_extra_height_dim , |
| 17097 |
left-xshift = \dim_use:N \l_@@_submatrix_left_xshift_dim , |
| 17098 |
right-xshift = \dim_use:N \l_@@_submatrix_right_xshift_dim , |
| 17099 |
slim = \bool_to_str:N \l_@@_submatrix_slim_bool , |
| 17100 |
#5 |
| 17101 |
] |
| 17102 |
} |
| 17103 |
\@@_SubMatrix_in_code_before_i { #2 } { #3 } |
| 17104 |
\ignorespaces |
| 17105 |
} |
| 17106 |
% \end{macrocode} |
| 17107 |
% |
| 17108 |
% \begin{macrocode} |
| 17109 |
\NewDocumentCommand \@@_SubMatrix_in_code_before_i |
| 17110 |
{ > { \SplitArgument { 1 } { - } } m > { \SplitArgument { 1 } { - } } m } |
| 17111 |
{ \@@_SubMatrix_in_code_before_i:nnnn #1 #2 } |
| 17112 |
% \end{macrocode} |
| 17113 |
% |
| 17114 |
% \begin{macrocode} |
| 17115 |
\cs_new_protected:Npn \@@_SubMatrix_in_code_before_i:nnnn #1 #2 #3 #4 |
| 17116 |
{ |
| 17117 |
\seq_gput_right:Ne \g_@@_submatrix_seq |
| 17118 |
{ |
| 17119 |
% \end{macrocode} |
| 17120 |
% We use |\str_if_eq:eeTF| because it is fully expandable (and slightly faster |
| 17121 |
% than |\tl_if_eq:nnTF|). |
| 17122 |
% \begin{macrocode} |
| 17123 |
{ \str_if_eq:eeTF { #1 } { last } { \int_use:N \c@iRow } { #1 } } |
| 17124 |
{ \str_if_eq:eeTF { #2 } { last } { \int_use:N \c@jCol } { #2 } } |
| 17125 |
{ \str_if_eq:eeTF { #3 } { last } { \int_use:N \c@iRow } { #3 } } |
| 17126 |
{ \str_if_eq:eeTF { #4 } { last } { \int_use:N \c@jCol } { #4 } } |
| 17127 |
} |
| 17128 |
} |
| 17129 |
% \end{macrocode} |
| 17130 |
% |
| 17131 |
% \medskip |
| 17132 |
% The following macro will compute |\l_@@_first_i_tl|, |\l_@@_first_j_tl|, |
| 17133 |
% |\l_@@_last_i_tl| and |\l_@@_last_j_tl| from the arguments of the command as |
| 17134 |
% provided by the user (for example |2-3| and |5-last|). |
| 17135 |
% \begin{macrocode} |
| 17136 |
\NewDocumentCommand \@@_compute_i_j:nn |
| 17137 |
{ > { \SplitArgument { 1 } { - } } m > { \SplitArgument { 1 } { - } } m } |
| 17138 |
{ \@@_compute_i_j:nnnn #1 #2 } |
| 17139 |
% \end{macrocode} |
| 17140 |
% |
| 17141 |
% \bigskip |
| 17142 |
% \begin{macrocode} |
| 17143 |
\cs_new_protected:Npn \@@_compute_i_j:nnnn #1 #2 #3 #4 |
| 17144 |
{ |
| 17145 |
\def \l_@@_first_i_tl { #1 } |
| 17146 |
\def \l_@@_first_j_tl { #2 } |
| 17147 |
\def \l_@@_last_i_tl { #3 } |
| 17148 |
\def \l_@@_last_j_tl { #4 } |
| 17149 |
\tl_if_eq:NnT \l_@@_first_i_tl { last } |
| 17150 |
{ \tl_set:NV \l_@@_first_i_tl \c@iRow } |
| 17151 |
\tl_if_eq:NnT \l_@@_first_j_tl { last } |
| 17152 |
{ \tl_set:NV \l_@@_first_j_tl \c@jCol } |
| 17153 |
\tl_if_eq:NnT \l_@@_last_i_tl { last } |
| 17154 |
{ \tl_set:NV \l_@@_last_i_tl \c@iRow } |
| 17155 |
\tl_if_eq:NnT \l_@@_last_j_tl { last } |
| 17156 |
{ \tl_set:NV \l_@@_last_j_tl \c@jCol } |
| 17157 |
} |
| 17158 |
% \end{macrocode} |
| 17159 |
% |
| 17160 |
% |
| 17161 |
% \bigskip |
| 17162 |
% In the pre-code-after and in the |\CodeAfter| the following command |
| 17163 |
% |\@@_SubMatrix| will be linked to |\SubMatrix|. |
| 17164 |
% \begin{itemize} |
| 17165 |
% \item |#1| is the left delimiter; |
| 17166 |
% \item |#2| is the upper-left cell of the matrix with the format $i$-$j$; |
| 17167 |
% \item |#3| is the lower-right cell of the matrix with the format $i$-$j$; |
| 17168 |
% \item |#4| is the right delimiter; |
| 17169 |
% \item |#5| is the list of options of the command; |
| 17170 |
% \item |#6| is the potential subscript; |
| 17171 |
% \item |#7| is the potential superscript. |
| 17172 |
% \end{itemize} |
| 17173 |
% For explanations about the construction with rescanning of the preamble, see |
| 17174 |
% the documentation for the user command |\Cdots|. |
| 17175 |
% \begin{macrocode} |
| 17176 |
\AtBeginDocument |
| 17177 |
{ |
| 17178 |
\tl_set_rescan:Nnn \l_tmpa_tl { } { m m m m O { } E { _ ^ } { { } { } } } |
| 17179 |
\exp_args:NNo \NewDocumentCommand \@@_SubMatrix \l_tmpa_tl |
| 17180 |
{ \@@_sub_matrix:nnnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } { #7 } } |
| 17181 |
} |
| 17182 |
% \end{macrocode} |
| 17183 |
|
| 17184 |
% |
| 17185 |
% |
| 17186 |
% \begin{macrocode} |
| 17187 |
\cs_new_protected:Npn \@@_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7 |
| 17188 |
{ |
| 17189 |
\group_begin: |
| 17190 |
% \end{macrocode} |
| 17191 |
% The four following token lists correspond to the position of the |\SubMatrix|. |
| 17192 |
% \begin{macrocode} |
| 17193 |
\@@_compute_i_j:nn { #2 } { #3 } |
| 17194 |
\int_compare:nNnT \l_@@_first_i_tl = \l_@@_last_i_tl |
| 17195 |
{ \def \arraystretch { 1 } } |
| 17196 |
\bool_lazy_or:nnTF |
| 17197 |
{ \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int } |
| 17198 |
{ \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int } |
| 17199 |
{ \@@_error:nn { Construct~too~large } { \SubMatrix } } |
| 17200 |
{ |
| 17201 |
\str_clear_new:N \l_@@_submatrix_name_str |
| 17202 |
\keys_set:nn { nicematrix / SubMatrix } { #5 } |
| 17203 |
\pgfpicture |
| 17204 |
\pgfrememberpicturepositiononpagetrue |
| 17205 |
\pgf@relevantforpicturesizefalse |
| 17206 |
\pgfset { inner~sep = \c_zero_dim } |
| 17207 |
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim |
| 17208 |
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } |
| 17209 |
% \end{macrocode} |
| 17210 |
% The last value of |\int_step_inline:nnn| is provided by curryfication. |
| 17211 |
% \begin{macrocode} |
| 17212 |
\bool_if:NTF \l_@@_submatrix_slim_bool |
| 17213 |
{ \int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl } |
| 17214 |
{ \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int } |
| 17215 |
{ |
| 17216 |
\cs_if_exist:cT |
| 17217 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl } |
| 17218 |
{ |
| 17219 |
\pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west } |
| 17220 |
\dim_compare:nNnT \pgf@x < \l_@@_x_initial_dim |
| 17221 |
{ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x } |
| 17222 |
} |
| 17223 |
\cs_if_exist:cT |
| 17224 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl } |
| 17225 |
{ |
| 17226 |
\pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east } |
| 17227 |
\dim_compare:nNnT \pgf@x > \l_@@_x_final_dim |
| 17228 |
{ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } |
| 17229 |
} |
| 17230 |
} |
| 17231 |
\dim_compare:nNnTF \l_@@_x_initial_dim = \c_max_dim |
| 17232 |
{ \@@_impossible_delimiter:n { left } } |
| 17233 |
{ |
| 17234 |
\dim_compare:nNnTF \l_@@_x_final_dim = { - \c_max_dim } |
| 17235 |
{ \@@_impossible_delimiter:n { right } } |
| 17236 |
{ \@@_sub_matrix_i:nnnn { #1 } { #4 } { #6 } { #7 } } |
| 17237 |
} |
| 17238 |
\endpgfpicture |
| 17239 |
} |
| 17240 |
\group_end: |
| 17241 |
\ignorespaces |
| 17242 |
} |
| 17243 |
% \end{macrocode} |
| 17244 |
% |
| 17245 |
% \bigskip |
| 17246 |
% The argument of the following command will be provided by curryfication. |
| 17247 |
% \begin{macrocode} |
| 17248 |
\cs_new_protected:Npn \@@_impossible_delimiter:n #1 |
| 17249 |
{ |
| 17250 |
\bool_if:NTF \l_@@_no_cell_nodes_bool |
| 17251 |
{ \@@_error:n { Impossible~SubMatrix~no~cell~nodes } } |
| 17252 |
{ \@@_error:nn { Impossible~SubMatrix } { #1 } } |
| 17253 |
} |
| 17254 |
% \end{macrocode} |
| 17255 |
% |
| 17256 |
% \bigskip |
| 17257 |
% |#1| is the left delimiter, |#2| is the right one, |#3| is the subscript and |
| 17258 |
% |#4| is the superscript. |
| 17259 |
% \begin{macrocode} |
| 17260 |
\cs_new_protected:Npn \@@_sub_matrix_i:nnnn #1 #2 #3 #4 |
| 17261 |
{ |
| 17262 |
\@@_qpoint:n { row - \l_@@_first_i_tl - base } |
| 17263 |
\dim_set:Nn \l_@@_y_initial_dim |
| 17264 |
{ |
| 17265 |
\fp_to_dim:n |
| 17266 |
{ |
| 17267 |
\pgf@y |
| 17268 |
+ ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch |
| 17269 |
} |
| 17270 |
} |
| 17271 |
\@@_qpoint:n { row - \l_@@_last_i_tl - base } |
| 17272 |
\dim_set:Nn \l_@@_y_final_dim |
| 17273 |
{ \fp_to_dim:n { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } } |
| 17274 |
\int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int |
| 17275 |
{ |
| 17276 |
\cs_if_exist:cT |
| 17277 |
{ pgf @ sh @ ns @ \@@_env: - \l_@@_first_i_tl - ##1 } |
| 17278 |
{ |
| 17279 |
\pgfpointanchor { \@@_env: - \l_@@_first_i_tl - ##1 } { north } |
| 17280 |
\dim_set:Nn \l_@@_y_initial_dim |
| 17281 |
{ \dim_max:nn \l_@@_y_initial_dim \pgf@y } |
| 17282 |
} |
| 17283 |
\cs_if_exist:cT |
| 17284 |
{ pgf @ sh @ ns @ \@@_env: - \l_@@_last_i_tl - ##1 } |
| 17285 |
{ |
| 17286 |
\pgfpointanchor { \@@_env: - \l_@@_last_i_tl - ##1 } { south } |
| 17287 |
\dim_compare:nNnT \pgf@y < \l_@@_y_final_dim |
| 17288 |
{ \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } |
| 17289 |
} |
| 17290 |
} |
| 17291 |
\dim_set:Nn \l_tmpa_dim |
| 17292 |
{ |
| 17293 |
\l_@@_y_initial_dim - \l_@@_y_final_dim + |
| 17294 |
\l_@@_submatrix_extra_height_dim - \arrayrulewidth |
| 17295 |
} |
| 17296 |
\dim_zero:N \nulldelimiterspace |
| 17297 |
% \end{macrocode} |
| 17298 |
% |
| 17299 |
% |
| 17300 |
% \bigskip |
| 17301 |
% We will draw the rules in the |\SubMatrix|. |
| 17302 |
% \begin{macrocode} |
| 17303 |
\group_begin: |
| 17304 |
\pgfsetlinewidth { 1.1 \arrayrulewidth } |
| 17305 |
\@@_set_CTarc:o \l_@@_rules_color_tl |
| 17306 |
\CT@arc@ |
| 17307 |
% \end{macrocode} |
| 17308 |
% Now, we draw the potential vertical rules specified in the preamble of the |
| 17309 |
% environments with the letter fixed with the key |vlines-in-sub-matrix|. The |
| 17310 |
% list of the columns where there is such rule to draw is in |\g_@@_cols_vlism_seq|. |
| 17311 |
% \begin{macrocode} |
| 17312 |
\seq_map_inline:Nn \g_@@_cols_vlism_seq |
| 17313 |
{ |
| 17314 |
\int_compare:nNnT \l_@@_first_j_tl < { ##1 } |
| 17315 |
{ |
| 17316 |
\int_compare:nNnT |
| 17317 |
{ ##1 } < { \int_eval:n { \l_@@_last_j_tl + 1 } } |
| 17318 |
{ |
| 17319 |
% \end{macrocode} |
| 17320 |
% First, we extract the value of the abscissa of the rule we have to draw. |
| 17321 |
% \begin{macrocode} |
| 17322 |
\@@_qpoint:n { col - ##1 } |
| 17323 |
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } |
| 17324 |
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim } |
| 17325 |
\pgfusepathqstroke |
| 17326 |
} |
| 17327 |
} |
| 17328 |
} |
| 17329 |
% \end{macrocode} |
| 17330 |
% |
| 17331 |
% \medskip |
| 17332 |
% Now, we draw the vertical rules specified in the key |vlines| of |\SubMatrix|. |
| 17333 |
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given |
| 17334 |
% by curryfication. |
| 17335 |
% \begin{macrocode} |
| 17336 |
\str_if_eq:eeTF \l_@@_submatrix_vlines_clist { all } |
| 17337 |
{ \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } } |
| 17338 |
{ \clist_map_inline:Nn \l_@@_submatrix_vlines_clist } |
| 17339 |
{ |
| 17340 |
\bool_lazy_and:nnTF |
| 17341 |
{ \int_compare_p:nNn { ##1 } > \c_zero_int } |
| 17342 |
{ |
| 17343 |
\int_compare_p:nNn |
| 17344 |
{ ##1 } < { \l_@@_last_j_tl - \l_@@_first_j_tl + 1 } } |
| 17345 |
{ |
| 17346 |
\@@_qpoint:n { col - \int_eval:n { ##1 + \l_@@_first_j_tl } } |
| 17347 |
\pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } |
| 17348 |
\pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim } |
| 17349 |
\pgfusepathqstroke |
| 17350 |
} |
| 17351 |
{ \@@_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } } |
| 17352 |
} |
| 17353 |
% \end{macrocode} |
| 17354 |
% |
| 17355 |
% \medskip |
| 17356 |
% Now, we draw the horizontal rules specified in the key |hlines| of |
| 17357 |
% |\SubMatrix|. |
| 17358 |
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given |
| 17359 |
% by curryfication. |
| 17360 |
% \begin{macrocode} |
| 17361 |
\str_if_eq:eeTF \l_@@_submatrix_hlines_clist { all } |
| 17362 |
{ \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } } |
| 17363 |
{ \clist_map_inline:Nn \l_@@_submatrix_hlines_clist } |
| 17364 |
{ |
| 17365 |
\bool_lazy_and:nnTF |
| 17366 |
{ \int_compare_p:nNn { ##1 } > \c_zero_int } |
| 17367 |
{ |
| 17368 |
\int_compare_p:nNn |
| 17369 |
{ ##1 } < { \l_@@_last_i_tl - \l_@@_first_i_tl + 1 } } |
| 17370 |
{ |
| 17371 |
\@@_qpoint:n { row - \int_eval:n { ##1 + \l_@@_first_i_tl } } |
| 17372 |
% \end{macrocode} |
| 17373 |
% We use a group to protect |\l_tmpa_dim| and |\l_tmpb_dim|. |
| 17374 |
% \begin{macrocode} |
| 17375 |
\group_begin: |
| 17376 |
% \end{macrocode} |
| 17377 |
% We compute in |\l_tmpa_dim| the $x$-value of the left end of the rule. |
| 17378 |
% \begin{macrocode} |
| 17379 |
\dim_set:Nn \l_tmpa_dim |
| 17380 |
{ \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim } |
| 17381 |
\str_case:nn { #1 } |
| 17382 |
{ |
| 17383 |
( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } |
| 17384 |
[ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } } |
| 17385 |
\{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } |
| 17386 |
} |
| 17387 |
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } |
| 17388 |
% \end{macrocode} |
| 17389 |
% We compute in |\l_tmpb_dim| the $x$-value of the right end of the rule. |
| 17390 |
% \begin{macrocode} |
| 17391 |
\dim_set:Nn \l_tmpb_dim |
| 17392 |
{ \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim } |
| 17393 |
\str_case:nn { #2 } |
| 17394 |
{ |
| 17395 |
) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } |
| 17396 |
] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } } |
| 17397 |
\} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } |
| 17398 |
} |
| 17399 |
\pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } |
| 17400 |
\pgfusepathqstroke |
| 17401 |
\group_end: |
| 17402 |
} |
| 17403 |
{ \@@_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } } |
| 17404 |
} |
| 17405 |
% \end{macrocode} |
| 17406 |
% |
| 17407 |
% \medskip |
| 17408 |
% If the key |name| has been used for the command |\SubMatrix|, we create a PGF |
| 17409 |
% node with that name for the submatrix (this node does not encompass the |
| 17410 |
% delimiters that we will put after). |
| 17411 |
% \begin{macrocode} |
| 17412 |
\str_if_empty:NF \l_@@_submatrix_name_str |
| 17413 |
{ |
| 17414 |
\@@_pgf_rect_node:nnnnn \l_@@_submatrix_name_str |
| 17415 |
\l_@@_x_initial_dim \l_@@_y_initial_dim |
| 17416 |
\l_@@_x_final_dim \l_@@_y_final_dim |
| 17417 |
} |
| 17418 |
\group_end: |
| 17419 |
% \end{macrocode} |
| 17420 |
% The group was for |\CT@arc@| (the color of the rules). |
| 17421 |
% |
| 17422 |
% \medskip |
| 17423 |
% Now, we deal with the left delimiter. Of course, the environment |
| 17424 |
% |{pgfscope}| is for the |\pgftransformshift|. |
| 17425 |
% \begin{macrocode} |
| 17426 |
\begin { pgfscope } |
| 17427 |
\pgftransformshift |
| 17428 |
{ |
| 17429 |
\pgfpoint |
| 17430 |
{ \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim } |
| 17431 |
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } |
| 17432 |
} |
| 17433 |
\str_if_empty:NTF \l_@@_submatrix_name_str |
| 17434 |
{ \@@_node_left:nn #1 { } } |
| 17435 |
{ \@@_node_left:nn #1 { \@@_env: - \l_@@_submatrix_name_str - left } } |
| 17436 |
\end { pgfscope } |
| 17437 |
% \end{macrocode} |
| 17438 |
% |
| 17439 |
% \medskip |
| 17440 |
% Now, we deal with the right delimiter. |
| 17441 |
% \begin{macrocode} |
| 17442 |
\pgftransformshift |
| 17443 |
{ |
| 17444 |
\pgfpoint |
| 17445 |
{ \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim } |
| 17446 |
{ ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } |
| 17447 |
} |
| 17448 |
\str_if_empty:NTF \l_@@_submatrix_name_str |
| 17449 |
{ \@@_node_right:nnnn #2 { } { #3 } { #4 } } |
| 17450 |
{ |
| 17451 |
\@@_node_right:nnnn #2 |
| 17452 |
{ \@@_env: - \l_@@_submatrix_name_str - right } { #3 } { #4 } |
| 17453 |
} |
| 17454 |
% \end{macrocode} |
| 17455 |
% |
| 17456 |
% \bigskip |
| 17457 |
% Now, we deal with the key |code| of |\SubMatrix|. That key should contain a |
| 17458 |
% TikZ instruction and the nodes in that instruction will be relative to the |
| 17459 |
% current |\SubMatrix|. That's why we need a redefinition of |\pgfpointanchor|. |
| 17460 |
% \begin{macrocode} |
| 17461 |
\cs_set_eq:NN \pgfpointanchor \@@_pgfpointanchor:n |
| 17462 |
\flag_clear_new:N \l_@@_code_flag |
| 17463 |
\l_@@_code_tl |
| 17464 |
} |
| 17465 |
% \end{macrocode} |
| 17466 |
% |
| 17467 |
% \bigskip |
| 17468 |
% In the key |code| of the command |\SubMatrix| there may be TikZ instructions. |
| 17469 |
% We want that, in these instructions, the $i$ and $j$ in specifications of |
| 17470 |
% nodes of the forms $i$|-|$j$, |row-|$i$, |col-|$j$ and $i$\verb+-|+$j$ refer |
| 17471 |
% to the number of row and column \emph{relative} of the current |\SubMatrix|. |
| 17472 |
% That's why we will patch (locally in the |\SubMatrix|) the command |
| 17473 |
% |\pgfpointanchor|. |
| 17474 |
% \begin{macrocode} |
| 17475 |
\cs_set_eq:NN \@@_old_pgfpointanchor: \pgfpointanchor |
| 17476 |
% \end{macrocode} |
| 17477 |
% |
| 17478 |
% \bigskip |
| 17479 |
% The following command will be linked to |\pgfpointanchor| just before the |
| 17480 |
% execution of the option |code| of the command |\SubMatrix|. In this command, |
| 17481 |
% we catch the argument |#1| of |\pgfpointanchor| and we apply to it the command |
| 17482 |
% |\@@_pgfpointanchor_i:nn| before passing it to the original |\pgfpointanchor|. |
| 17483 |
% We have to act in an expandable way because the command |\pgfpointanchor| is |
| 17484 |
% used in names of TikZ nodes which are computed in an expandable way. |
| 17485 |
% |
| 17486 |
% The original command |\pgfpointanchor| takes in two arguments: the name of the |
| 17487 |
% name and the name of the anchor. However, you don't have to modify the anchor, |
| 17488 |
% and that's why we do a redefinition of |\pgfpointanchor| by curryfication. |
| 17489 |
% \begin{macrocode} |
| 17490 |
\cs_new:Npn \@@_pgfpointanchor:n #1 |
| 17491 |
{ \exp_args:Ne \@@_old_pgfpointanchor: { \@@_pgfpointanchor_i:n { #1 } } } |
| 17492 |
% \end{macrocode} |
| 17493 |
% |
| 17494 |
% \medskip |
| 17495 |
% First, we must detect whether the argument is of the form |\tikz@pp@name{...}| |
| 17496 |
% (the command |\tikz@pp@name| is a command of TikZ that adds the prefix and the |
| 17497 |
% suffix of the name. If the name refers to a TikZ node which does not exist, |
| 17498 |
% there isn't the wrapper |\tikz@pp@name|. |
| 17499 |
% \begin{macrocode} |
| 17500 |
\cs_new:Npn \@@_pgfpointanchor_i:n #1 |
| 17501 |
{ \@@_pgfpointanchor_ii:w #1 \tikz@pp@name \q_stop } |
| 17502 |
% \end{macrocode} |
| 17503 |
% |
| 17504 |
% \begin{macrocode} |
| 17505 |
\cs_new:Npn \@@_pgfpointanchor_ii:w #1 \tikz@pp@name #2 \q_stop |
| 17506 |
{ |
| 17507 |
% \end{macrocode} |
| 17508 |
% The command |\str_if_empty:nTF| is ``fully expandable''. |
| 17509 |
% \begin{macrocode} |
| 17510 |
\str_if_empty:nTF { #1 } |
| 17511 |
% \end{macrocode} |
| 17512 |
% First, when the name of the name begins with |\tikz@pp@name|. |
| 17513 |
% \begin{macrocode} |
| 17514 |
{ \@@_pgfpointanchor_iv:w #2 } |
| 17515 |
% \end{macrocode} |
| 17516 |
% And now, when there is no |\tikz@pp@name|. |
| 17517 |
% \begin{macrocode} |
| 17518 |
{ \@@_pgfpointanchor_ii:n { #1 } } |
| 17519 |
} |
| 17520 |
% \end{macrocode} |
| 17521 |
% |
| 17522 |
% In the case where the name begins with |\tikz@pp@name|, we must retrieve |
| 17523 |
% the second |\tikz@pp@name|, that is to say to marker that we have added at the |
| 17524 |
% end (cf. |\@@_pgfpointanchor_i:n|). |
| 17525 |
% \begin{macrocode} |
| 17526 |
\cs_new:Npn \@@_pgfpointanchor_iv:w #1 \tikz@pp@name |
| 17527 |
{ \@@_pgfpointanchor_ii:n { #1 } } |
| 17528 |
% \end{macrocode} |
| 17529 |
% |
| 17530 |
% \bigskip |
| 17531 |
% With the command |\@@_pgfpointanchor_ii:n|, we deal with the actual name of |
| 17532 |
% the node (without the |\tikz@pp@name|). First, we have to detect whether it is |
| 17533 |
% of the form |i| of the form |i-j| (with an hyphen). |
| 17534 |
% |
| 17535 |
% Remark: It would be possible to test the presence of the hyphen in an |
| 17536 |
% expandable way to using |\etl_if_in:nnTF| of the package \pkg{etl} but, as of |
| 17537 |
% now, we do not load \pkg{etl}. |
| 17538 |
% \begin{macrocode} |
| 17539 |
\cs_new:Npn \@@_pgfpointanchor_ii:n #1 { \@@_pgfpointanchor_i:w #1- \q_stop } |
| 17540 |
% \end{macrocode} |
| 17541 |
% \bigskip |
| 17542 |
% \begin{macrocode} |
| 17543 |
\cs_new:Npn \@@_pgfpointanchor_i:w #1-#2 \q_stop |
| 17544 |
{ |
| 17545 |
% \end{macrocode} |
| 17546 |
% The command |\str_if_empty:nTF| is ``fully expandable''. |
| 17547 |
% \begin{macrocode} |
| 17548 |
\str_if_empty:nTF { #2 } |
| 17549 |
% \end{macrocode} |
| 17550 |
% First the case where the argument does \emph{not} contain an hyphen. |
| 17551 |
% \begin{macrocode} |
| 17552 |
{ \@@_pgfpointanchor_iii:n { #1 } } |
| 17553 |
% \end{macrocode} |
| 17554 |
% And now the case the argument contains a hyphen. In that case, we have a weird |
| 17555 |
% construction because we must retreive the extra hyphen we have added as marker |
| 17556 |
% (cf. |\@@_pgfpointanchor_ii:n|). |
| 17557 |
% \begin{macrocode} |
| 17558 |
{ \@@_pgfpointanchor_iii:w { #1 } #2 } |
| 17559 |
} |
| 17560 |
% \end{macrocode} |
| 17561 |
% |
| 17562 |
% |
| 17563 |
% The following function is for the case when the name contains an hyphen. |
| 17564 |
% \begin{macrocode} |
| 17565 |
\cs_new:Npn \@@_pgfpointanchor_iii:w #1 #2 - |
| 17566 |
{ |
| 17567 |
% \end{macrocode} |
| 17568 |
% We have to add the prefix |\@@_env:| ``by hand'' since we have retreived the |
| 17569 |
% potential |\tikz@pp@name|. |
| 17570 |
% \begin{macrocode} |
| 17571 |
\@@_env: |
| 17572 |
- \int_eval:n { #1 + \l_@@_first_i_tl - 1 } |
| 17573 |
- \int_eval:n { #2 + \l_@@_first_j_tl - 1 } |
| 17574 |
} |
| 17575 |
% \end{macrocode} |
| 17576 |
% |
| 17577 |
% |
| 17578 |
% \bigskip |
| 17579 |
% Since |\seq_if_in:NnTF| and |\clist_if_in:NnTF| are not expandable, we will |
| 17580 |
% use the following token list and |\str_case:nVTF| to test whether we have an |
| 17581 |
% integer or not. |
| 17582 |
% \begin{macrocode} |
| 17583 |
\tl_const:Nn \c_@@_integers_alist_tl |
| 17584 |
{ |
| 17585 |
{ 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { } |
| 17586 |
{ 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { } |
| 17587 |
{ 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { } |
| 17588 |
{ 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { } |
| 17589 |
} |
| 17590 |
% \end{macrocode} |
| 17591 |
% |
| 17592 |
% \bigskip |
| 17593 |
% \begin{macrocode} |
| 17594 |
\cs_new:Npn \@@_pgfpointanchor_iii:n #1 |
| 17595 |
{ |
| 17596 |
% \end{macrocode} |
| 17597 |
% If there is no hyphen, that means that the node is of the form of a single |
| 17598 |
% number (ex.: |5| or |11|). In that case, we are in an analysis which result |
| 17599 |
% from a specification of node of the form $i$\verb+-|+$j$. That special form is |
| 17600 |
% the reason of the special form of the argument of |\pgfpointanchor| which |
| 17601 |
% arises witht its command |\name_of_command| (see above). |
| 17602 |
% |
| 17603 |
% In that case, the $i$ of the number of row arrives first (and alone) in a |
| 17604 |
% |\pgfpointanchor| and, the, the $j$ arrives (alone) in the following |
| 17605 |
% |\pgfpointanchor|. In order to know whether we have a number of row or a |
| 17606 |
% number of column, we keep track of the number of such treatments by the |
| 17607 |
% expandable flag called |nicematrix|. |
| 17608 |
% \begin{macrocode} |
| 17609 |
\str_case:nVTF { #1 } \c_@@_integers_alist_tl |
| 17610 |
{ |
| 17611 |
\flag_raise:N \l_@@_code_flag |
| 17612 |
% \end{macrocode} |
| 17613 |
% We have to add the prefix |\@@_env:| ``by hand'' since we have retreived the |
| 17614 |
% potential |\tikz@pp@name|. |
| 17615 |
% \begin{macrocode} |
| 17616 |
\@@_env: - |
| 17617 |
\int_if_even:nTF { \flag_height:N \l_@@_code_flag } |
| 17618 |
{ \int_eval:n { #1 + \l_@@_first_i_tl - 1 } } |
| 17619 |
{ \int_eval:n { #1 + \l_@@_first_j_tl - 1 } } |
| 17620 |
} |
| 17621 |
{ |
| 17622 |
\str_if_eq:eeTF { #1 } { last } |
| 17623 |
{ |
| 17624 |
\flag_raise:N \l_@@_code_flag |
| 17625 |
\@@_env: - |
| 17626 |
\int_if_even:nTF { \flag_height:N \l_@@_code_flag } |
| 17627 |
{ \int_eval:n { \l_@@_last_i_tl + 1 } } |
| 17628 |
{ \int_eval:n { \l_@@_last_j_tl + 1 } } |
| 17629 |
} |
| 17630 |
{ #1 } |
| 17631 |
} |
| 17632 |
} |
| 17633 |
% \end{macrocode} |
| 17634 |
% |
| 17635 |
% |
| 17636 |
% \bigskip |
| 17637 |
% The command |\@@_node_left:nn| puts the left delimiter with the correct size. |
| 17638 |
% The argument |#1| is the delimiter to put. The argument |#2| is the name we |
| 17639 |
% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). |
| 17640 |
% \begin{macrocode} |
| 17641 |
\cs_new_protected:Npn \@@_node_left:nn #1 #2 |
| 17642 |
{ |
| 17643 |
\pgfnode |
| 17644 |
{ rectangle } |
| 17645 |
{ east } |
| 17646 |
{ |
| 17647 |
\nullfont |
| 17648 |
$ % $ |
| 17649 |
\@@_color:o \l_@@_delimiters_color_tl |
| 17650 |
\left #1 |
| 17651 |
\vcenter |
| 17652 |
{ |
| 17653 |
\nullfont |
| 17654 |
\hrule \@height \l_tmpa_dim |
| 17655 |
\@depth \c_zero_dim |
| 17656 |
\@width \c_zero_dim |
| 17657 |
} |
| 17658 |
\right . |
| 17659 |
$ % $ |
| 17660 |
} |
| 17661 |
{ #2 } |
| 17662 |
{ } |
| 17663 |
} |
| 17664 |
% \end{macrocode} |
| 17665 |
% |
| 17666 |
% \medskip |
| 17667 |
% The command |\@@_node_right:nn| puts the right delimiter with the correct size. |
| 17668 |
% The argument |#1| is the delimiter to put. The argument |#2| is the name we |
| 17669 |
% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). |
| 17670 |
% The argument |#3| is the subscript and |#4| is the superscript. |
| 17671 |
% \begin{macrocode} |
| 17672 |
\cs_new_protected:Npn \@@_node_right:nnnn #1 #2 #3 #4 |
| 17673 |
{ |
| 17674 |
\pgfnode |
| 17675 |
{ rectangle } |
| 17676 |
{ west } |
| 17677 |
{ |
| 17678 |
\nullfont |
| 17679 |
$ % $ |
| 17680 |
\colorlet { current-color } { . } |
| 17681 |
\@@_color:o \l_@@_delimiters_color_tl |
| 17682 |
\left . |
| 17683 |
\vcenter |
| 17684 |
{ |
| 17685 |
\nullfont |
| 17686 |
\hrule \@height \l_tmpa_dim |
| 17687 |
\@depth \c_zero_dim |
| 17688 |
\@width \c_zero_dim |
| 17689 |
} |
| 17690 |
\right #1 |
| 17691 |
\tl_if_empty:nF { #3 } { _ { \smash { #3 } } } |
| 17692 |
^ { \color { current-color } \smash { #4 } } |
| 17693 |
$ % $ |
| 17694 |
} |
| 17695 |
{ #2 } |
| 17696 |
{ } |
| 17697 |
} |
| 17698 |
% \end{macrocode} |
| 17699 |
% |
| 17700 |
% |
| 17701 |
% \bigskip |
| 17702 |
% \section{Les commandes \textbackslash UnderBrace et \textbackslash |
| 17703 |
% OverBrace} |
| 17704 |
% |
| 17705 |
% The following commands will be linked to |\UnderBrace| and |\OverBrace| in the |
| 17706 |
% |\CodeAfter|. |
| 17707 |
% |
| 17708 |
% \begin{macrocode} |
| 17709 |
\NewDocumentCommand \@@_UnderBrace { O { } m m m O { } } |
| 17710 |
{ |
| 17711 |
\@@_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { under } |
| 17712 |
\ignorespaces |
| 17713 |
} |
| 17714 |
% \end{macrocode} |
| 17715 |
% |
| 17716 |
% \begin{macrocode} |
| 17717 |
\NewDocumentCommand \@@_OverBrace { O { } m m m O { } } |
| 17718 |
{ |
| 17719 |
\@@_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { over } |
| 17720 |
\ignorespaces |
| 17721 |
} |
| 17722 |
% \end{macrocode} |
| 17723 |
% |
| 17724 |
% \medskip |
| 17725 |
% \begin{macrocode} |
| 17726 |
\keys_define:nn { nicematrix / Brace } |
| 17727 |
{ |
| 17728 |
left-shorten .bool_set:N = \l_@@_brace_left_shorten_bool , |
| 17729 |
left-shorten .value_forbidden:n = true , |
| 17730 |
right-shorten .bool_set:N = \l_@@_brace_right_shorten_bool , |
| 17731 |
right-shorten .value_forbidden:n = true , |
| 17732 |
shorten .meta:n = { left-shorten , right-shorten } , |
| 17733 |
shorten .value_forbidden:n = true , |
| 17734 |
yshift .dim_set:N = \l_@@_brace_yshift_dim , |
| 17735 |
color .tl_set:N = \l_tmpa_tl , |
| 17736 |
color .value_required:n = true , |
| 17737 |
unknown .code:n = |
| 17738 |
\@@_unknown_key:nn |
| 17739 |
{ nicematrix / Brace } |
| 17740 |
{ Unknown~key~for~Brace } |
| 17741 |
} |
| 17742 |
% \end{macrocode} |
| 17743 |
% |
| 17744 |
% \medskip |
| 17745 |
% |#1| is the first cell of the rectangle (with the syntax $i$\verb+-|+$j$; |
| 17746 |
% |#2| is the last cell of the rectangle; |
| 17747 |
% |#3| is the label of the text; |
| 17748 |
% |#4| is the optional argument (a list of \textsl{key}-\textsl{value} pairs); |
| 17749 |
% |#5| is equal to |under| or |over|. |
| 17750 |
% \begin{macrocode} |
| 17751 |
\cs_new_protected:Npn \@@_brace:nnnnn #1 #2 #3 #4 #5 |
| 17752 |
{ |
| 17753 |
\group_begin: |
| 17754 |
% \end{macrocode} |
| 17755 |
% The four following token lists correspond to the position of the sub-matrix to |
| 17756 |
% which a brace will be attached. |
| 17757 |
% \begin{macrocode} |
| 17758 |
\@@_compute_i_j:nn { #1 } { #2 } |
| 17759 |
\bool_lazy_or:nnTF |
| 17760 |
{ \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int } |
| 17761 |
{ \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int } |
| 17762 |
{ |
| 17763 |
\str_if_eq:eeTF { #5 } { under } |
| 17764 |
{ \@@_error:nn { Construct~too~large } { \UnderBrace } } |
| 17765 |
{ \@@_error:nn { Construct~too~large } { \OverBrace } } |
| 17766 |
} |
| 17767 |
{ |
| 17768 |
\tl_clear:N \l_tmpa_tl |
| 17769 |
\keys_set:nn { nicematrix / Brace } { #4 } |
| 17770 |
\tl_if_empty:NF \l_tmpa_tl { \color \l_tmpa_tl } |
| 17771 |
\pgfpicture |
| 17772 |
\pgfrememberpicturepositiononpagetrue |
| 17773 |
\pgf@relevantforpicturesizefalse |
| 17774 |
\bool_if:NT \l_@@_brace_left_shorten_bool |
| 17775 |
{ |
| 17776 |
\dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim |
| 17777 |
\int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl |
| 17778 |
{ |
| 17779 |
\cs_if_exist:cT |
| 17780 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl } |
| 17781 |
{ |
| 17782 |
\pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west } |
| 17783 |
|
| 17784 |
\dim_compare:nNnT \pgf@x < \l_@@_x_initial_dim |
| 17785 |
{ \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x } |
| 17786 |
} |
| 17787 |
} |
| 17788 |
} |
| 17789 |
\bool_lazy_or:nnT |
| 17790 |
{ \bool_not_p:n \l_@@_brace_left_shorten_bool } |
| 17791 |
{ \dim_compare_p:nNn \l_@@_x_initial_dim = \c_max_dim } |
| 17792 |
{ |
| 17793 |
\@@_qpoint:n { col - \l_@@_first_j_tl } |
| 17794 |
\dim_set_eq:NN \l_@@_x_initial_dim \pgf@x |
| 17795 |
} |
| 17796 |
\bool_if:NT \l_@@_brace_right_shorten_bool |
| 17797 |
{ |
| 17798 |
\dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } |
| 17799 |
\int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl |
| 17800 |
{ |
| 17801 |
\cs_if_exist:cT |
| 17802 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl } |
| 17803 |
{ |
| 17804 |
\pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east } |
| 17805 |
\dim_compare:nNnT \pgf@x > \l_@@_x_final_dim |
| 17806 |
{ \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } |
| 17807 |
} |
| 17808 |
} |
| 17809 |
} |
| 17810 |
\bool_lazy_or:nnT |
| 17811 |
{ \bool_not_p:n \l_@@_brace_right_shorten_bool } |
| 17812 |
{ \dim_compare_p:nNn \l_@@_x_final_dim = { - \c_max_dim } } |
| 17813 |
{ |
| 17814 |
\@@_qpoint:n { col - \int_eval:n { \l_@@_last_j_tl + 1 } } |
| 17815 |
\dim_set_eq:NN \l_@@_x_final_dim \pgf@x |
| 17816 |
} |
| 17817 |
\pgfset { inner~sep = \c_zero_dim } |
| 17818 |
\str_if_eq:eeTF { #5 } { under } |
| 17819 |
{ \@@_underbrace_i:n { #3 } } |
| 17820 |
{ \@@_overbrace_i:n { #3 } } |
| 17821 |
\endpgfpicture |
| 17822 |
} |
| 17823 |
\group_end: |
| 17824 |
} |
| 17825 |
% \end{macrocode} |
| 17826 |
% |
| 17827 |
% \medskip |
| 17828 |
% The argument is the text to put above the brace. |
| 17829 |
% \begin{macrocode} |
| 17830 |
\cs_new_protected:Npn \@@_overbrace_i:n #1 |
| 17831 |
{ |
| 17832 |
\@@_qpoint:n { row - \l_@@_first_i_tl } |
| 17833 |
\pgftransformshift |
| 17834 |
{ |
| 17835 |
\pgfpoint |
| 17836 |
{ ( \l_@@_x_initial_dim + \l_@@_x_final_dim ) / 2 } |
| 17837 |
{ \pgf@y + \l_@@_brace_yshift_dim - 3 pt } |
| 17838 |
} |
| 17839 |
\pgfnode |
| 17840 |
{ rectangle } |
| 17841 |
{ south } |
| 17842 |
{ |
| 17843 |
\vtop |
| 17844 |
{ |
| 17845 |
\group_begin: |
| 17846 |
\everycr { } |
| 17847 |
\halign |
| 17848 |
{ |
| 17849 |
\hfil ## \hfil \crcr |
| 17850 |
\bool_if:NTF \l_@@_tabular_bool |
| 17851 |
{ \begin { tabular } { c } #1 \end { tabular } } |
| 17852 |
{ $ \begin { array } { c } #1 \end { array } $ } |
| 17853 |
\cr |
| 17854 |
$ % $ |
| 17855 |
\overbrace |
| 17856 |
{ |
| 17857 |
\hbox_to_wd:nn |
| 17858 |
{ \l_@@_x_final_dim - \l_@@_x_initial_dim } |
| 17859 |
{ } |
| 17860 |
} |
| 17861 |
$ % $ |
| 17862 |
\cr |
| 17863 |
} |
| 17864 |
\group_end: |
| 17865 |
} |
| 17866 |
} |
| 17867 |
{ } |
| 17868 |
{ } |
| 17869 |
} |
| 17870 |
% \end{macrocode} |
| 17871 |
% |
| 17872 |
% |
| 17873 |
% \medskip |
| 17874 |
% The argument is the text to put under the brace. |
| 17875 |
% \begin{macrocode} |
| 17876 |
\cs_new_protected:Npn \@@_underbrace_i:n #1 |
| 17877 |
{ |
| 17878 |
\@@_qpoint:n { row - \int_eval:n { \l_@@_last_i_tl + 1 } } |
| 17879 |
\pgftransformshift |
| 17880 |
{ |
| 17881 |
\pgfpoint |
| 17882 |
{ ( \l_@@_x_initial_dim + \l_@@_x_final_dim ) / 2 } |
| 17883 |
{ \pgf@y - \l_@@_brace_yshift_dim + 3 pt } |
| 17884 |
} |
| 17885 |
\pgfnode |
| 17886 |
{ rectangle } |
| 17887 |
{ north } |
| 17888 |
{ |
| 17889 |
\group_begin: |
| 17890 |
\everycr { } |
| 17891 |
\vbox |
| 17892 |
{ |
| 17893 |
\halign |
| 17894 |
{ |
| 17895 |
\hfil ## \hfil \crcr |
| 17896 |
$ % $ |
| 17897 |
\underbrace |
| 17898 |
{ |
| 17899 |
\hbox_to_wd:nn |
| 17900 |
{ \l_@@_x_final_dim - \l_@@_x_initial_dim } |
| 17901 |
{ } |
| 17902 |
} |
| 17903 |
$ % $ |
| 17904 |
\cr |
| 17905 |
\bool_if:NTF \l_@@_tabular_bool |
| 17906 |
{ \begin { tabular } { c } #1 \end { tabular } } |
| 17907 |
{ $ \begin { array } { c } #1 \end { array } $ } |
| 17908 |
\cr |
| 17909 |
} |
| 17910 |
} |
| 17911 |
\group_end: |
| 17912 |
} |
| 17913 |
{ } |
| 17914 |
{ } |
| 17915 |
} |
| 17916 |
% \end{macrocode} |
| 17917 |
% |
| 17918 |
% \bigskip |
| 17919 |
% \section{The commands HBrace et VBrace} |
| 17920 |
% |
| 17921 |
% |
| 17922 |
% \bigskip |
| 17923 |
% The TikZ style |nicematrix/brace| is a TikZ style used to draw the braces created by |
| 17924 |
% |\Hbrace| and |\Vbrace|. |
| 17925 |
% |
| 17926 |
% We can't load that definition right away because of course, maybe the final user has not |
| 17927 |
% yet loaded TikZ (|\Hbrace| and |\Vbrace| are available only when TikZ is loaded and also |
| 17928 |
% its library |decorations.pathreplacing|). |
| 17929 |
% |
| 17930 |
% \begin{macrocode} |
| 17931 |
\AddToHook { package / tikz / after } |
| 17932 |
{ |
| 17933 |
\tikzset |
| 17934 |
{ |
| 17935 |
nicematrix / brace / .style = |
| 17936 |
{ |
| 17937 |
decoration = { brace , raise = -0.15 em } , |
| 17938 |
decorate , |
| 17939 |
} , |
| 17940 |
% \end{macrocode} |
| 17941 |
% Unlike the previous one, the following set of keys is internal. It won't be |
| 17942 |
% provided by the final user. |
| 17943 |
% \begin{macrocode} |
| 17944 |
nicematrix / mirrored-brace / .style = |
| 17945 |
{ |
| 17946 |
nicematrix / brace , |
| 17947 |
decoration = mirror , |
| 17948 |
} |
| 17949 |
} |
| 17950 |
} |
| 17951 |
% \end{macrocode} |
| 17952 |
% |
| 17953 |
% \bigskip |
| 17954 |
% The following set of keys will be used only for security since the keys will |
| 17955 |
% be sent to the command |\Ldots| or |\Vdots|. |
| 17956 |
% \begin{macrocode} |
| 17957 |
\keys_define:nn { nicematrix / Hbrace } |
| 17958 |
{ |
| 17959 |
color .code:n = , |
| 17960 |
horizontal-label .code:n = , |
| 17961 |
horizontal-labels .code:n = , |
| 17962 |
shorten .code:n = , |
| 17963 |
shorten-start .code:n = , |
| 17964 |
shorten-end .code:n = , |
| 17965 |
shorten+ .code:n = , |
| 17966 |
shorten-start+ .code:n = , |
| 17967 |
shorten-end+ .code:n = , |
| 17968 |
shorten~+ .code:n = , |
| 17969 |
shorten-start~+ .code:n = , |
| 17970 |
shorten-end~+ .code:n = , |
| 17971 |
brace-shift .code:n = , |
| 17972 |
brace-shift+ .code:n = , |
| 17973 |
brace-shift~+ .code:n = , |
| 17974 |
unknown .code:n = \@@_fatal:n { Unknown~key~for~Hbrace } |
| 17975 |
} |
| 17976 |
% \end{macrocode} |
| 17977 |
% |
| 17978 |
% \bigskip |
| 17979 |
% Here we need an ``fully expandable'' command. |
| 17980 |
% \begin{macrocode} |
| 17981 |
\NewExpandableDocumentCommand { \@@_Hbrace } { O { } m m } |
| 17982 |
{ |
| 17983 |
\cs_if_exist:cTF { tikz@[email protected]@loaded } |
| 17984 |
{ \@@_hbrace:nnn { #1 } { #2 } { #3 } } |
| 17985 |
{ \@@_error:nn { Hbrace~not~allowed } { \Hbrace } } |
| 17986 |
} |
| 17987 |
% \end{macrocode} |
| 17988 |
% |
| 17989 |
% \bigskip |
| 17990 |
% The following command must \emph{not} be protected because of the |
| 17991 |
% |\Hdotsfor| which contains a |\multicolumn| |
| 17992 |
% (whereas the similar command |\@@_vbrace:nnn| \emph{must} be protected). |
| 17993 |
% \begin{macrocode} |
| 17994 |
\cs_new:Npn \@@_hbrace:nnn #1 #2 #3 |
| 17995 |
{ |
| 17996 |
\int_compare:nNnTF \c@iRow < { 2 } |
| 17997 |
{ |
| 17998 |
% \end{macrocode} |
| 17999 |
% We recall that |\str_if_eq:nnTF| is ``fully expandable''. |
| 18000 |
% \begin{macrocode} |
| 18001 |
\str_if_eq:nnTF { #2 } { * } |
| 18002 |
{ |
| 18003 |
\bool_set_true:N \l_@@_nullify_dots_bool |
| 18004 |
\Ldots |
| 18005 |
[ |
| 18006 |
line-style = nicematrix / brace , |
| 18007 |
#1 , |
| 18008 |
up = |
| 18009 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18010 |
] |
| 18011 |
} |
| 18012 |
{ |
| 18013 |
\Hdotsfor |
| 18014 |
[ |
| 18015 |
line-style = nicematrix / brace , |
| 18016 |
#1 , |
| 18017 |
up = |
| 18018 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18019 |
] |
| 18020 |
{ #2 } |
| 18021 |
} |
| 18022 |
} |
| 18023 |
{ |
| 18024 |
\str_if_eq:nnTF { #2 } { * } |
| 18025 |
{ |
| 18026 |
\bool_set_true:N \l_@@_nullify_dots_bool |
| 18027 |
\Ldots |
| 18028 |
[ |
| 18029 |
line-style = nicematrix / mirrored-brace , |
| 18030 |
#1 , |
| 18031 |
down = |
| 18032 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18033 |
] |
| 18034 |
} |
| 18035 |
{ |
| 18036 |
\Hdotsfor |
| 18037 |
[ |
| 18038 |
line-style = nicematrix / mirrored-brace , |
| 18039 |
#1 , |
| 18040 |
down = |
| 18041 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18042 |
] |
| 18043 |
{ #2 } |
| 18044 |
} |
| 18045 |
} |
| 18046 |
\keys_set:nn { nicematrix / Hbrace } { #1 } |
| 18047 |
} |
| 18048 |
% \end{macrocode} |
| 18049 |
% |
| 18050 |
% \bigskip |
| 18051 |
% \begin{macrocode} |
| 18052 |
\NewDocumentCommand { \@@_Vbrace } { O { } m m } |
| 18053 |
{ |
| 18054 |
\cs_if_exist:cTF { tikz@[email protected]@loaded } |
| 18055 |
{ \@@_vbrace:nnn { #1 } { #2 } { #3 } } |
| 18056 |
{ \@@_error:nn { Hbrace~not~allowed } { \Vbrace } } |
| 18057 |
} |
| 18058 |
% \end{macrocode} |
| 18059 |
% |
| 18060 |
% |
| 18061 |
% The following command must be protected (whereas the similar |
| 18062 |
% command |\@@_hbrace:nnn| must not. |
| 18063 |
% \begin{macrocode} |
| 18064 |
\cs_new_protected:Npn \@@_vbrace:nnn #1 #2 #3 |
| 18065 |
{ |
| 18066 |
\int_compare:nNnTF \c@jCol < { 2 } |
| 18067 |
{ |
| 18068 |
\str_if_eq:nnTF { #2 } { * } |
| 18069 |
{ |
| 18070 |
\bool_set_true:N \l_@@_nullify_dots_bool |
| 18071 |
\Vdots |
| 18072 |
[ |
| 18073 |
Vbrace , |
| 18074 |
line-style = nicematrix / mirrored-brace , |
| 18075 |
#1 , |
| 18076 |
down = |
| 18077 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18078 |
] |
| 18079 |
} |
| 18080 |
{ |
| 18081 |
\Vdotsfor |
| 18082 |
[ |
| 18083 |
Vbrace , |
| 18084 |
line-style = nicematrix / mirrored-brace , |
| 18085 |
#1 , |
| 18086 |
down = |
| 18087 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18088 |
] |
| 18089 |
{ #2 } |
| 18090 |
} |
| 18091 |
} |
| 18092 |
{ |
| 18093 |
\str_if_eq:nnTF { #2 } { * } |
| 18094 |
{ |
| 18095 |
\bool_set_true:N \l_@@_nullify_dots_bool |
| 18096 |
\Vdots |
| 18097 |
[ |
| 18098 |
Vbrace , |
| 18099 |
line-style = nicematrix / brace , |
| 18100 |
#1 , |
| 18101 |
up = |
| 18102 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18103 |
] |
| 18104 |
} |
| 18105 |
{ |
| 18106 |
\Vdotsfor |
| 18107 |
[ |
| 18108 |
Vbrace , |
| 18109 |
line-style = nicematrix / brace , |
| 18110 |
#1 , |
| 18111 |
up = |
| 18112 |
\bool_if:NT \l_@@_tabular_bool \text { \exp_not:n { #3 } } |
| 18113 |
] |
| 18114 |
{ #2 } |
| 18115 |
} |
| 18116 |
} |
| 18117 |
\keys_set:nn { nicematrix / Hbrace } { #1 } |
| 18118 |
} |
| 18119 |
% \end{macrocode} |
| 18120 |
% |
| 18121 |
% \bigskip |
| 18122 |
% \section{The command TikzEveryCell} |
| 18123 |
% |
| 18124 |
% \begin{macrocode} |
| 18125 |
\bool_new:N \l_@@_not_empty_bool |
| 18126 |
\bool_new:N \l_@@_empty_bool |
| 18127 |
|
| 18128 |
\keys_define:nn { nicematrix / TikzEveryCell } |
| 18129 |
{ |
| 18130 |
not-empty .code:n = |
| 18131 |
\bool_lazy_or:nnTF \l_@@_in_code_after_bool \g_@@_create_cell_nodes_bool |
| 18132 |
{ \bool_set_true:N \l_@@_not_empty_bool } |
| 18133 |
{ \@@_error:n { detection~of~empty~cells } } , |
| 18134 |
not-empty .value_forbidden:n = true , |
| 18135 |
empty .code:n = |
| 18136 |
\bool_lazy_or:nnTF \l_@@_in_code_after_bool \g_@@_create_cell_nodes_bool |
| 18137 |
{ \bool_set_true:N \l_@@_empty_bool } |
| 18138 |
{ \@@_error:n { detection~of~empty~cells } } , |
| 18139 |
empty .value_forbidden:n = true , |
| 18140 |
unknown .code:n = \@@_error:n { Unknown~key~for~TikzEveryCell } |
| 18141 |
} |
| 18142 |
|
| 18143 |
|
| 18144 |
\NewDocumentCommand { \@@_TikzEveryCell } { O { } m } |
| 18145 |
{ |
| 18146 |
\IfPackageLoadedTF { tikz } |
| 18147 |
{ |
| 18148 |
\group_begin: |
| 18149 |
\keys_set:nn { nicematrix / TikzEveryCell } { #1 } |
| 18150 |
% \end{macrocode} |
| 18151 |
% The inner pair of braces in the following line is mandatory because, the last |
| 18152 |
% argument of |\@@_tikz:nnnnn| is \emph{a list of lists} of TikZ keys. |
| 18153 |
% \begin{macrocode} |
| 18154 |
\tl_set:Nn \l_tmpa_tl { { #2 } } |
| 18155 |
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq |
| 18156 |
{ \@@_for_a_block:nnnnn ##1 } |
| 18157 |
\@@_all_the_cells: |
| 18158 |
\group_end: |
| 18159 |
} |
| 18160 |
{ \@@_error:n { TikzEveryCell~without~tikz } } |
| 18161 |
} |
| 18162 |
|
| 18163 |
|
| 18164 |
\cs_new_protected:Nn \@@_all_the_cells: |
| 18165 |
{ |
| 18166 |
\int_step_inline:nn \c@iRow |
| 18167 |
{ |
| 18168 |
\int_step_inline:nn \c@jCol |
| 18169 |
{ |
| 18170 |
\cs_if_exist:cF { cell - ##1 - ####1 } |
| 18171 |
{ |
| 18172 |
\clist_if_in:NeF \l_@@_corners_cells_clist |
| 18173 |
{ ##1 - ####1 } |
| 18174 |
{ |
| 18175 |
\bool_set_false:N \l_tmpa_bool |
| 18176 |
\cs_if_exist:cTF |
| 18177 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - ####1 } |
| 18178 |
{ |
| 18179 |
\bool_if:NF \l_@@_empty_bool |
| 18180 |
{ \bool_set_true:N \l_tmpa_bool } |
| 18181 |
} |
| 18182 |
{ |
| 18183 |
\bool_if:NF \l_@@_not_empty_bool |
| 18184 |
{ \bool_set_true:N \l_tmpa_bool } |
| 18185 |
} |
| 18186 |
\bool_if:NT \l_tmpa_bool |
| 18187 |
{ |
| 18188 |
\@@_block_tikz:onnnn |
| 18189 |
\l_tmpa_tl { ##1 } { ####1 } { ##1 } { ####1 } |
| 18190 |
} |
| 18191 |
} |
| 18192 |
} |
| 18193 |
} |
| 18194 |
} |
| 18195 |
} |
| 18196 |
|
| 18197 |
\cs_new_protected:Nn \@@_for_a_block:nnnnn |
| 18198 |
{ |
| 18199 |
\bool_if:NF \l_@@_empty_bool |
| 18200 |
{ |
| 18201 |
\@@_block_tikz:onnnn |
| 18202 |
\l_tmpa_tl { #1 } { #2 } { #3 } { #4 } |
| 18203 |
} |
| 18204 |
\@@_mark_cells_of_block:nnnn { #1 } { #2 } { #3 } { #4 } |
| 18205 |
} |
| 18206 |
|
| 18207 |
\cs_new_protected:Nn \@@_mark_cells_of_block:nnnn |
| 18208 |
{ |
| 18209 |
\int_step_inline:nnn { #1 } { #3 } |
| 18210 |
{ |
| 18211 |
\int_step_inline:nnn { #2 } { #4 } |
| 18212 |
{ \cs_set_nopar:cpn { cell - ##1 - ####1 } { } } |
| 18213 |
} |
| 18214 |
} |
| 18215 |
% \end{macrocode} |
| 18216 |
% |
| 18217 |
% \bigskip |
| 18218 |
% \section{The key draw-trees-in-col} |
| 18219 |
% |
| 18220 |
% |
| 18221 |
% \begin{macrocode} |
| 18222 |
\cs_new_protected:Npn \@@_draw_trees: |
| 18223 |
{ |
| 18224 |
\bool_if:NTF \l_@@_no_cell_nodes_bool |
| 18225 |
{ \@@_error:n { draw-trees~with~no-cell-nodes } } |
| 18226 |
\@@_draw_trees_i: |
| 18227 |
} |
| 18228 |
% \end{macrocode} |
| 18229 |
% |
| 18230 |
% \begin{macrocode} |
| 18231 |
\cs_new_protected:Npn \@@_draw_trees_i: |
| 18232 |
{ |
| 18233 |
\@@_expand_clist_hvlines:NN \g_@@_col_with_trees_clist \c@jCol |
| 18234 |
\dim_zero_new:N \l_@@_em_dim |
| 18235 |
\dim_set:Nn \l_@@_em_dim { 1 em } |
| 18236 |
\dim_zero_new:N \l_@@_ex_dim |
| 18237 |
\dim_set:Nn \l_@@_ex_dim { 1 ex } |
| 18238 |
\pgfpicture |
| 18239 |
\pgfrememberpicturepositiononpagetrue |
| 18240 |
\pgf@relevantforpicturesizefalse |
| 18241 |
\dim_compare:nNnT \l_@@_trees_line_width_dim > \c_zero_dim |
| 18242 |
{ \pgfsetlinewidth { \l_@@_trees_line_width_dim } } |
| 18243 |
\@@_color:o \l_@@_trees_color_tl |
| 18244 |
\pgfsetcornersarced |
| 18245 |
{ \pgfpoint \l_@@_trees_rounded_corners_dim \l_@@_trees_rounded_corners_dim } |
| 18246 |
\clist_map_function:NN \g_@@_col_with_trees_clist |
| 18247 |
\@@_draw_trees_in_col:n |
| 18248 |
\clist_gclear:N \g_@@_col_with_trees_clist |
| 18249 |
\endpgfpicture |
| 18250 |
} |
| 18251 |
% \end{macrocode} |
| 18252 |
% |
| 18253 |
% \bigskip |
| 18254 |
% \begin{macrocode} |
| 18255 |
\cs_new_protected:Npn \@@_draw_trees_in_col:n #1 |
| 18256 |
{ |
| 18257 |
% \end{macrocode} |
| 18258 |
% The argument is provided by curryfication. |
| 18259 |
% \begin{macrocode} |
| 18260 |
\int_compare:nNnTF { #1 } > \c@jCol |
| 18261 |
{ \@@_error:nn { Col~outside~tabular~in~trees } } |
| 18262 |
{ |
| 18263 |
\int_compare:nNnTF { #1 } = \c@jCol |
| 18264 |
{ \@@_error:nn { Last~col~in~trees } } |
| 18265 |
\@@_draw_trees_in_col_i:n |
| 18266 |
} |
| 18267 |
{ #1 } |
| 18268 |
} |
| 18269 |
% \end{macrocode} |
| 18270 |
% |
| 18271 |
% \bigskip |
| 18272 |
% \begin{macrocode} |
| 18273 |
\cs_new_protected:Npn \@@_draw_trees_in_col_i:n #1 |
| 18274 |
{ |
| 18275 |
\int_set:Nn \l_tmpa_int { 1 } |
| 18276 |
\int_step_inline:nn { \c@iRow + 1 } |
| 18277 |
{ |
| 18278 |
\cs_if_exist:cT |
| 18279 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - #1 } |
| 18280 |
{ |
| 18281 |
\int_compare:nNnT { ##1 } > { \l_tmpa_int + 1 } |
| 18282 |
{ |
| 18283 |
% \end{macrocode} |
| 18284 |
% Now, you will, potentially, draw a tree. |
| 18285 |
% \begin{macrocode} |
| 18286 |
\@@_draw_tree:nee |
| 18287 |
{ #1 } |
| 18288 |
{ \int_use:N \l_tmpa_int } |
| 18289 |
{ \int_eval:n { ##1 - 1 } } |
| 18290 |
} |
| 18291 |
\int_set:Nn \l_tmpa_int { ##1 } |
| 18292 |
} |
| 18293 |
} |
| 18294 |
\int_compare:nNnT \c@iRow > \l_tmpa_int |
| 18295 |
{ |
| 18296 |
\@@_draw_tree:nee |
| 18297 |
{ #1 } |
| 18298 |
{ \int_use:N \l_tmpa_int } |
| 18299 |
{ \int_eval:n { \c@iRow } } |
| 18300 |
} |
| 18301 |
} |
| 18302 |
% \end{macrocode} |
| 18303 |
% |
| 18304 |
% \bigskip |
| 18305 |
% |#1| is the number of column; |
| 18306 |
% |#2| is the first row : the root of the tree; |
| 18307 |
% |#3| is the last row of the blank zone where we will draw our tree. |
| 18308 |
% \begin{macrocode} |
| 18309 |
\cs_new_protected:Npn \@@_draw_tree:nnn #1 #2 #3 |
| 18310 |
{ |
| 18311 |
% \end{macrocode} |
| 18312 |
% |\l_tmpa_dim| will be the $x$-value of the vertical rule that we will draw. |
| 18313 |
% \begin{macrocode} |
| 18314 |
\pgfpointanchor { \@@_env: - #1 } { 5 } |
| 18315 |
\dim_set_eq:NN \l_tmpa_dim \pgf@x |
| 18316 |
% \end{macrocode} |
| 18317 |
% We will begin by the \emph{last} branch of the tree. When that last branch |
| 18318 |
% has been drawn (with the vertical line), we will rise the boolean |\l_tmpa_bool|. |
| 18319 |
% \begin{macrocode} |
| 18320 |
\bool_set_false:N \l_tmpa_bool |
| 18321 |
\int_step_inline:nnnn { #3 } { -1 } { #2 + 1 } |
| 18322 |
{ |
| 18323 |
\cs_if_exist:cT |
| 18324 |
{ pgf @ sh @ ns @ \@@_env: - ##1 - \int_eval:n { #1 + 1 } } |
| 18325 |
% \end{macrocode} |
| 18326 |
% We have found the last branch to draw. |
| 18327 |
% \begin{macrocode} |
| 18328 |
{ |
| 18329 |
\pgfpointanchor |
| 18330 |
{ \@@_env: - ##1 - \int_eval:n { #1 + 1 } } |
| 18331 |
{ base~west } |
| 18332 |
\pgfpathmoveto |
| 18333 |
{ |
| 18334 |
\pgfpoint |
| 18335 |
{ \dim_eval:n { \pgf@x - 0.7 \l_@@_ex_dim } } |
| 18336 |
{ \dim_eval:n { \pgf@y + 0.25 \l_@@_em_dim } } |
| 18337 |
} |
| 18338 |
\pgfpathlineto { \pgfpoint \l_tmpa_dim \pgf@y } |
| 18339 |
\bool_if:NF \l_tmpa_bool |
| 18340 |
{ |
| 18341 |
\pgfpointanchor{ \@@_env: - #2 - #1 } { south } |
| 18342 |
\pgfpathlineto |
| 18343 |
{ \pgfpoint \l_tmpa_dim { \dim_eval:n { \pgf@y - 3pt } } } |
| 18344 |
\bool_set_true:N \l_tmpa_bool |
| 18345 |
} |
| 18346 |
\pgfusepath { stroke } |
| 18347 |
} |
| 18348 |
} |
| 18349 |
} |
| 18350 |
\cs_generate_variant:Nn \@@_draw_tree:nnn { n e e } |
| 18351 |
% \end{macrocode} |
| 18352 |
% |
| 18353 |
% |
| 18354 |
% \bigskip |
| 18355 |
% \section{The key create-blocks-in-col} |
| 18356 |
% |
| 18357 |
% \begin{macrocode} |
| 18358 |
\cs_new_protected:Npn \@@_create_blocks_in_col: |
| 18359 |
{ |
| 18360 |
\@@_expand_clist_hvlines:NN \g_@@_cbic_clist \c@jCol |
| 18361 |
\clist_map_inline:Nn \g_@@_cbic_clist |
| 18362 |
{ |
| 18363 |
\cs_set:cpn |
| 18364 |
{ |
| 18365 |
pgf @ sh @ ns @ \@@_env: |
| 18366 |
- \int_eval:n { \c@iRow + 1 } - ##1 } |
| 18367 |
{ rien } |
| 18368 |
% \end{macrocode} |
| 18369 |
% |\l_tmpa_int| will be the first row of the block being created. |
| 18370 |
% \begin{macrocode} |
| 18371 |
\int_set:Nn \l_tmpa_int { 1 } |
| 18372 |
\int_step_inline:nn { \c@iRow + 1 } |
| 18373 |
{ |
| 18374 |
\cs_if_exist:cT |
| 18375 |
{ pgf @ sh @ ns @ \@@_env: - ####1 - ##1 } |
| 18376 |
{ |
| 18377 |
\int_compare:nNnT { ####1 } > { \l_tmpa_int + 1 } |
| 18378 |
{ |
| 18379 |
\seq_gput_right:Ne \g_@@_pos_of_blocks_seq |
| 18380 |
{ |
| 18381 |
{ \int_use:N \l_tmpa_int } |
| 18382 |
{ ##1 } |
| 18383 |
{ \int_eval:n { ####1 - 1 } } |
| 18384 |
{ ##1 } |
| 18385 |
{ } |
| 18386 |
} |
| 18387 |
} |
| 18388 |
\int_set:Nn \l_tmpa_int { ####1 } |
| 18389 |
} |
| 18390 |
} |
| 18391 |
} |
| 18392 |
\clist_gclear:N \g_@@_cbic_clist |
| 18393 |
} |
| 18394 |
% \end{macrocode} |
| 18395 |
% |
| 18396 |
% \bigskip |
| 18397 |
% \section{The command \textbackslash ShowCellNames} |
| 18398 |
% |
| 18399 |
% |
| 18400 |
% \medskip |
| 18401 |
% When the command |\ShowCellNames| is used in the |\CodeBefore|, we want to stroke |
| 18402 |
% the names of the cells \emph{after} the potential backgrounds of the cells. That's why |
| 18403 |
% we add the command |\@@_ShowCellNames| to the right of the command |\@@_actually_color:| |
| 18404 |
% which actually fill the backgrounds. |
| 18405 |
% |
| 18406 |
% |
| 18407 |
% \begin{macrocode} |
| 18408 |
\cs_new_protected:Npn \@@_ShowCellNamesCodeBefore |
| 18409 |
{ \tl_put_right:Nn \@@_actually_color: \@@_ShowCellNames } % noqa |
| 18410 |
% \end{macrocode} |
| 18411 |
% |
| 18412 |
% \bigskip |
| 18413 |
% \begin{macrocode} |
| 18414 |
\NewDocumentCommand \@@_ShowCellNames { } |
| 18415 |
{ |
| 18416 |
\bool_if:NT \l_@@_in_code_after_bool |
| 18417 |
{ |
| 18418 |
\pgfpicture |
| 18419 |
\pgfrememberpicturepositiononpagetrue |
| 18420 |
\pgf@relevantforpicturesizefalse |
| 18421 |
\pgfpathrectanglecorners |
| 18422 |
{ \@@_qpoint:n { 1 } } |
| 18423 |
{ \@@_qpoint:n { \int_eval:n { 1 + \int_max:nn \c@iRow \c@jCol } } } |
| 18424 |
\pgfsetfillopacity { 0.75 } |
| 18425 |
\pgfsetfillcolor { white } |
| 18426 |
\pgfusepathqfill |
| 18427 |
\endpgfpicture |
| 18428 |
} |
| 18429 |
\dim_gzero_new:N \g_@@_tmpc_dim |
| 18430 |
\dim_gzero_new:N \g_@@_tmpd_dim |
| 18431 |
\dim_gzero_new:N \g_@@_tmpe_dim |
| 18432 |
\int_step_inline:nn \c@iRow |
| 18433 |
{ |
| 18434 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 18435 |
{ |
| 18436 |
\pgfpicture |
| 18437 |
\pgfrememberpicturepositiononpagetrue |
| 18438 |
\pgf@relevantforpicturesizefalse |
| 18439 |
} |
| 18440 |
{ \begin { pgfpicture } } |
| 18441 |
\@@_qpoint:n { row - ##1 } |
| 18442 |
\dim_set_eq:NN \l_tmpa_dim \pgf@y |
| 18443 |
\@@_qpoint:n { row - \int_eval:n { ##1 + 1 } } |
| 18444 |
\dim_gset:Nn \g_tmpa_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } |
| 18445 |
\dim_gset:Nn \g_tmpb_dim { \l_tmpa_dim - \pgf@y } |
| 18446 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 18447 |
{ \endpgfpicture } |
| 18448 |
{ \end { pgfpicture } } |
| 18449 |
\int_step_inline:nn \c@jCol |
| 18450 |
{ |
| 18451 |
\hbox_set:Nn \l_tmpa_box |
| 18452 |
{ |
| 18453 |
\normalfont \Large \sffamily \bfseries |
| 18454 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 18455 |
{ \color { red } } |
| 18456 |
{ \color { red ! 50 } } |
| 18457 |
##1 - ####1 |
| 18458 |
} |
| 18459 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 18460 |
{ |
| 18461 |
\pgfpicture |
| 18462 |
\pgfrememberpicturepositiononpagetrue |
| 18463 |
\pgf@relevantforpicturesizefalse |
| 18464 |
} |
| 18465 |
{ \begin { pgfpicture } } |
| 18466 |
\@@_qpoint:n { col - ####1 } |
| 18467 |
\dim_gset_eq:NN \g_@@_tmpc_dim \pgf@x |
| 18468 |
\@@_qpoint:n { col - \int_eval:n { ####1 + 1 } } |
| 18469 |
\dim_gset:Nn \g_@@_tmpd_dim { \pgf@x - \g_@@_tmpc_dim } |
| 18470 |
\dim_gset_eq:NN \g_@@_tmpe_dim \pgf@x |
| 18471 |
\bool_if:NTF \l_@@_in_code_after_bool |
| 18472 |
{ \endpgfpicture } |
| 18473 |
{ \end { pgfpicture } } |
| 18474 |
\fp_set:Nn \l_tmpa_fp |
| 18475 |
{ |
| 18476 |
\fp_min:nn |
| 18477 |
{ |
| 18478 |
\fp_min:nn |
| 18479 |
{ \dim_ratio:nn \g_@@_tmpd_dim { \box_wd:N \l_tmpa_box } } |
| 18480 |
{ \dim_ratio:nn \g_tmpb_dim { \box_ht_plus_dp:N \l_tmpa_box } } |
| 18481 |
} |
| 18482 |
{ 1.0 } |
| 18483 |
} |
| 18484 |
\box_scale:Nnn \l_tmpa_box { \fp_use:N \l_tmpa_fp } { \fp_use:N \l_tmpa_fp } |
| 18485 |
\pgfpicture |
| 18486 |
\pgfrememberpicturepositiononpagetrue |
| 18487 |
\pgf@relevantforpicturesizefalse |
| 18488 |
\pgftransformshift |
| 18489 |
{ |
| 18490 |
\pgfpoint |
| 18491 |
{ 0.5 * ( \g_@@_tmpc_dim + \g_@@_tmpe_dim ) } |
| 18492 |
\g_tmpa_dim |
| 18493 |
} |
| 18494 |
\pgfnode |
| 18495 |
{ rectangle } |
| 18496 |
{ center } |
| 18497 |
{ \box_use:N \l_tmpa_box } |
| 18498 |
{ } |
| 18499 |
{ } |
| 18500 |
\endpgfpicture |
| 18501 |
} |
| 18502 |
} |
| 18503 |
} |
| 18504 |
% \end{macrocode} |
| 18505 |
% |
| 18506 |
% \bigskip |
| 18507 |
% \section{We process the options at package loading} |
| 18508 |
% |
| 18509 |
% |
| 18510 |
% We process the options when the package is loaded (with |\usepackage|) but we |
| 18511 |
% recommend to use |\NiceMatrixOptions| instead. |
| 18512 |
% |
| 18513 |
% We must process these options after the definition of the environment |
| 18514 |
% |{NiceMatrix}| because the option |renew-matrix| executes the code |
| 18515 |
% |\cs_set_eq:NN \env@matrix \NiceMatrix|. |
| 18516 |
% |
| 18517 |
% Of course, the command |\NiceMatrix| must be defined before such an |
| 18518 |
% instruction is executed. |
| 18519 |
% |
| 18520 |
% |
| 18521 |
% \medskip |
| 18522 |
% The boolean |\g_@@_footnotehyper_bool| will indicate if the option |
| 18523 |
% |footnotehyper| is used. |
| 18524 |
% \begin{macrocode} |
| 18525 |
\bool_new:N \g_@@_footnotehyper_bool |
| 18526 |
% \end{macrocode} |
| 18527 |
% |
| 18528 |
% \medskip |
| 18529 |
% The boolean |\g_@@_footnote_bool| will indicate if the option |footnote| is |
| 18530 |
% used, but quickly, it will also be set to |true| if the option |footnotehyper| |
| 18531 |
% is used. |
| 18532 |
% \begin{macrocode} |
| 18533 |
\bool_new:N \g_@@_footnote_bool |
| 18534 |
% \end{macrocode} |
| 18535 |
% |
| 18536 |
% \begin{macrocode} |
| 18537 |
\msg_new:nnnn { nicematrix } { Unknown~key~for~package } |
| 18538 |
{ |
| 18539 |
You~have~used~the~key~' \l_keys_key_str '~when~loading~nicematrix~ |
| 18540 |
but~that~key~is~unknown. \\ |
| 18541 |
It~will~be~ignored. \\ |
| 18542 |
For~a~list~of~the~available~keys,~type~H~<return>. |
| 18543 |
} |
| 18544 |
{ |
| 18545 |
The~available~keys~are~(in~alphabetic~order):~ |
| 18546 |
footnote,~ |
| 18547 |
footnotehyper,~ |
| 18548 |
messages-for-Overleaf,~ |
| 18549 |
renew-dots~and~ |
| 18550 |
renew-matrix. |
| 18551 |
} |
| 18552 |
% \end{macrocode} |
| 18553 |
% |
| 18554 |
% |
| 18555 |
% \begin{macrocode} |
| 18556 |
\keys_define:nn { nicematrix } |
| 18557 |
{ |
| 18558 |
renew-dots .bool_set:N = \l_@@_renew_dots_bool , |
| 18559 |
renew-dots .value_forbidden:n = true , |
| 18560 |
renew-matrix .code:n = \@@_renew_matrix: , |
| 18561 |
renew-matrix .value_forbidden:n = true , |
| 18562 |
messages-for-Overleaf .bool_set:N = \g_@@_messages_for_Overleaf_bool , |
| 18563 |
footnote .bool_set:N = \g_@@_footnote_bool , |
| 18564 |
footnotehyper .bool_set:N = \g_@@_footnotehyper_bool , |
| 18565 |
unknown .code:n = \@@_error:n { Unknown~key~for~package } |
| 18566 |
} |
| 18567 |
\ProcessKeyOptions |
| 18568 |
% \end{macrocode} |
| 18569 |
% |
| 18570 |
% |
| 18571 |
% \bigskip |
| 18572 |
% \begin{macrocode} |
| 18573 |
\@@_msg_new:nn { footnote~with~footnotehyper~package } |
| 18574 |
{ |
| 18575 |
You~can't~use~the~option~'footnote'~because~the~package~ |
| 18576 |
footnotehyper~has~already~been~loaded.~ |
| 18577 |
If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~ |
| 18578 |
within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~ |
| 18579 |
of~the~package~footnotehyper.\\ |
| 18580 |
The~package~footnote~won't~be~loaded. |
| 18581 |
} |
| 18582 |
% \end{macrocode} |
| 18583 |
% |
| 18584 |
% \begin{macrocode} |
| 18585 |
\@@_msg_new:nn { footnotehyper~with~footnote~package } |
| 18586 |
{ |
| 18587 |
You~can't~use~the~option~'footnotehyper'~because~the~package~ |
| 18588 |
footnote~has~already~been~loaded.~ |
| 18589 |
If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~ |
| 18590 |
within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~ |
| 18591 |
of~the~package~footnote.\\ |
| 18592 |
The~package~footnotehyper~won't~be~loaded. |
| 18593 |
} |
| 18594 |
% \end{macrocode} |
| 18595 |
% |
| 18596 |
% \medskip |
| 18597 |
% \begin{macrocode} |
| 18598 |
\bool_if:NT \g_@@_footnote_bool |
| 18599 |
{ |
| 18600 |
% \end{macrocode} |
| 18601 |
% The class \cls{beamer} has its own system to extract footnotes and that's why |
| 18602 |
% we have nothing to do if \cls{beamer} is used. |
| 18603 |
% \begin{macrocode} |
| 18604 |
\IfClassLoadedTF { beamer } |
| 18605 |
{ \bool_set_false:N \g_@@_footnote_bool } |
| 18606 |
{ |
| 18607 |
\IfPackageLoadedTF { footnotehyper } |
| 18608 |
{ \@@_error:n { footnote~with~footnotehyper~package } } |
| 18609 |
{ \usepackage { footnote } } |
| 18610 |
} |
| 18611 |
} |
| 18612 |
% \end{macrocode} |
| 18613 |
% |
| 18614 |
% \begin{macrocode} |
| 18615 |
\bool_if:NT \g_@@_footnotehyper_bool |
| 18616 |
{ |
| 18617 |
% \end{macrocode} |
| 18618 |
% The class \cls{beamer} has its own system to extract footnotes and that's why |
| 18619 |
% we have nothing to do if \cls{beamer} is used. |
| 18620 |
% \begin{macrocode} |
| 18621 |
\IfClassLoadedTF { beamer } |
| 18622 |
{ \bool_set_false:N \g_@@_footnote_bool } |
| 18623 |
{ |
| 18624 |
\IfPackageLoadedTF { footnote } |
| 18625 |
{ \@@_error:n { footnotehyper~with~footnote~package } } |
| 18626 |
{ \usepackage { footnotehyper } } |
| 18627 |
} |
| 18628 |
\bool_set_true:N \g_@@_footnote_bool |
| 18629 |
} |
| 18630 |
% \end{macrocode} |
| 18631 |
% The flag |\g_@@_footnote_bool| is raised and so, we will only have to test |
| 18632 |
% |\g_@@_footnote_bool| in order to know if we have to insert an environment |
| 18633 |
% |{savenotes}|. |
| 18634 |
% |
| 18635 |
% \bigskip |
| 18636 |
% \section{About the package underscore} |
| 18637 |
% |
| 18638 |
% If the user loads the package \pkg{underscore}, it must be loaded |
| 18639 |
% \emph{before} the package \pkg{nicematrix}. If it is loaded after, we raise an |
| 18640 |
% error. |
| 18641 |
% |
| 18642 |
% \begin{macrocode} |
| 18643 |
\bool_new:N \l_@@_underscore_loaded_bool |
| 18644 |
\IfPackageLoadedT { underscore } |
| 18645 |
{ \bool_set_true:N \l_@@_underscore_loaded_bool } |
| 18646 |
% \end{macrocode} |
| 18647 |
% |
| 18648 |
% \begin{macrocode} |
| 18649 |
\AtBeginDocument |
| 18650 |
{ |
| 18651 |
\bool_if:NF \l_@@_underscore_loaded_bool |
| 18652 |
{ |
| 18653 |
\IfPackageLoadedT { underscore } |
| 18654 |
{ \@@_error:n { underscore~after~nicematrix } } |
| 18655 |
} |
| 18656 |
} |
| 18657 |
% \end{macrocode} |
| 18658 |
% |
| 18659 |
% \bigskip |
| 18660 |
% \section{Compatibility with threeparttable} |
| 18661 |
% |
| 18662 |
% |
| 18663 |
% \begin{macrocode} |
| 18664 |
\AtBeginDocument |
| 18665 |
{ |
| 18666 |
\IfPackageLoadedT { threeparttable } |
| 18667 |
{ |
| 18668 |
\AddToHook { env / threeparttable / begin } |
| 18669 |
{ |
| 18670 |
\TPT@hookin { NiceTabular } |
| 18671 |
\TPT@hookin { NiceTabular* } |
| 18672 |
\TPT@hookin { NiceTabularX } |
| 18673 |
} |
| 18674 |
} |
| 18675 |
} |
| 18676 |
% \end{macrocode} |
| 18677 |
% |
| 18678 |
% \bigskip |
| 18679 |
% \section{Error messages of the package} |
| 18680 |
% |
| 18681 |
% \bigskip |
| 18682 |
% When there is a unknown key, maybe the user has tried to use an inexistent |
| 18683 |
% ``additive syntax'' for that key. Of course, in that case, the last character of the |
| 18684 |
% name of the key is |+|. |
| 18685 |
% |
| 18686 |
% |#1| is a clist of names of sets of keys and |#2| is the error message |
| 18687 |
% to send. |
| 18688 |
% \begin{macrocode} |
| 18689 |
\cs_new_protected:Npn \@@_unknown_key:nn #1 #2 |
| 18690 |
{ |
| 18691 |
\str_if_eq:eeTF |
| 18692 |
{ \str_item:Nn \l_keys_key_str { \str_count:N \l_keys_key_str } } |
| 18693 |
{ + } |
| 18694 |
{ |
| 18695 |
\str_set:Ne \l_tmpa_str |
| 18696 |
{ \str_range:Nnn \l_keys_key_str { 1 } { \str_count:N \l_keys_key_str - 1 } } |
| 18697 |
\bool_set_false:N \l_tmpa_bool |
| 18698 |
\clist_map_inline:nn { #1 } |
| 18699 |
{ |
| 18700 |
\keys_if_exist:neT { ##1 } { \l_tmpa_str } |
| 18701 |
{ |
| 18702 |
\@@_error:n { key~without~+~exists } |
| 18703 |
\bool_set_true:N \l_tmpa_bool |
| 18704 |
\clist_map_break: |
| 18705 |
} |
| 18706 |
} |
| 18707 |
\bool_if:NF \l_tmpa_bool |
| 18708 |
{ |
| 18709 |
\str_set:Ne \l_keys_key_str { \tl_trim_right_spaces:V \l_tmpa_str } |
| 18710 |
\@@_unknown_key_i:nn { #1 } { #2 } |
| 18711 |
} |
| 18712 |
} |
| 18713 |
{ \@@_unknown_key_i:nn { #1 } { #2 } } |
| 18714 |
} |
| 18715 |
% \end{macrocode} |
| 18716 |
% |
| 18717 |
% \bigskip |
| 18718 |
% We try a normalisation of the name of the key, and, when that normal form |
| 18719 |
% exists, we add that information in the error message. |
| 18720 |
% |
| 18721 |
% The normal form is the lower case form of the key, with all the spaces |
| 18722 |
% replaced by hyphens (there is never spaces in the keys of \pkg{nicematrix}). |
| 18723 |
% |
| 18724 |
% |#1| is a clist of names of sets of keys and |#2| is the error message |
| 18725 |
% to send. |
| 18726 |
% \begin{macrocode} |
| 18727 |
\cs_new_protected:Npn \@@_unknown_key_i:nn #1 #2 |
| 18728 |
{ |
| 18729 |
\str_set_eq:NN \l_tmpa_str \l_keys_key_str |
| 18730 |
\str_replace_all:Nnn \l_tmpa_str { ~ } { - } |
| 18731 |
\str_set:Ne \l_tmpa_str { \str_lowercase:f { \l_tmpa_str } } |
| 18732 |
\bool_set_false:N \l_tmpa_bool |
| 18733 |
\clist_map_inline:nn { #1 } |
| 18734 |
{ |
| 18735 |
\keys_if_exist:neT { ##1 } { \l_tmpa_str } |
| 18736 |
{ |
| 18737 |
\@@_error:n { key~with~normal~form~exists } |
| 18738 |
\bool_set_true:N \l_tmpa_bool |
| 18739 |
\clist_map_break: |
| 18740 |
} |
| 18741 |
} |
| 18742 |
\bool_if:NF \l_tmpa_bool |
| 18743 |
{ |
| 18744 |
\@@_error:n { #2 } |
| 18745 |
% \end{macrocode} |
| 18746 |
% |
| 18747 |
% If |messages-for-Overleaf| is not in force, the list of the available keys is |
| 18748 |
% not written in the main error message but only in the complement (if the final user |
| 18749 |
% presses |H|). That's why we write, in all circunstancies, the list of the |
| 18750 |
% available keys in order to facilitate the work of the systems which analyze the error |
| 18751 |
% by IA (such as Prism). |
| 18752 |
% \begin{macrocode} |
| 18753 |
\bool_if:NF \g_@@_messages_for_Overleaf_bool |
| 18754 |
{ \msg_info:nn { nicematrix } { #2~+ } } |
| 18755 |
} |
| 18756 |
} |
| 18757 |
% \end{macrocode} |
| 18758 |
% |
| 18759 |
% \begin{macrocode} |
| 18760 |
\@@_msg_new:nn { key~without~+~exists } |
| 18761 |
{ |
| 18762 |
The~key~'\tl_trim_right_spaces:V \l_tmpa_str'~exists~but~does~not~accept~an~ |
| 18763 |
additive~syntax~(with~+=).~It~will~be~ignored. |
| 18764 |
} |
| 18765 |
% \end{macrocode} |
| 18766 |
% |
| 18767 |
% \begin{macrocode} |
| 18768 |
\@@_msg_new:nn { key~with~normal~form~exists } |
| 18769 |
{ |
| 18770 |
No~key~'\l_keys_key_str'.\\ |
| 18771 |
It~will~be~ignored.~Maybe~you~want~to~use~the~key~'\l_tmpa_str'. |
| 18772 |
} |
| 18773 |
% \end{macrocode} |
| 18774 |
% |
| 18775 |
% \begin{macrocode} |
| 18776 |
\str_const:Ne \c_@@_available_keys_str |
| 18777 |
{ |
| 18778 |
\bool_if:nT { ! \g_@@_messages_for_Overleaf_bool } |
| 18779 |
{ For~a~list~of~the~available~keys,~type~H~<return>. } |
| 18780 |
} |
| 18781 |
% \end{macrocode} |
| 18782 |
% |
| 18783 |
% \begin{macrocode} |
| 18784 |
\seq_new:N \g_@@_types_of_matrix_seq |
| 18785 |
\seq_gset_from_clist:Nn \g_@@_types_of_matrix_seq |
| 18786 |
{ |
| 18787 |
NiceMatrix , |
| 18788 |
pNiceMatrix , bNiceMatrix , vNiceMatrix, BNiceMatrix, VNiceMatrix |
| 18789 |
} |
| 18790 |
\seq_gset_map_e:NNn \g_@@_types_of_matrix_seq \g_@@_types_of_matrix_seq |
| 18791 |
{ \tl_to_str:n { #1 } } |
| 18792 |
% \end{macrocode} |
| 18793 |
% |
| 18794 |
% \bigskip |
| 18795 |
% If the user uses too much columns, the command |\@@_err_too_many_cols:| is |
| 18796 |
% triggered. This command raises an error but also tries to give the best |
| 18797 |
% information to the user in the error message. The command |\seq_if_in:NoF| is |
| 18798 |
% not expandable and that's why we can't put it in the error message itself. We |
| 18799 |
% have to do the test before the |\@@_fatal:n|. |
| 18800 |
% \begin{macrocode} |
| 18801 |
\cs_new_protected:Npn \@@_err_too_many_cols: |
| 18802 |
{ |
| 18803 |
\seq_if_in:NoF \g_@@_types_of_matrix_seq \g_@@_name_env_str |
| 18804 |
{ \@@_fatal:nn { too~many~cols~for~array } } |
| 18805 |
\int_compare:nNnT \l_@@_last_col_int = { -2 } |
| 18806 |
{ \@@_fatal:n { too~many~cols~for~matrix } } |
| 18807 |
\int_compare:nNnT \l_@@_last_col_int = { -1 } |
| 18808 |
{ \@@_fatal:n { too~many~cols~for~matrix } } |
| 18809 |
\bool_if:NF \l_@@_last_col_without_value_bool |
| 18810 |
{ \@@_fatal:n { too~many~cols~for~matrix~with~last~col } } |
| 18811 |
} |
| 18812 |
% \end{macrocode} |
| 18813 |
% |
| 18814 |
% |
| 18815 |
% The following command must \emph{not} be protected since it's used in an error message. |
| 18816 |
% \begin{macrocode} |
| 18817 |
\cs_new:Npn \@@_message_hdotsfor: |
| 18818 |
{ |
| 18819 |
\tl_if_empty:oF \g_@@_HVdotsfor_lines_tl |
| 18820 |
{ ~Maybe~your~use~of~ \token_to_str:N \Hdotsfor \ or~ |
| 18821 |
\token_to_str:N \Hbrace \ is~incorrect. } |
| 18822 |
} |
| 18823 |
% \end{macrocode} |
| 18824 |
% |
| 18825 |
% \medskip |
| 18826 |
% \begin{macrocode} |
| 18827 |
\cs_new_protected:Npn \@@_Hline_in_cell: |
| 18828 |
{ \@@_error:n { Misuse~of~Hline } } |
| 18829 |
% \end{macrocode} |
| 18830 |
% |
| 18831 |
% \begin{macrocode} |
| 18832 |
\@@_msg_new:nn { Misuse~of~Hline } |
| 18833 |
{ |
| 18834 |
Misuse~of~\token_to_str:N \Hline. \\ |
| 18835 |
Error~in~the~row~ \int_use:N \c@iRow\ of~your~\@@_full_name_env:.~ |
| 18836 |
\token_to_str:N \Hline\ (like~\token_to_str:N \hline)~must~be~used~only~ |
| 18837 |
at~the~beginning~of~a~row.~Your~command~will~be~ignored. |
| 18838 |
} |
| 18839 |
% \end{macrocode} |
| 18840 |
% |
| 18841 |
% \begin{macrocode} |
| 18842 |
\@@_msg_new:nn { hvlines,~rounded-corners~and~corners } |
| 18843 |
{ |
| 18844 |
Incompatible~options.\\ |
| 18845 |
You~should~not~use~'hvlines',~'rounded-corners'~and~'corners'~at~the~same~time.~ |
| 18846 |
The~output~will~not~be~reliable. |
| 18847 |
} |
| 18848 |
% \end{macrocode} |
| 18849 |
% |
| 18850 |
% \begin{macrocode} |
| 18851 |
\@@_msg_new:nn { Body~alone } |
| 18852 |
{ |
| 18853 |
\token_to_str:N \Body\ alone. \\ |
| 18854 |
You~have~used~\token_to_str:N \Body\ without~\token_to_str:N \CodeBefore. |
| 18855 |
} |
| 18856 |
% \end{macrocode} |
| 18857 |
% |
| 18858 |
% \begin{macrocode} |
| 18859 |
\@@_msg_new:nn { Bad~use~of~CodeBefore } |
| 18860 |
{ |
| 18861 |
Bad~use~of~\token_to_str:N \CodeBefore. \\ |
| 18862 |
\token_to_str:N \CodeBefore\ must~be~used~only~at~the~beginning~of~ |
| 18863 |
the~environment. |
| 18864 |
} |
| 18865 |
% \end{macrocode} |
| 18866 |
% |
| 18867 |
% \begin{macrocode} |
| 18868 |
\@@_msg_new:nn { NiceTabularX~probably~required } |
| 18869 |
{ |
| 18870 |
Incorrect~syntax.\\ |
| 18871 |
You~probably~want~to~use~\{NiceTabularX\}~whose~first~argument~is~the~ |
| 18872 |
~width~that~you~wish~for~your~tabular.~But~you~can~also~use~\{NiceTabular\}~ |
| 18873 |
with~the~key~'width'. |
| 18874 |
} |
| 18875 |
% \end{macrocode} |
| 18876 |
% |
| 18877 |
% \begin{macrocode} |
| 18878 |
\@@_msg_new:nn { cellcolor~in~Block } |
| 18879 |
{ |
| 18880 |
Bad~use~of~\token_to_str:N \cellcolor \\ |
| 18881 |
You~can't~use~\token_to_str:N \cellcolor\ in~\token_to_str:N \Block\ |
| 18882 |
\bool_if:NTF \l_@@_amp_in_blocks_bool |
| 18883 |
{ (but~you~could~use~it~in~a~sub-block~since~'&-in-blocks'~is~in~force) } |
| 18884 |
{ (it's~possible~in~a~sub-block~when~'&-in-blocks'~is~in~force) } |
| 18885 |
.~Here,~you~should~use~the~key~'fill'~of~the~block.~Your~command~will~be~ignored. |
| 18886 |
} |
| 18887 |
% \end{macrocode} |
| 18888 |
% |
| 18889 |
% \begin{macrocode} |
| 18890 |
\@@_msg_new:nn { rowcolor~in~Block } |
| 18891 |
{ |
| 18892 |
Bad~use~of~\token_to_str:N \rowcolor \\ |
| 18893 |
You~can't~use~\token_to_str:N \rowcolor\ in~\token_to_str:N \Block.~ |
| 18894 |
However,~it's~possible~to~color~the~block~with~its~key~'fill'.~ |
| 18895 |
Your~command~will~be~ignored. |
| 18896 |
} |
| 18897 |
% \end{macrocode} |
| 18898 |
% |
| 18899 |
% \begin{macrocode} |
| 18900 |
\@@_msg_new:nn { key~color-inside } |
| 18901 |
{ |
| 18902 |
Deleted~key.\\ |
| 18903 |
The~key~'color-inside'~(and~its~alias~'colortbl-like')~has~been~deleted~in |
| 18904 |
~'nicematrix'~and~must~not~be~used. |
| 18905 |
} |
| 18906 |
% \end{macrocode} |
| 18907 |
% |
| 18908 |
% \begin{macrocode} |
| 18909 |
\@@_msg_new:nn { Invalid~argument~for~w } |
| 18910 |
{ |
| 18911 |
Invalid~argument~for~w.\\ |
| 18912 |
You~have~used~the~type~of~alignment~'#1'~for~your~column~'w'~ |
| 18913 |
but~only~'c',~'r',~'l'~and~'s'~are~allowed~in~a~column~'w'.~ |
| 18914 |
If~you~go~on,~'c'~will~be~used. |
| 18915 |
} |
| 18916 |
% \end{macrocode} |
| 18917 |
% |
| 18918 |
% |
| 18919 |
% \begin{macrocode} |
| 18920 |
\@@_msg_new:nn { invalid~weight } |
| 18921 |
{ |
| 18922 |
Unknown~key.\\ |
| 18923 |
The~key~' \l_keys_key_str '~of~your~column~X~is~unknown~and~will~be~ignored.~ |
| 18924 |
The~available~keys~are:~l,~c,~r,~t~(=p),~m,~b,~V~ |
| 18925 |
\IfPackageLoadedTF { varwidth } |
| 18926 |
{ (since~'varwidth'~is~loaded)~} |
| 18927 |
{ (if~you~load~'varwidth')~} |
| 18928 |
and~real~numbers~for~the~weight~of~the~X~column. |
| 18929 |
} |
| 18930 |
% \end{macrocode} |
| 18931 |
% |
| 18932 |
% \begin{macrocode} |
| 18933 |
\@@_msg_new:nn { last~col~not~used } |
| 18934 |
{ |
| 18935 |
Column~not~used.\\ |
| 18936 |
The~key~'last-col'~is~in~force~but~you~have~not~used~that~last~column~ |
| 18937 |
in~your~\@@_full_name_env: .~However,~you~can~go~on. |
| 18938 |
} |
| 18939 |
% \end{macrocode} |
| 18940 |
% |
| 18941 |
% \begin{macrocode} |
| 18942 |
\@@_msg_new:nn { too~many~cols~for~matrix~with~last~col } |
| 18943 |
{ |
| 18944 |
Too~many~columns.\\ |
| 18945 |
In~the~row~ \int_eval:n { \c@iRow },~ |
| 18946 |
you~try~to~use~more~columns~ |
| 18947 |
than~allowed~by~your~ \@@_full_name_env: . |
| 18948 |
\@@_message_hdotsfor: \ |
| 18949 |
The~maximal~number~of~columns~is~ \int_eval:n { \l_@@_last_col_int - 1 }~ |
| 18950 |
(plus~the~exterior~columns).~ |
| 18951 |
But,~maybe,~you~have~forgotten~a~\token_to_str:N \\. |
| 18952 |
} |
| 18953 |
% \end{macrocode} |
| 18954 |
% |
| 18955 |
% |
| 18956 |
% \begin{macrocode} |
| 18957 |
\@@_msg_new:nn { too~many~cols~for~matrix } |
| 18958 |
{ |
| 18959 |
Too~many~columns.\\ |
| 18960 |
In~the~row~ \int_eval:n { \c@iRow } ,~ |
| 18961 |
you~try~to~use~more~columns~than~allowed~by~your~ \@@_full_name_env: . |
| 18962 |
\@@_message_hdotsfor: \ |
| 18963 |
Recall~that~the~maximal~number~of~columns~for~a~matrix~ |
| 18964 |
(excepted~the~potential~exterior~columns)~is~fixed~by~the~ |
| 18965 |
LaTeX~counter~'MaxMatrixCols'.~ |
| 18966 |
Its~current~value~is~ \int_use:N \c@MaxMatrixCols \ |
| 18967 |
(use~ \token_to_str:N \setcounter \ to~change~that~value).~ |
| 18968 |
But,~maybe,~you~have~forgotten~a~\token_to_str:N \\. |
| 18969 |
} |
| 18970 |
% \end{macrocode} |
| 18971 |
% |
| 18972 |
% \medskip |
| 18973 |
% \begin{macrocode} |
| 18974 |
\@@_msg_new:nn { too~many~cols~for~array } |
| 18975 |
{ |
| 18976 |
Too~many~columns.\\ |
| 18977 |
In~the~row~ \int_eval:n { \c@iRow } ,~ |
| 18978 |
~you~try~to~use~more~columns~than~allowed~by~your~ |
| 18979 |
\@@_full_name_env: . \@@_message_hdotsfor: \ The~maximal~number~of~columns~is~ |
| 18980 |
\int_use:N \g_@@_static_num_of_col_int \ |
| 18981 |
\bool_if:nT |
| 18982 |
{ \int_compare_p:n { \l_@@_first_col_int = 0 } || \g_@@_last_col_found_bool } |
| 18983 |
{ (plus~the~exterior~ones)~} |
| 18984 |
since~the~preamble~is~' \g_@@_user_preamble_tl '.~ |
| 18985 |
But,~maybe,~you~have~forgotten~a~\token_to_str:N \\. |
| 18986 |
} |
| 18987 |
% \end{macrocode} |
| 18988 |
% |
| 18989 |
% |
| 18990 |
% \begin{macrocode} |
| 18991 |
\@@_msg_new:nn { columns~not~used } |
| 18992 |
{ |
| 18993 |
Columns~not~used.\\ |
| 18994 |
The~preamble~of~your~ \@@_full_name_env: \ is~' \g_@@_user_preamble_tl '.~ |
| 18995 |
It~announces~ \int_use:N \g_@@_static_num_of_col_int \ |
| 18996 |
columns~but~you~only~used~ \int_use:N \c@jCol .~The~columns~you~did~not~ |
| 18997 |
used~won't~be~created.~You~won't~have~similar~warning~till~the~end~of~the~document. |
| 18998 |
} |
| 18999 |
% \end{macrocode} |
| 19000 |
% |
| 19001 |
% \begin{macrocode}} |
| 19002 |
\@@_msg_new:nn { Bad~use~of~NiceTabularNotes } |
| 19003 |
{ |
| 19004 |
Bad~use~of~\token_to_str:N \NiceTabularNotes \\ |
| 19005 |
\token_to_str:N~\NiceTabularNotes\ should~be~used~only~after~at~tabular~ |
| 19006 |
which~uses~`notes/no-print`.~ Your~command~will~be~ignored. |
| 19007 |
} |
| 19008 |
% \end{macrocode} |
| 19009 |
% |
| 19010 |
% |
| 19011 |
% \begin{macrocode} |
| 19012 |
\@@_msg_new:nn { empty~preamble } |
| 19013 |
{ |
| 19014 |
Empty~preamble.\\ |
| 19015 |
The~preamble~of~your~ \@@_full_name_env: \ is~empty. |
| 19016 |
} |
| 19017 |
% \end{macrocode} |
| 19018 |
% |
| 19019 |
% |
| 19020 |
% \begin{macrocode} |
| 19021 |
\@@_msg_new:nn { in~first~col } |
| 19022 |
{ |
| 19023 |
Erroneous~use.\\ |
| 19024 |
You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.~ |
| 19025 |
Your~command~will~be~ignored.~You~can~try~to~delete~the~key~'first-col'. |
| 19026 |
} |
| 19027 |
% \end{macrocode} |
| 19028 |
% |
| 19029 |
% \begin{macrocode} |
| 19030 |
\@@_msg_new:nn { in~last~col } |
| 19031 |
{ |
| 19032 |
Erroneous~use.\\ |
| 19033 |
You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.~ |
| 19034 |
Your~command~will~be~ignored.~You~can~try~to~delete~the~key~'last-col'. |
| 19035 |
} |
| 19036 |
% \end{macrocode} |
| 19037 |
% |
| 19038 |
% \begin{macrocode} |
| 19039 |
\@@_msg_new:nn { in~first~row } |
| 19040 |
{ |
| 19041 |
Erroneous~use.\\ |
| 19042 |
You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.~ |
| 19043 |
Your~command~will~be~ignored.~You~can~try~to~delete~the~key~'first-row'. |
| 19044 |
} |
| 19045 |
% \end{macrocode} |
| 19046 |
% |
| 19047 |
% \begin{macrocode} |
| 19048 |
\@@_msg_new:nn { in~last~row } |
| 19049 |
{ |
| 19050 |
Erroneous~use.\\ |
| 19051 |
You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.~ |
| 19052 |
Your~command~will~be~ignored.~You~can~try~to~delete~the~key~'last-row'. |
| 19053 |
} |
| 19054 |
% \end{macrocode} |
| 19055 |
% |
| 19056 |
% \begin{macrocode} |
| 19057 |
\@@_msg_new:nn { TopRule~without~booktabs } |
| 19058 |
{ |
| 19059 |
Erroneous~use.\\ |
| 19060 |
You~can't~use~the~command~ #1 because~'booktabs'~is~not~loaded.~ |
| 19061 |
You~should~load~'booktabs'~(before~or~after~'nicematrix').~ |
| 19062 |
Your~command~will~be~ignored. |
| 19063 |
} |
| 19064 |
% \end{macrocode} |
| 19065 |
% |
| 19066 |
% \begin{macrocode} |
| 19067 |
\@@_msg_new:nn{ rotate~in~p~col } |
| 19068 |
{ |
| 19069 |
\token_to_str:N \rotate\ forbidden.\\ |
| 19070 |
You~should~not~use~\token_to_str:N \rotate\ in~a~column~of~type~'p',~ |
| 19071 |
'b',~'m'\IfPackageLoadedTF { varwidth } { ,~'X'~or~'V' } { ~or~'X'}.~ |
| 19072 |
If~you~go~on,~maybe~you~won't~have~the~expected~output.~You~should~ |
| 19073 |
consider~the~classical~command~\token_to_str:N \rotatebox. |
| 19074 |
} |
| 19075 |
% \end{macrocode} |
| 19076 |
% |
| 19077 |
% \begin{macrocode} |
| 19078 |
\@@_msg_new:nn { TopRule~without~tikz } |
| 19079 |
{ |
| 19080 |
Erroneous~use.\\ |
| 19081 |
You~can't~use~the~command~ #1 because~TikZ~is~not~loaded.~ |
| 19082 |
You~should~load~TikZ~with~\token_to_str:N \usepackage \{tikz\}.~ |
| 19083 |
\IfPackageLoadedF { booktabs } |
| 19084 |
{ You~should~also~load~'booktabs'~ |
| 19085 |
with~\token_to_str:N \usepackage \{booktabs\}.~ } |
| 19086 |
Your~command~will~be~ignored. |
| 19087 |
} |
| 19088 |
% \end{macrocode} |
| 19089 |
% |
| 19090 |
% \begin{macrocode} |
| 19091 |
\@@_msg_new:nn { caption~outside~float } |
| 19092 |
{ |
| 19093 |
Key~caption~forbidden.\\ |
| 19094 |
You~can't~use~the~key~'caption'~because~you~are~not~in~a~floating~ |
| 19095 |
environment~(such~as~\{table\}).~Your~key~will~be~ignored. |
| 19096 |
} |
| 19097 |
% \end{macrocode} |
| 19098 |
% |
| 19099 |
% \begin{macrocode} |
| 19100 |
\@@_msg_new:nn { short-caption~without~caption } |
| 19101 |
{ |
| 19102 |
You~should~not~use~the~key~'short-caption'~without~'caption'.~ |
| 19103 |
However,~your~'short-caption'~will~be~used~as~'caption'. |
| 19104 |
} |
| 19105 |
% \end{macrocode} |
| 19106 |
% |
| 19107 |
% \begin{macrocode} |
| 19108 |
\@@_msg_new:nn { double~closing~delimiter } |
| 19109 |
{ |
| 19110 |
Double~delimiter.\\ |
| 19111 |
You~can't~put~a~second~closing~delimiter~"#1"~just~after~a~first~closing~ |
| 19112 |
delimiter.~This~delimiter~will~be~ignored.~You~can~try~to~use~ |
| 19113 |
\token_to_str:N \SubMatrix\ in~the~\token_to_str:N \CodeAfter. |
| 19114 |
} |
| 19115 |
% \end{macrocode} |
| 19116 |
% |
| 19117 |
% \begin{macrocode} |
| 19118 |
\@@_msg_new:nn { delimiter~after~opening } |
| 19119 |
{ |
| 19120 |
Double~delimiter.\\ |
| 19121 |
You~can't~put~a~second~delimiter~"#1"~just~after~a~first~opening~ |
| 19122 |
delimiter.~That~delimiter~will~be~ignored. |
| 19123 |
} |
| 19124 |
% \end{macrocode} |
| 19125 |
% |
| 19126 |
% \begin{macrocode} |
| 19127 |
\@@_msg_new:nn { bad~option~for~line-style } |
| 19128 |
{ |
| 19129 |
Bad~line~style.\\ |
| 19130 |
Since~you~haven't~loaded~TikZ,~the~only~value~you~can~give~to~'line-style'~ |
| 19131 |
is~'standard'.~Your~key~will~be~ignored.~You~can~load~TikZ~with~ |
| 19132 |
\token_to_str:N \usepackage \{tikz\},~before~or~after~'nicematrix'. |
| 19133 |
} |
| 19134 |
% \end{macrocode} |
| 19135 |
% |
| 19136 |
% \begin{macrocode} |
| 19137 |
\@@_msg_new:nn { draw-trees~with~no-cell-nodes } |
| 19138 |
{ |
| 19139 |
Incompatible~keys.\\ |
| 19140 |
You~can't~use~the~key~'draw-trees-in-col'~here~because~the~key~'no-cell-nodes'~ |
| 19141 |
is~in~force~(you~should~deactive~the~key~'no-cell-nodes'~whose~only~goal~ |
| 19142 |
is~to~speed~compilation~up).~If~you~go~on,~that~key~will~be~ignored. |
| 19143 |
} |
| 19144 |
% \end{macrocode} |
| 19145 |
% |
| 19146 |
% \begin{macrocode} |
| 19147 |
\@@_msg_new:nn { corners~with~no-cell-nodes } |
| 19148 |
{ |
| 19149 |
Incompatible~keys.\\ |
| 19150 |
You~can't~use~the~key~'corners'~here~because~the~key~'no-cell-nodes'~ |
| 19151 |
is~in~force~(you~should~deactive~the~key~'no-cell-nodes'~whose~only~goal~ |
| 19152 |
is~to~speed~compilation~up).\\ |
| 19153 |
If~you~go~on,~that~key~will~be~ignored. |
| 19154 |
} |
| 19155 |
% \end{macrocode} |
| 19156 |
% |
| 19157 |
% \begin{macrocode} |
| 19158 |
\@@_msg_new:nn { extra-nodes~with~no-cell-nodes } |
| 19159 |
{ |
| 19160 |
Incompatible~keys.\\ |
| 19161 |
You~can't~create~'extra~nodes'~here~because~the~key~'no-cell-nodes'~ |
| 19162 |
is~in~force~(you~should~deactive~the~key~'no-cell-nodes'~whose~only~goal~ |
| 19163 |
is~to~speed~compilation~up).~If~you~go~on,~those~extra~nodes~won't~be~created. |
| 19164 |
} |
| 19165 |
% \end{macrocode} |
| 19166 |
% |
| 19167 |
% \begin{macrocode} |
| 19168 |
\@@_msg_new:nn { Identical~notes~in~caption } |
| 19169 |
{ |
| 19170 |
Identical~tabular~notes.\\ |
| 19171 |
You~can't~put~several~notes~with~the~same~content~in~ |
| 19172 |
\token_to_str:N \caption \ (but~it's~possible~in~the~main~tabular).~ |
| 19173 |
If~you~go~on,~the~output~will~probably~be~erroneous. |
| 19174 |
} |
| 19175 |
% \end{macrocode} |
| 19176 |
% |
| 19177 |
% \begin{macrocode} |
| 19178 |
\@@_msg_new:nn { tabularnote~below~the~tabular } |
| 19179 |
{ |
| 19180 |
\token_to_str:N \tabularnote \ forbidden\\ |
| 19181 |
You~can't~use~ \token_to_str:N \tabularnote \ in~the~caption~ |
| 19182 |
of~your~tabular~because~the~caption~will~be~composed~below~ |
| 19183 |
the~tabular.~If~you~want~the~caption~above~the~tabular~use~the~ |
| 19184 |
key~'caption-above'~in~ \token_to_str:N \NiceMatrixOptions .~ |
| 19185 |
Your~ \token_to_str:N \tabularnote \ will~be~ignored~and~ |
| 19186 |
no~similar~error~will~raised~in~this~document. |
| 19187 |
} |
| 19188 |
% \end{macrocode} |
| 19189 |
% |
| 19190 |
% \begin{macrocode} |
| 19191 |
\@@_msg_new:nn { Unknown~key~for~rules } |
| 19192 |
{ |
| 19193 |
Unknown~key.\\ |
| 19194 |
There~are~only~three~keys~available~here:~'width',~'color'~and~ |
| 19195 |
'fix-vertex'.~Your~key~' \l_keys_key_str '~will~be~ignored. |
| 19196 |
} |
| 19197 |
% \end{macrocode} |
| 19198 |
% |
| 19199 |
% \begin{macrocode} |
| 19200 |
\@@_msg_new:nn { Unknown~key~for~trees } |
| 19201 |
{ |
| 19202 |
Unknown~key.\\ |
| 19203 |
There~are~only~three~keys~available~here:~width~color~and~ |
| 19204 |
rounded-corners.~Your~key~' \l_keys_key_str '~will~be~ignored. |
| 19205 |
} |
| 19206 |
% \end{macrocode} |
| 19207 |
% |
| 19208 |
% |
| 19209 |
% \begin{macrocode} |
| 19210 |
\@@_msg_new:nn { Unknown~key~for~Hbrace } |
| 19211 |
{ |
| 19212 |
Unknown~key.\\ |
| 19213 |
You~have~used~the~key~' \l_keys_key_str '~but~the~only~ |
| 19214 |
keys~allowed~for~the~commands~ \token_to_str:N \Hbrace \ |
| 19215 |
and~ \token_to_str:N \Vbrace \ are:~'brace-shift(+)',~'color',~ |
| 19216 |
'horizontal-label(s)',~'shorten'~'shorten-end'~ |
| 19217 |
and~'shorten-start'. |
| 19218 |
} |
| 19219 |
% \end{macrocode} |
| 19220 |
% |
| 19221 |
% \begin{macrocode} |
| 19222 |
\@@_msg_new:nn { Unknown~key~for~TikzEveryCell } |
| 19223 |
{ |
| 19224 |
Unknown~key.\\ |
| 19225 |
There~is~only~two~keys~available~here:~ |
| 19226 |
'empty'~and~'not-empty'.~Your~key~' \l_keys_key_str '~will~be~ignored. |
| 19227 |
} |
| 19228 |
% \end{macrocode} |
| 19229 |
% |
| 19230 |
% \begin{macrocode} |
| 19231 |
\@@_msg_new:nn { Unknown~key~for~rotate } |
| 19232 |
{ |
| 19233 |
Unknown~key.\\ |
| 19234 |
The~only~keys~available~here~are~'c'~and~'-90'.~ |
| 19235 |
Your~key~' \l_keys_key_str '~will~be~ignored. |
| 19236 |
} |
| 19237 |
% \end{macrocode} |
| 19238 |
% |
| 19239 |
% \begin{macrocode} |
| 19240 |
\@@_msg_new:nnn { Unknown~key~for~custom-line } |
| 19241 |
{ |
| 19242 |
Unknown~key.\\ |
| 19243 |
The~key~' \l_keys_key_str '~is~unknown~in~a~'custom-line'.~ |
| 19244 |
It~you~go~on,~you~will~probably~have~other~errors. \\ |
| 19245 |
\c_@@_available_keys_str |
| 19246 |
} |
| 19247 |
{ |
| 19248 |
The~available~keys~are~(in~alphabetic~order):~ |
| 19249 |
ccommand,~ |
| 19250 |
color,~ |
| 19251 |
command,~ |
| 19252 |
dotted,~ |
| 19253 |
letter,~ |
| 19254 |
multiplicity,~ |
| 19255 |
sep-color,~ |
| 19256 |
tikz,~and~total-width. |
| 19257 |
} |
| 19258 |
% \end{macrocode} |
| 19259 |
% |
| 19260 |
% \begin{macrocode} |
| 19261 |
\@@_msg_new:nnn { Unknown~key~for~defaut-line } |
| 19262 |
{ |
| 19263 |
Unknown~key.\\ |
| 19264 |
The~key~' \l_keys_key_str '~is~unknown~in~a~'default-line'.~ |
| 19265 |
It~you~go~on,~you~will~probably~have~other~errors. \\ |
| 19266 |
\c_@@_available_keys_str |
| 19267 |
} |
| 19268 |
{ |
| 19269 |
The~available~keys~are~(in~alphabetic~order):~ |
| 19270 |
color,~ |
| 19271 |
dotted,~ |
| 19272 |
multiplicity,~ |
| 19273 |
sep-color,~ |
| 19274 |
tikz,~and~total-width. |
| 19275 |
} |
| 19276 |
% \end{macrocode} |
| 19277 |
% |
| 19278 |
% \begin{macrocode} |
| 19279 |
\@@_msg_new:nnn { Unknown~key~for~xdots } |
| 19280 |
{ |
| 19281 |
Unknown~key.\\ |
| 19282 |
The~key~' \l_keys_key_str '~is~unknown~for~a~command~for~drawing~dotted~rules.\\ |
| 19283 |
\c_@@_available_keys_str |
| 19284 |
} |
| 19285 |
{ |
| 19286 |
The~available~keys~are~(in~alphabetic~order):~ |
| 19287 |
'color',~ |
| 19288 |
'horizontal(s)-labels',~ |
| 19289 |
'inter',~ |
| 19290 |
'line-style',~ |
| 19291 |
'nullify',~ |
| 19292 |
'radius',~ |
| 19293 |
'shorten',~ |
| 19294 |
'shorten-end'~and~'shorten-start'. |
| 19295 |
} |
| 19296 |
% \end{macrocode} |
| 19297 |
% |
| 19298 |
% |
| 19299 |
% \begin{macrocode} |
| 19300 |
\@@_msg_new:nn { Unknown~key~for~rowcolors } |
| 19301 |
{ |
| 19302 |
Unknown~key.\\ |
| 19303 |
As~for~now,~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~ |
| 19304 |
(and~you~try~to~use~' \l_keys_key_str ').~Your~key~will~be~ignored. |
| 19305 |
} |
| 19306 |
% \end{macrocode} |
| 19307 |
% |
| 19308 |
% \begin{macrocode} |
| 19309 |
\@@_msg_new:nn { Col~outside~tabular~in~trees } |
| 19310 |
{ |
| 19311 |
Error~with~'draw-trees-in-col' \\ |
| 19312 |
The~number~of~column~'#1'~is~outside~your~tabular~since~the~last~column~ |
| 19313 |
is~\int_use:N \c@jCol.~It~will~be~ignored. |
| 19314 |
} |
| 19315 |
% \end{macrocode} |
| 19316 |
% |
| 19317 |
% \begin{macrocode} |
| 19318 |
\@@_msg_new:nn { Last~col~in~trees } |
| 19319 |
{ |
| 19320 |
Error~with~'draw-trees-in-col' \\ |
| 19321 |
You~can't~use~'draw-trees-in-col'~with~the~column~'#1'~ because~it's~ |
| 19322 |
the~last~column~of~your~tabular.~It~will~be~ignored. |
| 19323 |
} |
| 19324 |
% \end{macrocode} |
| 19325 |
% |
| 19326 |
% |
| 19327 |
% \begin{macrocode} |
| 19328 |
\@@_msg_new:nn { label~without~caption } |
| 19329 |
{ |
| 19330 |
You~can't~use~the~key~'label'~in~your~\{NiceTabular\}~because~ |
| 19331 |
you~have~not~used~the~key~'caption'.~The~key~'label'~will~be~ignored. |
| 19332 |
} |
| 19333 |
% \end{macrocode} |
| 19334 |
% |
| 19335 |
% |
| 19336 |
% \begin{macrocode} |
| 19337 |
\@@_msg_new:nn { W~warning } |
| 19338 |
{ |
| 19339 |
Line~ \msg_line_number: .~The~cell~is~too~wide~for~your~column~'W'~ |
| 19340 |
(row~ \int_use:N \c@iRow ). |
| 19341 |
} |
| 19342 |
% \end{macrocode} |
| 19343 |
% |
| 19344 |
% \begin{macrocode} |
| 19345 |
\@@_msg_new:nn { Construct~too~large } |
| 19346 |
{ |
| 19347 |
Construct~too~large.\\ |
| 19348 |
Your~command~ \token_to_str:N #1 |
| 19349 |
can't~be~drawn~because~your~matrix~is~too~small.~ |
| 19350 |
Your~command~will~be~ignored. |
| 19351 |
} |
| 19352 |
% \end{macrocode} |
| 19353 |
% |
| 19354 |
% \begin{macrocode} |
| 19355 |
\@@_msg_new:nn { underscore~after~nicematrix } |
| 19356 |
{ |
| 19357 |
Problem~with~'underscore'.\\ |
| 19358 |
The~package~'underscore'~should~be~loaded~before~'nicematrix'.~ |
| 19359 |
You~can~go~on~but~you~won't~be~able~to~write~something~such~as:\\ |
| 19360 |
' \token_to_str:N \Cdots \token_to_str:N _ |
| 19361 |
\{ n \token_to_str:N \text \{ ~times \} \}'. |
| 19362 |
} |
| 19363 |
% \end{macrocode} |
| 19364 |
% |
| 19365 |
% |
| 19366 |
% \begin{macrocode} |
| 19367 |
\@@_msg_new:nn { ampersand~in~light-syntax } |
| 19368 |
{ |
| 19369 |
Ampersand~forbidden.\\ |
| 19370 |
You~can't~use~an~ampersand~( \token_to_str:N &)~to~separate~columns~because~ |
| 19371 |
~the~key~'light-syntax'~is~in~force. |
| 19372 |
} |
| 19373 |
% \end{macrocode} |
| 19374 |
% |
| 19375 |
% \begin{macrocode} |
| 19376 |
\@@_msg_new:nn { double-backslash~in~light-syntax } |
| 19377 |
{ |
| 19378 |
Double~backslash~forbidden.\\ |
| 19379 |
You~can't~use~ \token_to_str:N \\ |
| 19380 |
~to~separate~rows~because~the~key~'light-syntax'~ |
| 19381 |
is~in~force.~You~must~use~the~character~' \l_@@_end_of_row_tl '~ |
| 19382 |
(set~by~the~key~'end-of-row'). |
| 19383 |
} |
| 19384 |
% \end{macrocode} |
| 19385 |
% |
| 19386 |
% \begin{macrocode} |
| 19387 |
\@@_msg_new:nn { bad~value~for~baseline } |
| 19388 |
{ |
| 19389 |
Bad~value~for~baseline.\\ |
| 19390 |
The~value~given~to~'baseline'~( \int_use:N \l_tmpa_int )~is~not~ |
| 19391 |
valid.~The~value~must~be~between~\int_use:N \l_@@_first_row_int\ and~ |
| 19392 |
\int_use:N \g_@@_row_total_int \ or~equal~to~'t',~'c'~or~'b'~or~of~ |
| 19393 |
the~form~'line-i'.~A~value~of~1~will~be~used. |
| 19394 |
} |
| 19395 |
% \end{macrocode} |
| 19396 |
% |
| 19397 |
% \begin{macrocode} |
| 19398 |
\@@_msg_new:nn { bad~value~for~baseline-line } |
| 19399 |
{ |
| 19400 |
Bad~value~for~baseline~with~line.\\ |
| 19401 |
The~value~given~to~'baseline'~( \int_use:N \l_tmpa_int )~is~not~ |
| 19402 |
valid.~The~number~of~the~line~must~be~between~1~and~ |
| 19403 |
\int_eval:n { \c@iRow + 1 }.~ |
| 19404 |
A~value~of~'line-1'~will~be~used. |
| 19405 |
} |
| 19406 |
% \end{macrocode} |
| 19407 |
% |
| 19408 |
% \begin{macrocode} |
| 19409 |
\@@_msg_new:nn { detection~of~empty~cells } |
| 19410 |
{ |
| 19411 |
Problem~with~'not-empty'\\ |
| 19412 |
For~technical~reasons,~you~must~activate~ |
| 19413 |
'create-cell-nodes'~in~ \token_to_str:N \CodeBefore \ |
| 19414 |
in~order~to~use~the~key~' \l_keys_key_str '.~ |
| 19415 |
Your~key~will~be~ignored. |
| 19416 |
} |
| 19417 |
% \end{macrocode} |
| 19418 |
% |
| 19419 |
% |
| 19420 |
% \begin{macrocode} |
| 19421 |
\@@_msg_new:nn { siunitx~too~old } |
| 19422 |
{ |
| 19423 |
siunitx~too~old\\ |
| 19424 |
You~can't~use~the~columns~'S'~because~your~version~of~'siunitx'~ |
| 19425 |
is~too~old.~You~need~at~least~the~version~3.5.1~(2026/03/26). |
| 19426 |
} |
| 19427 |
% \end{macrocode} |
| 19428 |
% |
| 19429 |
% \begin{macrocode} |
| 19430 |
\@@_msg_new:nn { Invalid~name } |
| 19431 |
{ |
| 19432 |
Invalid~name.\\ |
| 19433 |
You~can't~give~the~name~' \l_keys_value_tl '~to~a~ \token_to_str:N |
| 19434 |
\SubMatrix \ of~your~ \@@_full_name_env: .~ |
| 19435 |
A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\ |
| 19436 |
Your~key~will~be~ignored. |
| 19437 |
} |
| 19438 |
% \end{macrocode} |
| 19439 |
% |
| 19440 |
% \begin{macrocode} |
| 19441 |
\@@_msg_new:nn { Hbrace~not~allowed } |
| 19442 |
{ |
| 19443 |
Command~not~allowed.\\ |
| 19444 |
You~can't~use~the~command~ \token_to_str:N #1 |
| 19445 |
because~you~have~not~loaded~ |
| 19446 |
\IfPackageLoadedTF { tikz } |
| 19447 |
{ the~TikZ~library~'decorations.pathreplacing'.~Use~ } |
| 19448 |
{ TikZ.~ Use:~ \token_to_str:N \usepackage \{tikz\}~and~ } |
| 19449 |
\token_to_str:N \usetikzlibrary \{decorations.pathreplacing\}. \\ |
| 19450 |
Your~command~will~be~ignored. |
| 19451 |
} |
| 19452 |
% \end{macrocode} |
| 19453 |
% |
| 19454 |
% \begin{macrocode} |
| 19455 |
\@@_msg_new:nn { Vbrace~not~allowed } |
| 19456 |
{ |
| 19457 |
Command~not~allowed.\\ |
| 19458 |
You~can't~use~the~command~ \token_to_str:N \Vbrace \ |
| 19459 |
because~you~have~not~loaded~TikZ~ |
| 19460 |
and~the~TikZ~library~'decorations.pathreplacing'.~ |
| 19461 |
Use: ~\token_to_str:N \usepackage \{tikz\}~ |
| 19462 |
\token_to_str:N \usetikzlibrary \{decorations.pathreplacing\} \\ |
| 19463 |
Your~command~will~be~ignored. |
| 19464 |
} |
| 19465 |
% \end{macrocode} |
| 19466 |
% |
| 19467 |
% \begin{macrocode} |
| 19468 |
\@@_msg_new:nn { Wrong~line~in~SubMatrix } |
| 19469 |
{ |
| 19470 |
Wrong~line.\\ |
| 19471 |
You~try~to~draw~a~#1~line~of~number~'#2'~in~a~ |
| 19472 |
\token_to_str:N \SubMatrix \ of~your~ \@@_full_name_env: \ but~that~ |
| 19473 |
number~is~not~valid.~It~will~be~ignored. |
| 19474 |
} |
| 19475 |
% \end{macrocode} |
| 19476 |
% |
| 19477 |
% \begin{macrocode} |
| 19478 |
\@@_msg_new:nn { Impossible~SubMatrix } |
| 19479 |
{ |
| 19480 |
Impossible~SubMatrix.\\ |
| 19481 |
It's~impossible~to~draw~your~\token_to_str:N \SubMatrix \ |
| 19482 |
because~all~the~cells~are~empty~in~the~column~on~the~#1~ |
| 19483 |
side~of~that~\token_to_str:N \SubMatrix. |
| 19484 |
\bool_if:NT \l_@@_submatrix_slim_bool |
| 19485 |
{ ~Maybe~you~should~try~without~the~key~'slim'. } \\ |
| 19486 |
This~ \token_to_str:N \SubMatrix \ will~be~ignored. |
| 19487 |
} |
| 19488 |
% \end{macrocode} |
| 19489 |
% |
| 19490 |
% \begin{macrocode} |
| 19491 |
\@@_msg_new:nn { Impossible~SubMatrix~no~cell~nodes } |
| 19492 |
{ |
| 19493 |
Impossible~SubMatrix.\\ |
| 19494 |
It's~impossible~to~draw~your~ \token_to_str:N \SubMatrix \ |
| 19495 |
because~the~key~'no-cell-nodes'~is~in~force.~ |
| 19496 |
This~ \token_to_str:N \SubMatrix \ will~be~ignored. |
| 19497 |
} |
| 19498 |
% \end{macrocode} |
| 19499 |
% |
| 19500 |
% \begin{macrocode} |
| 19501 |
\@@_msg_new:nnn { width~without~X~columns } |
| 19502 |
{ |
| 19503 |
You~have~used~the~key~'width'~but~you~have~put~no~'X'~column~in~ |
| 19504 |
the~preamble~(' \g_@@_user_preamble_tl ')~of~your~ \@@_full_name_env: .~ |
| 19505 |
Your~key~will~be~ignored. |
| 19506 |
} |
| 19507 |
{ |
| 19508 |
This~message~is~the~message~'width~without~X~columns'~ |
| 19509 |
of~the~module~'nicematrix'.~ |
| 19510 |
The~experimented~users~can~disable~that~message~with~ |
| 19511 |
\token_to_str:N \msg_redirect_name:nnn .\\ |
| 19512 |
} |
| 19513 |
|
| 19514 |
% \end{macrocode} |
| 19515 |
% |
| 19516 |
% \begin{macrocode} |
| 19517 |
\@@_msg_new:nn { key~multiplicity~with~dotted } |
| 19518 |
{ |
| 19519 |
Incompatible~keys. \\ |
| 19520 |
You~have~used~the~key~'multiplicity'~with~the~key~'dotted'~ |
| 19521 |
in~a~'custom-line'.~They~are~incompatible.~ |
| 19522 |
The~key~'multiplicity'~will~be~ignored. |
| 19523 |
} |
| 19524 |
% \end{macrocode} |
| 19525 |
% |
| 19526 |
% \begin{macrocode} |
| 19527 |
\@@_msg_new:nn { empty~environment } |
| 19528 |
{ |
| 19529 |
Empty~environment.\\ |
| 19530 |
Your~ \@@_full_name_env: \ is~empty. |
| 19531 |
} |
| 19532 |
% \end{macrocode} |
| 19533 |
% |
| 19534 |
% |
| 19535 |
% \begin{macrocode} |
| 19536 |
\@@_msg_new:nn { No~letter~and~no~command } |
| 19537 |
{ |
| 19538 |
Erroneous~use.\\ |
| 19539 |
Your~use~of~'custom-line'~is~no-op~since~you~don't~have~used~the~ |
| 19540 |
key~'letter'~(for~a~letter~for~vertical~rules)~nor~the~keys~'command'~or~ |
| 19541 |
~'ccommand'~(to~draw~horizontal~rules).~However,~you~can~go~on. |
| 19542 |
} |
| 19543 |
% \end{macrocode} |
| 19544 |
% |
| 19545 |
% \begin{macrocode} |
| 19546 |
\@@_msg_new:nn { Forbidden~letter } |
| 19547 |
{ |
| 19548 |
Forbidden~letter.\\ |
| 19549 |
You~can't~use~the~letter~'#1'~for~a~customized~line.~ |
| 19550 |
It~will~be~ignored.~The~forbidden~letters~are:~\c_@@_forbidden_letters_str |
| 19551 |
} |
| 19552 |
% \end{macrocode} |
| 19553 |
% |
| 19554 |
% \begin{macrocode} |
| 19555 |
\@@_msg_new:nn { Several~letters } |
| 19556 |
{ |
| 19557 |
Wrong~name.\\ |
| 19558 |
You~must~use~only~one~letter~as~value~for~the~key~'letter'~(and~you~ |
| 19559 |
have~used~' \l_@@_letter_str ').~It~will~be~ignored. |
| 19560 |
} |
| 19561 |
% \end{macrocode} |
| 19562 |
% |
| 19563 |
% \begin{macrocode} |
| 19564 |
\@@_msg_new:nn { Delimiter~with~small } |
| 19565 |
{ |
| 19566 |
Delimiter~forbidden.\\ |
| 19567 |
You~can't~put~a~delimiter~in~the~preamble~of~your~ |
| 19568 |
\@@_full_name_env: \ |
| 19569 |
because~the~key~'small'~is~in~force. |
| 19570 |
} |
| 19571 |
% \end{macrocode} |
| 19572 |
% |
| 19573 |
% \begin{macrocode} |
| 19574 |
\@@_msg_new:nn { unknown~cell~for~line~in~CodeAfter } |
| 19575 |
{ |
| 19576 |
Unknown~cell.\\ |
| 19577 |
Your~command~ \token_to_str:N \line \{ #1 \} \{ #2 \}~in~ |
| 19578 |
the~ \token_to_str:N \CodeAfter \ of~your~ \@@_full_name_env: \ |
| 19579 |
can't~be~executed~because~a~cell~doesn't~exist.~ |
| 19580 |
Your~command~ \token_to_str:N \line \ will~be~ignored. |
| 19581 |
} |
| 19582 |
% \end{macrocode} |
| 19583 |
% |
| 19584 |
% |
| 19585 |
% \begin{macrocode} |
| 19586 |
\@@_msg_new:nnn { Duplicate~name~for~SubMatrix } |
| 19587 |
{ |
| 19588 |
Duplicate~name. \\ |
| 19589 |
The~name~'#1'~is~already~used~for~a~ \token_to_str:N \SubMatrix \ |
| 19590 |
in~this~ \@@_full_name_env: .~Your~key~will~be~ignored.~ |
| 19591 |
\bool_if:NF \g_@@_messages_for_Overleaf_bool |
| 19592 |
{ For~a~list~of~the~names~already~used,~type~H~<return>. } |
| 19593 |
} |
| 19594 |
{ |
| 19595 |
The~names~already~defined~in~this~ \@@_full_name_env: \ are:~ |
| 19596 |
\seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ } . |
| 19597 |
} |
| 19598 |
% \end{macrocode} |
| 19599 |
% |
| 19600 |
% \begin{macrocode} |
| 19601 |
\@@_msg_new:nn { r~or~l~with~preamble } |
| 19602 |
{ |
| 19603 |
Erroneous~use. \\ |
| 19604 |
You~can't~use~the~key~' \l_keys_key_str '~in~your~ \@@_full_name_env: .~ |
| 19605 |
You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~ |
| 19606 |
your~ \@@_full_name_env: .~ |
| 19607 |
Your~key~will~be~ignored. |
| 19608 |
} |
| 19609 |
% \end{macrocode} |
| 19610 |
% |
| 19611 |
% \begin{macrocode} |
| 19612 |
\@@_msg_new:nn { Hdotsfor~in~col~0 } |
| 19613 |
{ |
| 19614 |
Erroneous~use. \\ |
| 19615 |
You~can't~use~ \token_to_str:N \Hdotsfor\ or~\token_to_str:N \Hbrace\ |
| 19616 |
in~an~exterior~column~of~the~array. |
| 19617 |
} |
| 19618 |
% \end{macrocode} |
| 19619 |
% |
| 19620 |
% \begin{macrocode} |
| 19621 |
\@@_msg_new:nn { bad~corner } |
| 19622 |
{ |
| 19623 |
Bad~corner. \\ |
| 19624 |
'#1'~is~an~incorrect~specification~for~a~corner~(in~the~key~ |
| 19625 |
'corners').~The~available~values~are:~NW,~SW,~NE~and~SE.~ |
| 19626 |
This~specification~of~corner~will~be~ignored. |
| 19627 |
} |
| 19628 |
% \end{macrocode} |
| 19629 |
% |
| 19630 |
% \begin{macrocode} |
| 19631 |
\@@_msg_new:nn { bad~border } |
| 19632 |
{ |
| 19633 |
Bad~border.\\ |
| 19634 |
'\l_keys_key_str'~is~an~incorrect~specification~for~a~border~ |
| 19635 |
(in~the~key~'borders'~of~the~command~ \token_to_str:N \Block ).~ |
| 19636 |
The~available~values~are:~left,~right,~top~and~bottom~(and~you~can~ |
| 19637 |
also~use~the~key~'tikz' |
| 19638 |
\IfPackageLoadedF { tikz } |
| 19639 |
{ ~if~you~load~the~LaTeX~package~'tikz' } ).~ |
| 19640 |
This~specification~of~border~will~be~ignored. |
| 19641 |
} |
| 19642 |
% \end{macrocode} |
| 19643 |
% |
| 19644 |
% \begin{macrocode} |
| 19645 |
\@@_msg_new:nn { TikzEveryCell~without~tikz } |
| 19646 |
{ |
| 19647 |
TikZ~not~loaded. \\ |
| 19648 |
You~can't~use~ \token_to_str:N \TikzEveryCell \ |
| 19649 |
because~you~have~not~loaded~TikZ.~You~can~load~TikZ~with~ |
| 19650 |
\token_to_str:N \usepackage \{tikz\},~before~or~after~'nicematrix'.~ |
| 19651 |
Your~command~will~be~ignored. |
| 19652 |
} |
| 19653 |
% \end{macrocode} |
| 19654 |
% |
| 19655 |
% \begin{macrocode} |
| 19656 |
\@@_msg_new:nn { tikz~key~without~tikz } |
| 19657 |
{ |
| 19658 |
TikZ~not~loaded. \\ |
| 19659 |
You~can't~use~the~key~'tikz'~for~the~command~' \token_to_str:N |
| 19660 |
\Block '~because~you~have~not~loaded~TikZ.~ |
| 19661 |
You~can~load~TikZ~with~\token_to_str:N \usepackage \{tikz\},~ |
| 19662 |
before~or~after~'nicematrix'.~Your~key~will~be~ignored. |
| 19663 |
} |
| 19664 |
% \end{macrocode} |
| 19665 |
% |
| 19666 |
% \begin{macrocode} |
| 19667 |
\@@_msg_new:nn { Bad~argument~for~Block } |
| 19668 |
{ |
| 19669 |
Bad~argument. \\ |
| 19670 |
The~first~mandatory~argument~of~\token_to_str:N \Block\ must~ |
| 19671 |
be~of~the~form~'i-j'~(or~totally~empty)~and~you~have~used:~ |
| 19672 |
'#1'.~ If~you~go~on,~the~\token_to_str:N \Block\ will~be~mono-cell~(as~if~ |
| 19673 |
the~argument~was~empty). |
| 19674 |
} |
| 19675 |
% \end{macrocode} |
| 19676 |
% |
| 19677 |
% \begin{macrocode} |
| 19678 |
\@@_msg_new:nn { last-col~non~empty~for~NiceArray } |
| 19679 |
{ |
| 19680 |
Erroneous~use. \\ |
| 19681 |
In~the~ \@@_full_name_env: ,~you~must~use~the~key~ |
| 19682 |
'last-col'~without~value.~However,~you~can~go~on~for~this~time~ |
| 19683 |
(the~value~' \l_keys_value_tl '~will~be~ignored). |
| 19684 |
} |
| 19685 |
% \end{macrocode} |
| 19686 |
% |
| 19687 |
% |
| 19688 |
% \begin{macrocode} |
| 19689 |
\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } |
| 19690 |
{ |
| 19691 |
Erroneous~use. \\ |
| 19692 |
In~\token_to_str:N \NiceMatrixOptions ,~you~must~use~the~key~ |
| 19693 |
'last-col'~without~value.~ However,~you~can~go~on~for~this~time~ |
| 19694 |
(the~value~' \l_keys_value_tl '~will~be~ignored). |
| 19695 |
} |
| 19696 |
% \end{macrocode} |
| 19697 |
% |
| 19698 |
% |
| 19699 |
% \begin{macrocode} |
| 19700 |
\@@_msg_new:nn { Block~too~large~1 } |
| 19701 |
{ |
| 19702 |
Block~too~large. \\ |
| 19703 |
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ |
| 19704 |
too~small~for~that~block.~This~block~and~maybe~others~will~be~ignored. |
| 19705 |
} |
| 19706 |
% \end{macrocode} |
| 19707 |
% |
| 19708 |
% \begin{macrocode} |
| 19709 |
\@@_msg_new:nn { Block~too~large~2 } |
| 19710 |
{ |
| 19711 |
Block~too~large. \\ |
| 19712 |
The~preamble~of~your~ \@@_full_name_env: \ announces~ \int_use:N |
| 19713 |
\g_@@_static_num_of_col_int \ |
| 19714 |
columns~but~you~use~only~ \int_use:N \c@jCol \ and~that's~why~a~block~ |
| 19715 |
specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~ |
| 19716 |
(&)~at~the~end~of~the~first~row~of~your~ \@@_full_name_env: .~ |
| 19717 |
This~block~and~maybe~others~will~be~ignored. |
| 19718 |
} |
| 19719 |
% \end{macrocode} |
| 19720 |
% |
| 19721 |
% |
| 19722 |
% \begin{macrocode} |
| 19723 |
\@@_msg_new:nn { unknown~column~type } |
| 19724 |
{ |
| 19725 |
Bad~column~type. \\ |
| 19726 |
The~column~type~'#1'~in~your~ \@@_full_name_env: \ is~unknown. |
| 19727 |
} |
| 19728 |
% \end{macrocode} |
| 19729 |
% |
| 19730 |
% \begin{macrocode} |
| 19731 |
\@@_msg_new:nn { unknown~column~type~multicolumn } |
| 19732 |
{ |
| 19733 |
Bad~column~type. \\ |
| 19734 |
The~column~type~'#1'~in~the~command~\token_to_str:N \multicolumn \ |
| 19735 |
~of~your~ \@@_full_name_env: \ is~unknown. |
| 19736 |
} |
| 19737 |
% \end{macrocode} |
| 19738 |
% |
| 19739 |
% \begin{macrocode} |
| 19740 |
\@@_msg_new:nn { unknown~column~type~S } |
| 19741 |
{ |
| 19742 |
Bad~column~type. \\ |
| 19743 |
The~column~type~'S'~in~your~ \@@_full_name_env: \ is~unknown.~ |
| 19744 |
If~you~want~to~use~the~column~type~'S'~of~siunitx,~you~should~ |
| 19745 |
load~that~package~with~\token_to_str:N \usepackage \{siunitx\}. |
| 19746 |
} |
| 19747 |
% \end{macrocode} |
| 19748 |
% |
| 19749 |
% \begin{macrocode} |
| 19750 |
\@@_msg_new:nn { unknown~column~type~S~multicolumn } |
| 19751 |
{ |
| 19752 |
Bad~column~type. \\ |
| 19753 |
The~column~type~'S'~in~the~command~\token_to_str:N \multicolumn \ |
| 19754 |
of~your~ \@@_full_name_env: \ is~unknown.~If~you~want~to~use~the~column~ |
| 19755 |
type~'S'~of~siunitx,~you~should~load~that~package~with~ |
| 19756 |
\token_to_str:N \usepackage \{siunitx\}. |
| 19757 |
} |
| 19758 |
% \end{macrocode} |
| 19759 |
% |
| 19760 |
% \begin{macrocode} |
| 19761 |
\@@_msg_new:nn { tabularnote~forbidden } |
| 19762 |
{ |
| 19763 |
Forbidden~command. \\ |
| 19764 |
You~can't~use~the~command~ \token_to_str:N \tabularnote \ |
| 19765 |
~here.~This~command~is~available~only~in~ |
| 19766 |
\{NiceTabular\},~\{NiceTabular*\}~and~\{NiceTabularX\}~or~in~ |
| 19767 |
the~argument~of~a~command~\token_to_str:N \caption \ included~ |
| 19768 |
in~an~environment~\{table\}.~Your~command~will~be~ignored. |
| 19769 |
} |
| 19770 |
% \end{macrocode} |
| 19771 |
% |
| 19772 |
% \begin{macrocode} |
| 19773 |
\@@_msg_new:nn { borders~forbidden } |
| 19774 |
{ |
| 19775 |
Forbidden~key.\\ |
| 19776 |
You~can't~use~the~key~'borders'~of~the~command~ \token_to_str:N \Block \ |
| 19777 |
because~the~option~'rounded-corners'~is~in~force~with~a~non-zero~value.~ |
| 19778 |
Your~key~will~be~ignored. |
| 19779 |
} |
| 19780 |
% \end{macrocode} |
| 19781 |
% |
| 19782 |
% \begin{macrocode} |
| 19783 |
\@@_msg_new:nn { bottomrule~without~booktabs } |
| 19784 |
{ |
| 19785 |
booktabs~not~loaded.\\ |
| 19786 |
You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~ |
| 19787 |
loaded~'booktabs'.~You~should~load~'booktabs',~before~or~ |
| 19788 |
after~'nicematrix'.~Your~key~will~be~ignored. |
| 19789 |
} |
| 19790 |
% \end{macrocode} |
| 19791 |
% |
| 19792 |
% \begin{macrocode} |
| 19793 |
\@@_msg_new:nn { enumitem~not~loaded } |
| 19794 |
{ |
| 19795 |
enumitem~not~loaded. \\ |
| 19796 |
You~can't~use~the~command~ \token_to_str:N \tabularnote \ |
| 19797 |
~because~you~haven't~loaded~'enumitem'.~We~should~load~it~ |
| 19798 |
(before~or~after~'nicematrix').~All~the~commands~ |
| 19799 |
\token_to_str:N \tabularnote \ will~be~ignored~in~the~document. |
| 19800 |
} |
| 19801 |
% \end{macrocode} |
| 19802 |
% |
| 19803 |
% \begin{macrocode} |
| 19804 |
\@@_msg_new:nn { tikz~without~tikz } |
| 19805 |
{ |
| 19806 |
TikZ~not~loaded. \\ |
| 19807 |
You~can't~use~the~key~'tikz'~here~because~TikZ~is~not~loaded.~You~ |
| 19808 |
should~load~TikZ~~with~\token_to_str:N \usepackage \{tikz\}.~ |
| 19809 |
If~you~go~on,~your~key~will~be~ignored. |
| 19810 |
} |
| 19811 |
% \end{macrocode} |
| 19812 |
% |
| 19813 |
% \begin{macrocode} |
| 19814 |
\@@_msg_new:nn { tikz~in~custom-line~without~tikz } |
| 19815 |
{ |
| 19816 |
TikZ~not~loaded. \\ |
| 19817 |
You~have~used~the~key~'tikz'~in~the~definition~of~a~ |
| 19818 |
customized~line~(with~'custom-line')~but~TikZ~is~not~loaded.~ |
| 19819 |
You~can~go~on~but~you~will~have~another~error~if~you~actually~ |
| 19820 |
use~that~custom~line.~You~should~load~TikZ~~with~ |
| 19821 |
\token_to_str:N \usepackage \{tikz\}. |
| 19822 |
} |
| 19823 |
% \end{macrocode} |
| 19824 |
% |
| 19825 |
% \begin{macrocode} |
| 19826 |
\@@_msg_new:nn { tikz~in~borders~without~tikz } |
| 19827 |
{ |
| 19828 |
TikZ~not~loaded. \\ |
| 19829 |
You~have~used~the~key~'tikz'~in~a~key~'borders'~(of~a~ |
| 19830 |
command~' \token_to_str:N \Block ')~but~TikZ~is~not~loaded.~ |
| 19831 |
Your~key~will~be~ignored.~You~should~load~TikZ~~with~ |
| 19832 |
\token_to_str:N \usepackage \{tikz\} |
| 19833 |
} |
| 19834 |
% \end{macrocode} |
| 19835 |
% |
| 19836 |
% \begin{macrocode} |
| 19837 |
\@@_msg_new:nn { color~in~custom-line~with~tikz } |
| 19838 |
{ |
| 19839 |
Erroneous~use.\\ |
| 19840 |
In~a~'custom-line',~you~have~used~both~'tikz'~(or~'dashed')~and~'color',~ |
| 19841 |
which~is~forbidden~(you~should~use~'color'~inside~the~key~'tikz'~itself).~ |
| 19842 |
The~key~'color'~will~be~ignored. |
| 19843 |
} |
| 19844 |
% \end{macrocode} |
| 19845 |
% |
| 19846 |
% \begin{macrocode} |
| 19847 |
\@@_msg_new:nn { Wrong~last~row } |
| 19848 |
{ |
| 19849 |
Wrong~number.\\ |
| 19850 |
You~have~used~'last-row= \int_use:N \l_@@_last_row_int '~but~your~ |
| 19851 |
\@@_full_name_env: \ seems~to~have~ \int_use:N \c@iRow \ rows.~ |
| 19852 |
If~you~go~on,~the~value~of~ \int_use:N \c@iRow \ will~be~used~for~ |
| 19853 |
last~row~but~you~should~correct~your~code.~You~can~avoid~this~ |
| 19854 |
problem~by~using~'last-row'~without~value~(more~compilations~ |
| 19855 |
might~be~necessary). |
| 19856 |
} |
| 19857 |
% \end{macrocode} |
| 19858 |
% |
| 19859 |
% |
| 19860 |
% \begin{macrocode} |
| 19861 |
\@@_msg_new:nn { Yet~in~env } |
| 19862 |
{ |
| 19863 |
Nested~environments.\\ |
| 19864 |
Environments~of~nicematrix~can't~be~nested.~However~you~ |
| 19865 |
can~insert,~for~example,~a~\{tabular\}~in~a~\{NiceTabular\}~ |
| 19866 |
or~a~\{NiceTabular\}~in~a~\{tabular\}.~You~can~also~compose~ |
| 19867 |
an~environment~of~nicematrix~in~a~box~of~LaTeX~and~insert~ |
| 19868 |
that~box~in~another~environment~of~nicematrix. |
| 19869 |
} |
| 19870 |
% \end{macrocode} |
| 19871 |
% |
| 19872 |
% \begin{macrocode} |
| 19873 |
\@@_msg_new:nn { Outside~math~mode } |
| 19874 |
{ |
| 19875 |
Outside~math~mode.\\ |
| 19876 |
The~\@@_full_name_env: \ can~be~used~only~in~math~mode~ |
| 19877 |
(and~not~in~ \token_to_str:N \vcenter ). |
| 19878 |
} |
| 19879 |
% \end{macrocode} |
| 19880 |
% |
| 19881 |
% \begin{macrocode} |
| 19882 |
\@@_msg_new:nn { One~letter~allowed } |
| 19883 |
{ |
| 19884 |
Bad~name.\\ |
| 19885 |
The~value~of~key~' \l_keys_key_str '~must~be~of~length~1~and~ |
| 19886 |
you~have~used~' \l_keys_value_tl '.~Your~key~will~be~ignored. |
| 19887 |
} |
| 19888 |
% \end{macrocode} |
| 19889 |
% |
| 19890 |
% \begin{macrocode} |
| 19891 |
\@@_msg_new:nn { TabularNote~in~CodeAfter } |
| 19892 |
{ |
| 19893 |
Environment~\{TabularNote\}~forbidden.\\ |
| 19894 |
You~must~use~\{TabularNote\}~at~the~end~of~your~\{NiceTabular\}~ |
| 19895 |
but~*before*~the~ \token_to_str:N \CodeAfter .~Your~environment~ |
| 19896 |
\{TabularNote\}~will~be~ignored. |
| 19897 |
} |
| 19898 |
% \end{macrocode} |
| 19899 |
% |
| 19900 |
% \begin{macrocode} |
| 19901 |
\@@_msg_new:nn { varwidth~not~loaded } |
| 19902 |
{ |
| 19903 |
varwidth~not~loaded.\\ |
| 19904 |
You~can't~use~the~column~type~'V'~because~'varwidth'~is~not~ |
| 19905 |
loaded.~You~should~load~'varwidth',~before~or~after~'nicematrix'.~ |
| 19906 |
Your~column~will~behave~like~'p'. |
| 19907 |
} |
| 19908 |
% \end{macrocode} |
| 19909 |
% |
| 19910 |
% \begin{macrocode} |
| 19911 |
\@@_msg_new:nn { varwidth~not~loaded~in~X } |
| 19912 |
{ |
| 19913 |
varwidth~not~loaded.\\ |
| 19914 |
You~can't~use~the~key~'V'~in~your~column~'X'~ |
| 19915 |
because~'varwidth'~is~not~loaded.~You~should~load~'varwidth',~ |
| 19916 |
before~or~after~'nicematrix'.~ Your~key~will~be~ignored. |
| 19917 |
} |
| 19918 |
% \end{macrocode} |
| 19919 |
% |
| 19920 |
% |
| 19921 |
% \begin{macrocode} |
| 19922 |
\@@_msg_new:nnn { Unknown~key~for~a~rule } |
| 19923 |
{ |
| 19924 |
Unknown~key.\\ |
| 19925 |
Your~key~' \l_keys_key_str '~is~unknown~for~a~rule.\\ |
| 19926 |
\c_@@_available_keys_str |
| 19927 |
} |
| 19928 |
{ |
| 19929 |
The~available~keys~are:~color,~multiplicity,~sep-color,~tikz~ |
| 19930 |
and~total-width~(the~latter~is~meaningful~only~in~cunjonction~with~'tikz'). |
| 19931 |
} |
| 19932 |
% \end{macrocode} |
| 19933 |
% If fact, there is also the key |dotted| but it won't be very useful |
| 19934 |
% since we provide |\hdottedline|, |\cdottedline| and the letter~|:|. |
| 19935 |
% |
| 19936 |
% \medskip |
| 19937 |
% \begin{macrocode} |
| 19938 |
\@@_msg_new:nnn { Unknown~key~for~Block } |
| 19939 |
{ |
| 19940 |
Unknown~key. \\ |
| 19941 |
The~key~' \l_keys_key_str '~is~unknown~for~the~command~ |
| 19942 |
\token_to_str:N \Block .~Your~key~will~be~ignored. \\ |
| 19943 |
\c_@@_available_keys_str |
| 19944 |
} |
| 19945 |
{ |
| 19946 |
The~available~keys~are~(in~alphabetic~order):~&-in-blocks,~ampersand-in-blocks,~ |
| 19947 |
b,~B,~borders,~c,~draw,~fill,~hlines,~hvlines,~l,~name,~ |
| 19948 |
opacity,~rounded-corners,~r,~respect-arraystretch,~rules/width,~t,~T,~tikz,~ |
| 19949 |
transparent~and~vlines. |
| 19950 |
} |
| 19951 |
% \end{macrocode} |
| 19952 |
% |
| 19953 |
% |
| 19954 |
% \begin{macrocode} |
| 19955 |
\@@_msg_new:nnn { Unknown~key~for~Brace } |
| 19956 |
{ |
| 19957 |
Unknown~key.\\ |
| 19958 |
The~key~' \l_keys_key_str '~is~unknown~for~the~commands~ |
| 19959 |
\token_to_str:N \UnderBrace \ and~ \token_to_str:N \OverBrace .~ |
| 19960 |
Your~key~will~be~ignored. \\ |
| 19961 |
\c_@@_available_keys_str |
| 19962 |
} |
| 19963 |
{ |
| 19964 |
The~available~keys~are~(in~alphabetic~order):~color,~left-shorten,~ |
| 19965 |
right-shorten,~shorten~(which~fixes~both~left-shorten~and~ |
| 19966 |
right-shorten)~and~yshift. |
| 19967 |
} |
| 19968 |
% \end{macrocode} |
| 19969 |
% |
| 19970 |
% \begin{macrocode} |
| 19971 |
\@@_msg_new:nnn { Unknown~key~for~CodeAfter } |
| 19972 |
{ |
| 19973 |
Unknown~key.\\ |
| 19974 |
The~key~' \l_keys_key_str '~is~unknown.~It~will~be~ignored. \\ |
| 19975 |
\c_@@_available_keys_str |
| 19976 |
} |
| 19977 |
{ |
| 19978 |
The~available~keys~are~(in~alphabetic~order):~ |
| 19979 |
delimiters/color,~ |
| 19980 |
rules~(with~the~subkeys~'color'~and~'width'),~ |
| 19981 |
sub-matrix~(several~subkeys)~ |
| 19982 |
and~xdots~(several~subkeys).~ |
| 19983 |
The~latter~is~for~the~command~ \token_to_str:N \line . |
| 19984 |
} |
| 19985 |
% \end{macrocode} |
| 19986 |
% |
| 19987 |
% \begin{macrocode} |
| 19988 |
\@@_msg_new:nnn { Unknown~key~for~CodeBefore } |
| 19989 |
{ |
| 19990 |
Unknown~key.\\ |
| 19991 |
The~key~' \l_keys_key_str '~is~unknown.~Your~key~will~be~ignored. \\ |
| 19992 |
\c_@@_available_keys_str |
| 19993 |
} |
| 19994 |
{ |
| 19995 |
The~available~keys~are~(in~alphabetic~order):~ |
| 19996 |
create-cell-nodes,~ |
| 19997 |
delimiters/color~and~ |
| 19998 |
sub-matrix~(several~subkeys). |
| 19999 |
} |
| 20000 |
% \end{macrocode} |
| 20001 |
% |
| 20002 |
% \begin{macrocode} |
| 20003 |
\@@_msg_new:nnn { Unknown~key~for~SubMatrix } |
| 20004 |
{ |
| 20005 |
Unknown~key.\\ |
| 20006 |
The~key~' \l_keys_key_str '~is~unknown.~Your~key~will~be~ignored. \\ |
| 20007 |
\c_@@_available_keys_str |
| 20008 |
} |
| 20009 |
{ |
| 20010 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20011 |
'delimiters/color',~ |
| 20012 |
'extra-height',~ |
| 20013 |
'hlines',~ |
| 20014 |
'hvlines',~ |
| 20015 |
'left-xshift',~ |
| 20016 |
'name',~ |
| 20017 |
'right-xshift',~ |
| 20018 |
'rules'~(with~the~subkeys~'color'~and~'width'),~ |
| 20019 |
'slim',~ |
| 20020 |
'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~and~'right-xshift'). |
| 20021 |
} |
| 20022 |
% \end{macrocode} |
| 20023 |
% |
| 20024 |
% \begin{macrocode} |
| 20025 |
\@@_msg_new:nnn { Unknown~key~for~notes } |
| 20026 |
{ |
| 20027 |
Unknown~key.\\ |
| 20028 |
The~key~' \l_keys_key_str '~is~unknown.~ Your~key~will~be~ignored. \\ |
| 20029 |
\c_@@_available_keys_str |
| 20030 |
} |
| 20031 |
{ |
| 20032 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20033 |
bottomrule,~ |
| 20034 |
code-after,~ |
| 20035 |
code-before(+),~ |
| 20036 |
detect-duplicates,~ |
| 20037 |
enumitem-keys,~ |
| 20038 |
enumitem-keys-para,~ |
| 20039 |
para,~ |
| 20040 |
label-in-list,~ |
| 20041 |
label-in-tabular~and~ |
| 20042 |
style. |
| 20043 |
} |
| 20044 |
% \end{macrocode} |
| 20045 |
% |
| 20046 |
% \begin{macrocode} |
| 20047 |
\@@_msg_new:nnn { Unknown~key~for~RowStyle } |
| 20048 |
{ |
| 20049 |
Unknown~key.\\ |
| 20050 |
The~key~' \l_keys_key_str '~is~unknown~for~the~command~ |
| 20051 |
\token_to_str:N \RowStyle .~Your~key~will~be~ignored. \\ |
| 20052 |
\c_@@_available_keys_str |
| 20053 |
} |
| 20054 |
{ |
| 20055 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20056 |
bold,~ |
| 20057 |
cell-space-top-limit(+),~ |
| 20058 |
cell-space-bottom-limit(+),~ |
| 20059 |
cell-space-limits(+),~ |
| 20060 |
color,~ |
| 20061 |
fill~(alias:~rowcolor),~ |
| 20062 |
nb-rows,~ |
| 20063 |
opacity~and~ |
| 20064 |
rounded-corners. |
| 20065 |
} |
| 20066 |
% \end{macrocode} |
| 20067 |
% |
| 20068 |
% \begin{macrocode} |
| 20069 |
\@@_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } |
| 20070 |
{ |
| 20071 |
Unknown~key.\\ |
| 20072 |
The~key~' \l_keys_key_str '~is~unknown~for~the~command~ |
| 20073 |
\token_to_str:N \NiceMatrixOptions .~Your~key~will~be~ignored. \\ |
| 20074 |
\c_@@_available_keys_str |
| 20075 |
} |
| 20076 |
{ |
| 20077 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20078 |
&-in-blocks,~ |
| 20079 |
allow-duplicate-names,~ |
| 20080 |
ampersand-in-blocks,~ |
| 20081 |
caption-above,~ |
| 20082 |
cell-space-bottom-limit(+),~ |
| 20083 |
cell-space-limits(+),~ |
| 20084 |
cell-space-top-limit(+),~ |
| 20085 |
code-for-first-col(+),~ |
| 20086 |
code-for-first-row(+),~ |
| 20087 |
code-for-last-col(+),~ |
| 20088 |
code-for-last-row(+),~ |
| 20089 |
corners,~ |
| 20090 |
custom-key,~ |
| 20091 |
create-extra-nodes,~ |
| 20092 |
create-medium-nodes,~ |
| 20093 |
create-large-nodes,~ |
| 20094 |
custom-line,~ |
| 20095 |
delimiters~(several~subkeys),~ |
| 20096 |
end-of-row,~ |
| 20097 |
first-col,~ |
| 20098 |
first-row,~ |
| 20099 |
h(v)lines,~ |
| 20100 |
h(v)lines-except-borders,~ |
| 20101 |
last-col,~ |
| 20102 |
last-row,~ |
| 20103 |
left-margin,~ |
| 20104 |
light-syntax,~ |
| 20105 |
light-syntax-expanded,~ |
| 20106 |
matrix/columns-type,~ |
| 20107 |
no-cell-nodes,~ |
| 20108 |
notes~(several~subkeys),~ |
| 20109 |
nullify-dots,~ |
| 20110 |
pgf-node-code,~ |
| 20111 |
renew-dots,~ |
| 20112 |
renew-matrix,~ |
| 20113 |
respect-arraystretch,~ |
| 20114 |
rounded-corners,~ |
| 20115 |
right-margin,~ |
| 20116 |
rules~(with~the~subkeys~'color'~and~'width'),~ |
| 20117 |
small,~ |
| 20118 |
sub-matrix~(several~subkeys),~ |
| 20119 |
vlines,~ |
| 20120 |
xdots~(several~subkeys). |
| 20121 |
} |
| 20122 |
% \end{macrocode} |
| 20123 |
% |
| 20124 |
% For `|{NiceArray}|`, the set of keys is the same as for |{NiceMatrix}| |
| 20125 |
% excepted that there is no |l| and |r|. |
| 20126 |
% \begin{macrocode} |
| 20127 |
\@@_msg_new:nnn { Unknown~key~for~NiceArray } |
| 20128 |
{ |
| 20129 |
Unknown~key.\\ |
| 20130 |
The~key~' \l_keys_key_str '~is~unknown~for~the~environment~ |
| 20131 |
\{NiceArray\}.~Your~key~will~be~ignored. \\ |
| 20132 |
\c_@@_available_keys_str |
| 20133 |
} |
| 20134 |
{ |
| 20135 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20136 |
&-in-blocks,~ |
| 20137 |
ampersand-in-blocks,~ |
| 20138 |
b,~ |
| 20139 |
baseline,~ |
| 20140 |
c,~ |
| 20141 |
cell-space-bottom-limit,~ |
| 20142 |
cell-space-limits,~ |
| 20143 |
cell-space-top-limit,~ |
| 20144 |
code-after,~ |
| 20145 |
code-for-first-col(+),~ |
| 20146 |
code-for-first-row(+),~ |
| 20147 |
code-for-last-col(+),~ |
| 20148 |
code-for-last-row(+),~ |
| 20149 |
columns-width,~ |
| 20150 |
corners,~ |
| 20151 |
create-blocks-in-col,~ |
| 20152 |
create-extra-nodes,~ |
| 20153 |
create-medium-nodes,~ |
| 20154 |
create-large-nodes,~ |
| 20155 |
draw-trees-in-col,~ |
| 20156 |
extra-left-margin,~ |
| 20157 |
extra-right-margin,~ |
| 20158 |
first-col,~ |
| 20159 |
first-row,~ |
| 20160 |
h(v)lines,~ |
| 20161 |
h(v)lines-except-borders,~ |
| 20162 |
last-col,~ |
| 20163 |
last-row,~ |
| 20164 |
left-margin,~ |
| 20165 |
light-syntax,~ |
| 20166 |
light-syntax-expanded,~ |
| 20167 |
name,~ |
| 20168 |
no-cell-nodes,~ |
| 20169 |
nullify-dots,~ |
| 20170 |
pgf-node-code,~ |
| 20171 |
renew-dots,~ |
| 20172 |
respect-arraystretch,~ |
| 20173 |
right-margin,~ |
| 20174 |
rounded-corners,~ |
| 20175 |
rules~(with~the~subkeys~'color'~and~'width'),~ |
| 20176 |
small,~ |
| 20177 |
t,~ |
| 20178 |
vlines,~ |
| 20179 |
xdots/color,~ |
| 20180 |
xdots/shorten-start(+),~ |
| 20181 |
xdots/shorten-end(+),~ |
| 20182 |
xdots/shorten(+)~and~ |
| 20183 |
xdots/line-style. |
| 20184 |
} |
| 20185 |
% \end{macrocode} |
| 20186 |
% |
| 20187 |
% \medskip |
| 20188 |
% This error message is used for the set of keys |nicematrix/NiceMatrix| and |
| 20189 |
% |nicematrix/pNiceArray| (but not by |nicematrix/NiceArray| because, for this |
| 20190 |
% set of keys, there is no |l| and |r|). |
| 20191 |
% \begin{macrocode} |
| 20192 |
\@@_msg_new:nnn { Unknown~key~for~NiceMatrix } |
| 20193 |
{ |
| 20194 |
Unknown~key.\\ |
| 20195 |
The~key~' \l_keys_key_str '~is~unknown~for~the~ |
| 20196 |
\@@_full_name_env: .~Your~key~will~be~ignored. \\ |
| 20197 |
\c_@@_available_keys_str |
| 20198 |
} |
| 20199 |
{ |
| 20200 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20201 |
&-in-blocks,~ |
| 20202 |
ampersand-in-blocks,~ |
| 20203 |
b,~ |
| 20204 |
baseline,~ |
| 20205 |
c,~ |
| 20206 |
cell-space-bottom-limit,~ |
| 20207 |
cell-space-limits,~ |
| 20208 |
cell-space-top-limit,~ |
| 20209 |
code-after,~ |
| 20210 |
code-for-first-col(+),~ |
| 20211 |
code-for-first-row(+),~ |
| 20212 |
code-for-last-col(+),~ |
| 20213 |
code-for-last-row(+),~ |
| 20214 |
columns-type,~ |
| 20215 |
columns-width,~ |
| 20216 |
corners,~ |
| 20217 |
create-blocks-in-col,~ |
| 20218 |
create-extra-nodes,~ |
| 20219 |
create-medium-nodes,~ |
| 20220 |
create-large-nodes,~ |
| 20221 |
draw-trees-in-col,~ |
| 20222 |
extra-left-margin,~ |
| 20223 |
extra-right-margin,~ |
| 20224 |
first-col,~ |
| 20225 |
first-row,~ |
| 20226 |
h(v)lines,~ |
| 20227 |
h(v)lines-except-borders,~ |
| 20228 |
l,~ |
| 20229 |
last-col,~ |
| 20230 |
last-row,~ |
| 20231 |
left-margin,~ |
| 20232 |
light-syntax,~ |
| 20233 |
light-syntax-expanded,~ |
| 20234 |
name,~ |
| 20235 |
no-cell-nodes,~ |
| 20236 |
nullify-dots,~ |
| 20237 |
pgf-node-code,~ |
| 20238 |
r,~ |
| 20239 |
renew-dots,~ |
| 20240 |
respect-arraystretch,~ |
| 20241 |
right-margin,~ |
| 20242 |
rounded-corners,~ |
| 20243 |
rules~(with~the~subkeys~'color'~and~'width'),~ |
| 20244 |
small,~ |
| 20245 |
t,~ |
| 20246 |
vlines,~ |
| 20247 |
xdots/color,~ |
| 20248 |
xdots/shorten-start(+),~ |
| 20249 |
xdots/shorten-end(+),~ |
| 20250 |
xdots/shorten(+)~and~ |
| 20251 |
xdots/line-style. |
| 20252 |
} |
| 20253 |
% \end{macrocode} |
| 20254 |
% |
| 20255 |
% \begin{macrocode} |
| 20256 |
\@@_msg_new:nnn { Unknown~key~for~NiceTabular } |
| 20257 |
{ |
| 20258 |
Unknown~key.\\ |
| 20259 |
The~key~' \l_keys_key_str '~is~unknown~for~the~environment~ |
| 20260 |
\{NiceTabular\}.~Your~key~will~be~ignored. \\ |
| 20261 |
\c_@@_available_keys_str |
| 20262 |
} |
| 20263 |
{ |
| 20264 |
The~available~keys~are~(in~alphabetic~order):~ |
| 20265 |
&-in-blocks,~ |
| 20266 |
ampersand-in-blocks,~ |
| 20267 |
b,~ |
| 20268 |
baseline,~ |
| 20269 |
c,~ |
| 20270 |
caption,~ |
| 20271 |
cell-space-bottom-limit,~ |
| 20272 |
cell-space-limits,~ |
| 20273 |
cell-space-top-limit,~ |
| 20274 |
code-after,~ |
| 20275 |
code-for-first-col(+),~ |
| 20276 |
code-for-first-row(+),~ |
| 20277 |
code-for-last-col(+),~ |
| 20278 |
code-for-last-row(+),~ |
| 20279 |
columns-width,~ |
| 20280 |
corners,~ |
| 20281 |
custom-line,~ |
| 20282 |
create-blocks-in-col,~ |
| 20283 |
create-extra-nodes,~ |
| 20284 |
create-medium-nodes,~ |
| 20285 |
create-large-nodes,~ |
| 20286 |
draw-trees-in-col,~ |
| 20287 |
extra-left-margin,~ |
| 20288 |
extra-right-margin,~ |
| 20289 |
first-col,~ |
| 20290 |
first-row,~ |
| 20291 |
h(v)lines,~ |
| 20292 |
h(v)lines-except-borders,~ |
| 20293 |
label,~ |
| 20294 |
last-col,~ |
| 20295 |
last-row,~ |
| 20296 |
left-margin,~ |
| 20297 |
light-syntax,~ |
| 20298 |
light-syntax-expanded,~ |
| 20299 |
name,~ |
| 20300 |
no-cell-nodes,~ |
| 20301 |
notes~(several~subkeys),~ |
| 20302 |
nullify-dots,~ |
| 20303 |
pgf-node-code,~ |
| 20304 |
renew-dots,~ |
| 20305 |
respect-arraystretch,~ |
| 20306 |
right-margin,~ |
| 20307 |
rounded-corners,~ |
| 20308 |
rules~(with~the~subkeys~'color'~and~'width'),~ |
| 20309 |
short-caption,~ |
| 20310 |
t,~ |
| 20311 |
tabularnote,~ |
| 20312 |
vlines,~ |
| 20313 |
xdots/color,~ |
| 20314 |
xdots/shorten-start(+),~ |
| 20315 |
xdots/shorten-end(+),~ |
| 20316 |
xdots/shorten(+)~and~ |
| 20317 |
xdots/line-style. |
| 20318 |
} |
| 20319 |
% \end{macrocode} |
| 20320 |
% |
| 20321 |
% |
| 20322 |
% \begin{macrocode} |
| 20323 |
\@@_msg_new:nnn { Duplicate~name } |
| 20324 |
{ |
| 20325 |
Duplicate~name.\\ |
| 20326 |
The~name~' \l_keys_value_tl '~is~already~used~and~you~shouldn't~use~ |
| 20327 |
the~same~environment~name~twice.~You~can~go~on,~but,~ |
| 20328 |
maybe,~you~will~have~incorrect~results~especially~ |
| 20329 |
if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~ |
| 20330 |
message~again,~use~the~key~'allow-duplicate-names'~in~ |
| 20331 |
' \token_to_str:N \NiceMatrixOptions '.\\ |
| 20332 |
\bool_if:NF \g_@@_messages_for_Overleaf_bool |
| 20333 |
{ For~a~list~of~the~names~already~used,~type~H~<return>. } |
| 20334 |
} |
| 20335 |
{ |
| 20336 |
The~names~already~defined~in~this~document~are:~ |
| 20337 |
\clist_use:Nnnn \g_@@_names_clist { ~and~ } { ,~ } { ~and~ } . |
| 20338 |
} |
| 20339 |
% \end{macrocode} |
| 20340 |
% |
| 20341 |
% \begin{macrocode} |
| 20342 |
\@@_msg_new:nn { caption-above~in~env } |
| 20343 |
{ |
| 20344 |
The~key~'caption-above'~must~be~used~in~\token_to_str:N \NiceMatrixOptions.~ |
| 20345 |
Your~key~will~be~ignored. |
| 20346 |
} |
| 20347 |
% \end{macrocode} |
| 20348 |
% |
| 20349 |
% \begin{macrocode} |
| 20350 |
\@@_msg_new:nn { show-cell-names } |
| 20351 |
{ |
| 20352 |
There~is~no~key~'show-cell-names'~in~nicematrix.\\ |
| 20353 |
You~should~use~the~command~\token_to_str:N \ShowCellNames\ |
| 20354 |
in~the~\token_to_str:N \CodeBefore\ or~the~\token_to_str:N |
| 20355 |
\CodeAfter.~Your~key~will~be~ignored. |
| 20356 |
} |
| 20357 |
% \end{macrocode} |
| 20358 |
% |
| 20359 |
% \begin{macrocode} |
| 20360 |
\@@_msg_new:nn { Option~auto~for~columns-width } |
| 20361 |
{ |
| 20362 |
Erroneous~use.\\ |
| 20363 |
You~can't~give~the~value~'auto'~to~the~key~'columns-width'~here.~ |
| 20364 |
Your~key~will~be~ignored. |
| 20365 |
} |
| 20366 |
% \end{macrocode} |
| 20367 |
% |
| 20368 |
% \begin{macrocode} |
| 20369 |
\@@_msg_new:nn { NiceTabularX~without~X } |
| 20370 |
{ |
| 20371 |
NiceTabularX~without~X.\\ |
| 20372 |
You~should~not~use~\{NiceTabularX\}~without~X~columns.~However,~you~can~go~on. |
| 20373 |
} |
| 20374 |
% \end{macrocode} |
| 20375 |
% |
| 20376 |
% \begin{macrocode} |
| 20377 |
\@@_msg_new:nn { Preamble~forgotten } |
| 20378 |
{ |
| 20379 |
Preamble~forgotten.\\ |
| 20380 |
You~have~probably~forgotten~the~preamble~of~your~ |
| 20381 |
\@@_full_name_env: . |
| 20382 |
} |
| 20383 |
% \end{macrocode} |
| 20384 |
% |
| 20385 |
% \begin{macrocode} |
| 20386 |
\@@_msg_new:nn { Invalid~col~number } |
| 20387 |
{ |
| 20388 |
Invalid~column~number.\\ |
| 20389 |
A~color~instruction~in~the~ \token_to_str:N \CodeBefore \ |
| 20390 |
specifies~a~column~which~is~outside~the~array.~It~will~be~ignored.~ |
| 20391 |
Maybe~this~is~a~spurious~error~due~to~an~incorrect~'aux'~file. |
| 20392 |
} |
| 20393 |
% \end{macrocode} |
| 20394 |
% |
| 20395 |
% \begin{macrocode} |
| 20396 |
\@@_msg_new:nn { Invalid~row~number } |
| 20397 |
{ |
| 20398 |
Invalid~row~number.\\ |
| 20399 |
A~color~instruction~in~the~ \token_to_str:N \CodeBefore \ |
| 20400 |
specifies~a~row~which~is~outside~the~array.~It~will~be~ignored.~ |
| 20401 |
Maybe~this~is~a~spurious~error~due~to~an~incorrect~'aux'~file. |
| 20402 |
} |
| 20403 |
% \end{macrocode} |
| 20404 |
% |
| 20405 |
% |
| 20406 |
% |
| 20407 |
% \begin{macrocode} |
| 20408 |
\@@_define_com:NNN p ( ) |
| 20409 |
\@@_define_com:NNN b [ ] |
| 20410 |
\@@_define_com:NNN v | | |
| 20411 |
\@@_define_com:NNN V \| \| |
| 20412 |
\@@_define_com:NNN B \{ \} |
| 20413 |
% \end{macrocode} |
| 20414 |
% |
| 20415 |
% \newpage |
| 20416 |
% \tableofcontents |
| 20417 |
% |
| 20418 |
% \endinput |
| 20419 |
% Local Variables: |
| 20420 |
% fill-column: 80 |
| 20421 |
% End: |
| 20422 |
|