Debian Codegraph @

texmf-dist/source/latex/tensorstyles/tensorstyles.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2023-20** by Romain NOEL <[email protected]>
4 % -----------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the conditions of
7 % the LaTeX Project Public License, either version 1.3c of this license
8 % or (at your option) any later version. The latest version of this
9 % license is in:
10 %
11 % http://www.latex-project.org/lppl.txt
12 %
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2006/05/20 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %<*driver>
20 \ProvidesFile{tensorstyles.dtx}
21 %</driver>
22 %<*internal>
23 \input expl3-generic \relax
24 %</internal>
25 %<class>\NeedsTeXFormat{LaTeX3e}
26 %<package>\ProvidesExplPackage{tensorstyles}{2026-04-28}{1.0.1.4}{This package provides a generic customable display of tensors.}
27 %<author>Romain NOEL</author>
28 %<maintainer>Romain NOEL</maintainer>
29 %<url>https://gitlab.com/RomainNOEL/tensorstyles</url>
30 %<desc>
31 % This package let you display your tensors according to their order in a generic way. This let you choose and change options of display according to the context.
32 % </desc>
33 %
34 %<*driver>
35 \documentclass{l3doc}
36 \usepackage[T1]{fontenc}
37 \usepackage{pdfpages}
38 \usepackage{standalone}
39 \usepackage{tensorstyles}
40 % \usepackage{readprov}
41 % \ReadPackageInfos{tensorstyles}
42 \edef\tensorstylesVersion{v1.0.1.4} %{\fileversion}
43 \edef\tensorstylesDate{2026-04-28} %{\filedate}
44
45 \usepackage{parskip}
46 \usepackage{setspace}
47 \usepackage{xspace}
48 \onehalfspacing
49
50 \usepackage{xcolor}
51 \definecolor{tPrim}{HTML}{00707F} % Green-Blue
52 \definecolor{tSec}{HTML}{5FA4B0} % Green-Blue light
53 \definecolor{tAccent}{HTML}{F07F3C} % Orange
54 \definecolor{tGrey}{HTML}{E6E6E1} % Grey-Beige
55
56 % \usepackage{fancyvrb}
57 \usepackage{listings}
58 \lstset{
59 language=[LaTeX]{TeX},
60 basicstyle=\ttfamily,
61 keywordstyle=\color{tPrim}\bfseries,
62 commentstyle=\color{tSec},
63 stringstyle=\color{tSec},
64 backgroundcolor=\color{white},
65 numbers=none,
66 numberstyle=\tiny\ttfamily,
67 stepnumber=2,
68 showspaces=false,
69 showstringspaces=false,
70 showtabs=false,
71 frame=none,
72 framerule=1pt,
73 tabsize=2,
74 rulesep=5em,
75 captionpos=b,
76 breaklines=true,
77 breakatwhitespace=false,
78 framexleftmargin=0em,
79 framexrightmargin=0em,
80 xleftmargin=0em,
81 xrightmargin=0em,
82 aboveskip=1em,
83 belowskip=1em,
84 morekeywords={plain,tensorsset},
85 }
86 \lstMakeShortInline|
87
88 \usepackage{hyperref}
89 \setlength{\fboxsep}{0pt}%
90 \usepackage{subcaption} % For subfigures
91 \usepackage{cleveref} % for references
92
93 \providecommand{\defopt}[1]{\underline{#1}}%{default: #1}%
94 \NewDocumentEnvironment{DescribetensorstylesOption}{ o m m m }{
95 % At beginning of the environment
96 \DescribeOption{#2} % from l3doc
97 \IfNoValueTF{#1}{
98 % true => left empty intentionally
99 }{
100 %false
101 \DescribeOption{
102 % add extra info like added or updated dates to mimic 'function' env.
103 \rule[2.5ex]{\linewidth}{0.3pt}
104 \\[-3.5ex]
105 {\scriptsize #1 \hfill\ }
106 }
107 }
108 \begin{minipage}[t]{\textwidth}
109 \textit{\textbf{\textcolor{tSec}{#3}}}\dotfill\,\defopt{#4}\par
110 \begingroup
111 \vspace{0.5em}
112 }{
113 % At environment's end
114 \par
115 \endgroup
116 \end{minipage}
117 }
118
119
120 %% =====================================================================
121 \title{\textsc{ tensorstyles }\\
122 This package provides a generic customable display of tensors.
123 }
124 \author{Romain NOEL \\ \url{[email protected]}}
125 \date{\tensorstylesVersion~---~\tensorstylesDate}
126
127 \providecommand{\pkgName}{\textbf{\textsc{tensorstyles}}\xspace}
128
129 %% =====================================================================
130
131
132 %% l3doc commands
133 \EnableCrossrefs
134 \CodelineIndex
135 \RecordChanges
136 \begin{document}
137 \input{tensorstyles-doc.tex}
138 \clearpage
139 %\section{A simple example}
140 % \includepdf[pages=-,
141 % pagecommand=\section{A simple example},
142 % width=0.7\textwidth]
143 % {tensorstyles-exampleSimple.pdf}
144 \section{Commands description for users}
145 \EnableDocumentation
146 \DisableImplementation
147 \DocInput{\jobname.dtx}
148 \newpage
149 \section{Package implementation for developers}
150 \EnableImplementation
151 \DisableDocumentation
152 \GetFileInfo{\jobname.sty}
153 \DocInput{\jobname.dtx}
154 \PrintChanges
155 \end{document}
156 %</driver>
157 %
158 %<*devImpl>
159 \documentclass{l3doc}
160 \usepackage[T1]{fontenc}
161 \usepackage{pdfpages}
162 \usepackage{standalone}
163 \usepackage{tensorstyles}
164 \providecommand{\defopt}[1]{\underline{#1}}
165 % l3doc commands
166 \EnableCrossrefs
167 \CodelineIndex
168 \RecordChanges
169 \begin{document}
170 \section{Commands description for users}
171 \EnableImplementation
172 \DisableDocumentation
173 \DocInput{tensorstyles.dtx}
174 \end{document}
175 %</devImpl>
176 %
177 %
178 %<*userCmd>
179 \documentclass{l3doc}
180 \usepackage[T1]{fontenc}
181 \usepackage{pdfpages}
182 \usepackage{standalone}
183 %\usepackage{tensorstyles}
184 \providecommand{\defopt}[1]{\underline{#1}}
185 % l3doc commands
186 \EnableCrossrefs
187 \CodelineIndex
188 \RecordChanges
189 \begin{document}
190 \section{Package implementation for developers}
191 \EnableDocumentation
192 \DisableImplementation
193 \DocInput{tensorstyles.dtx}
194 \end{document}
195 %</userCmd>
196 %
197 % \fi
198 %
199 %
200 % \begin{implementation}
201 % \begin{macrocode}
202 %<*package>
203 %\ProvidesExplPackage{tensorstyles}{2026-04-28}{1.0.1.4}{This package provides a generic customable display of tensors.}
204 \RequirePackage{expl3}
205 % \RequirePackage{xparse,l3keys2e}% depreciated now.
206 \RequirePackage{amsmath}% \overrightarrow
207 \RequirePackage{amssymb}% \curvearrowright
208 % \RequirePackage{bm}% recommended for bold math
209 \RequirePackage{mathtools}% for \mathmakebox
210 % \end{macrocode}
211 % \end{implementation}
212 %
213
214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215 %%%%%%%%%%%% PACKAGE %%%%%%%%%%%%%
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217
218 % \begin{implementation}
219 % \begin{variable}{\c__tensorstyles_digits_tl}
220 % Constant variables containing the digits.
221 % \changes{v0.1.1.2}{2025-02-17}{original version}
222 % \begin{macrocode}
223 \tl_const:Nn \c__tensorstyles_digits_tl {123456789-0}
224 % \end{macrocode}
225 % \end{variable}
226 % \end{implementation}
227
228 % \begin{documentation}
229 % \begin{macro}{\usepackage[options]{tensorstyles}}
230 % \begin{syntax}
231 % \cs{usepackage{}}\oarg{option1=value1, ...}\marg{tensorstyles}
232 % \textrm{where the options are (default marked as} \defopt{default}\textrm{):}
233 % \meta{footer template} = \oarg{\defopt{tensorstyles} \textbar ... }
234 % \end{syntax}
235 % Description of |usepackage{tensorstyles}| which loads the package.
236 % \end{macro}
237 % \end{documentation}
238 %%%%
239 % \begin{implementation}
240 % \begin{macro}{\usepackage[options]{tensorstyles} }
241 % \begin{arguments}
242 % \item |no package option| are present for now.
243 % \end{arguments}
244 % Description
245 % \changes{v0.1.1.2}{2025-02-17}{original version}
246 % \UnitTested
247 % \TestFiles{tensorstyles-test-003}
248 % \begin{macrocode}
249 % Define keys/options for the package.
250 \keys_define:nn { tensorstyles / pkg }
251 {
252 % italic .choice:,
253 % italic .usage:n = { load },
254 % italic .default:n = { true },
255 % italic / true .code:n =
256 % {
257 % \bool_set_true:N \l__tensorstyles_pkg_italic_bool
258 % \bool_set_false:N \l__tensorstyles_pkg_upright_bool
259 % },
260 % italic / false .code:n =
261 % {
262 % \bool_set_false:N \l__tensorstyles_pkg_italic_bool
263 % \bool_set_true:N \l__tensorstyles_pkg_upright_bool
264 % },
265 % italic / unknown .code:n = { \msg_error:nnx { tensorstyles } { boolean-values-only } \l_keys_key_str },
266 % %
267 % upright .choice:,
268 % upright .usage:n = { load },
269 % upright .default:n = { true },
270 % upright / true .code:n =
271 % {
272 % \bool_set_true:N \l__tensorstyles_pkg_upright_bool
273 % \bool_set_false:N \l__tensorstyles_pkg_italic_bool
274 % },
275 % upright / false .code:n =
276 % {
277 % \bool_set_false:N \l__tensorstyles_pkg_upright_bool
278 % \bool_set_true:N \l__tensorstyles_pkg_italic_bool
279 % },
280 % upright / unknown .code:n = { \msg_error:nnx { tensorstyles } { boolean-values-only } \l_keys_key_str },
281 % upright .initial:n = true,
282 }
283 % process the options.
284 \ProcessKeyOptions[ tensorstyles / pkg ]
285 % \end{macrocode}
286 % \end{macro}
287 % \end{implementation}
288
289
290 %%%%%% Key-val: tensorstyles %%%%%%
291
292 % \begin{implementation}
293 % \begin{variable}{\l__tensorstyles_all_all_user_keys_prop, \c__tensorstyles_all_pkg_keys_prop}
294 % Property list containing the default value for options that are share by all command groups; and a list that will receive the values given by users for these options.
295 % \changes{v0.1.1.2}{2025-02-17}{original version}
296 % \TestFiles{tensorstyles-test-003}
297 % \begin{macrocode}
298 \prop_const_from_keyval:Nn \c__tensorstyles_all_pkg_keys_prop {scale-auto = leftright}
299 \prop_new:N \l__tensorstyles_all_all_user_keys_prop
300 % \end{macrocode}
301 % \end{variable}
302 % \end{implementation}
303
304 % \begin{documentation}
305 % \begin{macro}{\tensorsset{all}[options]}
306 % \begin{syntax}
307 % \cs{nameMacro}\oarg{option1=value1, ...}\marg{tensor-cmd}
308 % \textrm{where the options are (default marked as} \defopt{default}\textrm{):}
309 % \meta{scale-auto} = \oarg{\defopt{leftright} \textbar auto }
310 % \end{syntax}
311 % The option |scale-auto| that can be set for all command groups, can take |leftright| or |mleftmright| values.
312 % This option is controlling the delimiters to use in auto mode (|\left\right| or |\mleft| |\mright| from |mleftright| package).
313 % \end{macro}
314 % \end{documentation}
315 %%%%
316 % \begin{implementation}
317 % \begin{macro}{\tensorsset{all}[options]}
318 % \begin{arguments}
319 % \item |width| Name of the option to add, this name should also correspond to the name of the environment followed by the suffix 'env'.
320 % \end{arguments}
321 % Option available for all command groups controlling the delimiters in automatic scale mode.
322 % \changes{v0.1.1.2}{2025-02-17}{original version}
323 % \UnitTested
324 % \TestFiles{tensorstyles-test-005}
325 % \begin{macrocode}
326 % Define the options for all group commands (package included).
327 \keys_define:nn { tensorstyles / all / all } {
328 scale-auto .choice:,
329 scale-auto / leftright .code:n = {
330 \cs_set_eq:NN \__tensorstyles_auto_left:n \left
331 \cs_set_eq:NN \__tensorstyles_auto_right:n \right
332 },
333 scale-auto / mleftmright .code:n = {
334 \cs_set_nopar:Npn \__tensorstyles_auto_left:n { \mleft }
335 \cs_set_nopar:Npn \__tensorstyles_auto_right:n { \mright }
336 }
337 }
338 % \end{macrocode}
339 % \end{macro}
340 % \end{implementation}
341
342 % \begin{implementation}
343 % \begin{variable}{\l__tensorstyles_new_var_seq}
344 % Local sequence storing new variables names to create.
345 % \changes{v0.1.1.2}{2025-02-17}{original version}
346 % \begin{macrocode}
347 \seq_new:N \l__tensorstyles_new_var_seq
348 % \end{macrocode}
349 % \end{variable}
350 % \end{implementation}
351
352 % \begin{implementation}
353 % \begin{function}[added= 2025-02-17]{\__tensorstyles_new}
354 % \begin{arguments}
355 % \item |variable-type| eg. "tl" (token list), "dim", "seq", etc.
356 % \item |grp-cmd+variant| eg. "$tensor_tensor$"
357 % \item |variable-category| eg. "style"
358 % \item |cs-var-list| comma separated list of variable names to create.
359 % \end{arguments}
360 % This function is creating the local variables |\l__tensorstyles_'type'_'variant'_'cat'_'var'| for all the variable names given in the argument 4 (|cs-var-list|).
361 % \changes{v0.1.1.2}{2025-02-17}{original version}
362 % \TestFiles{tensorstyles-test-005}
363 % \begin{macrocode}
364 \cs_new:Npn \__tensorstyles_new:nnnn #1 #2 #3 #4 {
365 \seq_set_from_clist:Nn \l__tensorstyles_new_var_seq { #4 }
366 \seq_map_inline:Nn \l__tensorstyles_new_var_seq
367 { \cs:w #1_new:c \cs_end: { l__tensorstyles_#2_#3_##1_#1 } }
368 }
369 % \end{macrocode}
370 % \end{function}
371 % \end{implementation}
372
373 %
374 % %%%%% Setting keys %%%%%
375 %
376 % \begin{implementation}
377 % \begin{function}[added= 2025-02-17]{\__tensorstyles_set_default_from_keyval}
378 % \begin{arguments}
379 % \item |variable-type| eg. tl (token list), dim, seq etc.
380 % \item |preset| eg. preset
381 % \item |keyval| the option given
382 % \item |cs-var-list| comma separated list of variable names to create.
383 % \end{arguments}
384 % This function is setting the default keys/options from a list of keyval.
385 % \changes{v0.1.1.2}{2025-02-17}{original version}
386 % \TestFiles{tensorstyles-test-005}
387 % \begin{macrocode}
388 % \__tensorstyles_set_default_from_keyval: variant, preset, keyval, group command
389 \cs_new_protected:Npn \__tensorstyles_set_default_from_keyval:nnnn #1 #2 #3 #4 {
390 % tensorstyles~set~default~from~keyval
391 % Check if keyvalues have been given.
392 \tl_if_novalue:nTF { #3 }
393 { % no user keys given so _user_keys_prop is taking pkg prop
394 \prop_set_eq:cc { l__tensorstyles_#4_#1_user_keys_prop } { c__tensorstyles_#4_#2_pkg_keys_prop }
395 }{ % user key given and put it in prop
396 \prop_put_from_keyval:cn { l__tensorstyles_#4_#1_user_keys_prop } { #3 }
397 }% end if
398 %
399 % prepare the map of keys
400 \__tensorstyles_set_default_auxi:cnn { l__tensorstyles_#4_#1_user_keys_prop } { #1 } { #4 }
401 %
402 % set this map as default
403 \keys_set:nn { tensorstyles/#4/#1 } { default }
404 }
405 \cs_generate_variant:Nn \__tensorstyles_set_default_from_keyval:nnnn { nVnn }
406 % \end{macrocode}
407 % \end{function}
408 % \end{implementation}
409
410 % \begin{implementation}
411 % \begin{function}[added= 2025-02-17]{\__tensorstyles_set_default_auxi, \__tensorstyles_set_default_auxii}
412 % \begin{arguments}
413 % \item |prop-key-val| eg. tl (token list), dim, seq etc.
414 % \item |variant| eg. 'options=toto'
415 % \item |grp-cmd| eg. "style"
416 % \end{arguments}
417 % These functions are internally used to set the default keys/options.
418 % \changes{v0.1.1.2}{2025-02-17}{original version}
419 % \TestFiles{tensorstyles-test-005}
420 % \begin{macrocode}
421 \cs_new_protected:Npn \__tensorstyles_set_default_auxi:Nnn #1 #2 #3 {
422 \__tensorstyles_set_default_auxii:fnn { \prop_to_keyval:N #1 } { #2 } { #3 }
423 }
424 \cs_generate_variant:Nn \__tensorstyles_set_default_auxi:Nnn { c }
425 %
426 % key-val, variant, group command
427 \cs_new_protected:Npn \__tensorstyles_set_default_auxii:nnn #1 #2 #3 {
428 \keys_define:nn { tensorstyles/#3/#2 } { default .meta:n = { #1 } }
429 }
430 \cs_generate_variant:Nn \__tensorstyles_set_default_auxii:nnn { f }
431 % \end{macrocode}
432 % \end{function}
433 % \end{implementation}
434
435 % \begin{implementation}
436 % \begin{function}[added= 2025-02-17]{\tensorsset}
437 % \begin{arguments}
438 % \item |command| for which options will be set or reset.
439 % \item |options| input given as setting options.
440 % \end{arguments}
441 % Function to (re)set keys/options by default for a group of commands.
442 % \changes{v0.1.1.2}{2025-02-17}{original version}
443 % \TestFiles{tensorstyles-test-005}
444 % \begin{macrocode}
445 % \tensorsset m:command:#1 o:options:#2
446 \DeclareDocumentCommand{\tensorsset}{ m o } {
447 \str_if_eq:nnTF { #1 } { all }
448 {
449 % True: if the 'all' commands have to be set.
450 \__tensorstyles_set_default_from_keyval:nnnn { all } {empty} { #2 } { all }
451 \keys_set:nn { tensorstyles/all/all } { default }
452 }{
453 %False: if the command name is given then apply to it:
454 % capture the command name.
455 \tl_set:Nx \l__tensorstyles_tensorsset_tl { \cs_to_str:N #1 }
456 % apply option to the command.
457 \tensorstyles_set_keys:Vn \l__tensorstyles_tensorsset_tl { #2 }
458 }
459 }
460 % \end{macrocode}
461 % \end{function}
462 % \end{implementation}
463
464 % \begin{implementation}
465 % \begin{function}[added= 2025-02-17]{\tensorstyles_local_keys}
466 % \begin{arguments}
467 % \item |keyval| for which options will be set or reset.
468 % \item |grp-cmd| input given as setting options.
469 % \item |command| input given as setting options.
470 % \item |preset| of options.
471 % \end{arguments}
472 % Set options according to the keys-value given by the user locally.
473 % This command is used in the code definition of the 'command'-group, ie., is called every time the 'command' is called.
474 % \changes{v0.1.1.2}{2025-02-17}{original version}
475 % \TestFiles{tensorstyles-test-005}
476 % \begin{macrocode}
477 % tensorstyles_local_keys:nnnn #1=keyval, #2=group-command, #3=command, #4=preset
478 \cs_new_protected:Npn \tensorstyles_local_keys:nnnn #1 #2 #3 #4 {
479 % in tensorstyles~local~keys
480 \tl_set:Ne \l_tmpa_tl { #4 }
481
482 \tl_if_novalue:nTF { #1 }
483 {
484 % keyval NOT given
485 \bool_if:cT { l__tensorstyles_#2_#3_local_keys_bool }
486 {
487 % True
488 \keys_set:nV { tensorstyles/#2/#3 } \l_tmpa_tl
489 \bool_set_false:c { l__tensorstyles_#2_#3_local_keys_bool }
490 }
491 }{
492 % keyvalue given
493 \bool_if:cTF { l__tensorstyles_#2_#3_local_keys_bool }
494 {
495 % True
496 \tl_put_right:Nn \l_tmpa_tl { , #1 } % append #1 unexpanded
497 \keys_set:nV { tensorstyles/#2/#3 } \l_tmpa_tl
498 }{
499 % False
500 \tl_put_right:Nn \l_tmpa_tl { , #1 } % append #1 unexpanded
501 \keys_set:nV { tensorstyles/#2/#3 } \l_tmpa_tl
502 }
503 \bool_set_true:c { l__tensorstyles_#2_#3_local_keys_bool }
504 }
505 }
506 \cs_generate_variant:Nn \keys_set:nn { nV }
507 % \end{macrocode}
508 % \end{function}
509 % \end{implementation}
510
511 % \begin{implementation}
512 % \begin{function}[added= 2025-02-17]{\tensorstyles_local_preset }
513 % \begin{arguments}
514 % \item |keyval| for which options will be set or reset.
515 % \item |grp-cmd| input given as setting options.
516 % \item |preset| of options.
517 % \item |variant| of options.
518 % \end{arguments}
519 % Set options according to the keys-value given by the user locally.
520 % This command is used in the code definition of the 'command'-group, ie., is called every time the 'command' is called.
521 % \changes{v0.1.1.2}{2025-02-17}{original version}
522 % \TestFiles{tensorstyles-test-005}
523 % \begin{macrocode}
524 % tensorstyles_local_preset:nnn #1=group-command, #2=preset, #3=star-preset #4=variant
525 \cs_new_protected:Npn \tensorstyles_local_preset:nVVnn #1 #2 #3 #4 {
526 \tl_if_eq:NnTF { #2 } { None } {
527 \keys_define:nn { tensorstyles/tensor/#1 } { pres .meta:n = { default }}
528 } {
529 \prop_set_eq:cc { l__tensorstyles_#4_#1_user_keys_prop } { c__tensorstyles_#4_#2_pkg_keys_prop }
530 \keys_define:nn { tensorstyles/tensor/#1 } {
531 pres .code:n = {
532 \prop_map_inline:cn { l__tensorstyles_#4_#1_user_keys_prop }
533 { \keys_set:nn { tensorstyles/tensor/#1 } { ####1 = {####2} } }
534 }
535 }
536 }
537 \tl_if_eq:NnTF { #3 } { None } {
538 \keys_define:nn { tensorstyles/tensor/#1 } { pres* .meta:n = { default }}
539 } {
540 \prop_set_eq:cc { l__tensorstyles_#4_#1*_user_keys_prop } { c__tensorstyles_#4_#3_pkg_keys_prop }
541 \keys_define:nn { tensorstyles/tensor/#1 } {
542 pres* .code:n = {
543 \prop_map_inline:cn { l__tensorstyles_#4_#1*_user_keys_prop }
544 { \keys_set:nn { tensorstyles/tensor/#1 } { ####1* = {####2} } }
545 }
546 }
547 }
548 }
549 % \end{macrocode}
550 % \end{function}
551 % \end{implementation}
552
553 % \begin{implementation}
554 % \begin{function}[added= 2025-02-17]{\tensorstyles_addto_globalvar_and_setkeys:NNnnn}
555 % \begin{arguments}
556 % \item |tl-tensor| token list used to concatenate the name of the command.
557 % \item |macro| input given as setting options.
558 % \item |command| input given as setting options.
559 % \item |keyval| for which options will be set or reset.
560 % \item |grp-cmd| input given as setting options.
561 % \end{arguments}
562 % Set options according to the keys-value given by the user locally.
563 % This command is used in the code definition of the 'command'-group, ie., is called every time the 'command' is called.
564 % \changes{v0.1.1.2}{2025-02-17}{original version}
565 % \TestFiles{tensorstyles-test-005}
566 % \begin{macrocode}
567 %
568 % \tensorstyles_addto_globalvar_and_setkeys:NNnnn #1=tl-tensor, #2=macro, #3=inf, #4=keyval, #5=group command
569 \cs_new_protected:Npn \tensorstyles_addto_globalvar_and_setkeys:NNnnn #1 #2 #3 #4 #5 {
570 % store
571 \tl_set:Nx #1 { \cs_to_str:N #2 }
572
573 % Check if the keyval has values.
574 \tl_if_novalue:nTF { #4 }
575 {
576 % if empty then create the variables by default.
577 \__tensorstyles_preamble_aux:Vnnnn #1 { empty } { empty } { } { #5 }
578 }{
579 % otherwise, create then set the variables.
580 \use:c { __tensorstyles_#5_define_preset_keys:n } { #1 }
581 \keys_set:nn {tensorstyles/preset/#1} { #4 }
582 \tl_set:Nx \l_tmpa_tl { \tl_use:c { l__tensorstyles_tensor_#1_preset } }
583 \tl_set:Nx \l_tmpb_tl { \tl_use:c { l__tensorstyles_tensor_#1*_preset } }
584
585 \__tensorstyles_preamble_aux:VVVnn #1 \l_tmpa_tl \l_tmpb_tl { #4 } { #5 }
586 % \__tensorstyles_preamble_aux:Veenn #1 { full } { empty } { #4 } { #5 }
587 }
588
589 }
590 %
591 % \__tensorstyles_preamble_aux:nnnn #1=variant, #2=preset, #3=star-preset, #4=key-value, #5=grp-cmd
592 \cs_new_protected:Npn \__tensorstyles_preamble_aux:nnnnn #1 #2 #3 #4 #5 {
593 % Check if the command is in the global sequence
594 \seq_if_in:cnF { l__tensorstyles_#5_variant_seq } { #1 }
595 {
596
597 % if not present
598 % add the command to the sequence
599 \seq_put_left:cn { l__tensorstyles_#5_variant_seq } { #1 }
600 % create new variables (tl) for the new command
601 \use:c { __tensorstyles_#5_variables:n } { #1 }
602 \use:c { __tensorstyles_#5_variables:n } { #1* }
603 % define keys for this command
604 \use:c { __tensorstyles_#5_define_keys:n } { #1 }
605 \use:c { __tensorstyles_#5_define_keys:n } { #1* }
606 }
607
608 % Apply package options
609 \prop_set_eq:cc { l__tensorstyles_#5_#1_user_keys_prop } { c__tensorstyles_#5_#2_pkg_keys_prop }
610 \prop_set_eq:cc { l__tensorstyles_#5_#1*_user_keys_prop } { c__tensorstyles_#5_#3_pkg_keys_prop }
611 % Apply the newly given options by default
612 \__tensorstyles_set_default_from_keyval:nnnn { #1* } { #3 } { } { #5 }
613 \__tensorstyles_set_default_from_keyval:nnnn { #1 } { #2 } { #4 } { #5 }
614 }
615 \cs_generate_variant:Nn \__tensorstyles_preamble_aux:nnnnn { VVVnn }
616 \cs_generate_variant:Nn \__tensorstyles_preamble_aux:nnnnn { V }
617 % \end{macrocode}
618 % \end{function}
619 % \end{implementation}
620
621 %
622 %
623 %%%%%% 'TENSOR' GROUP COMMAND CODE %%%%%%
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625 %
626 % \begin{implementation}
627 % \begin{variable}[added= 2025-02-17]{\l__tensorstyles_tensor_variant_seq, \l__tensorstyles_tensor_rank_holder_tl, \l__tensorstyles_tensor_rank_counter_int}
628 % |\l__tensorstyles_tensor_variant_seq| is a sequence to store all the command of this type.
629 % |\l__tensorstyles_tensor_rank_holder_tl| is storing the value of the tensor rank given.
630 % |\l__tensorstyles_tensor_rank_counter_int| is storing the local value of the rank counter (as Einstein indices are running for example).
631 % \changes{v0.1.1.2}{2025-02-17}{original version}
632 % \begin{macrocode}
633 \seq_new:N \l__tensorstyles_tensor_variant_seq
634 \tl_new:N \l__tensorstyles_tensor_rank_holder_tl
635 \int_new:N \l__tensorstyles_tensor_rank_counter_int
636 % \end{macrocode}
637 % \end{variable}
638 % \end{implementation}
639
640 % \begin{implementation}
641 % \begin{function}[added= 2025-02-17]{\__tensorstyles_tensor_variables:n}
642 % \begin{arguments}
643 % \item |variant| for which variables have to be declared.
644 % \end{arguments}
645 % Define variables of the `tensor` command-group, according to the keys-value given by the user locally.
646 % \changes{v0.1.1.2}{2025-02-17}{original version}
647 % \TestFiles{tensorstyles-test-005}
648 % \begin{macrocode}
649 % Define variables for the tensor group.
650 % \__tensorstyles_tensor_variables:n variant
651 \cs_new_protected:Npn \__tensorstyles_tensor_variables:n #1 {
652 %%\__tensorstyles_new:nnnn data-type, grp-cmd+variant, category, cs-var-list
653 %
654 % switch
655 \__tensorstyles_new:nnnn { bool } {tensor_#1} { switch } { star }
656 \__tensorstyles_new:nnnn { bool } {tensor_#1} { switch } { font, einstein, dirac, arrows, recursiveArrows } %
657 % font
658 \__tensorstyles_new:nnnn { prop } {tensor_#1} { font } { cmd }
659 % Einstein
660 \__tensorstyles_new:nnnn { tl } {tensor_#1} { indexstyle } { covariant, contra }
661 % arrows
662 \__tensorstyles_new:nnnn { prop } {tensor_#1} { arrow } { cmd }
663 % recursive arrows
664 \__tensorstyles_new:nnnn { tl } {tensor_#1} { recursive } { arrowCmd }
665 % Dirac bra-ket
666 \__tensorstyles_new:nnnn { tl } {tensor_#1} { scale } { var }
667 \__tensorstyles_new:nnnn { tl } {tensor_#1} { delims } { eval }
668 % keys
669 \__tensorstyles_new:nnnn { prop } {tensor_#1} { user } { keys }
670 \__tensorstyles_new:nnnn { bool } {tensor_#1} { local } { keys }
671 }
672 % \end{macrocode}
673 % \end{function}
674 % \end{implementation}
675
676 % \begin{implementation}
677 % \begin{macro}[added= 2025-02-17]{\__tensorstyles_tensor_define_keys:n}
678 % \begin{arguments}
679 % \item |variant| for which key corresponding the command associated, have to be declared.
680 % \end{arguments}
681 % Set options for the `tensor` group-command according to the keys-value given by the user locally.
682 % \changes{v0.1.1.2}{2025-02-17}{original version}
683 % \TestFiles{tensorstyles-test-005}
684 % \begin{macrocode}
685 % Define keys/options for tensor group command style.
686 % \__tensorstyles_tensor_define_keys:n variant
687 \cs_new:Npn \__tensorstyles_tensor_define_keys:n #1 {
688 \keys_define:nn { tensorstyles/tensor/#1 } {
689 switch-* .bool_set:c = { l__tensorstyles_tensor_#1_switch_star_bool },
690 preset .code:n = {},
691 deduce-var .tl_set:c = { l__tensorstyles_tensor_#1_deduce_var_tl },
692
693 % font
694 font .bool_set:c = { l__tensorstyles_tensor_#1_switch_font_bool },
695 font-cmd .code:n = { \prop_set_from_keyval:cn { l_tensorstyles_tensor_#1_font_cmd_prop } {##1} },
696
697 % arrow
698 arrows .bool_set:c = { l__tensorstyles_tensor_#1_switch_arrows_bool },
699 arrow-cmd .code:n = { \prop_set_from_keyval:cn { l_tensorstyles_tensor_#1_arrow_cmd_prop } {##1} },
700
701 recursive-arrows .bool_set:c = { l__tensorstyles_tensor_#1_switch_recursiveArrows_bool },
702 recurs-arrows-cmd .tl_set:c = { l__tensorstyles_tensor_#1_recursive_arrowCmd_tl },
703
704 % bra-ket
705 bra-ket .bool_set:c = { l__tensorstyles_tensor_#1_switch_dirac_bool },
706 scale-var .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__tensorstyles_set_scale:nnn {tensor_#1} {##1} { var } },
707 scale-var .default:n = { auto },
708 scale-var .initial:n = { auto },
709 delims-var .tl_set:c = { l__tensorstyles_tensor_#1_delims_var_tl },
710 mix-delims .bool_set:c = { l__tensorstyles_tensor_#1_mix_delimiter_bool },
711
712 % Einstein
713 contra-variant .bool_set:c = { l__tensorstyles_tensor_#1_switch_einstein_bool },
714 % \__tensorstyles_set_index_style:nnn #1= grp-cmd variant, #2= covariant or contra, #3= option selected,
715 covariant-style .choices:nn = { alph, arabic, greek } { \__tensorstyles_set_index_style:nnn {#1} {covariant} {##1} },
716 covariant-style .default:n = { greek },
717 covariant-style .initial:n = { greek },
718 contra-style .choices:nn = { alph, arabic, greek } { \__tensorstyles_set_index_style:nnn {#1} {contra} {##1} },
719 contra-style .default:n = { alph },
720 contra-style .initial:n = { alph },
721 default-indices .choices:nn = { covariant, contra } { \__tensorstyles_set_index_type:nn {#1} { ##1 }},
722 default-indices .default:n = { covariant },
723 default-indices .initial:n = { covariant },
724 index-marker .tl_set:c = { l__tensorstyles_tensor_#1_index_marker_tl },
725 specific-indices .clist_set:c = { l__tensorstyles_tensor_#1_specific_indices_clist },
726 collapsed-indices .bool_set:c = { l__tensorstyles_tensor_#1_collapsed_indices },
727 index-offset .int_set:c = { l__tensorstyles_tensor_#1_index_offset },
728
729 %%% Star Version
730 %%%%%%%%%%%%%%%%
731
732 % switch-** .bool_set:c = { l__tensorstyles_tensor_#1*_switch_star_bool },
733 switch-** .code:n = { printSwitchStarStar },
734 preset* .code:n = {},
735 deduce-var* .tl_set:c = { l__tensorstyles_tensor_#1*_deduce_var_tl },
736
737 % font
738 font* .bool_set:c = { l__tensorstyles_tensor_#1*_switch_font_bool },
739 font-cmd* .code:n = { \prop_set_from_keyval:cn { l_tensorstyles_tensor_#1*_font_cmd_prop } {##1} },
740
741 % arrow
742 arrows* .bool_set:c = { l__tensorstyles_tensor_#1*_switch_arrows_bool },
743 arrow-cmd* .code:n = { \prop_set_from_keyval:cn { l_tensorstyles_tensor_#1*_arrow_cmd_prop } {##1} },
744
745 recursive-arrows* .bool_set:c = { l__tensorstyles_tensor_#1*_switch_recursiveArrows_bool },
746 recurs-arrows-cmd* .tl_set:c = { l__tensorstyles_tensor_#1*_recursive_arrowCmd_tl },
747
748 % bra-ket
749 bra-ket* .bool_set:c = { l__tensorstyles_tensor_#1*_switch_dirac_bool },
750 scale-var* .choices:nn = { auto, none, big, Big, bigg, Bigg } { \__tensorstyles_set_scale:nnn {tensor_#1*} {##1} { var } },
751 delims-var* .tl_set:c = { l__tensorstyles_tensor_#1*_delims_var_tl },
752 mix-delims* .bool_set:c = { l__tensorstyles_tensor_#1*_mix_delimiter_bool },
753
754 % Einstein
755 contra-variant* .bool_set:c = { l__tensorstyles_tensor_#1*_switch_einstein_bool },
756 % \__tensorstyles_set_index_style:nnn #1= grp-cmd variant, #2= covariant or contra, #3= option selected,
757 covariant-style* .choices:nn = { alph, arabic, greek } { \__tensorstyles_set_index_style:nnn {#1*} {covariant} {##1} },
758 contra-style* .choices:nn = { alph, arabic, greek } { \__tensorstyles_set_index_style:nnn {#1*} {contra} {##1} },
759 default-indices* .choices:nn = { covariant, contra } { \__tensorstyles_set_index_type:nn {#1*} { ##1 }},
760 index-marker* .tl_set:c = { l__tensorstyles_tensor_#1*_index_marker_tl },
761 specific-indices* .clist_set:c = { l__tensorstyles_tensor_#1*_specific_indices_clist },
762 collapsed-indices* .bool_set:c = { l__tensorstyles_tensor_#1*_collapsed_indices },
763 index-offset* .int_set:c = { l__tensorstyles_tensor_#1*_index_offset },
764 }
765 }
766 % \end{macrocode}
767 % \end{macro}
768 % \end{implementation}
769
770 % \begin{implementation}
771 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_tensor_define_preset_keys:n, \__tensorstyles_tensor_define_local_preset_keys:n}
772 % \begin{arguments}
773 % \item |variant| of the `tensor` group-command.
774 % \end{arguments}
775 % Define the keys and variables for presets.
776 % \changes{v1.0.1}{2025-02-12}{original version}
777 % \TestFiles{tensorstyles-test-005}
778 % \begin{macrocode}
779 \cs_new:Npn \__tensorstyles_tensor_define_preset_keys:n #1 {
780 % Initialize variables to "empty" as baseline
781 \tl_set:cn { l__tensorstyles_tensor_#1_preset } { empty }
782 \tl_set:cn { l__tensorstyles_tensor_#1*_preset } { empty }
783 \keys_define:nn { tensorstyles/preset/#1 } {
784 preset .tl_set:c = { l__tensorstyles_tensor_#1_preset } ,
785 preset* .tl_set:c = { l__tensorstyles_tensor_#1*_preset } ,
786 unknown .code:n = {}
787 }
788 }
789
790 \cs_new:Npn \__tensorstyles_tensor_define_local_preset_keys:n #1 {
791 % Initialize variables to "empty" as baseline
792 \tl_set:cn { l__tensorstyles_tensor_#1_local_preset } { None }
793 \tl_set:cn { l__tensorstyles_tensor_#1*_local_preset } { None }
794 \keys_define:nn { tensorstyles/preset/#1 } {
795 preset .tl_set:c = { l__tensorstyles_tensor_#1_local_preset } ,
796 preset* .tl_set:c = { l__tensorstyles_tensor_#1*_local_preset } ,
797 unknown .code:n = {}
798 }
799 }
800 % \end{macrocode}
801 % \end{function}
802 % \end{implementation}
803
804 % \begin{implementation}
805 % \begin{variable}[added= 2025-02-17]{\c__tensorstyles_tensor_empty_pkg_keys_prop, \c__tensorstyles_tensor_einstein_pkg_keys_prop, \c__tensorstyles_tensor_math_pkg_keys_prop, \c__tensorstyles_tensor_arrow_pkg_keys_prop, \c__tensorstyles_tensor_engineer_pkg_keys_prop, \c__tensorstyles_tensor_bra_pkg_keys_prop, \c__tensorstyles_tensor_ket_pkg_keys_prop, \c__tensorstyles_tensor_full_pkg_keys_prop}
806 % Define dictionaries of presets.
807 % \changes{v0.1.1.2}{2025-02-17}{original version}
808 % \TestFiles{tensorstyles-test-008}
809 % \begin{macrocode}
810 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_empty_pkg_keys_prop {
811 % Font
812 font = false,
813 % Einstein index notation
814 contra-variant = false,
815 % Arrows
816 arrows = false,
817 recursive-arrows = false,
818 % Dirac bra-ket
819 bra-ket = false,
820 }
821
822 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_einstein_pkg_keys_prop {
823 % Font
824 font = false,
825 % Einstein index notation
826 contra-variant = true,
827 contra-style = alph,
828 covariant-style = alph, %greek, %, alph, arabic
829 default-indices = covariant,
830 index-marker = \ ,
831 collapsed-indices = false,
832 specific-indices = {},
833 index-offset = 0,
834 % covariant-indices = 1,
835 % indexOffset = 0,
836 % Arrows
837 arrows = false,
838 recursive-arrows = false,
839 % Dirac bra-ket
840 % bra-ket = false,
841 }
842
843 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_math_pkg_keys_prop {
844 % Font
845 font = true,
846 font-cmd = {0={}, 1=\boldsymbol, 2=\MakeUppercase, 3=\MakeUpperCal, 4=\MakeUpperBB, 5=\MakeBoldUppercase, n=\mathfrak},
847 % Einstein index notation
848 contra-variant = false,
849 % Arrows
850 arrows = false,
851 recursive-arrows = false,
852 % Dirac bra-ket
853 bra-ket = false,
854 }
855
856 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_arrow_pkg_keys_prop {
857 % Font
858 font = false,
859 % Einstein index notation
860 contra-variant = false,
861 % Arrows
862 arrows = true,
863 arrow-cmd = {0={}, 1=\overrightarrow, 2=\overleftrightarrow, 3=\overrightleftrightarrow, 4=\overdoubleleftrightarrow, 5=\overrightdoubleleftrightarrow, n=\underleftrightarrow},
864 recursive-arrows = false,
865 % Dirac bra-ket
866 bra-ket = false,
867 }
868
869 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_engineer_pkg_keys_prop {
870 % Font
871 font = false,
872 % Einstein index notation
873 contra-variant = false,
874 % Arrows
875 arrows = false,
876 recursive-arrows = true,
877 recurs-arrows-cmd =\underline,
878 % Dirac bra-ket
879 bra-ket = false,
880 }
881
882 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_bra_pkg_keys_prop {
883 % Font
884 font = false,
885 % Einstein index notation
886 contra-variant = false,
887 % Arrows
888 arrows = false,
889 recursive-arrows = false,
890 % Dirac bra-ket
891 bra-ket = true,
892 scale-var = auto,
893 delims-var = \langle\rvert,
894 mix-delims = true,
895 }
896
897 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_ket_pkg_keys_prop {
898 % Font
899 font = false,
900 % Einstein index notation
901 contra-variant = false,
902 % Arrows
903 arrows = false,
904 recursive-arrows = false,
905 % Dirac bra-ket
906 bra-ket = true,
907 scale-var = auto,
908 delims-var = \lvert\rangle,
909 mix-delims = true,
910 }
911
912 \prop_const_from_keyval:Nn \c__tensorstyles_tensor_full_pkg_keys_prop {
913 % style-inf=d,
914 % style-var = \bold,
915 % switch-* = false,
916 deduce-var= xX,
917 % order = 1,
918 % Font
919 font = true,
920 font-cmd = {0={}, 1=\boldsymbol, 2=\MakeUppercase, 3=\MakeUpperCal, 4=\MakeUpperBB, 5=\MakeBoldUppercase, n=\mathfrak}, %6=\mathfrak, n=\MakeUpperFrak},
921 % Einstein index notation
922 contra-variant = true,
923 contra-style = alph,
924 covariant-style = greek, %greek, %, alph, arabic
925 default-indices = covariant,
926 index-marker = \ ,
927 collapsed-indices = false,
928 specific-indices = {},
929 index-offset = 0,
930 % covariant-indices = 1,
931 % indexOffset = 0,
932 % Arrows
933 arrows = true,
934 arrow-cmd = {0={}, 1=\overrightarrow, 2=\overleftrightarrow, 3=\widetilde, 4=\overdoubleleftrightarrow, 5=\widehat, n=\underline},
935 recursive-arrows = false,
936 recurs-arrows-cmd = \underline,
937 % Dirac bra-ket
938 bra-ket = true,
939 scale-var = auto,
940 delims-var = \lbrace\rvert,
941 mix-delims = true,
942 % style= Dirac(bra-ket), Einstein-contravariant, engineer (underline), physics (double-curved-arrows), mathematics (bold)
943 }
944 % \end{macrocode}
945 % \end{variable}
946 % \end{implementation}
947
948 % \begin{implementation}
949 % \begin{function}[added= 2025-02-17]{\tensorstyles_tensor_define:Nnn}
950 % \begin{arguments}
951 % \item |new/declare/renew/provide| corresponding to the type of command declaration desired.
952 % \item |variant| of the command group.
953 % \item |macro| for name (given by the user) the command that will be created.
954 % \end{arguments}
955 % Generic declaration of new function from tensor-type.
956 % \changes{v0.1.1.2}{2025-02-17}{original version}
957 % \TestFiles{tensorstyles-test-005}
958 % \begin{macrocode}
959 % \tensorstyles_tensor_define:Nnn #1=new/declare/renew/provide, #2=variant, #3=macro
960 \cs_new_protected:Npn \tensorstyles_tensor_define:Nnn #1 #2 #3 {
961 % define the tensor-type of command: \declare {\toto}{ o m }{ code }
962 \tl_new:c { l__tensorstyles_tensor_#2_preset_default_tl }
963 \exp_args:Nne #1 { #3 }{ s o m m o !e{\char_generate:nn {`_}{8}^} } {
964 %% ##1: star, ##2: options, ##3: tensor order, ##4 variable, ##5: einstein indices, ##6: subscript, ##7: superscript
965 \group_begin:
966 % capture and treat eventual indices given
967 \tl_if_in:cnTF { l__tensorstyles_tensor_#2_deduce_var_tl } {##3} {
968 % \tl_show:c l__tensorstyles_tensor_#1_deduce_var_tl
969 \tl_if_novalue:nTF {##5} { \int_set:Nn \l__tensorstyles_tensor_rank_counter_int 0} {
970 \tl_set:Nn \l__tensorstyles_indices_tl {##5}
971 \tl_map_inline:Nn \l__tensorstyles_indices_tl {
972 \tl_if_single:nTF { ####1 } {
973 \token_if_eq_meaning:NNTF ####1 ^{ }{
974 \token_if_eq_charcode:NNTF ####1 _{ }{
975 \int_incr:N \l__tensorstyles_tensor_rank_counter_int
976 }
977 }
978 }
979 {
980 \int_incr:N \l__tensorstyles_tensor_rank_counter_int
981 }
982 }
983 }
984 \tl_set:Nn \l__tensorstyles_tensor_rank_holder_tl { \int_use:N \l__tensorstyles_tensor_rank_counter_int }
985 }{
986 \tl_set:Nn \l__tensorstyles_tensor_rank_holder_tl { ##3 }
987 }
988
989 % Capture and store presets.
990 \tl_if_novalue:nTF { ##2 } {
991 \tl_set:cn { l__tensorstyles_tensor_#2_preset_default_tl } { default }
992 }{
993 \use:c { __tensorstyles_tensor_define_local_preset_keys:n } { #2 }
994 \keys_set:nn {tensorstyles/preset/#2} { ##2 }
995 \tl_set:Nx \l_tmpa_tl { \tl_use:c { l__tensorstyles_tensor_#2_local_preset } }
996
997 \tl_set:Nx \l_tmpb_tl { \tl_use:c { l__tensorstyles_tensor_#2*_local_preset } }
998 \tensorstyles_local_preset:nVVnn {#2} \l_tmpa_tl \l_tmpb_tl { tensor }
999 \tl_set:cn { l__tensorstyles_tensor_#2_preset_default_tl } { pres }
1000 }
1001
1002 %% \__tensorstyles_evaluation_sub_sup grp-cmd_variant, sub, sup, code-for-fraction
1003 \__tensorstyles_evaluation_sub_sup:nnnn {#2} {##6} {##7} {
1004 % if star is present
1005 \bool_if:nTF {##1} {
1006 % star only
1007 % Capture and apply options from keys.
1008 \tl_if_novalue:nTF { ##2 } {
1009 \tensorstyles_local_keys:nnnn { } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} }
1010 }{
1011 \tensorstyles_local_keys:nnnn { ##2 } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} * }
1012 }
1013
1014 \__tensorstyles_tensor_no:nnen {#2*} {##4} {\tl_use:N \l__tensorstyles_tensor_rank_holder_tl} {##5}
1015 }{
1016 % treat a first time the option as if no star will be used (ie if switch-*=false)
1017 \tl_if_novalue:nTF { ##2 } {
1018 \tensorstyles_local_keys:nnnn { } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} }
1019 }{
1020 \tensorstyles_local_keys:nnnn { ##2 } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} }
1021 }
1022
1023 \bool_if:cTF {l__tensorstyles_tensor_#2_switch_star_bool}{
1024 % star detected => retreat the options
1025 \tl_if_novalue:nTF { ##2 } {
1026 \tensorstyles_local_keys:nnnn { } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} }
1027 }{
1028 \tensorstyles_local_keys:nnnn { ##2 } { tensor } { #2 } { \tl_use:c {l__tensorstyles_tensor_#2_preset_default_tl} * }
1029 }
1030 \__tensorstyles_tensor_no:nnen {#2*} {##4} {\tl_use:N \l__tensorstyles_tensor_rank_holder_tl} {##5}
1031 }{
1032 % no star
1033 \__tensorstyles_tensor_no:nnen {#2} {##4} {\tl_use:N \l__tensorstyles_tensor_rank_holder_tl} {##5}
1034 }
1035 }
1036 }
1037 \group_end:
1038 }
1039 }
1040 \cs_generate_variant:Nn \tensorstyles_tensor_define:Nnn { NV }
1041 % \end{macrocode}
1042 % \end{function}
1043 % \end{implementation}
1044
1045 % \begin{implementation}
1046 % \begin{function}[added= 2025-02-17]{\__tensorstyles_tensor_no:nnnn}
1047 % \begin{arguments}
1048 % \item |grp-cmd(tensor)_variant| to which the setting is related to.
1049 % \item |variable| to be displayed.
1050 % \item |tensor order| (integer) of the variable.
1051 % \item |indices| only if it has to be specified.
1052 % \end{arguments}
1053 % Command to display tensor command, ie apply font, then, arrows, index and delimiters.
1054 % \changes{v0.1.1.2}{2025-02-17}{original version}
1055 % \TestFiles{tensorstyles-test-005}
1056 % \begin{macrocode}
1057 % \__tensorstyles_tensor_no:nnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order, #4=Indices
1058 \cs_new_protected:Npn \__tensorstyles_tensor_no:nnnn #1 #2 #3 #4 {
1059 \__tensorstyles_add_delims:nnn {#1} { var } {
1060 \__tensorstyles_add_einsteinIndex:nnnn {#1} {
1061 % \__tensorstyles_add_fontCmd:nnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order
1062 \__tensorstyles_add_recursiveCmd:nnn {#1} {
1063 \__tensorstyles_add_arrowCmd:nnn {#1} {
1064 \__tensorstyles_add_fontCmd:nnn {#1} {#2} {#3}
1065 } {#3}
1066 } {#3}
1067 } {#3} {#4}
1068 }
1069 }
1070 \cs_generate_variant:Nn \__tensorstyles_tensor_no:nnnn { nnen }
1071 % \end{macrocode}
1072 % \end{function}
1073 % \end{implementation}
1074
1075
1076 %
1077 % %%%%% Command Declaration %%%%%
1078 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1079 %
1080 % \begin{implementation}
1081 % \begin{variable}[added= 2025-02-17]{\l__tensorstyles_cs_name_tl}
1082 % Local and temporary variable to concatenate the name of the command as a token list.
1083 % \changes{v0.1.1.2}{2025-02-17}{original version}
1084 % \TestFiles{tensorstyles-test-005}
1085 % \begin{macrocode}
1086 \tl_new:N \l__tensorstyles_cs_name_tl
1087 \seq_new:N \g__tensorstyles_existing_command_seq
1088 % \end{macrocode}
1089 % \end{variable}
1090 % \end{implementation}
1091
1092 % \begin{documentation}
1093 % \begin{function}[added= 2025-02-17]{\DeclareTensorsCmd}
1094 % \begin{arguments}
1095 % \item |command name| to be declared.
1096 % \item |keyval| (option) to be given to the new command as a first (non-default) setup.
1097 % \end{arguments}
1098 % Command to declare a new command from a command group, with eventually options to be given to this new option.
1099 % Such new definition are useful for users who would like to create their own custom command that will have the same behaviour than the ones furnished by the package.
1100 % \end{function}
1101 % \end{documentation}
1102 %%%%
1103 % \begin{implementation}
1104 % \begin{function}[added= 2025-02-17]{\DeclareTensorsCmd}
1105 % \begin{arguments}
1106 % \item |command name| to be defined/declared.
1107 % \item |keyval| (option) to be given to the new command as a first (non-default) setup.
1108 % \end{arguments}
1109 % Command accessible by the users to declare a new command from a command group, with eventually options to be given to this new option.
1110 % \changes{v0.1.1.2}{2025-02-17}{original version}
1111 % \TestFiles{tensorstyles-test-005}
1112 % \begin{macrocode}
1113 \DeclareDocumentCommand{\DeclareTensorsCmd}{ m o } {
1114 % \tensorstyles_addto_globalvar_and_setkeys:NNnnnnnn tl-tensor, macro, inf, keyval, preset, star-keyval, star-preset group command
1115 \tensorstyles_addto_globalvar_and_setkeys:NNnnn \l__tensorstyles_cs_name_tl #1 {d} { #2 } { tensor }
1116
1117 % \tensorstyles_tensor_define:NVn declare/renew..., variant, macro
1118 % DeclareDocumentCommand #1 { #2 } { #3 }
1119 \tensorstyles_tensor_define:NVn \DeclareDocumentCommand \l__tensorstyles_cs_name_tl { #1 }
1120
1121 \seq_put_right:Nn \g__tensorstyles_existing_command_seq { #1 }
1122 }
1123 % \end{macrocode}
1124 % \end{function}
1125 % \end{implementation}
1126
1127 %
1128 % %%%%% Rest of the Code (common) %%%%%
1129 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1130 %
1131 % \begin{implementation}
1132 % \begin{function}[added= 2025-02-17]{\__tensorstyles_set_scale:nnn}
1133 % \begin{arguments}
1134 % \item |grp-cmd_variant| for which the scaling will be set.
1135 % \item |scale| the desired scale, eg, auto or none or big or Big...
1136 % \item |delimiters-name| the name of the category of delimiters to scale.
1137 % \end{arguments}
1138 % Set the scale of a pair of delimiters.
1139 % \changes{v0.1.1.2}{2025-02-17}{original version}
1140 % \TestFiles{tensorstyles-test-005}
1141 % \begin{macrocode}
1142 % \__tensorstyles_set_scale:nnn #1=grp-cmd_variant, #2=scale, #3=delimiter-name
1143 \cs_new:Npn \__tensorstyles_set_scale:nnn #1 #2 #3 {
1144 \str_case:nnF { #2 }{
1145 % if the scale desired is 'auto' or 'none'
1146 { auto } { \tl_set:cn { l__tensorstyles_#1_scale_#3_tl } { \__tensorstyles_scale_auto:nnn } }
1147 { none } { \tl_set:cn { l__tensorstyles_#1_scale_#3_tl } { \__tensorstyles_scale_none:nnn } }
1148 }{
1149 % otherwise, applied the given scale
1150 \tl_set:cn { l__tensorstyles_#1_scale_#3_tl } { \__tensorstyles_scale_big:nnnn { #2 } }
1151 }
1152 }
1153 % \end{macrocode}
1154 % \end{function}
1155 % \end{implementation}
1156
1157
1158 %
1159 % %%%%% Scale, delimiters, evaluation %%%%%
1160 %
1161 %
1162 % \begin{implementation}
1163 % \begin{variable}[added= 2025-02-12, updated= 2025-02-12]{\g__tensorstyles_last_delim, \g__tensorstyles_follow_up}
1164 % |\g__tensorstyles_follow_up| is capturing if the delimiters are followed by another, in order to maybe compress them.
1165 % |\g__tensorstyles_last_delim| is capturing the last delimiter seen.
1166 % \changes{v1.0.1}{2025-02-12}{original version}
1167 % \begin{macrocode}
1168 % counters and local variables
1169 \bool_new:N \g__tensorstyles_follow_up
1170 \tl_new:N \g__tensorstyles_last_delim
1171 % \end{macrocode}
1172 % \end{variable}
1173 % \end{implementation}
1174
1175 % \begin{implementation}
1176 % \begin{function}[added= 2025-02-17]{\__tensorstyles_add_delims:nnn}
1177 % \begin{arguments}
1178 % \item |grp-cmd_variant| for which the scaling will be set.
1179 % \item |delimiters-name| name of the delimiters to add.
1180 % \item |inner-arg| inside value between the delimiters.
1181 % \end{arguments}
1182 % Apply a pair of delimiters (scaled) around an inner argument.
1183 % \changes{v0.1.1.2}{2025-02-17}{original version}
1184 % \TestFiles{tensorstyles-test-005}
1185 % \begin{macrocode}
1186 % \__tensorstyles_add_delims:nnn #1=grp-cmd_variant, #2=delimiter-name, #3=value
1187 \cs_new:Npn \__tensorstyles_add_delims:nnn #1 #2 #3 {
1188 \bool_if:cTF {l__tensorstyles_tensor_#1_switch_dirac_bool} {
1189 \tl_use:c { l__tensorstyles_tensor_#1_scale_#2_tl } { tensor_#1 } { #2 } { #3 }
1190 \tl_set:Nx \l_tmpb_tl { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 2 } }
1191 \bool_if:cTF {l__tensorstyles_tensor_#1_mix_delimiter_bool} {
1192 \seq_map_inline:Nn \g__tensorstyles_existing_command_seq {
1193 \bool_gset_false:N \g__tensorstyles_follow_up
1194 \token_if_eq_meaning:NNT \l_peek_token ##1 {
1195 \bool_gset_true:N \g__tensorstyles_follow_up
1196 \tl_gset:Nx \g__tensorstyles_last_delim { \tl_item:cn { l__tensorstyles_tensor_#1_delims_#2_tl } { 2 } }
1197 \seq_map_break:
1198 }
1199 }
1200 } {
1201 \bool_gset_false:N \g__tensorstyles_follow_up
1202 }
1203 }{
1204 #3
1205 }
1206 }
1207 % \end{macrocode}
1208 % \end{function}
1209 % \end{implementation}
1210
1211 % \begin{implementation}
1212 % \begin{function}[added= 2025-02-17]{\__tensorstyles_scale_auto:nnn}
1213 % \begin{arguments}
1214 % \item |grp-cmd_variant| for which the scaling will be set.
1215 % \item |delimiters-name| name of the delimiters to add.
1216 % \item |inner-code| inside value to be displayed between the delimiters.
1217 % \end{arguments}
1218 % Command for auto scaling delimiters (mleft and mright).
1219 % \changes{v0.1.1.2}{2025-02-17}{original version}
1220 % \TestFiles{tensorstyles-test-005}
1221 % \begin{macrocode}
1222 %\__tensorstyles_scale_auto:nnn #1=grp-cmd_variant, #2=delimiters-name, #3=inner-arg
1223 \cs_new:Npn \__tensorstyles_scale_auto:nnn #1 #2 #3 {
1224 \tl_set:Nx \l_tmpa_tl { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1225 \tl_set:Nx \l_tmpb_tl { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 2 } }
1226 \tl_if_empty:NTF \l_tmpa_tl { } {
1227 \bool_if:NTF \g__tensorstyles_follow_up {
1228 \bool_if:cTF {l__tensorstyles_#1_mix_delimiter_bool} {
1229 \tl_if_eq:NNTF \g__tensorstyles_last_delim \l_tmpa_tl {
1230 \! \__tensorstyles_auto_left:n .
1231 } {
1232 \tl_if_eq:NnTF \g__tensorstyles_last_delim { \rvert } {
1233 \tl_if_eq:NnTF \l_tmpa_tl { \lvert } {
1234 \! \__tensorstyles_auto_left:n .
1235 } {
1236 \__tensorstyles_auto_left:n \l_tmpa_tl
1237 }
1238 } {
1239 \__tensorstyles_auto_left:n \l_tmpa_tl
1240 }
1241 }
1242 }{
1243 \__tensorstyles_auto_left:n \l_tmpa_tl
1244 }
1245 } {
1246 \__tensorstyles_auto_left:n \l_tmpa_tl
1247 }
1248 }
1249 #3
1250 \tl_if_empty:NTF \l_tmpb_tl { } {
1251 \__tensorstyles_auto_right:n \l_tmpb_tl
1252 }
1253 }
1254 % \end{macrocode}
1255 % \end{function}
1256 % \end{implementation}
1257
1258 % \begin{implementation}
1259 % \begin{function}[added= 2025-02-17]{\__tensorstyles_scale_none:nnn}
1260 % \begin{arguments}
1261 % \item |grp-cmd_variant| for which the scaling will be set.
1262 % \item |delimiters-name| name of the delimiters to add.
1263 % \item |inner-code| inside value to be displayed between the delimiters.
1264 % \end{arguments}
1265 % Command for intentionally no-scaling delimiters.
1266 % \changes{v0.1.1.2}{2025-02-17}{original version}
1267 % \TestFiles{tensorstyles-test-005}
1268 % \begin{macrocode}
1269 %\__tensorstyles_scale_none:nnn #1=grp-cmd_variant, #2=delimiters-name, #3=inner-arg
1270 \cs_new:Npn \__tensorstyles_scale_none:nnn #1 #2 #3 {
1271 \tl_set:Nx \l_tmpa_tl { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1272 \tl_set:Nx \l_tmpb_tl { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 2 } }
1273 \tl_if_empty:NTF \l_tmpa_tl { } {
1274 \bool_if:NTF \g__tensorstyles_follow_up {
1275 \bool_if:cTF {l__tensorstyles_#1_mix_delimiter_bool} {
1276 \tl_if_eq:NNTF \g__tensorstyles_last_delim \l_tmpa_tl { } {
1277 \tl_if_eq:NnTF \g__tensorstyles_last_delim { \rvert } {
1278 \tl_if_eq:NnTF \l_tmpa_tl { \lvert } { } {
1279 \__tensorstyles_dont_use_dot:x { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1280 }
1281 } {
1282 \__tensorstyles_dont_use_dot:x { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1283 }
1284 }
1285 } {
1286 \__tensorstyles_dont_use_dot:x { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1287 }
1288 } {
1289 \__tensorstyles_dont_use_dot:x { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 1 } }
1290 }
1291 }
1292 #3
1293 \__tensorstyles_dont_use_dot:x { \tl_item:cn { l__tensorstyles_#1_delims_#2_tl } { 2 } }
1294 }
1295 % \end{macrocode}
1296 % \end{function}
1297 % \end{implementation}
1298
1299 % \begin{implementation}
1300 % \begin{function}[added= 2025-02-17]{\__tensorstyles_dont_use_dot:n}
1301 % \begin{arguments}
1302 % \item |delimiter-symbol| to be not scaled.
1303 % \end{arguments}
1304 % Command to force no scaling on the given delimiter.
1305 % \changes{v0.1.1.2}{2025-02-17}{original version}
1306 % \TestFiles{tensorstyles-test-005}
1307 % \begin{macrocode}
1308 % \__tensorstyles_dont_use_dot:n #1=delimiter-symbol
1309 \cs_new:Npn \__tensorstyles_dont_use_dot:n #1 {
1310 \str_if_eq:nnF { #1 } { . } { #1 }
1311 }
1312 \cs_generate_variant:Nn \__tensorstyles_dont_use_dot:n { x }
1313 % \end{macrocode}
1314 % \end{function}
1315 % \end{implementation}
1316
1317 % \begin{implementation}
1318 % \begin{function}[added= 2025-02-17]{\__tensorstyles_scale_big:nnnn, \__tensorstyles_scale_big_auxi:nNn}
1319 % \begin{arguments}
1320 % \item |scale| the desired scale, eg, big or Big...
1321 % \item |grp-cmd_variant| for which the scaling will be set.
1322 % \item |delimiters-name| the name of the category of delimiters to scale.
1323 % \item |inner-code| inside value to be displayed between the delimiters.
1324 % \end{arguments}
1325 % Apply the scale of a pair of delimiters and display what is inside.
1326 % \changes{v0.1.1.2}{2025-02-17}{original version}
1327 % \TestFiles{tensorstyles-test-005}
1328 % \begin{macrocode}
1329 %\__tensorstyles_scale_big:nnnn #1 #2=grp-cmd_variant, #3=delimiters-name, #4=inner-code
1330 \cs_new:Npn \__tensorstyles_scale_big:nnnn #1 #2 #3 #4 {
1331 \__tensorstyles_scale_big_auxi:ncnn { #1 } {l__tensorstyles_#2_delims_#3_tl} { #4 } { #2 }
1332 }
1333 %
1334 % \__tensorstyles_scale_big_auxi:nNn #1=scaling, #2=delimiters, #3=inner-code, #4=grp-cmd
1335 \cs_new:Npn \__tensorstyles_scale_big_auxi:nNnn #1 #2 #3 #4 {
1336 \tl_set:Nx \l_tmpa_tl { \tl_item:Nn #2 { 1 } }
1337 \tl_set:Nx \l_tmpb_tl { \tl_item:Nn #2 { 2 } }
1338 \tl_if_empty:NTF \l_tmpa_tl { } {
1339 \bool_if:NTF \g__tensorstyles_follow_up {
1340 \bool_if:cTF {l__tensorstyles_#4_mix_delimiter_bool} {
1341 \tl_if_eq:NNTF \g__tensorstyles_last_delim \l_tmpa_tl { } {
1342 \tl_if_eq:NnTF \g__tensorstyles_last_delim { \rvert } {
1343 \tl_if_eq:NnTF \l_tmpa_tl { \lvert } { } {
1344 \tl_use:c { #1 l } { \tl_item:Nn #2 { 1 } }
1345 }
1346 }{
1347 \tl_use:c { #1 l } { \tl_item:Nn #2 { 1 } }
1348 }
1349 }
1350 }{
1351 \tl_use:c { #1 l } { \tl_item:Nn #2 { 1 } }
1352 }
1353 }{
1354 \tl_use:c { #1 l } { \tl_item:Nn #2 { 1 } }
1355 }
1356 }
1357 #3
1358 \tl_use:c { #1 r } { \tl_item:Nn #2 { 2 } }
1359 }
1360 \cs_generate_variant:Nn \__tensorstyles_scale_big_auxi:nNnn { nc }
1361 % \end{macrocode}
1362 % \end{function}
1363 % \end{implementation}
1364
1365
1366 % \begin{implementation}
1367 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\nam\__tensorstyles_evaluation_sub_sup:nnnn}
1368 % \begin{arguments}
1369 % \item |variant| Name of the variant grp-cmd
1370 % \item |sub| subscript to add to the inner code
1371 % \item |sup| superscript to add to the inner code
1372 % \item |inner code| on which the sub and sup will be added
1373 % \end{arguments}
1374 % Function to add sub and superscript to an inner variable.
1375 % \changes{v1.0.1}{2025-02-12}{original version}
1376 % \TestFiles{tensorstyles-test-005}
1377 % \begin{macrocode}
1378 %
1379 % \__tensorstyles_evaluation_sub_sup:nnnn #1=variant #2=sub #3=sup #4=inner part
1380 \cs_new:Npn \__tensorstyles_evaluation_sub_sup:nnnn #1 #2 #3 #4 {
1381 \tl_if_novalue:nTF {#2} {
1382 % if no value, skip sub-point
1383 \tl_if_novalue:nTF {#3} {
1384 % if no value skip sup-point, then add only the code-fraction
1385 #4
1386 }{
1387 % if value add only sup-point
1388 {#4}
1389 \sp{ #3 }
1390 }
1391 }{
1392 % if value, add sub-point
1393 {#4}
1394 \sb{ #2 }
1395 \tl_if_novalue:nTF {#3} {
1396 % if no value skip sup-point
1397 }{
1398 \sp{ #3 }
1399 }
1400 }
1401 }
1402 % \end{macrocode}
1403 % \end{function}
1404 % \end{implementation}
1405
1406
1407 % \begin{implementation}
1408 % \begin{variable}[added= 2025-02-12, updated= 2025-02-12]{\l__indice_sub_bool}
1409 % |\l__indice_sub_bool| is triggering either indices should be displayed
1410 % \changes{v1.0.1}{2025-02-12}{original version}
1411 % \begin{macrocode}
1412 % counters and local variables
1413 \bool_new:N \l__indice_sub_bool
1414 % \end{macrocode}
1415 % \end{variable}
1416 % \end{implementation}
1417
1418 % \begin{implementation}
1419 % \begin{variable}[added= 2025-02-12, updated= 2025-02-12]{\l__tensorstyles_var_int_tmpa, \g__tensorstyles_offset_int_tmpa}
1420 % |\l__tensorstyles_var_int_tmpa| is internal index counter
1421 % |\g__tensorstyles_offset_int_tmpa| is the offset to apply on the index counter.
1422 % \changes{v1.0.1}{2025-02-12}{original version}
1423 % \begin{macrocode}
1424 % counters and local variables
1425 \int_new:N \l__tensorstyles_var_int_tmpa
1426 \int_new:N \g__tensorstyles_offset_int_tmpa
1427 \int_gset:Nn \g__tensorstyles_offset_int_tmpa {0}
1428 % \end{macrocode}
1429 % \end{variable}
1430 % \end{implementation}
1431
1432 % \begin{implementation}
1433 % \begin{variable}[added= 2025-02-12, updated= 2025-02-12]{\l__tensorstyles_covariant_seq_tmpa, \l__tensorstyles_covariant_manual_seq_tmpa, \l__tensorstyles_contra_seq_tmpa, \l__tensorstyles_contra_manual_seq_tmpa, \l__tensorstyles_indices_tl, \l_tmp_covariant_tl, \l_tmp_contra_tl, \l_tmpc_dim}
1434 % |\l__tensorstyles_covariant_seq_tmpa| is local sequence of covariant index
1435 % |\l__tensorstyles_covariant_manual_seq_tmpa| is the local sequence of covariant index given manually
1436 % |\l__tensorstyles_contra_seq_tmpa| is the local sequence of contravariant of index
1437 % |\l__tensorstyles_contra_manual_seq_tmpa| is the local sequence of contravariant of index given manually
1438 % |\l__tensorstyles_indices_tl| is the token list that will be decoded to create the sequence
1439 % |\l_tmp_covariant_tl|
1440 % |\l_tmp_contra_tl|
1441 % |\l_tmpc_dim| the internal length for collapsed indices
1442 % \changes{v1.0.1}{2025-02-12}{original version}
1443 % \begin{macrocode}
1444 % counters and local variables
1445 \seq_new:N \l__tensorstyles_covariant_seq_tmpa
1446 \seq_new:N \l__tensorstyles_covariant_manual_seq_tmpa
1447 \seq_new:N \l__tensorstyles_contra_seq_tmpa
1448 \seq_new:N \l__tensorstyles_contra_manual_seq_tmpa
1449
1450 \tl_new:N \l__tensorstyles_indices_tl
1451 \tl_new:N \l_tmp_covariant_tl
1452 \tl_new:N \l_tmp_contra_tl
1453
1454 \dim_new:N \l_tmpc_dim
1455 % \end{macrocode}
1456 % \end{variable}
1457 % \end{implementation}
1458
1459 % \begin{implementation}
1460 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_manual_indices:nn}
1461 % \begin{arguments}
1462 % \item |grp-cmd(tensor) variant| variant of the tensor grp-cmd that is used.
1463 % \item |index list| to add manually
1464 % \end{arguments}
1465 % Adds indices manually (since they have been given by the user) without collapse of indices.
1466 % \changes{v1.0.1}{2025-02-12}{original version}
1467 % \TestFiles{tensorstyles-test-006}
1468 % \begin{macrocode}
1469
1470 %\__tensorstyles_add_manual_indices:nn #1= grp-cmd(tensor) variant, #2 = index list
1471 \cs_new_protected:Npn \__tensorstyles_add_manual_indices:nn #1 #2 {
1472 \tl_set:Nn \l__tensorstyles_indices_tl {#2}
1473 % browse the list
1474 \tl_map_inline:Nn \l__tensorstyles_indices_tl
1475 {
1476 \tl_if_single:nTF { ##1 } {
1477 \token_if_eq_meaning:NNTF ##1 ^{
1478 \bool_set_false:N \l__indice_sub_bool
1479 }{
1480 \token_if_eq_charcode:NNTF ##1 _{
1481 \bool_set_true:N \l__indice_sub_bool
1482 }{
1483 \settowidth{\l_tmpa_dim}{$##1$}
1484 \bool_if:NTF \l__indice_sub_bool{
1485 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1486 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1487 { ##1 }
1488 }
1489 \seq_put_right:Nx \l__tensorstyles_contra_seq_tmpa {
1490 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1491 { \exp_not:v { l__tensorstyles_tensor_#1_index_marker_tl } }
1492 }
1493 }{
1494 \seq_put_right:Nx \l__tensorstyles_contra_seq_tmpa {
1495 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1496 { ##1 }
1497 }
1498 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1499 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1500 { \exp_not:v { l__tensorstyles_tensor_#1_index_marker_tl } }
1501 }
1502 }
1503 \int_incr:N \l__tensorstyles_var_int_tmpa
1504 }
1505 }
1506 }{
1507 %Index is a group
1508 \settowidth{\l_tmpa_dim}{$##1$}
1509 \bool_if:NTF \l__indice_sub_bool{
1510 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1511 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1512 { \exp_not:n {##1} }
1513 }
1514 \seq_put_right:Nx \l__tensorstyles_contra_seq_tmpa {
1515 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1516 \exp_not:v { l__tensorstyles_tensor_#1_index_marker_tl }
1517 }
1518 }{
1519 \seq_put_right:Nx \l__tensorstyles_contra_seq_tmpa {
1520 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1521 { \exp_not:n {##1} }
1522 }
1523 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1524 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpa_dim \exp_not:n {][c]}
1525 \exp_not:v { l__tensorstyles_tensor_#1_index_marker_tl }
1526 }
1527 }
1528 \int_incr:N \l__tensorstyles_var_int_tmpa
1529 }
1530 }
1531 }
1532 % \end{macrocode}
1533 % \end{function}
1534 % \end{implementation}
1535
1536 % \begin{implementation}
1537 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_manual_collapsed_indices:n}
1538 % \begin{arguments}
1539 % \item |index list| to add manually
1540 % \end{arguments}
1541 % Adds indices manually (since they have been given by the user) with collapse of indices.
1542 % \changes{v1.0.1}{2025-02-12}{original version}
1543 % \TestFiles{tensorstyles-test-006}
1544 % \begin{macrocode}
1545
1546 %\__tensorstyles_add_manual_collapsed_indices:n #1= index list
1547 \cs_new_protected:Npn \__tensorstyles_add_manual_collapsed_indices:n #1 {
1548 \tl_set:Nn \l__tensorstyles_indices_tl {#1}
1549 \tl_map_inline:Nn \l__tensorstyles_indices_tl
1550 {
1551 \tl_if_single:nTF { ##1 } {
1552 \token_if_eq_meaning:NNTF ##1 ^{
1553 \bool_set_false:N \l__indice_sub_bool
1554 }{
1555 \token_if_eq_charcode:NNTF ##1 _{
1556 \bool_set_true:N \l__indice_sub_bool
1557 }{
1558 \bool_if:NTF \l__indice_sub_bool{
1559 \seq_put_right:Nx \l__tensorstyles_covariant_manual_seq_tmpa { ##1 }
1560 }{
1561 \seq_put_right:Nx \l__tensorstyles_contra_manual_seq_tmpa { ##1 }
1562 }
1563 \int_incr:N \l__tensorstyles_var_int_tmpa
1564 }
1565 }
1566 }{
1567 \bool_if:NTF \l__indice_sub_bool{
1568 \seq_put_right:Nx \l__tensorstyles_covariant_manual_seq_tmpa { ##1 }
1569 }{
1570 \seq_put_right:Nx \l__tensorstyles_contra_manual_seq_tmpa { ##1 }
1571 }
1572 \int_incr:N \l__tensorstyles_var_int_tmpa
1573 }
1574 }
1575 \int_step_inline:nn {
1576 \int_max:nn { \seq_count:N \l__tensorstyles_covariant_manual_seq_tmpa } { \seq_count:N \l__tensorstyles_contra_manual_seq_tmpa }
1577 }{
1578 \tl_set:Nx \l_tmp_covariant_tl { \seq_item:Nn \l__tensorstyles_covariant_manual_seq_tmpa { ##1 } }
1579 \tl_set:Nx \l_tmp_contra_tl { \seq_item:Nn \l__tensorstyles_contra_manual_seq_tmpa { ##1 } }
1580 \settowidth{\l_tmpa_dim}{$\l_tmp_covariant_tl$}
1581 \settowidth{\l_tmpb_dim}{$\l_tmp_contra_tl$}
1582 \dim_compare:nTF { \l_tmpa_dim > \l_tmpb_dim }{
1583 \dim_set_eq:NN \l_tmpc_dim \l_tmpa_dim
1584 }{
1585 \dim_set_eq:NN \l_tmpc_dim \l_tmpb_dim
1586 }
1587
1588 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1589 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpc_dim \exp_not:n {][c]}
1590 { \exp_not:V \l_tmp_covariant_tl }
1591 }
1592
1593 \seq_put_right:Nx \l__tensorstyles_contra_seq_tmpa {
1594 \exp_not:n { \mathmakebox[} \dim_use:N \l_tmpc_dim \exp_not:n {][c]}
1595 { \exp_not:V \l_tmp_contra_tl }
1596 }
1597 }
1598 }
1599 % \end{macrocode}
1600 % \end{function}
1601 % \end{implementation}
1602
1603 % \begin{implementation}
1604 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_one_einsteinIndex:nnn}
1605 % \begin{arguments}
1606 % \item |grp-cmd(tensor) variant| variant of the tensor grp-cmd that is used.
1607 % \item |index-style| ie alph, greek or arabic
1608 % \item |index-type| ie contra or covariant
1609 % \end{arguments}
1610 % Adds only one Einstein index.
1611 % \changes{v1.0.1}{2025-02-12}{original version}
1612 % \TestFiles{tensorstyles-test-006}
1613 % \begin{macrocode}
1614 % \usepackage{mathtools} % for \mathmakebox
1615
1616 % \__tensorstyles_add_one_einsteinIndex:nn #1= grp-cmd(tensor) variant, #2=Indice type #3=Blank Type
1617 \cs_new_protected:Npn \__tensorstyles_add_one_einsteinIndex:nnn #1 #2 #3 {
1618 \settowidth{\l_tmpa_dim}{$\use:c { l__tensorstyles_tensor_#1_indexstyle_#2_tl }{\int_eval:n{\l__tensorstyles_var_int_tmpa+\g__tensorstyles_offset_int_tmpa}}$}
1619 \seq_put_right:cx { l__tensorstyles_#2_seq_tmpa } {
1620 \exp_not:n { \mathmakebox[\l_tmpa_dim][c] }
1621 { \exp_not:c { l__tensorstyles_tensor_#1_indexstyle_#2_tl }
1622 { \int_use:N \l__tensorstyles_var_int_tmpa }
1623 }
1624 }
1625
1626 \bool_if:cTF {l__tensorstyles_tensor_#1_collapsed_indices} {
1627 % We do not add any marker
1628 }{
1629 \seq_put_right:cx { l__tensorstyles_#3_seq_tmpa } {
1630 \exp_not:n { \mathmakebox[\l_tmpa_dim][c] }
1631 { \exp_not:v { l__tensorstyles_tensor_#1_index_marker_tl } }
1632 }
1633 }
1634 }
1635 % \end{macrocode}
1636 % \end{function}
1637 % \end{implementation}
1638
1639 % \begin{implementation}
1640 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_einsteinIndex:nnnn}
1641 % \begin{arguments}
1642 % \item |grp-cmd(tensor) variant| variant of the tensor grp-cmd that is used.
1643 % \item |variable| variable on which the indices will be added
1644 % \item |tensor order| to determine the number of indices to add.
1645 % \item |indices| if the list has been explicitly defined by the user.
1646 % \end{arguments}
1647 % Adds multiple Einstein indices
1648 % \changes{v1.0.1}{2025-02-12}{original version}
1649 % \TestFiles{tensorstyles-test-006}
1650 % \begin{macrocode}
1651
1652 % \__tensorstyles_add_einsteinIndex:nnnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order #4=Indices
1653 \cs_new_protected:Npn \__tensorstyles_add_einsteinIndex:nnnn #1 #2 #3 #4 {
1654 \bool_if:cTF {l__tensorstyles_tensor_#1_switch_einstein_bool} {
1655 % true switch einstein
1656 \seq_clear:N \l__tensorstyles_covariant_seq_tmpa
1657 \seq_clear:N \l__tensorstyles_contra_seq_tmpa
1658 % Do we raise an error if we do not add #3 indices?
1659 \tl_if_novalue:nTF {#4} {
1660 \tl_if_in:NnTF \c__tensorstyles_digits_tl {#3} {
1661 % The order is a number
1662 \int_set:Nn \l__tensorstyles_var_int_tmpa { \int_use:c { l__tensorstyles_tensor_#1_index_offset } }
1663 \int_step_inline:nn {#3} {
1664 % increase the counter
1665 \int_incr:N \l__tensorstyles_var_int_tmpa
1666
1667 \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l__tensorstyles_var_int_tmpa - \int_use:c { l__tensorstyles_tensor_#1_index_offset } } }
1668 \clist_if_in:cVTF { l__tensorstyles_tensor_#1_specific_indices_clist } \l_tmpa_tl
1669 {
1670 \exp_args:Nne \__tensorstyles_add_one_einsteinIndex:nnn {#1} { \tl_use:c { l__tensorstyles_tensor_#1_opposed_indices_tl }} { \tl_use:c { l__tensorstyles_tensor_#1_default_indices_tl } }
1671 }
1672 {
1673 \exp_args:Nne \__tensorstyles_add_one_einsteinIndex:nnn {#1} { \tl_use:c { l__tensorstyles_tensor_#1_default_indices_tl }} { \tl_use:c { l__tensorstyles_tensor_#1_opposed_indices_tl } }
1674 }
1675 % add this counter (+ the offset) of the sequence of index
1676 }
1677 }{
1678 % if the order is not a number then add it as if it a vector.
1679 \seq_put_right:Nx \l__tensorstyles_covariant_seq_tmpa {
1680 \__tensorstyles_add_fontCmd:nnn {#1} {#3} {1}
1681 }
1682 }
1683 }{
1684 %Indices were given manually
1685 \bool_if:cTF {l__tensorstyles_tensor_#1_collapsed_indices} {
1686 \__tensorstyles_add_manual_collapsed_indices:n {#4}
1687 }{
1688 \__tensorstyles_add_manual_indices:nn {#1} {#4}
1689 }
1690 \int_compare:nTF { \l__tensorstyles_var_int_tmpa = #3 } {
1691 %Rank and number of indices match
1692 }{
1693 %User has given too many or not enough indices
1694 \msg_error:nnx { tensorstyles } { rank_indices_missmatch } { \msg_line_context: }
1695 }
1696 }
1697 % print
1698 #2\sb{
1699 \seq_use:Nn \l__tensorstyles_covariant_seq_tmpa {}
1700 }\sp{
1701 \seq_use:Nn \l__tensorstyles_contra_seq_tmpa {}
1702 }
1703 }{
1704 % false switch font
1705 #2
1706 }
1707 }
1708 % \end{macrocode}
1709 % \end{function}
1710 % \end{implementation}
1711
1712 % \begin{implementation}
1713 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_set_index_style:nnn}
1714 % \begin{arguments}
1715 % \item |grp-cmd(tensor) variant| variant of the tensor grp-cmd that is used.
1716 % \item |index-type| covariant or contra.
1717 % \item |index-style| greek, alph or arabic.
1718 % \end{arguments}
1719 % Turn the index integer into a string according to the index-style to use.
1720 % \changes{v1.0.1}{2025-02-12}{original version}
1721 % \TestFiles{tensorstyles-test-006}
1722 % \begin{macrocode}
1723
1724 % \__tensorstyles_set_index_style:nnn #1= grp-cmd variant, #2= index-type, #3= index-style,
1725 \cs_new:Npn \__tensorstyles_set_index_style:nnn #1 #2 #3 {
1726 \str_case:nnF {#3} {
1727 { alph }{ \tl_set:cn { l__tensorstyles_tensor_#1_indexstyle_#2_tl } { \int_to_alph:n } }
1728 { arabic }{ \tl_set:cn { l__tensorstyles_tensor_#1_indexstyle_#2_tl } { \int_to_arabic:n } }
1729 { greek }{ \tl_set:cn { l__tensorstyles_tensor_#1_indexstyle_#2_tl } { \int_to_greek:n } }
1730 }{
1731 \msg_error:nnxx { tensorstyles } { index-style-option-not-defined }
1732 {#3} {'#3'}
1733 }
1734 }
1735 % \end{macrocode}
1736 % \end{function}
1737 % \end{implementation}
1738
1739
1740 % \begin{implementation}
1741 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_set_index_style:nnn}
1742 % \begin{arguments}
1743 % \item |grp-cmd(tensor) variant| variant of the tensor grp-cmd that is used.
1744 % \item |index-type| covariant or contra.
1745 % \end{arguments}
1746 % Set the default index type to use.
1747 % \changes{v1.0.1}{2025-02-12}{original version}
1748 % \TestFiles{tensorstyles-test-006}
1749 % \begin{macrocode}
1750
1751 % \__tensorstyles_set_index_type:nnn #1= grp-cmd variant, #2= index-type
1752 \cs_new:Npn \__tensorstyles_set_index_type:nn #1 #2 {
1753 \tl_set:cn { l__tensorstyles_tensor_#1_default_indices_tl } { #2 }
1754 \str_case:nnF {#2} {
1755 { covariant }{
1756 \tl_set:cn { l__tensorstyles_tensor_#1_default_indices_tl } { covariant }
1757 \tl_set:cn { l__tensorstyles_tensor_#1_opposed_indices_tl } { contra }
1758 }{ contra }{
1759 \tl_set:cn { l__tensorstyles_tensor_#1_default_indices_tl } { contra }
1760 \tl_set:cn { l__tensorstyles_tensor_#1_opposed_indices_tl } { covariant }
1761 }
1762 }{
1763 \msg_error:nnxx { tensorstyles } { index-type-option-not-defined }
1764 {#2} {'#2'}
1765 }
1766 }
1767 % \end{macrocode}
1768 % \end{function}
1769 % \end{implementation}
1770
1771
1772 % \begin{implementation}
1773 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_fontCmd:nnn}
1774 % \begin{arguments}
1775 % \item |variant| grp-cmd(tensor) variant
1776 % \item |variable| on which the font command will be applied
1777 % \item |tensor order| to determine which font select.
1778 % \end{arguments}
1779 % Apply a font on a variable according to the tensor order.
1780 % \changes{v1.0.1}{2025-02-12}{original version}
1781 % \TestFiles{tensorstyles-test-005}
1782 % \begin{macrocode}
1783
1784 % \__tensorstyles_add_fontCmd:nnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order
1785 \cs_new_protected:Npn \__tensorstyles_add_fontCmd:nnn #1 #2 #3 {
1786 \bool_if:cTF {l__tensorstyles_tensor_#1_switch_font_bool}{
1787 % true switch font
1788 \prop_if_in:cnTF {l_tensorstyles_tensor_#1_font_cmd_prop} {#3} {
1789 % true
1790 %\exp_args:NNV
1791 \prop_item:cn {l_tensorstyles_tensor_#1_font_cmd_prop} {#3} {#2}
1792 }{
1793 % false
1794 false\ the\ order\ #3\ is\ not\ present\ in\ font\ option!
1795 }
1796 }{
1797 % false switch font
1798 #2
1799 }
1800 }
1801 % \end{macrocode}
1802 % \end{function}
1803 % \end{implementation}
1804
1805
1806 % \begin{implementation}
1807 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\int_to_greek:n}
1808 % \begin{arguments}
1809 % \item |integer| to turn into a symbol (string).
1810 % \end{arguments}
1811 % Function that returns the greek symbol corresponding to the integer given.
1812 % \changes{v1.0.1}{2025-02-12}{original version}
1813 % \TestFiles{tensorstyles-test-005}
1814 % \begin{macrocode}
1815 %%
1816 \cs_new:Npn \int_to_greek:n #1 {
1817 % \int_to_symbols:nnn {⟨int expr ⟩} {⟨total symbols ⟩} {⟨value to symbol mapping ⟩}
1818 \int_to_symbols:nnn {#1} { 23 } {
1819 { 1 }{ \alpha }
1820 { 2 }{ \beta }
1821 { 3 }{ \gamma }
1822 { 4 }{ \delta }
1823 { 5 }{ \varepsilon }
1824 { 6 }{ \zeta }
1825 { 7 }{ \eta }
1826 { 8 }{ \theta }
1827 { 9 }{ \iota }
1828 { 10 }{ \kappa }
1829 { 11 }{ \lambda }
1830 { 12 }{ \mu }
1831 { 13 }{ \nu }
1832 { 14 }{ \xi }
1833 { 15 }{ o }
1834 { 16 }{ \pi }
1835 { 17 }{ \varrho }
1836 { 18 }{ \sigma }
1837 { 19 }{ \tau }
1838 { 20 }{ \upsilon }
1839 { 21 }{ \phi }
1840 { 22 }{ \chi }
1841 { 23 }{ \psi }
1842 { 23 }{ \omega }
1843 }
1844 }
1845 % \end{macrocode}
1846 % \end{function}
1847 % \end{implementation}
1848
1849 % \begin{implementation}
1850 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\recursive_cmd:nnn}
1851 % \begin{arguments}
1852 % \item |cmd| to apply recursively
1853 % \item |number| of occurrence to apply
1854 % \item |variable| on which the recursively command will be applied
1855 % \end{arguments}
1856 % Apply a given number of times a command on an input variable.
1857 % The input command (to apply) can only take one positional argument.
1858 % \changes{v1.0.1}{2025-02-12}{original version}
1859 % \TestFiles{tensorstyles-test-005}
1860 % \begin{macrocode}
1861
1862 % internal variable to store the counter of occurrence
1863 \int_new:N \g__tensorstyles_int_tmpa
1864 %
1865 % \recursive_cmd:nnn cmd, number, var
1866 \cs_set:Npn \recursive_cmd:nnn #1 #2 #3 {
1867 \group_begin:
1868 %
1869 % all variable assignments will be constrained in this group
1870 \int_gset:Nn \g__tensorstyles_int_tmpa {#2}
1871 %
1872 % while the number of call is higher than 1
1873 \int_compare:nNnTF {#2} > {1} {
1874 %true % then apply recursively the command
1875 \int_gdecr:N \g__tensorstyles_int_tmpa
1876 \exp_args:Nnx \recursive_cmd:nnV {#1} {\int_use:N \g__tensorstyles_int_tmpa} {#1{#3}}
1877 }{
1878 % false %
1879 \int_compare:nNnTF {#2} = {0} {
1880 %true
1881 #3
1882 }{
1883 % false % equal 1
1884 #1{#3}
1885 }
1886 }
1887 \group_end:
1888 }
1889 % variant command for \recursive_cmd:nnn
1890 \cs_generate_variant:Nn \recursive_cmd:nnn { nnV, vnn }
1891 % \end{macrocode}
1892 % \end{function}
1893 % \end{implementation}
1894
1895 % \begin{implementation}
1896 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_recursiveCmd:nnn}
1897 % \begin{arguments}
1898 % \item |variant| grp-cmd(tensor) variant
1899 % \item |variable| on which the recursively command will be applied
1900 % \item |tensor order| which will correspond to the number of occurrence to apply recursively
1901 % \end{arguments}
1902 % Apply (if needed) as many time as the tensor order a command on an input variable.
1903 % \changes{v1.0.1}{2025-02-12}{original version}
1904 % \TestFiles{tensorstyles-test-005}
1905 % \begin{macrocode}
1906 %
1907 % \__tensorstyles_add_recurseCmd:nnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order
1908 \cs_new_protected:Npn \__tensorstyles_add_recursiveCmd:nnn #1 #2 #3 {
1909 \bool_if:cTF {l__tensorstyles_tensor_#1_switch_recursiveArrows_bool} {
1910 % true switch recursive
1911 \tl_if_in:NnTF \c__tensorstyles_digits_tl {#3} {
1912 % The order is a number
1913 \recursive_cmd:vnn {l__tensorstyles_tensor_#1_recursive_arrowCmd_tl} {#3} {#2}
1914 }{
1915 % else the order is a letter
1916 \__tensorstyles_add_arrowCmd:nnn {#1} {#2} {#3}
1917 }
1918 }{
1919 % false switch recursive
1920 #2
1921 }
1922 }
1923 % \end{macrocode}
1924 % \end{function}
1925 % \end{implementation}
1926
1927 % \begin{implementation}
1928 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\__tensorstyles_add_arrowCmd:nnn}
1929 % \begin{arguments}
1930 % \item |variant| grp-cmd(tensor) variant
1931 % \item |variable| on which the arrow command will be applied
1932 % \item |tensor order| to determine which arrow command apply
1933 % \end{arguments}
1934 % Apply an arrow-command according to the tensor-order on an input variable.
1935 % \changes{v1.0.1}{2025-02-12}{original version}
1936 % \TestFiles{tensorstyles-test-005}
1937 % \begin{macrocode}
1938
1939 % \__tensorstyles_add_arrowCmd:nnn #1= grp-cmd(tensor) variant, #2=variable, #3=tensor order
1940 \cs_new_protected:Npn \__tensorstyles_add_arrowCmd:nnn #1 #2 #3 {
1941 \bool_if:cTF {l__tensorstyles_tensor_#1_switch_arrows_bool} {
1942 % true switch arrow
1943 \prop_if_in:cnTF {l_tensorstyles_tensor_#1_arrow_cmd_prop} {#3} {
1944 % true
1945 \prop_item:cn {l_tensorstyles_tensor_#1_arrow_cmd_prop} {#3} {#2}
1946 }{
1947 % false
1948 false\ the\ order\ #3\ is\ not\ present\ in\ arrows\ option!
1949 \prop_show:c {l_tensorstyles_tensor_#1_arrow_cmd_prop}
1950 }
1951 }{
1952 % false switch arrow
1953 #2
1954 }
1955 }
1956
1957 % \end{macrocode}
1958 % \end{function}
1959 % \end{implementation}
1960
1961 % \begin{documentation}
1962 % \begin{function}{\MakeBoldUppercase, \MakeUpperBB, \MakeUpperCal, \MakeUpperFrak, \overdoubleleftrightarrow, \overrightleftrightarrow, \overrightdoubleleftrightarrow}
1963 % \begin{syntax}
1964 % \cs{MakeBoldUppercase, MakeUpperBB, MakeUpperCal, MakeUpperFrak, overdoubleleftrightarrow, overrightleftrightarrow, overrightdoubleleftrightarrow}\marg{variable}
1965 % \end{syntax}
1966 % Commands applying a combination of font commands or glyph (arrow) commands.
1967 % The combinations are quite explicit from the command names.
1968 % \end{function}
1969 % \end{documentation}
1970 %%%%
1971 % \begin{implementation}
1972 % \begin{function}[added= 2025-02-12, updated= 2025-02-12]{\MakeBoldUppercase, \MakeUpperBB, \MakeUpperCal, \MakeUpperFrak, \overdoubleleftrightarrow, \overrightleftrightarrow, \overrightdoubleleftrightarrow}
1973 % \begin{arguments}
1974 % \item |cmd| to apply recursively
1975 % \item |number| of occurrence to apply
1976 % \item |variable| on which the recursively command will be applied
1977 % \end{arguments}
1978 % Apply a given number of times a command on an input variable.
1979 % The input command (to apply) can only take one positional argument.
1980 % \changes{v1.0.1}{2025-02-12}{original version}
1981 % \TestFiles{tensorstyles-test-005}
1982 % \begin{macrocode}
1983 %
1984 % \RequirePackage{amsmath}% \overrightarrow
1985 % \RequirePackage{amssymb}% \curvearrowright
1986 % \RequirePackage{bm} % recommended for bold math
1987 %
1988 \DeclareDocumentCommand{\MakeBoldUppercase}{ m }{
1989 \mathbf{\MakeUppercase{#1}}
1990 }
1991 \DeclareDocumentCommand{\MakeUpperBB}{ m }{
1992 \mathbb{\MakeUppercase{#1}}
1993 }
1994 \DeclareDocumentCommand{\MakeUpperCal}{ m }{
1995 \mathcal{\MakeUppercase{#1}}
1996 }
1997 \DeclareDocumentCommand{\MakeUpperFrak}{ m }{
1998 {\mathfrak{\MakeUppercase{#1}}}
1999 }
2000 \DeclareDocumentCommand{\overdoubleleftrightarrow}{ m }{
2001 {\overleftrightarrow{\overleftrightarrow{#1}}}
2002 }
2003 \DeclareDocumentCommand{\overrightleftrightarrow}{ m }{
2004 {\overrightarrow{\overleftrightarrow{#1}}}
2005 }
2006 \DeclareDocumentCommand{\overrightdoubleleftrightarrow}{ m }{
2007 {\overrightarrow{\overleftrightarrow{\overleftrightarrow{#1}}}}
2008 }
2009 % \end{macrocode}
2010 % \end{function}
2011 % \end{implementation}
2012
2013 %
2014 %
2015 % %%%%% Generate variants %%%%%
2016 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2017 %
2018 %
2019 % \begin{implementation}
2020 % \begin{function}[added= 2025-02-17]{\__tensorstyles_set_scale:nnn}
2021 % \begin{arguments}
2022 % \item |grp-cmd_variant| for which the scaling will be set.
2023 % \item |scale| the desired scale, eg, auto or none or big or Big...
2024 % \item |delimiters-name| the name of the category of delimiters to scale.
2025 % \end{arguments}
2026 % Set the scale of a pair of delimiters .
2027 % \changes{v0.1.1.2}{2025-02-17}{original version}
2028 % \TestFiles{tensorstyles-test-005}
2029 % \begin{macrocode}
2030 % \tensorstyles_set_keys:nn #1:tensor, #2:keyval
2031 \cs_new_protected:Npn \tensorstyles_set_keys:nn #1 #2 {
2032 %
2033 \tl_set:Nx \l_tmpa_tl { \tl_use:c { l__tensorstyles_tensor_#1_preset } }
2034 \tl_set:Nx \l_tmpb_tl { \tl_use:c { l__tensorstyles_tensor_#1*_preset } }
2035 \use:c { __tensorstyles_tensor_define_local_preset_keys:n } { #1 }
2036 \keys_set:nn {tensorstyles/preset/#1} { #2 }
2037
2038 \tl_if_eq:cnF { l__tensorstyles_tensor_#1_local_preset } { None } {
2039 \tl_set:Nx \l_tmpa_tl { \tl_use:c { l__tensorstyles_tensor_#1_local_preset } }
2040 \tl_set:cx { l__tensorstyles_tensor_#1_preset } { \tl_use:c { l__tensorstyles_tensor_#1_local_preset } }
2041 }
2042
2043 \tl_if_eq:cnF { l__tensorstyles_tensor_#1*_local_preset } { None } {
2044 \tl_set:Nx \l_tmpb_tl { \tl_use:c { l__tensorstyles_tensor_#1*_local_preset } }
2045 \tl_set:cx { l__tensorstyles_tensor_#1*_preset } { \tl_use:c { l__tensorstyles_tensor_#1*_local_preset } }
2046 }
2047
2048 \seq_if_in:NnTF \l__tensorstyles_tensor_variant_seq { #1 } {
2049 % True tensor
2050 \prop_set_eq:cc { l__tensorstyles_tensor_#1_user_keys_prop } { c__tensorstyles_tensor_ \tl_use:N \l_tmpa_tl _pkg_keys_prop }
2051 \prop_set_eq:cc { l__tensorstyles_tensor_#1*_user_keys_prop } { c__tensorstyles_tensor_ \tl_use:N \l_tmpb_tl _pkg_keys_prop }
2052
2053 \__tensorstyles_set_default_from_keyval:nVnn { #1 } \l_tmpa_tl { #2 } { tensor }
2054 \__tensorstyles_set_default_from_keyval:nVnn { #1* } \l_tmpb_tl { #2 } { tensor }
2055 }{
2056 % False tensor
2057 \seq_if_in:NnTF \l__tensorstyles_i_variant_seq { #1 }{
2058 % True I
2059 \prop_set_eq:cc { l__tensorstyles_tensor_#1_user_keys_prop } { c__tensorstyles_i_ \tl_use:N \l_tmpa_tl _pkg_keys_prop }
2060 \prop_set_eq:cc { l__tensorstyles_tensor_#1*_user_keys_prop } { c__tensorstyles_i_ \tl_use:N \l_tmpb_tl _pkg_keys_prop }
2061
2062 \__tensorstyles_set_default_from_keyval:nVnn { #1 } \l_tmpa_tl { #2 } { i }
2063 \__tensorstyles_set_default_from_keyval:nVnn { #1* } \l_tmpb_tl { #2 } { i }
2064 } {
2065 % False I
2066 \msg_error:nnxx { tensorstyles } { tensor-not-defined }
2067 { \token_to_str:N #1 }
2068 { \token_to_str:N \tensorsset }
2069 }
2070 }
2071 }
2072 \cs_generate_variant:Nn \tensorstyles_set_keys:nn { V }
2073 % \cs_generate_variant:Nn \__tensorstyles_set_rubber_length:Nn { c }
2074 % \cs_generate_variant:Nn \__tensorstyles_var_bool_seq:NNN { c }
2075 % \end{macrocode}
2076 % \end{function}
2077 % \end{implementation}
2078
2079 %
2080 %
2081 % %%%%% Messages %%%%%
2082 % %%%%%%%%%%%%%%%%%%%%%%%%
2083 %
2084 % \begin{implementation}
2085 % \begin{function}[added= 2025-02-17]{messages}
2086 % Set the messages that can be emitted.
2087 % \changes{v0.1.1.2}{2025-02-17}{original version}
2088 % \begin{macrocode}
2089 % \msg_new:nnnn { tensorstyles } { command-already-defined }
2090 % { Command~'#1'~already~defined! }
2091 % {
2092 % You~have~used~#2~with~a~command~that~already~has~a~definition. \\
2093 % The~existing~definition~of~'#1'~will~not~be~altered.
2094 % }
2095 \msg_new:nnn { tensorstyles } { rank_indices_missmatch }
2096 { The~number~of~given~indices~and~rank~do~not~match~(#1) }
2097 \msg_new:nnn { tensorstyles } { index-type-option-not-define }
2098 { The~default-indices~is~only~accepting~contra~or~covariant~choice }
2099 \msg_new:nnn { tensorstyles } { index-style-option-not-defined }
2100 { Index~styles~(ie~contra-style~or~covariant-style)~on~accept~greek,~alph~or~arabic~choice }
2101 % \end{macrocode}
2102 % \end{function}
2103 % \end{implementation}
2104
2105 %
2106 %
2107 % %%%%% Declaring \& Generate %%%%%
2108 % %%%%% new group of commands %%%%%
2109 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2110 %
2111 % \begin{implementation}
2112 % \begin{macro}[added= 2025-02-17]{\tensorsset{all}}
2113 % First setup of the options for 'all' commands.
2114 % \changes{v0.1.1.2}{2025-02-17}{original version}
2115 % \TestFiles{tensorstyles-test-005}
2116 % \begin{macrocode}
2117 \@ifpackageloaded{mleftright}
2118 { \tensorsset{all}[scale-auto = mleftmright] }
2119 { \tensorsset{all}[scale-auto = leftright] }
2120 % \end{macrocode}
2121 % \end{macro}
2122 % \end{implementation}
2123 %
2124 % \begin{implementation}
2125 % \begin{macro}[added= 2025-02-17]{\DeclareTensorsCmd{\testCmd}}
2126 % Declare the official commands of the package: testCmd
2127 % \changes{v0.1.1.2}{2025-02-17}{original version}
2128 % \TestFiles{tensorstyles-test-005}
2129 % \begin{macrocode}
2130 \DeclareTensorsCmd{\tensor}[preset=full]
2131 % \end{macrocode}
2132 % \end{macro}
2133 % \end{implementation}
2134
2135 % \begin{implementation}
2136 % \begin{macrocode}
2137 \endinput
2138 %</package>
2139 % \end{macrocode}
2140 % \end{implementation}
2141
2142 %
2143 % \Finale