diff options
author | Norbert Preining <norbert@preining.info> | 2019-10-02 03:01:29 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-10-02 03:01:29 +0000 |
commit | d94b7a8c132734a1bc4046d54a75c7882c4c2619 (patch) | |
tree | 7326afd537da7739f5e5127da75d0766835e3c3e /macros | |
parent | 31d84cec65917cfc6ef446f1bf6031cff7c6dc7b (diff) |
CTAN sync 201910020301
Diffstat (limited to 'macros')
22 files changed, 1371 insertions, 752 deletions
diff --git a/macros/latex/contrib/embrac/README b/macros/latex/contrib/embrac/README index 477c644cbe..e07d2f2340 100644 --- a/macros/latex/contrib/embrac/README +++ b/macros/latex/contrib/embrac/README @@ -3,13 +3,13 @@ the EMBRAC package Upright Brackets in Emphasized Text -2017/07/04 v0.7 +2019/10/01 v0.8 -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/embrac/ E-Mail: contact@mychemistry.eu -------------------------------------------------------------------------- -Copyright 2012--2017 Clemens Niederberger +Copyright 2012--2019 Clemens Niederberger This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/macros/latex/contrib/embrac/embrac.sty b/macros/latex/contrib/embrac/embrac.sty index 2a5d12675b..279291a553 100644 --- a/macros/latex/contrib/embrac/embrac.sty +++ b/macros/latex/contrib/embrac/embrac.sty @@ -8,7 +8,7 @@ % Web: https://bitbucket.org/cgnieder/embrac/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012--2017 Clemens Niederberger +% Copyright 2012--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -34,14 +34,17 @@ \RequirePackage { expl3 , xparse , l3keys2e } \ProvidesExplPackage {embrac} - {2017/07/04} - {0.7} + {2019/10/01} + {0.8} {Upright Brackets in Emphasized Text} % -------------------------------------------------------------------------- \bool_new:N \l__embrac_treat_biblatex_bool -\tl_new:N \l__embrac_tmpa_tl -\tl_new:N \l__embrac_treat_biblatex_tl + +\tl_new:N \l__embrac_tmpa_tl +\tl_new:N \l__embrac_treat_biblatex_tl + +\int_new:N \l__embrac_penalty_int \keys_define:nn {embrac} { @@ -85,56 +88,102 @@ } } -\cs_new:Npn \embrac_nobreak: - { \tex_penalty:D \c_ten_thousand } +\cs_new_protected:Npn \embrac_nobreak: + { \embrac_allow_break:n {10000} } + +\cs_new_protected:Npn \embrac_allow_break:n #1 + { \tex_penalty:D #1 \scan_stop: } + +\cs_new_protected:Npn \embrac_save_penalty: + { \int_set:Nn \l__embrac_penalty_int { \lastpenalty } } % -------------------------------------------------------------------------- % THE MAIN PART: % storage of the tokens to be replaced: -\prop_new:N \l__embrac_emph_obrackets_symp_prop -\prop_new:N \l__embrac_emph_obrackets_prop -\prop_new:N \l__embrac_emph_obrackets_before_prop -\prop_new:N \l__embrac_emph_cbrackets_symp_prop -\prop_new:N \l__embrac_emph_cbrackets_prop -\prop_new:N \l__embrac_emph_cbrackets_after_prop - -\cs_new_protected:Npn \__embrac_replace:Nnnn #1#2#3#4 - { - \tl_replace_all:Nnn #1 {#3} +\prop_new:N \l__embrac_emph_obrackets_symbol_prop +\prop_new:N \l__embrac_emph_obrackets_inner_prop +\prop_new:N \l__embrac_emph_obrackets_outer_prop +\prop_new:N \l__embrac_emph_cbrackets_symbol_prop +\prop_new:N \l__embrac_emph_cbrackets_inner_prop +\prop_new:N \l__embrac_emph_cbrackets_outer_prop + +\bool_new:N \l__embrac_opening_bool + +% #1: tl macro +% #2: code before +% #3: kerning before +% #4: symbol +% #5: kerning after +% #6: code after +\cs_new_protected:Npn \__embrac_replace:Nnnnnn #1#2#3#4#5#6 + { + \tl_replace_all:Nnn #1 {#4} { \mode_if_math:TF - {#3} + {#4} { - \embrac_kern:n {#2} + #2 + \embrac_kern:n {#3} \embrac_nobreak: - \embrac_braces_format:n {#3} - \embrac_nobreak: - \embrac_kern:n {#4} + \embrac_braces_format:n {#4} \embrac_nobreak: + \embrac_kern:n {#5} + #6 } } } -\cs_generate_variant:Nn \__embrac_replace:Nnnn {Nxx,Nnxx} +\cs_generate_variant:Nn \__embrac_replace:Nnnnnn {Nnxx,Nnnxx} % do the replacing: +% #1: tl macro \cs_new_protected:Npn \embrac_replace_brackets:N #1 { - \prop_map_inline:Nn \l__embrac_emph_obrackets_prop + \prop_map_inline:Nn \l__embrac_emph_obrackets_inner_prop { - \__embrac_replace:Nxxn #1 - { \prop_item:Nn \l__embrac_emph_obrackets_before_prop {##1} } - { \prop_item:Nn \l__embrac_emph_obrackets_symp_prop {##1} } + \__embrac_replace:Nnxxnn #1 + { \embrac_allow_break:n { \lastpenalty } } + { \prop_item:Nn \l__embrac_emph_obrackets_outer_prop {##1} } + { \prop_item:Nn \l__embrac_emph_obrackets_symbol_prop {##1} } {##2} + { \embrac_nobreak: } } - \prop_map_inline:Nn \l__embrac_emph_cbrackets_prop + \prop_map_inline:Nn \l__embrac_emph_cbrackets_inner_prop { - \__embrac_replace:Nnxx #1 + \__embrac_replace:Nnnxxn #1 + { \embrac_save_penalty: \embrac_nobreak: } {##2} - { \prop_item:Nn \l__embrac_emph_cbrackets_symp_prop {##1} } - { \prop_item:Nn \l__embrac_emph_cbrackets_after_prop {##1} } + { \prop_item:Nn \l__embrac_emph_cbrackets_symbol_prop {##1} } + { \prop_item:Nn \l__embrac_emph_cbrackets_outer_prop {##1} } + { \embrac_allow_break:n { \l__embrac_penalty_int } } } } +\cs_new_protected:Npn \embrac_enparen:nnn #1#2#3 + { + \group_begin: + \embrac_allow_break:n { \lastpenalty } + \embrac_kern:n + { \prop_item:Nn \l__embrac_emph_obrackets_outer_prop {#1} } + \embrac_nobreak: + \embrac_braces_format:n + { \prop_item:Nn \l__embrac_emph_obrackets_symbol_prop {#1} } + \embrac_nobreak: + \embrac_kern:n + { \prop_item:Nn \l__embrac_emph_obrackets_inner_prop {#1} } + #3 + \embrac_save_penalty: \embrac_nobreak: + \embrac_kern:n + { \prop_item:Nn \l__embrac_emph_cbrackets_inner_prop {#2} } + \embrac_nobreak: + \embrac_braces_format:n + { \prop_item:Nn \l__embrac_emph_cbrackets_symbol_prop {#2} } + \embrac_nobreak: + \embrac_kern:n + { \prop_item:Nn \l__embrac_emph_cbrackets_outer_prop {#2} } + \embrac_allow_break:n { \l__embrac_penalty_int } + \group_end: + } + % -------------------------------------------------------------------------- % biblatex compatibility: \cs_new_protected:Npn \embrac_treat_bibparens: @@ -165,6 +214,7 @@ % redefine \emph and friends: \seq_new:N \l__embrac_changed_macros_seq +% #1: name of macro to be treated \cs_new_protected:Npn \embrac_new_replacement_macro:n #1 { \seq_put_right:Nn \l__embrac_changed_macros_seq {#1} @@ -230,24 +280,24 @@ % internal add commands: \cs_new_protected:Npn \embrac_add_op_to_emph:nnn #1#2#3 { - \prop_put:Nnn \l__embrac_emph_obrackets_symp_prop {#1} {#1} + \prop_put:Nnn \l__embrac_emph_obrackets_symbol_prop {#1} {#1} \embrac_empty_or_no_value:nTF {#2} - { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_prop {#1} {0pt} } - { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_prop {#1} {#2} } + { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_inner_prop {#1} {0pt} } + { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nTF {#3} - { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_before_prop {#1} {0pt} } - { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_before_prop {#1} {#3} } + { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_outer_prop {#1} {0pt} } + { \prop_put_if_new:Nnn \l__embrac_emph_obrackets_outer_prop {#1} {#3} } } \cs_new_protected:Npn \embrac_add_cl_to_emph:nnn #1#2#3 { - \prop_put:Nnn \l__embrac_emph_cbrackets_symp_prop {#1} {#1} + \prop_put:Nnn \l__embrac_emph_cbrackets_symbol_prop {#1} {#1} \embrac_empty_or_no_value:nTF {#2} - { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_prop {#1} {0pt} } - { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_prop {#1} {#2} } + { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_inner_prop {#1} {0pt} } + { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nTF {#3} - { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_after_prop {#1} {0pt} } - { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_after_prop {#1} {#3} } + { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_outer_prop {#1} {0pt} } + { \prop_put_if_new:Nnn \l__embrac_emph_cbrackets_outer_prop {#1} {#3} } } \cs_new_protected:Npn \embrac_add_to_emph:nnnnnn #1#2#3#4#5#6 @@ -259,14 +309,14 @@ % internal delete commands: \cs_new_protected:Npn \embrac_remove_op_from_emph:n #1 { - \prop_remove:Nn \l__embrac_emph_obrackets_prop {#1} - \prop_remove:Nn \l__embrac_emph_obrackets_before_prop {#1} + \prop_remove:Nn \l__embrac_emph_obrackets_inner_prop {#1} + \prop_remove:Nn \l__embrac_emph_obrackets_outer_prop {#1} } \cs_new_protected:Npn \embrac_remove_cl_from_emph:n #1 { - \prop_remove:Nn \l__embrac_emph_cbrackets_prop {#1} - \prop_remove:Nn \l__embrac_emph_cbrackets_after_prop {#1} + \prop_remove:Nn \l__embrac_emph_cbrackets_inner_prop {#1} + \prop_remove:Nn \l__embrac_emph_cbrackets_outer_prop {#1} } \cs_new_protected:Npn \embrac_remove_from_emph:nn #1#2 @@ -279,21 +329,21 @@ \cs_new_protected:Npn \embrac_renew_op_emph:nnn #1#2#3 { \embrac_empty_or_no_value:nTF {#2} - { \prop_put:Nnn \l__embrac_emph_obrackets_prop {#1} {0pt} } - { \prop_put:Nnn \l__embrac_emph_obrackets_prop {#1} {#2} } + { \prop_put:Nnn \l__embrac_emph_obrackets_inner_prop {#1} {0pt} } + { \prop_put:Nnn \l__embrac_emph_obrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nTF {#3} - { \prop_put:Nnn \l__embrac_emph_obrackets_before_prop {#1} {0pt} } - { \prop_put:Nnn \l__embrac_emph_obrackets_before_prop {#1} {#3} } + { \prop_put:Nnn \l__embrac_emph_obrackets_outer_prop {#1} {0pt} } + { \prop_put:Nnn \l__embrac_emph_obrackets_outer_prop {#1} {#3} } } \cs_new_protected:Npn \embrac_renew_cl_emph:nnn #1#2#3 { \embrac_empty_or_no_value:nTF {#2} - { \prop_put:Nnn \l__embrac_emph_cbrackets_prop {#1} {0pt} } - { \prop_put:Nnn \l__embrac_emph_cbrackets_prop {#1} {#2} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_inner_prop {#1} {0pt} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nTF {#3} - { \prop_put:Nnn \l__embrac_emph_cbrackets_after_prop {#1} {0pt} } - { \prop_put:Nnn \l__embrac_emph_cbrackets_after_prop {#1} {#3} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_outer_prop {#1} {0pt} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_outer_prop {#1} {#3} } } \cs_new_protected:Npn \embrac_renew_emph:nnnnnn #1#2#3#4#5#6 @@ -305,23 +355,23 @@ % internal change commands: \cs_new_protected:Npn \embrac_change_op_emph:nnn #1#2#3 { - \prop_if_in:NnT \l__embrac_emph_obrackets_prop {#1} + \prop_if_in:NnT \l__embrac_emph_obrackets_inner_prop {#1} { \embrac_empty_or_no_value:nF {#2} - { \prop_put:Nnn \l__embrac_emph_obrackets_prop {#1} {#2} } + { \prop_put:Nnn \l__embrac_emph_obrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nF {#3} - { \prop_put:Nnn \l__embrac_emph_obrackets_before_prop {#1} {#3} } + { \prop_put:Nnn \l__embrac_emph_obrackets_outer_prop {#1} {#3} } } } \cs_new_protected:Npn \embrac_change_cl_emph:nnn #1#2#3 { - \prop_if_in:NnT \l__embrac_emph_cbrackets_prop {#1} + \prop_if_in:NnT \l__embrac_emph_cbrackets_inner_prop {#1} { \embrac_empty_or_no_value:nF {#2} - { \prop_put:Nnn \l__embrac_emph_cbrackets_prop {#1} {#2} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_inner_prop {#1} {#2} } \embrac_empty_or_no_value:nF {#3} - { \prop_put:Nnn \l__embrac_emph_cbrackets_after_prop {#1} {#3} } + { \prop_put:Nnn \l__embrac_emph_cbrackets_outer_prop {#1} {#3} } } } @@ -423,6 +473,15 @@ \ignorespaces } +\NewDocumentCommand \embparen {+m} + { \embrac_enparen:nnn {(} {)} {#1} } + +\NewDocumentCommand \embbracket {+m} + { \embrac_enparen:nnn {[} {]} {#1} } + +\NewDocumentCommand \emb {mm+m} + { \embrac_enparen:nnn {#1} {#2} {#3} } + % -------------------------------------------------------------------------- % add some defaults and finalize package: \AddEmph{[}{]}[.04em,-.12em] @@ -432,7 +491,7 @@ \AtBeginDocument { \embrac_treat_bibemph: } -\tex_endinput:D +\file_input_stop: % -------------------------------------------------------------------------- % HISTORY @@ -457,3 +516,5 @@ 2016/01/07 - v0.6d - \prop_get:Nn => \prop_item:Nn 2017/07/04 - v0.7 - implement issue #8 (now treatment of symbols with catcode other than 12 is possible) +2019/10/01 - v0.8 - fix issue #9 + - new macros \embparen, \embbracket and \emb diff --git a/macros/latex/contrib/embrac/embrac_en.pdf b/macros/latex/contrib/embrac/embrac_en.pdf Binary files differindex 457f76889f..41adfcec3b 100644 --- a/macros/latex/contrib/embrac/embrac_en.pdf +++ b/macros/latex/contrib/embrac/embrac_en.pdf diff --git a/macros/latex/contrib/embrac/embrac_en.tex b/macros/latex/contrib/embrac/embrac_en.tex index ec1bfb379e..635475e443 100644 --- a/macros/latex/contrib/embrac/embrac_en.tex +++ b/macros/latex/contrib/embrac/embrac_en.tex @@ -12,7 +12,7 @@ % Web: https://bitbucket.org/cgnieder/embrac/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012--2017 Clemens Niederberger +% Copyright 2012--2019 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -40,6 +40,7 @@ AddEmph, ChangeEmph, DeleteEmph, + emb,embbracket,embparen, EmbracOff, EmbracOn, printbibliography, @@ -97,17 +98,6 @@ I like to thank both Dominik Waßenhoven for inspiration~\cite{dtk12-dw} and Bruno Le Floch for providing code~\cite{lefloch11}. Without either of them this package probably wouldn't exist. -\section{New} -\begin{description} - \item[v0.1a] The command \cs{RenewEmph} has been renamed into - \cs{ChangeEmph} and a new slightly different \cs{RenewEmph} has been added. - \item[v0.2] Improved interaction with \pkg{biblatex}. - \item[v0.3] Added support for \pkg*{fontspec}'s \cs{textsi}. - \item[v0.5] Don't replace brackets in math mode. - \item[v0.6] Added support for \cs{textsl}. - \item[v0.7] Added support for symbols with a catcode other than~12. -\end{description} - \section{About}\label{sec:about} \begin{cnltxquote}[{\cite[85]{bringhurst04}}] Parentheses and brackets are not letters, and it makes little sense to speak @@ -127,7 +117,6 @@ package probably wouldn't exist. from my [sic] bed}.\kern.05em} \end{cnltxquote} -\noindent Both this quote from~\citetitle{bringhurst04} by Robert Bringhurst and the article \citetitle{dtk12-dw} by Dominik Waßenhoven~\cite{dtk12-dw} inspired this package. Indeed, \embrac\ heavily borrows from the code @@ -341,5 +330,32 @@ Please be aware that \embrac\ does not affect \cs{itshape} nor \cs{em} (nor \begin{example} \itshape This is italic [sic] text. \end{example} +In cases like this one of the following commands could be used: +\begin{commands} + \command{emb}[\marg{op}\marg{cl}\marg{text}] + Encloses\sinceversion{v0.8} \meta{text} with \meta{op} and \meta{cl}. Both + \meta{op} and \meta{cl} must be brackets known to \embrac. + \command{embparen}[\marg{text}] + Encloses\sinceversion{v0.8} \meta{text} with upright parentheses. This is + the same as \cs{emb}\Marg{(}\Marg{)}\marg{text}. + \command{embbracket}[\marg{text}] + Encloses\sinceversion{v0.8} \meta{text} with upright brackets. This is + the same as \cs{emb}\Marg{[}\Marg{]}\marg{text}. +\end{commands} +\begin{example} + \itshape This is italic \embbracket{sic} text. +\end{example} + +\section{Version History} +\begin{description} + \item[v0.1a] The command \cs{RenewEmph} has been renamed into + \cs{ChangeEmph} and a new slightly different \cs{RenewEmph} has been added. + \item[v0.2] Improved interaction with \pkg{biblatex}. + \item[v0.3] Added support for \pkg*{fontspec}'s \cs{textsi}. + \item[v0.5] Don't replace brackets in math mode. + \item[v0.6] Added support for \cs{textsl}. + \item[v0.7] Added support for symbols with a catcode other than~12. + \item[v0.8] Added \cs{embparen}, \cs{embbracket} and \cs{emb}. +\end{description} \end{document} diff --git a/macros/latex/contrib/embrac/embrac_kerning_test.tex b/macros/latex/contrib/embrac/embrac_kerning_test.tex index ec1425c169..dbd52af477 100644 --- a/macros/latex/contrib/embrac/embrac_kerning_test.tex +++ b/macros/latex/contrib/embrac/embrac_kerning_test.tex @@ -1,4 +1,4 @@ -% arara: pdflatex +% arara: lualatex: { interaction: nonstopmode } % -------------------------------------------------------------------------- % the EMBRAC package % @@ -35,8 +35,8 @@ \usepackage{fontspec} % load desired font, for example: -% \usepackage{libertine} -\setmainfont{Minion Pro} +\usepackage{libertine} +% \setmainfont{Minion Pro} \usepackage{embrac} @@ -76,4 +76,4 @@ \emph{This is emphasized text (as you can see).} -\end{document}
\ No newline at end of file +\end{document} diff --git a/macros/latex/contrib/gindex/README.md b/macros/latex/contrib/gindex/README.md new file mode 100644 index 0000000000..ab045e6f42 --- /dev/null +++ b/macros/latex/contrib/gindex/README.md @@ -0,0 +1,30 @@ +## gindex + +This package provides a way to generate the format of index entries from within LaTeX. + +What it does is to generate blocks like this for each first-level entry: +``` +\setcounter{indexsubitems}{2}% +\indexitem{blah1}{1}% + \indexsubitem{subblah1}{3}% + \indexsubitem{subblah2}{5}% +\indexnoitem{}{}% +``` + +Then you can define `\indexitem` and the like to whatever you want. + +### Recent changes + +``` +0.1 2019-10-01 + - First released version, with the most basic tools. +``` + +License: MIT +________ +Javier Bezos --- http://www.texnia.com + + + + + diff --git a/macros/latex/contrib/gindex/gindex.ist b/macros/latex/contrib/gindex/gindex.ist new file mode 100644 index 0000000000..9200efe193 --- /dev/null +++ b/macros/latex/contrib/gindex/gindex.ist @@ -0,0 +1,42 @@ +% +% Copyright (C) 2019 Javier Bezos http://www.texnia.com +% +% 2019/10/01 v0.1 +% +% This file may be distributed and/or modified under the conditions of +% the MIT License. A version can be found at the end of this file. +% +% Repository: https://github.com/jbezos/gindex +% +% Required by gindex +% ------------------ + +item_0 "}\n\\addindexitem{" +item_1 "}\n \\addindexsubitem{" +item_01 "}\n \\addindexsubitem{" +item_x1 "}{}\n \\addindexsubitem{" +item_2 "}\n \\addindexsubsubitem{" +item_12 "}\n \\addindexsubsubitem{" +item_x2 "}{}\n \\addindexsubsubitem{" +delim_0 "}{" +delim_1 "}{" +delim_2 "}{" +group_skip "}\n%\n\\addindexskip{" +heading_prefix "}\n%\n\\addindexheading{" +heading_suffix "}\n%\n{" +preamble "\\begin{theindex}\\indexpreamble\n\n{" +postamble "}\n\\indexpostamble\\end{theindex}" +indent_space "" +indent_length 0 +delim_r "{\\indexrangesep}" + +% Modify to fit your own requirements +% ----------------------------------- + +headings_flag -1 % Usually redefining \indexheading is better +actual '@' +quote '"' +level '!' +page_precedence "rnaRA" +keyword "\\indexentry" +delim_n ", "
\ No newline at end of file diff --git a/macros/latex/contrib/gindex/gindex.pdf b/macros/latex/contrib/gindex/gindex.pdf Binary files differnew file mode 100644 index 0000000000..f2c092f75d --- /dev/null +++ b/macros/latex/contrib/gindex/gindex.pdf diff --git a/macros/latex/contrib/gindex/gindex.sty b/macros/latex/contrib/gindex/gindex.sty new file mode 100644 index 0000000000..36311da7f9 --- /dev/null +++ b/macros/latex/contrib/gindex/gindex.sty @@ -0,0 +1,99 @@ +% +% Copyright (C) 2019 Javier Bezos http://www.texnia.com +% +% This file may be distributed and/or modified under the conditions of +% the MIT License. A version can be found at the end of this file. +% +% Repository: https://github.com/jbezos/gindex +% + +\ProvidesPackage{gindex}[2019/10/01 v0.1 Formatting indexes] + +\newcounter{indexsubitems} + +\let\esx@save\@empty +\let\indexnoitem\@gobbletwo + +\def\addindexitem#1#2{% + \esx@save + \indexnoitem{}{}% + \setcounter{indexsubitems}{0}% + \let\esx@save\@empty + \g@addto@macro\esx@save{\indexitem{#1}{#2}}} + +\def\addindexskip#1{% + \esx@save + \indexnoitem{}{}% + \setcounter{indexsubitems}{0}% + \let\esx@save\@empty + \indexskip{#1}} + +\def\addindexheading#1{% + \esx@save + \indexnoitem{}{}% + \setcounter{indexsubitems}{0}% + \let\esx@save\@empty + \indexheading{#1}} + +\def\addindexsubitem#1#2{% + \stepcounter{indexsubitems}% + \g@addto@macro\esx@save{\indexsubitem{#1}{#2}}} + +\def\addindexsubsubitem#1#2{% + \g@addto@macro\esx@save{\indexsubsubitem{#1}{#2}}} + +\newcommand\indexitem[2]{\item #1\ifx\\#2\\\else, #2\fi} +\newcommand\indexsubitem[2]{\subitem #1\ifx\\#2\\\else, #2\fi} +\newcommand\indexsubsubitem[2]{\subsubitem #1\ifx\\#2\\\else, #2\fi} + +\newcommand\indexitemhang[6]{% + \par\hangindent#2\relax + \ifdim#1=0pt\relax\else + \hspace*{#1}% + \fi + #5% + \ifx\@empty#6\@empty + #3% + \else + #4#6% + \fi} + +\ifx\indexspace\@undefined + \newcommand\indexskip[1]{\par\vskip10\p@\@plus5\p@\@minus3\p@\relax} +\else + \newcommand\indexskip[1]{\indexspace} +\fi +\newcommand\indexheading[1]{% + {\bfseries\hfil + \MakeUppercase{#1}% + \hfil}% + \nopagebreak} + +\let\indexpreamble\relax +\let\indexpostamble\relax + +\def\indexrangesep{-} + +\endinput + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/macros/latex/contrib/gindex/gindex.tex b/macros/latex/contrib/gindex/gindex.tex new file mode 100644 index 0000000000..c240281dfd --- /dev/null +++ b/macros/latex/contrib/gindex/gindex.tex @@ -0,0 +1,184 @@ +% +% Copyright (C) 2019 Javier Bezos http://www.texnia.com +% +% This file may be distributed and/or modified under the conditions of +% the MIT License. A version can be found at the end of this file. +% +% Repository: https://github.com/jbezos/esindex +% + +\documentclass[a4paper]{ltxguide} + +\title{\textsf{gindex}\\\large Version 0.1} + +\author{Javier Bezos\\\texttt{http://www.texnia.com}} + +\date{2019-10-01} + +\raggedright +\parskip=.8ex +\advance\oddsidemargin-.7cm +\advance\textwidth2cm +\addtolength{\textheight}{3.5cm} +\addtolength{\topmargin}{-2cm} + +\usepackage{xcolor,bera} + +\definecolor{notes}{rgb}{.75, .3, .3}% + +\makeatletter +\def\@begintheorem#1#2{% + \list{}{}% + \global\advance\@listdepth\m@ne + \item[{\sffamily\bfseries\color{notes}\MakeUppercase{#1}}]}% +\makeatother +\newtheorem{warning}{Warning} +\newtheorem{note}{Note} +\newtheorem{example}{Example} + +\begin{document} + +\vspace*{1cm} +{\fontsize{48}{48}\selectfont \color{notes}{gindex}\par} +{\LARGE Formatting indexes with \LaTeX\par} +\vspace*{1ex} +Version 0.1 (2019-10-01)\par +Javier Bezos (\texttt{http://www.texnia.com}) + +\vspace*{6ex} + +This package works in conjunction with a \textit{\bfseries g}eneric +\verb|ist| file, which provides a way to \textit{\bfseries g}enerate +the format of index entries from within \LaTeX. With standard classes, +it works out of the box with some predefined values, which you can (and +in fact should) redefine with |\renewcommand|. + +Note it is version 0.1. Changes of the existing features are unlikely +to happen (but who knows), but new features, on the other hand, will be +added in the near future. + +What it does is to generate blocks like this for each first-level entry: +\begin{verbatim} + \setcounter{indexsubitems}{2}% The number of subitems + \indexitem{blah1}{1}% + \indexsubitem{subblah1}{3}% + \indexsubitem{subblah2}{5}% + \indexnoitem{}{}% Usually dummy +\end{verbatim} + +As you can see, when |\indexitem| is executed, you know the number of +subitems, which is necessary for some styles. + +The default values are: +\begin{verbatim} +\newcommand\indexitem[2]{\item #1\ifx\\#2\\\else, #2\fi} +\newcommand\indexsubitem[2]{\subitem #1\ifx\\#2\\\else, #2\fi} +\newcommand\indexsubsubitem[2]{\subsubitem #1\ifx\\#2\\\else, #2\fi} +\end{verbatim} +For example, to replace the comma by a quad: +\begin{verbatim} +\renewcommand\indexitem[2]{\item #1\ifx\\#2\\\else\quad #2\fi} +\end{verbatim} + +It is guaranteed that these command can take up to 5 arguments. If you +define |\indexitem| with all of them, the parameters in the previous +example will be: +\begin{enumerate} + \item |blah1| + \item |1| + \item |\indexsubitem| + \item |subblah1| + \item |3| +\end{enumerate} +This explains the line |\indexnoitem{}{}| above, which by default does +nothing. By inspecting the third parameter you decide how to format the +current parameter (of course, in most cases you must emit it again at +the end of your definition of |\indexitem|). + +Subsubitems are allowed, but not counted. Only subitems are counted. + + +There is a tool to define the most usual entry format, which is used in +the following way: +\begin{verbatim} +\renewcommand\indexitem[2]{% + \indexitemhang{0pt}% First line left margin + {10pt}% Second, third... lines left margin + {}% After entry if no locator + {: }% Entry-locator separator + {#1}% Entry + {#2}}% Locator +\end{verbatim} + +Other macros are: +\begin{itemize} +\item \verb|\indexpreamble|, executed just after + \verb|\begin{theindex}| (\verb|\relax| by default). +\item \verb|\indexpostamble|, executed before + \verb|\end{theindex}| (\verb|\relax| by default). +\item \verb|\indexskip|, which is \verb|\indexspace| by default, +with similar purpose. +\item \verb|\indexheading|, is defined as follows: +\begin{verbatim} +\newcommand\indexheading[1]{% + {\bfseries\hfil + \MakeUppercase{#1}% + \hfil}% + \nopagebreak} +\end{verbatim} +\item \verb|\indexrangesep|, which by default is |-|. +\end{itemize} + +Remember to set the style to |gindex| when running \textsf{makeindex}: +\begin{verbatim} + makeindex -s gindex yourfile +\end{verbatim} + +Note also there is no need to run \textsf{makeindex} to fine tune the +format. + +\section{Internals} + +The |ind| files is generated by |gindex.ist| with generic macros like: +\begin{verbatim} + \addindexitem{bla1}{1} + \addindexsubitem{subbla1}{3} + \addindexsubitem{subbla2}{5} +\end{verbatim} +What \textsf{gindex} does is to convert them to the above format. Some +parameters should be cuntomized in the |ist| file, however. These are: +\begin{verbatim} +headings_flag -1 +actual '@' +quote '"' +level '!' +page_precedence "rnaRA" +keyword "\\indexentry" +delim_n ", " +\end{verbatim} +As to |headings_flag|, the recommended way to deal with case is with +|\indexheading|. + +\end{document} + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/macros/latex/contrib/nicematrix/README.md b/macros/latex/contrib/nicematrix/README.md index aadca62b15..056f0d84a4 100644 --- a/macros/latex/contrib/nicematrix/README.md +++ b/macros/latex/contrib/nicematrix/README.md @@ -12,7 +12,7 @@ The LaTeX extension `nicematrix` is distributed under the LPPL 1.3 license. The LaTeX package `nicematrix` provides new environments similar to the classical environments `{array}` and `{matrix}` but with some additional features. Among these features are the possibilities to fix the width of the columns, to draw continuous ellipsis dots between the cells -of the array and to add an exterior line and an exterior column. +of the array and to add exterior rows and columns (so called 'border matrices'). ## Installation diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf Binary files differindex 735084e1e5..8829f14771 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.pdf +++ b/macros/latex/contrib/nicematrix/nicematrix-french.pdf diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex index 5d6e573f66..fa07724b59 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -1,4 +1,4 @@ -\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) +\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) \usepackage{xltxtra} \usepackage[french]{babel} @@ -212,8 +212,7 @@ des raisons techniques, dans le préambule de l'environnement |{NiceArray}|, l'u |W{...}{...}|\footnote{Pour les colonnes de type |w| et |W|, les cases sont composées en mode mathématique (dans les environnements de \pkg{nicematrix}) alors que dans |{array}| de \pkg{array}, elles sont composées en mode texte.}, \verb+|+, |>{...}|, |<{...}|, |@{...}|, |!{...}| et |*{n}{...}| mais les lettres |p|, |m| et |b| ne -doivent pas être employées. L'environnement |{NiceArray}| et ses variantes fournissent des options qui permettent -de tracer des rangées et colonnes extérieures. Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}|. +doivent pas être employées. Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}|. \section{Les lignes en pointillés continues} @@ -316,7 +315,8 @@ $\begin{bNiceMatrix} \bigskip Il y a aussi d'autres moyens de changer la taille d'une matrice. On pourrait vouloir utiliser l'argument optionnel de la commande~|\\| pour l'espacement vertical et la commande~|\hspace*| dans une case pour l'espacement -horizontal.\footnote{On peut aussi régler la largeur des colonnes en utilisant l'environnement |{NiceArray}| (ou +horizontal.\footnote{Dans \pkg{nicematrix}, il faut utiliser |\hspace*| et non |\hspace| car \pkg{nicematrix} + utilise \pkg{array}. Remarquons aussi que l'on peut également régler la largeur des colonnes en utilisant l'environnement |{NiceArray}| (ou une de ses variantes) avec une colonne de type~|w| ou |W|: cf. p.~\pageref{width}} Toutefois, une commande~|\hspace*| pourrait interférer dans la construction des lignes en pointillés. C'est @@ -501,10 +501,11 @@ même rangée que |\Hdotsfor|). \subsection{Comment créer les lignes en pointillés de manière transparente} L'extension \pkg{nicematrix} fournit une option appelée |transparent| qui permet d'utiliser du code existant de -manière transparente dans les environnements |{matrix}|. Cette option peut être passée en option du |\usepackage| -ou bien être fixée avec la commande |\NiceMatrixOptions|. - -En fait, cette option est un alias pour la conjonction de deux options : |renew-dots| et |renew-matrix|. +manière transparente dans les environnements de l'\pkg{amsmath} : |{matrix}|, |{pmatrix}|, |{bmatrix}|, etc. En +fait, cette option est un alias pour la conjonction de deux options : |renew-dots| et +|renew-matrix|.\footnote{Comme toutes les autres options, les options |renew-dots|, |renew-matrix| et |transparent| + peuvent être fixées avec la commande |\NiceMatrixOptions|, mais elles peuvent aussi être passées en options du + |\usepackage| (ce sont les trois seules).} \smallskip @@ -800,8 +801,8 @@ Il existe également des variantes pour l'environnement |{NiceArray}| : |{pNiceA |{BNiceArray}|, |{vNiceArray}| et |{VNiceArray}|. -Dans l'exemple suivant, on utilise un environnment |{pNiceArray}| (on n'utilise pas |{pNiceMatrix}| car on souhaite -utiliser les types de colonne |L| et |R| --- avec |{pNiceMatrix}|, toutes les colonnes sont de type |C|). +Dans l'exemple suivant, on utilise un environnement |{pNiceArray}| (on n'utilise pas |{pNiceMatrix}| car on +souhaite utiliser les types de colonne |L| et |R| --- avec |{pNiceMatrix}|, toutes les colonnes sont de type |C|). \bigskip @@ -820,42 +821,81 @@ a_{21} & & a_{2n} \\ a_{n-1,1} & \Cdots & a_{n-1,n} \end{pNiceArray}$ -\vspace{1cm} -L'environnement |{NiceArray}| et ses variantes permettent de composer des rangées et des colonnes «extérieures» grâce aux options + +\bigskip +\bigskip +En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé +|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche +et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}| +si on a besoin de délimiteurs atypiques. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{~emphase#NiceArrayWithDelims@} + {\downarrow}{\downarrow}{CCC} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{~emphase#NiceArrayWithDelims@}$ +\end{BVerbatim} +$\begin{NiceArrayWithDelims} + {\downarrow}{\downarrow}{CCC} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{NiceArrayWithDelims}$ + + + +\bigskip +\section{Les rangées et colonnes extérieures} +Les environnements de \pkg{nicematrix} permettent de composer des rangées et des colonnes «extérieures» grâce aux options |first-row|, |last-row|, |first-col| et |last-col|. \label{exterior} -Il n'y a pas de spécification de colonne à fournir pour l'éventuelle «première colonne» (qui sera automatiquement -une colonne de type |R|) ou pour l'éventuelle «dernière colonne» (qui sera automatiquement de type |L|). - +Si elle est présente, la première rangée est numérotée par $0$ (et non $1$). Il en est de même pour la première +colonne. Dans le cas général, on doit spécifier le numéro de la dernière rangée et de la dernière colonne (si elles +sont présentes). \begin{Verbatim} -$\begin{pNiceArray}{CCCC}[~emphase#first-row,last-row,first-col,last-col@] +$\begin{pNiceMatrix}[~emphase#first-row,last-row=5,first-col,last-col=5@] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ & C_1 & C_2 & C_3 & C_4 & -\end{pNiceArray}$ +\end{pNiceMatrix}$ \end{Verbatim} % -\[\begin{pNiceArray}{CCCC}[first-row,last-row,first-col,last-col] +\[\begin{pNiceMatrix}[first-row,last-row=5,first-col,last-col=5] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ & C_1 & C_2 & C_3 & C_4 & -\end{pNiceArray}\] +\end{pNiceMatrix}\] \bigskip -Néanmoins, il y a une particularité avec l'option |last-row| : quand LaTeX compose un tableau |{array}| (via une -commande |\halign| de TeX), il le compose rangée par rangée et il n'y a pas de moyen direct de savoir que l'on est -arrivé à la dernière rangée avant la composition de celle-ci. Pour remédier à ce problème, \pkg{nicematrix} écrit -dans le fichier |aux| le nombre de rangées du tableau pour pouvoir l'utiliser à la compilation suivante. Il est -néanmoins également possible de passer directement le nombre de rangées en argument de l'option |last-row| et, -ainsi, \pkg{nicematrix} le connaîtra dès la première compilation. +Il y a plusieurs remarques à formuler. +% +\begin{itemize} +\item Si on utilise un environnement avec préambule explicite (c'est-à -dire |{NiceArray}| ou l'une de ses +variantes), on ne doit pas mettre de spécification de colonne pour les éventuelles première et dernière colonne : +la première colonne sera automatiquement (et nécessairement) de type |R| et la dernière de type |L|). + +\item Si on utilise un environnement avec préambule explicite et une dernière colonne, on doit utiliser l'option +|last-col| \emph{sans} valeur. En effet le numéro de la dernière colonne est, dans ce cas, déduit du préambule (qui +contient nécessairement l'information du nombre de colonnes non extérieures). + +\item Pour une dernière rangée, l'option |last-row| peut en fait être utilisée sans préciser de valeur. Dans ce +cas, \pkg{nicematrix} détermine, lors de la première compilation, le nombre de rangées rencontrées dans le tableau +et l'écrit dans le fichier |.aux| pour la prochaine compilation. Dans l'exemple qui suit, l'option |last-row| sera +utilisée sans valeur explicite. +\end{itemize} + + \bigskip On peut contrôler l'apparence de ces rangées et colonnes avec les options |code-for-first-row|, @@ -867,7 +907,7 @@ insérées au début de chaque case de la rangée ou de la colonne considérée. ~emphase#code-for-first-col@ = \color{blue}, ~emphase#code-for-last-row@ = \color{green}, ~emphase#code-for-last-col@ = \color{magenta}} -$\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col] +$\begin{pNiceArray}{CC|CC}[first-row,last-row,first-col,last-col] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ @@ -884,7 +924,7 @@ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ code-for-last-row = \color{green}, code-for-last-col = \color{magenta}} \begin{displaymath} -\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col] +\begin{pNiceArray}{CC|CC}[first-row,last-row,first-col,last-col] & C_1 & \multicolumn1C{C_2} & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ @@ -907,9 +947,6 @@ tableau) ne s'étend pas dans les rangées extérieures.\footnote{Ce dernier poi sont pas parfaitement compatibles car \pkg{arydshln} redéfinit beaucoup de structures internes à \pkg{array}. Par ailleurs, si on veut vraiment un filet qui s'étende dans la première et la dernière rangée, on peut utiliser |!{\vline}| dans le préambule à la place de \verb+|+.} -\item La «première rangée» d'un environnement |{pNiceArray}| porte le numéro $0$, et non $1$ (de même pour la -«première colonne»). Ce numéro est utilisé, par exemple, pour les noms des nœuds Tikz (les noms de ces nœuds sont -utilisés, par exemple, par la commande |\line| dans le |code-after|). \item Sans surprise, une éventuelle option |columns-width| (décrite p.~\pageref{width}) ne s'applique pas à la «première colonne» ni à la «dernière colonne». \item Pour des raisons techniques, il n'est pas possible d'utiliser l'option de la commande |\\| après la @@ -917,28 +954,6 @@ utilisés, par exemple, par la commande |\line| dans le |code-after|). \end{itemize} -\bigskip -En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé -|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche -et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}| -si on a besoin de délimiteurs atypiques. - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=11cm] -$\begin{~emphase#NiceArrayWithDelims@} - {\downarrow}{\downarrow}{CCC}[last-col] -1 & 2 & 3 & L_1 \\ -4 & 5 & 6 & L_2 \\ -7 & 8 & 9 & L_3 -\end{~emphase#NiceArrayWithDelims@}$ -\end{BVerbatim} -$\begin{NiceArrayWithDelims} - {\downarrow}{\downarrow}{CCC}[last-col] -1 & 2 & 3 & L_1 \\ -4 & 5 & 6 & L_2 \\ -7 & 8 & 9 & L_3 -\end{NiceArrayWithDelims}$ - @@ -1065,8 +1080,8 @@ $\begin{pNiceArray}{Wc{1cm}CC} \bigskip -Avec \pkg{nicematrix}, il est aussi possible de fixer la largeur de toutes les colonnes de la matrice directement -avec l'option |columns-width| (disponible dans tous les environnements de \pkg{nicematrix}). +Dans les environnements de \pkg{nicematrix}, il est aussi possible de fixer la largeur de toutes les colonnes de la +matrice directement avec l'option |columns-width|. \medskip \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1088,8 +1103,9 @@ possible de le supprimer en mettant |\arraycolsep| à ~$0$). \bigskip Il est possible de donner la valeur |auto| à l'option |columns-width| : toutes les colonnes du tableau -auront alors une largeur égale à la largeur de la case la plus large du tableau. \textbf{Deux ou trois - compilations successives peuvent être nécessaires.}\par\nobreak +auront alors une largeur égale à la largeur de la case la plus large du tableau.\footnote{Le résultat est atteint +dès la première compilation (mais Tikz écrivant des informations dans le fichier |.aux|, un message demandant une +deuxième compilation apparaîtra).}\par\nobreak \medskip \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1159,9 +1175,12 @@ $\begin{pNiceMatrix} = \begin{pNiceMatrix} 1 & 1245 \\ 345 & 2 - \end{pNiceMatrix}$ +\end{pNiceMatrix}$ \end{NiceMatrixBlock} +\medskip +\textbf{Plusieurs compilations peuvent être nécessaires pour obtenir le résultat désiré.} + \section{Les matrices par blocs} Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 684b34c5b4..44a38c9a0b 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{3.2a} -\def\myfiledate{2019/09/21} +\def\myfileversion{3.3} +\def\myfiledate{2019/10/01} % % %<*batchfile> @@ -211,7 +211,7 @@ c & c & b & a & e % \{VNiceMatrix\} & & \{NiceArrayWithDelims\} \\ % \end{tabular} % \end{ttfamily} -%b +% % % \medskip % By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, @@ -229,9 +229,8 @@ c & c & b & a & e % |W|, the cells are composed in math mode (in the environments of % \pkg{nicematrix}) whereas in |{array}| of \pkg{array}, they are composed in text mode.}, "|", % |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, -% |m| and |b| should not be used. The environment |{NiceArray}| and its variants -% provide also options to draw exterior rows and columns. See p.~\pageref{NiceArray} -% the section relating to |{NiceArray}| +% |m| and |b| should not be used. See p.~\pageref{NiceArray} the section +% relating to |{NiceArray}|. % % % \section{The continuous dotted lines} @@ -337,13 +336,15 @@ c & c & b & a & e % 0 & & \Cdots & 0 % \end{bNiceMatrix}$ % -% \bigskip e +% \bigskip % There are also other means to change the size of the matrix. Someone might % want to use the optional argument of the command~|\\| for the vertical % dimension and a command~|\hspace*| in a cell for the horizontal -% dimension.\footnote{It's also possible to fix the width of a column -% by using the environment |{NiceArray}| (or one of its variants) with a column of -% type~|w| or~|W|: see p.~\pageref{width}} +% dimension.\footnote{In \pkg{nicematrix}, one should use |\hspace*| and not +% |\hspace| for such an usage because \pkg{nicematrix} loads \pkg{array}. One +% may also remark that it's possible to fix the width of a column by using the +% environment |{NiceArray}| (or one of its variants) with a column of type~|w| +% or~|W|: see p.~\pageref{width}} % % However, a command~|\hspace*| might interfer with the construction of the % dotted lines. That's why the package \pkg{nicematrix} provides a @@ -534,12 +535,14 @@ c & c & b & a & e % \subsection{How to generate the continuous dotted lines transparently} % % The package \pkg{nicematrix} provides an option called |transparent| for using -% existing code transparently in the environments |{matrix}|. This option can be -% set as option of |\usepackage| or with the command |\NiceMatrixOptions|. -% -% -% In fact, this option is an alias for the conjonction of two options: -% |renew-dots| and |renew-matrix|. +% existing code transparently in the environments of the \pkg{amsmath} : +% |{matrix}|, |{pmatrix}|, |{bmatrix}|, etc. In fact, this +% option is an alias for the conjonction of two options: +% |renew-dots| and |renew-matrix|.\footnote{The options |renew-dots|, +% |renew-matrix| and |transparent| can be fixed with the command +% |\NiceMatrixOptiosn| like the other options. However, they can also be fixed +% as options of the command |\usepackage| (it's an exception for these three +% specific options.)} % % \smallskip % @@ -869,46 +872,78 @@ c & c & b & a & e % \end{pNiceArray}$ % % -% \vspace{1cm} -% With the environment |{NiceArray}| and its the variants, it's possible to -% compose exterior rows and columns with the options |first-row|, |last-row|, -% |first-col| and |last-col|. +% \bigskip +% In fact, the environment |{pNiceArray}| and its variants are based upon a +% more general environment, called |{NiceArrayWithDelims}|. The first two +% mandatory arguments of this environment are the left and right delimiters used +% in the construction of the matrix. It's possible to use +% |{NiceArrayWithDelims}| if we want to use atypical delimiters. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{~emphase#NiceArrayWithDelims@} +% {\downarrow}{\downarrow}{CCC} +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{~emphase#NiceArrayWithDelims@}$ +% \end{BVerbatim} +% $\begin{NiceArrayWithDelims} +% {\downarrow}{\downarrow}{CCC} +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{NiceArrayWithDelims}$ +% +% +% \bigskip +% \section{The exterior row and columns} +% The options |first-row|, |last-row|, |first-col| and |last-col| allow the +% composition of exterior rows and columns in the environments of \pkg{nicematrix}. % \label{exterior} % -% There is no specification of column to provide for the potential ``first -% column'' (it will automatically be a |R| column) and for the potential ``last -% column'' (it will automatically be a |L| column). +% A potential first row has the number $0$ (and not $1$). Idem for the potential +% first column. In general cases, one must specify the number of the last row +% and the number of the last column as values of |last-row| and |last-col|. % % \begin{Verbatim} -% $\begin{pNiceArray}{CCCC}[~emphase#first-row,last-row,first-col,last-col@] +% $\begin{pNiceMatrix}[~emphase#first-row,last-row=5,first-col,last-col=5@] % & C_1 & C_2 & C_3 & C_4 & \\ % L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ % L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ % L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ % L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ % & C_1 & C_2 & C_3 & C_4 & -% \end{pNiceArray}$ +% \end{pNiceMatrix}$ % \end{Verbatim} % -% \[\begin{pNiceArray}{CCCC}[first-row,last-row,first-col,last-col] +% \[\begin{pNiceMatrix}[first-row,last-row=5,first-col,last-col=5] % & C_1 & C_2 & C_3 & C_4 & \\ % L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ % L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ % L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ % L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ % & C_1 & C_2 & C_3 & C_4 & -% \end{pNiceArray}\] +% \end{pNiceMatrix}\] % % \bigskip -% However, there is a particularity for the option |last-row|: when LaTeX -% composes an array (with the TeX command |\halign|) it composes it row by row -% and there is no direct way to know if we are at the last row before the -% composition of that row. That's why \pkg{nicematrix} writes in the |aux| file -% the number of rows of the array in order to use it at the next run. -% Nevertheless, it's possible to give directly the number of rows as the value -% of the key |last-row|. It that way, \pkg{nicematrix} will know the correct -% value by the first compilation. -% +% We have several remarks to do. +% \begin{itemize} +% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and +% its variants), no letter must be given in the preamble for the potential first +% column and the potential last column: the first column will be automatically +% (and necessarily) of type |R| and the last column will be automatically of +% type |L|). +% \item In an environment with an explicit preamble, the option |last-col| must +% be used \emph{without} value: the number of columns will be automatically +% computed from the preamble of the array. +% \item For the potential last row, the option |last-row| may, in fact, be used +% without value. In this case, \pkg{nicematrix} computes, during the first +% compilation, the number of row of the array and writes that information in the +% |.aux| file for the second run. In the following example, the option +% |last-row| will be used without value. +% \end{itemize} +% % \bigskip % It's possible to control the appearance of these rows and columns with options % |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and @@ -961,10 +996,6 @@ c & c & b & a & e % \pkg{array}. On another note, if one really wants a vertical rule running in % the first and in the last row, he should use |!{\vline}| instead of \verb+|+ % in the preamble of the array.} -% \item The ``first row'' of an environment |{pNiceArray}| has the number $0$, and not -% $1$. Idem for the ``first column''. This number is used for the names of the Tikz -% nodes (the names of these nodes are used, for example, by the command |\line| -% in |code-after|). % \item Logically, the potential option |columns-width| (described % p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. % \item For technical reasons, it's not possible to use the option of the command |\\| @@ -975,30 +1006,6 @@ c & c & b & a & e % % % -% \bigskip -% In fact, the environment |{pNiceArray}| and its variants are based upon a -% more general environment, called |{NiceArrayWithDelims}|. The first two -% mandatory arguments of this environment are the left and right delimiters used -% in the construction of the matrix. It's possible to use -% |{NiceArrayWithDelims}| if we want to use atypical delimiters. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{~emphase#NiceArrayWithDelims@} -% {\downarrow}{\downarrow}{CCC}[last-col] -% 1 & 2 & 3 & L_1 \\ -% 4 & 5 & 6 & L_2 \\ -% 7 & 8 & 9 & L_3 -% \end{~emphase#NiceArrayWithDelims@}$ -% \end{BVerbatim} -% $\begin{NiceArrayWithDelims} -% {\downarrow}{\downarrow}{CCC}[last-col] -% 1 & 2 & 3 & L_1 \\ -% 4 & 5 & 6 & L_2 \\ -% 7 & 8 & 9 & L_3 -% \end{NiceArrayWithDelims}$ -% -% % % \section{The dotted lines to separate rows or columns} % @@ -1122,8 +1129,8 @@ c & c & b & a & e % % % \bigskip -% It's also possible to fix the width of all the columns of a matrix directly -% with the option |columns-width| (in all the environments of \pkg{nicematrix}). +% In the environments of \pkg{nicematrix}, it's also possible to fix the width +% of all the columns of a matrix directly with the option |columns-width|. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1146,8 +1153,10 @@ c & c & b & a & e % % \bigskip % It's possible to give the value |auto| to the option |columns-width|: all the -% columns of the array will have a width equal to the widest cell of the array. -% \textbf{Two or three compilations may be necessary.}\par\nobreak +% columns of the array will have a width equal to the widest cell of the +% array.\footnote{The result is achieved with only one compilation (but Tikz +% will have written informations in the |.aux| file and a message requiring a +% second compilation will appear).}\par\nobreak % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1221,6 +1230,10 @@ c & c & b & a & e % \end{pNiceMatrix}$ % \end{NiceMatrixBlock} % +% \medskip +% \textbf{Several compilations may be necessary to achieve the job.} +% +% % \section{Block matrices} % % In the environments of \pkg{nicematrix}, it's possible to use the command @@ -1258,11 +1271,12 @@ c & c & b & a & e % \end{scope} % % \bigskip -% One may wish raise the size of the ``$A$'' placed in the block of the previous -% example. Since this element is composed in math mode, it's not possible to use -% directly a command like |\large|, |\Large| and |\LARGE|. That's why the command -% |\Block| provides an option between angle brackets to specificy some TeX code -% which will be inserted before the beginning of the math mode. +% One may wish to raise the size of the ``$A$'' placed in the block of the +% previous example. Since this element is composed in math mode, it's not +% possible to use directly a command like |\large|, |\Large| and |\LARGE|. +% That's why the command |\Block| provides an option between angle brackets to +% specificy some TeX code which will be inserted before the beginning of the +% math mode. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] @@ -2429,8 +2443,16 @@ c & c & b & a & e % \end{macrocode} % % \bigskip +% We also define a counter to count the environments |{NiceMatrixBlock}|. +% \begin{macrocode} +\int_new:N \g_@@_NiceMatrixBlock_int +% \end{macrocode} +% +% \bigskip % The dimension |\l_@@_columns_width_dim| will be used when the options specify -% that all the columns must have the same width. +% that all the columns must have the same width (but, if the key |columns-width| +% is used with the special value |auto|, the boolean +% |l_@@_auto_columns_width_bool| will be raised). % \begin{macrocode} \dim_new:N \l_@@_columns_width_dim % \end{macrocode} @@ -2461,7 +2483,6 @@ c & c & b & a & e % position (|t|, |b| or |c|). % \begin{macrocode} \bool_new:N \l_@@_NiceArray_bool -\bool_new:N \g_@@_NiceArray_bool % \end{macrocode} % % @@ -2536,6 +2557,10 @@ c & c & b & a & e % \begin{macrocode} \str_new:N \g_@@_type_env_str % \end{macrocode} +% +% \begin{macrocode} +\tl_new:N \g_@@_code_after_tl +% \end{macrocode} % % \bigskip % \subsubsection{Variables for the exterior rows and columns} @@ -2554,7 +2579,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_first_row_int \int_set:Nn \l_@@_first_row_int 1 -\int_new:N \g_@@_first_row_int % \end{macrocode} % % \medskip @@ -2565,7 +2589,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_first_col_int \int_set:Nn \l_@@_first_col_int 1 -\int_new:N \g_@@_first_col_int % \end{macrocode} % % \medskip @@ -2578,7 +2601,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_last_row_int \int_set:Nn \l_@@_last_row_int { -2 } -\int_new:N \g_@@_last_row_int % \end{macrocode} % % \smallskip @@ -2590,18 +2612,19 @@ c & c & b & a & e % value from the |aux| file, the value of the counter won't be $-1$ any longer.} % \begin{macrocode} \bool_new:N \l_@@_last_row_without_value_bool -\bool_new:N \g_@@_last_row_without_value_bool % \end{macrocode} % % \medskip % \item \textbf{Last column}\par\nobreak % -% For the eventual ``last column'', we have a boolean an not an integer. +% For the eventual ``last column'', we use an integer. A value of $-1$ means +% that there is no last column. % \begin{macrocode} -\bool_new:N \l_@@_last_col_bool +\int_new:N \l_@@_last_col_int +\int_set:Nn \l_@@_last_col_int { -1 } % \end{macrocode} % -% However, we have also another boolean. Consider the following code: +% However, we have also a boolean. Consider the following code: % \begin{center} % \begin{BVerbatim} % \begin{pNiceArray}{CC}[last-col] @@ -2807,20 +2830,11 @@ c & c & b & a & e % % % \bigskip -% We don't want to patch any existing code. That's why some code must be -% executed in a |\group_insert_after:N|. That's why the parameters used in that -% code must be transfered outside the current group. To do this, we copy those -% quantities in global variables just before the |\group_insert_after:N|. -% Therefore, for those quantities, we have two parameters, one local and one -% global. For example, we have |\l_@@_name_str| and |\g_@@_name_str|. -% -% \bigskip % The token list |\l_@@_name_str| will contain the optional name of the % environment: this name can be used to access to the Tikz nodes created in the % array from outside the environment. % \begin{macrocode} \str_new:N \l_@@_name_str -\str_new:N \g_@@_name_str % \end{macrocode} % % \bigskip @@ -2837,8 +2851,6 @@ c & c & b & a & e % \begin{macrocode} \dim_new:N \l_@@_left_margin_dim \dim_new:N \l_@@_right_margin_dim -\dim_new:N \g_@@_left_margin_dim -\dim_new:N \g_@@_right_margin_dim \dim_new:N \g_@@_width_last_col_dim \dim_new:N \g_@@_width_first_col_dim % \end{macrocode} @@ -2850,7 +2862,6 @@ c & c & b & a & e % \begin{macrocode} \dim_new:N \l_@@_extra_left_margin_dim \dim_new:N \l_@@_extra_right_margin_dim -\dim_new:N \g_@@_extra_right_margin_dim % \end{macrocode} % % @@ -2861,6 +2872,14 @@ c & c & b & a & e % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , + code-for-first-col .value_required:n = true , + code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , + code-for-last-col .value_required:n = true , + code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , + code-for-first-row .value_required:n = true , + code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , + code-for-last-row .value_required:n = true , small .bool_set:N = \l_@@_small_bool , hlines .bool_set:N = \l_@@_hlines_bool , parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , @@ -2872,6 +2891,7 @@ c & c & b & a & e % |\Vdots| and |\Ddots|. % \begin{macrocode} renew-dots .bool_set:N = \l_@@_renew_dots_bool , + renew-dots .value_forbidden:n = true , nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , % \end{macrocode} % @@ -2897,23 +2917,6 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The following set of keys concerns the options to \emph{customize} the -% exterior rows and columns, that is to say the options |code-for-first-row|, etc. -% \begin{macrocode} -\keys_define:nn { NiceMatrix / Code } - { - code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , - code-for-first-col .value_required:n = true , - code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , - code-for-last-col .value_required:n = true , - code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , - code-for-first-row .value_required:n = true , - code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , - code-for-last-row .value_required:n = true , - } -% \end{macrocode} -% -% \bigskip % We define a set of keys used by the environments of \pkg{nicematrix} (but not % by the command |\NiceMatrixOptions|). % \begin{macrocode} @@ -2932,8 +2935,11 @@ c & c & b & a & e \str_set_eq:NN \l_@@_name_str \l_tmpa_str , name .value_required:n = true , code-after .tl_gset:N = \g_@@_code_after_tl , - code-after .initial:n = \c_empty_tl , code-after .value_required:n = true , + first-col .code:n = \int_zero:N \l_@@_first_col_int , + first-row .code:n = \int_zero:N \l_@@_first_row_int , + last-row .int_set:N = \l_@@_last_row_int , + last-row .default:n = -1 , } % \end{macrocode} % @@ -2946,7 +2952,6 @@ c & c & b & a & e NiceMatrixOptions .inherit:n = { NiceMatrix / Global , - NiceMatrix / Code } , NiceMatrix .inherit:n = { @@ -2957,13 +2962,11 @@ c & c & b & a & e { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } } % \end{macrocode} @@ -3038,7 +3041,6 @@ c & c & b & a & e { \@@_error:n { Bad~value~for~letter~for~dotted~lines } } } , letter-for-dotted-lines .value_required:n = true , - letter-for-dotted-lines .initial:n = \c_colon_str , % \end{macrocode} % % \bigskip @@ -3047,7 +3049,11 @@ c & c & b & a & e } % \end{macrocode} % -% +% \begin{macrocode} +\str_new:N \l_@@_letter_for_dotted_lines_str +\str_set_eq:NN \l_@@_letter_for_dotted_lines_str \c_colon_str +% \end{macrocode} +% % \bigskip % |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix % options at the document level. The scope of these specifications is the @@ -3064,15 +3070,19 @@ c & c & b & a & e % % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrix } - { unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } + { + last-col .code:n = \tl_if_empty:nTF {#1} + { \@@_error:n { last-col~empty~for~NiceMatrix } } + { \int_set:Nn \l_@@_last_col_int { #1 } } , + unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } + } % \end{macrocode} % % -% \bigskip % % \bigskip -% We finalise the definition of the set of keys -% ``|NiceMatrix / NiceArray|'' with the options specific to |{NiceArray}|. +% We finalise the definition of the set of keys ``|NiceMatrix / NiceArray|'' +% with the options specific to |{NiceArray}|. % % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceArray } @@ -3086,11 +3096,15 @@ c & c & b & a & e c .code:n = \str_set:Nn \l_@@_pos_env_str c , t .code:n = \str_set:Nn \l_@@_pos_env_str t , b .code:n = \str_set:Nn \l_@@_pos_env_str b , - first-col .code:n = \int_zero:N \l_@@_first_col_int , - last-col .bool_set:N = \l_@@_last_col_bool , - first-row .code:n = \int_zero:N \l_@@_first_row_int , - last-row .int_set:N = \l_@@_last_row_int , - last-row .default:n = -1 , +% \end{macrocode} +% +% In the environments |{NiceArray}| and its variants, the option |last-col| must +% be used without value because the number of columns of the array can be read +% in the preamble of the array. +% \begin{macrocode} + last-col .code:n = \tl_if_empty:nF {#1} + { \@@_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l_@@_last_col_int , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -3101,16 +3115,18 @@ c & c & b & a & e \keys_define:nn { NiceMatrix / pNiceArray } { first-col .code:n = \int_zero:N \l_@@_first_col_int , - last-col .bool_set:N = \l_@@_last_col_bool , + last-col .code:n = \tl_if_empty:nF {#1} + { \@@_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l_@@_last_col_int , first-row .code:n = \int_zero:N \l_@@_first_row_int , last-row .int_set:N = \l_@@_last_row_int , last-row .default:n = -1 , - unknown .code:n = \@@_error:n { Unknown~option~for~pNiceArray } + unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} % % -% \subsection{Code common to \{NiceArrayWithDelims\} and \{NiceMatrix\}} +% \subsection{Important code used by \{NiceArrayWithDelims\} } % % The pseudo-environment |\@@_Cell:|--|\@@_end_Cell:| will be used to format the % cells of the array. In the code, the affectations are global because this @@ -3327,8 +3343,8 @@ c & c & b & a & e % \interitem % The argument of the following command |\@@_instruction_of_type:n| defined % below is the type of the instruction (|Cdots|, |Vdots|, |Ddots|, etc.). This -% command writes in the correspondint |\g_@@_|\textsl{type}|_lines_tl| the -% instruction that will really draw the line after the construction of the +% command writes in the corresponding |\g_@@_|\textsl{type}|_lines_tl| the +% instruction which will really draw the line after the construction of the % matrix. % % \medskip @@ -3348,8 +3364,10 @@ c & c & b & a & e % 7 & \Cdots \\ % \end{pNiceMatrix}$ % +% \smallskip % the content of |\g_@@_Cdots_lines_tl| will be: % +% \smallskip % \begin{scope} % \color{gray} % \verb|\@@_draw_Cdots:nn {2}{2}| @@ -3430,7 +3448,7 @@ c & c & b & a & e % \begin{macrocode} \int_compare:nNnT \g_@@_row_int > { -1 } { - \int_compare:nNnF \g_@@_row_int = \g_@@_last_row_int + \int_compare:nNnF \g_@@_row_int = \l_@@_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } @@ -3441,14 +3459,14 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The following code |\@@_pre_array:| is used in |{NiceArray}| and in -% |{NiceMatrix}|. It contains code that will be executed \emph{before} the -% construction of the array. +% The following code |\@@_pre_array:| is used in |{NiceArrayWithDelims}|. It +% exists as a standalone macro only for lisibility. % \label{prearray} % % \begin{macrocode} \cs_new_protected:Npn \@@_pre_array: - { + { + \tl_clear:N \g_@@_code_after_tl % \end{macrocode} % If the option |small| is used, we have to do some tuning. In particular, we % change the value of |\arraystretch| (this parameter is used in the @@ -3463,61 +3481,20 @@ c & c & b & a & e } % \end{macrocode} % -% If the user requires all the columns to have a width equal to the widest cell -% of the array, we read this length in the file |.aux| (of, course, this is -% possible only on the second run of LaTeX: on the first run, the dimension -% |\l_@@_columns_width_dim| will be set to zero --- and the columns will have -% their natural width). Remark that, even if the environment has a name (see -% just below) we have to write in the |aux| file the information with the number -% of environment because of |auto-columns-width| of |{NiceMatrixBlock}|. -% \begin{macrocode} - \bool_if:NT \l_@@_auto_columns_width_bool - { - \group_insert_after:N \@@_write_max_cell_width: - \cs_if_free:cTF { _@@_max_cell_width_ \int_use:N \g_@@_env_int } - { \dim_zero:N \l_@@_columns_width_dim } - { - \dim_set:Nx \l_@@_columns_width_dim - { \use:c { _@@_max_cell_width _ \int_use:N \g_@@_env_int } } - } -% \end{macrocode} -% If the environment has a name, we read the value of the maximal value of the -% columns from |_@@_name_cell_width|{\ttfamily\slshape name} (the value will be -% the correct value even if the number of the environment has changed (for -% example because the user has created or deleted an environment before the -% current one)). -% \begin{macrocode} - \str_if_empty:NF \l_@@_name_str - { - \cs_if_free:cF { _@@_max_cell_width_ \l_@@_name_str } - { - \dim_set:Nx \l_@@_columns_width_dim - { \use:c { _@@_max_cell_width_ \l_@@_name_str } } - } - } - } -% \end{macrocode} -% We don't want to patch any code and that's why some code is executed in a -% |\group_insert_after:N|. In particular, in this |\group_insert_after:N|, we -% will have to know the value of some parameters like |\l_@@_extra_nodes_bool|. -% That's why we transit via a global version for some variables. +% +% \medskip +% We switch to a global version of the boolean |\g_@@_extra_nodes_bool|, +% because, in some circonstancies, the boolean will be raised from inside a +% cell of the |\halign| (in particular in a column of type |w|). +% % \begin{macrocode} \bool_gset_eq:NN \g_@@_extra_nodes_bool \l_@@_extra_nodes_bool - \dim_gset_eq:NN \g_@@_left_margin_dim \l_@@_left_margin_dim - \dim_gset_eq:NN \g_@@_right_margin_dim \l_@@_right_margin_dim - \dim_gset_eq:NN \g_@@_extra_right_margin_dim \l_@@_extra_right_margin_dim - \int_gset_eq:NN \g_@@_last_row_int \l_@@_last_row_int - \tl_gset_eq:NN \g_@@_name_str \l_@@_name_str - \int_gset_eq:NN \g_@@_first_row_int \l_@@_first_row_int - \int_gset_eq:NN \g_@@_first_col_int \l_@@_first_col_int - \bool_gset_eq:NN \g_@@_NiceArray_bool \l_@@_NiceArray_bool - \bool_gset_eq:NN \g_@@_last_row_without_value_bool - \l_@@_last_row_without_value_bool - \bool_gset_eq:NN \g_@@_small_bool \l_@@_small_bool % \end{macrocode} +% +% \bigskip % The environment |{array}| uses internally the command |\ialign|. We change the % definition of |\ialign| for several reasons. In particular, |\ialign| sets -% |\everycr| to |{ }|. However, we have to change the value of |\everycr|. +% |\everycr| to |{ }| and we \emph{need} to have to change the value of |\everycr|. % \begin{macrocode} \cs_set:Npn \ialign { @@ -3532,6 +3509,7 @@ c & c & b & a & e { \everycr { \@@_everycr: } } \tabskip = \c_zero_skip % \end{macrocode} +% % The box |\@arstrutbox| is a box constructed in the beginning of the % environment |{array}|. The construction of that box takes into account the % current values of |\arraystretch|\footnote{The option |small| of @@ -3575,24 +3553,10 @@ c & c & b & a & e % We define the new column types |L|, |C| and |R| that must be used instead of % |l|, |c| and |r| in the preamble of |{NiceArray}|. % \begin{macrocode} - \dim_compare:nNnTF \l_@@_columns_width_dim = \c_zero_dim - { - \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } - \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } - \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } - } -% \end{macrocode} -% If there is an option that specify that all the columns must have the same -% width, the column types~|L|, |C| and~|R| are in fact defined upon the column -% type~|w| of \pkg{array} which is, in fact, redefined below. -% \begin{macrocode} - { - \newcolumntype L { w l { \dim_use:N \l_@@_columns_width_dim } } - \newcolumntype C { w c { \dim_use:N \l_@@_columns_width_dim } } - \newcolumntype R { w r { \dim_use:N \l_@@_columns_width_dim } } - } -% \end{macrocode} -% + \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } + \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } + \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } +% \end{macrocode} % % \begin{macrocode} \cs_set_eq:NN \Ldots \@@_Ldots @@ -3759,14 +3723,6 @@ c & c & b & a & e \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } % \end{macrocode} -% In |{NiceArrayWithDelims}|, it would have been possible to avoid the -% |\group_insert_after:N| and to put |\@@_after_array| in the second -% part of the environment |{NiceArrayWithDelims}|. However, it's not possible to -% do that in |{NiceMatrix}| (because of the option |renew-matrix|) and that's -% why we use this technique in |{NiceArrayWithDelims}| and in |{NiceMatrix}|. -% \begin{macrocode} - \group_insert_after:N \@@_after_array: -% \end{macrocode} % % We increment the counter |\g_@@_env_int| which counts the environments % of the extension. @@ -3807,7 +3763,7 @@ c & c & b & a & e % A value based on the name is more reliable than a value based on the number of % the environment. % \begin{macrocode} - \str_if_empty:NTF \g_@@_name_str + \str_if_empty:NTF \l_@@_name_str { \cs_if_exist:cT { @@_last_row_ \int_use:N \g_@@_env_int } { @@ -3816,10 +3772,10 @@ c & c & b & a & e } } { - \cs_if_exist:cT { @@_last_row_ \g_@@_name_str } + \cs_if_exist:cT { @@_last_row_ \l_@@_name_str } { \int_set:Nn \l_@@_last_row_int - { \use:c { @@_last_row_ \g_@@_name_str } } + { \use:c { @@_last_row_ \l_@@_name_str } } } } } @@ -3833,8 +3789,8 @@ c & c & b & a & e % \medskip % We compute the width of the two delimiters. % \begin{macrocode} - \dim_zero_new:N \g_@@_left_delim_dim - \dim_zero_new:N \g_@@_right_delim_dim + \dim_gzero_new:N \g_@@_left_delim_dim + \dim_gzero_new:N \g_@@_right_delim_dim \bool_if:NTF \l_@@_NiceArray_bool { \dim_gset:Nn \g_@@_left_delim_dim { 2 \arraycolsep } @@ -3884,7 +3840,7 @@ c & c & b & a & e { \tl_put_left:Nn \l_tmpa_tl { @ { } } } } } - \bool_if:NTF \l_@@_last_col_bool + \int_compare:nNnTF \l_@@_last_col_int > { -1 } { \tl_put_right:NV \l_tmpa_tl \c_@@_preamble_last_col_tl } { \bool_if:NT \l_@@_NiceArray_bool @@ -3911,27 +3867,99 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% We begin the second part of the environment |{NiceArrayWithDelims}|. +% We begin the second part of the environment |{NiceArrayWithDelims}|. If all +% the columns must have the same width (if the user has used the option +% |columns-width| or the option |auto-column-width| of the environment +% |{NiceMatrixBlock}|), we add a row in the array to fix the width of the +% columns and construct the ``|col|'' nodes |nm-|\textsl{a}|-col-|\textsl{j} (these +% nodes will be used by the horizontal open dotted lines and by the potential +% commands |\@@_vdottedline:n|). +% % \begin{macrocode} { + \bool_if:nT + { + ( \l_@@_auto_columns_width_bool && ! \l_@@_block_auto_columns_width_bool) + || \dim_compare_p:nNn \l_@@_columns_width_dim > \c_zero_dim + } + { + \crcr + \int_compare:nNnT \l_@@_first_col_int = 0 { \omit & } + \omit +% \end{macrocode} +% First, we put a ``|col|'' node on the left of the first column (of course, we +% have to do that \emph{after} the |\omit|). +% \begin{macrocode} + \tikz [ remember~picture , overlay ] + \coordinate [ name = nm - \int_use:N \g_@@_env_int - col - 0 ] ; +% \end{macrocode} +% We compute in |\g_tmpa_dim| the common width of the columns. We use a global +% variable because we are in a cell of an |\halign| and that we have to use this +% variable in other cells (of the same row). The affectation of |\g_tmpa_dim|, +% like all the affectations, must be done after the |\omit| of the cell. +% \begin{macrocode} + \bool_if:nTF + { + \l_@@_auto_columns_width_bool + && ! \l_@@_block_auto_columns_width_bool + } + { + \dim_gset:Nn \g_tmpa_dim + { \g_@@_max_cell_width_dim + 2 \arraycolsep } + } + { + \dim_gset:Nn \g_tmpa_dim + { \l_@@_columns_width_dim + 2 \arraycolsep } + } + \skip_horizontal:N \g_tmpa_dim +% \end{macrocode} +% We begin a loop over the columns. The integer |\g_tmpa_int| will be the +% number of columns of the current cell. This integer is not used to fix the +% width of the column (since all the columns have the same width equal to +% |\g_@@_tmpa_dim|) but for the Tikz nodes. +% \begin{macrocode} + \int_gset:Nn \g_tmpa_int 1 + \bool_if:nTF \g_@@_last_col_found_bool + { \prg_replicate:nn { \g_@@_col_total_int - 2 } } + { \prg_replicate:nn { \g_@@_col_total_int - 1 } } + { + & + \omit +% \end{marocode} +% The incrementation of the counter |\g_tmpa_int| must be done after the |\omit| +% of the cell. +% \begin{macrocode} + \int_gincr:N \g_tmpa_int + \skip_horizontal:N \g_tmpa_dim +% \end{macrocode} +% We create a ``|col|'' node on the right of the current column. +% \begin{macrocode} + \tikz [ remember~picture , overlay ] + \coordinate + [ + name = nm - \int_use:N \g_@@_env_int - + col - \int_use:N \g_tmpa_int + ] ; + } + } \endarray \c_math_toggle_token - \skip_horizontal:n \g_@@_right_margin_dim - \skip_horizontal:n \g_@@_extra_right_margin_dim + \skip_horizontal:n \l_@@_right_margin_dim + \skip_horizontal:n \l_@@_extra_right_margin_dim \hbox_set_end: % \end{macrocode} % % \bigskip % % \begin{macrocode} - \int_compare:nNnT \g_@@_last_row_int > { -2 } + \int_compare:nNnT \l_@@_last_row_int > { -2 } { - \bool_if:NF \g_@@_last_row_without_value_bool + \bool_if:NF \l_@@_last_row_without_value_bool { - \int_compare:nNnF \g_@@_last_row_int = \g_@@_row_int + \int_compare:nNnF \l_@@_last_row_int = \g_@@_row_int { \@@_error:n { Wrong~last~row } - \int_gset_eq:NN \g_@@_last_row_int \g_@@_row_int + \int_gset_eq:NN \l_@@_last_row_int \g_@@_row_int } } } @@ -3977,7 +4005,7 @@ c & c & b & a & e % column'' has been constructed in an overlapping position and that we have computed % its width in |\g_@@_width_first_col_dim|: see p.~\pageref{overlap-left}). % \begin{macrocode} - \int_compare:nNnT \g_@@_first_col_int = \c_zero_int + \int_compare:nNnT \l_@@_first_col_int = \c_zero_int { \skip_horizontal:n \arraycolsep \skip_horizontal:n \g_@@_width_first_col_dim @@ -3989,9 +4017,9 @@ c & c & b & a & e % into account the option of position (|t|, |c| or |b|). We begin with % |{NiceArray}|. % \begin{macrocode} - \bool_if:NTF \g_@@_NiceArray_bool + \bool_if:NTF \l_@@_NiceArray_bool { - \int_compare:nNnT \g_@@_first_row_int = \c_zero_int + \int_compare:nNnT \l_@@_first_row_int = \c_zero_int { \str_if_eq:VnTF \l_@@_pos_env_str { t } { @@ -4000,7 +4028,7 @@ c & c & b & a & e } } { - \bool_if:NT \g_@@_last_row_int + \int_compare:nNnT \l_@@_last_row_int > 0 { \str_if_eq:VnT \l_@@_pos_env_str { b } { @@ -4059,10 +4087,12 @@ c & c & b & a & e \skip_horizontal:n \g_@@_width_last_col_dim \skip_horizontal:n \arraycolsep } + \@@_after_array: } % \end{macrocode} % This is the end of the environment |{NiceArrayWithDelims}|. % +% % \interitem % Here is the preamble for the ``first column'' (if the user uses the key |first-col|) % \begin{macrocode} @@ -4249,7 +4279,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { pNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { pNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims ( ) } @@ -4259,7 +4290,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { bNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { NiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims [ ] } @@ -4269,7 +4301,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { BNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { BNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims \{ \} } @@ -4279,7 +4312,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { vNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { vNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { vNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims | | } @@ -4289,7 +4323,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { VNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { VNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims \| \| } @@ -4299,165 +4334,41 @@ c & c & b & a & e % \bigskip % \subsection{The environment \{NiceMatrix\} and its variants} % -% Our environment |{NiceMatrix}| must have the same second part as the -% environment |{matrix}| of \pkg{amsmath} (because of the programmation of the -% option |renew-matrix|). Hence, this second part is the following: -% -% \begin{Verbatim} -% \endarray -% \skip_horizontal:n { - \arraycolsep } -% \end{Verbatim} -% -% That's why in the definition of |{NiceMatrix}|, we have to use |\array| and -% not |\begin{array}|. This command |\array| is in |\@@_array:| (we have written -% this command because of the redefinition of |\array| done in the classes -% \cls{revtex4-1} and \cls{revtex4-2}). -% -% In order to execute code after the array, we use a command -% |\group_insert_after:N|. -% -% \medskip -% Here's the definition of |{NiceMatrix}|: -% \begin{macrocode} -\NewDocumentEnvironment { NiceMatrix } { ! O { } } - { - \str_if_empty:NT \g_@@_type_env_str - { \str_gset:Nn \g_@@_type_env_str { NiceMatrix } } - \@@_test_if_math_mode: - \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } - \bool_set_true:N \l_@@_in_env_bool -% \end{macrocode} -% We have to deactivate the potential externalisation of Tikz because -% \pkg{nicematrix} uses Tikz with |remember picture|. -% \begin{macrocode} - \cs_if_exist:NT \tikz@library@external@loaded - { \tikzset { external / export = false } } -% \end{macrocode} -% The instruction for actual drawing of the dotted lines must be in a -% |\group_insert_after:N| because the second part of the environment must be the -% same as in |{array}| (for the option |renew-matrix|). % \begin{macrocode} - \group_insert_after:N \@@_after_array: - \int_gincr:N \g_@@_env_int - \bool_if:NF \l_@@_block_auto_columns_width_bool - { \dim_gzero_new:N \g_@@_max_cell_width_dim } - \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } -% \end{macrocode} -% The macro |\@@_pre_array:| is defined above (see p.~\pageref{prearray}). It -% is also used in |{NiceArrayWithDelims}|. -% \begin{macrocode} - \@@_pre_array: - \skip_horizontal:n { - \arraycolsep } - \skip_horizontal:n \l_@@_left_margin_dim - \skip_horizontal:n \l_@@_extra_left_margin_dim - \str_set:Nn \l_@@_pos_env_str c - \bool_set_false:N \l_@@_exterior_arraycolsep_bool - \@@_array: { * \c@MaxMatrixCols C } - } - { - \endarray - \skip_horizontal:n { - \arraycolsep } -% \end{macrocode} -% The two following lines are, of course, not in the second part of |{array}|, -% but that doesn't matter because, when |renew-matrix| is used, -% |\g_@@_right_margin_dim| and |\g_@@_extra_right_margin_dim| will be equal to $0$~pt. -% \begin{macrocode} - \skip_horizontal:n \g_@@_right_margin_dim - \skip_horizontal:n \g_@@_extra_right_margin_dim - } -% \end{macrocode} -% -% \interitem -% We create the variants of the environment |{NiceMatrix}|. -% \begin{macrocode} -\NewDocumentEnvironment { pNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { pNiceMatrix } - \@@_test_if_math_mode: - \left( \begin{NiceMatrix} - } - { \end{NiceMatrix} \right) } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { bNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { bNiceMatrix } - \@@_test_if_math_mode: - \left[ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right] } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { BNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { BNiceMatrix } - \@@_test_if_math_mode: - \left\{ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\} } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { vNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { vNiceMatrix } - \@@_test_if_math_mode: - \left\lvert \begin{NiceMatrix} +\cs_new_protected:Npn \@@_define_env:n #1 + { + \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } + { + \str_gset:Nn \g_@@_type_env_str { #1 NiceMatrix } + \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } + \begin { #1 NiceArray } + { + * + { + \int_compare:nNnTF \l_@@_last_col_int = { -1 } + \c@MaxMatrixCols + { \int_eval:n { \l_@@_last_col_int - 1 } } + } + C + } + } + { \end { #1 NiceArray } } } - { \end{NiceMatrix} \right\rvert } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment { VNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { VNiceMatrix } - \@@_test_if_math_mode: - \left\lVert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rVert } +\@@_define_env:n { } +\@@_define_env:n p +\@@_define_env:n b +\@@_define_env:n B +\@@_define_env:n v +\@@_define_env:n V % \end{macrocode} % % % \bigskip % \subsection{Automatic width of the cells} % -% For the option |columns-width=auto| (or the option |auto-columns-width| -% of the environment |{NiceMatrixBlock}|), we want to know the maximal width of -% the cells of the array (except the cells of the ``exterior'' column of an -% environment of the kind of |{pNiceAccayC}|). This length can be known only -% after the end of the construction of the array (or at the end of the -% environment |{NiceMatrixBlock}|). That's why we store this value in the main -% |.aux| file and it will be available in the next run. We write a dedicated -% command for this because it will be called in a~|\group_insert_after:N|. -% \begin{macrocode} -\cs_new_protected:Nn \@@_write_max_cell_width: - { - \bool_if:NF \l_@@_block_auto_columns_width_bool - { - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@_max_cell_width_ \int_use:N \g_@@_env_int } - { \dim_use:N \g_@@_max_cell_width_dim } - } -% \end{macrocode} -% If the environment has a name, we also create an alias named -% |\@@_max_cell_width_|{\ttfamily\slshape name}. -% \begin{macrocode} - \str_if_empty:NF \g_@@_name_str - { - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@_max_cell_width_ \g_@@_name_str } - { \dim_use:N \g_@@_max_cell_width_dim } - } - } - \iow_now:Nn \@mainaux \ExplSyntaxOff - } - } -% \end{macrocode} % % \bigskip % \subsection{How to know whether a cell is ``empty''} @@ -4599,14 +4510,14 @@ c & c & b & a & e % same principle. % \begin{macrocode} \int_gset_eq:NN \g_@@_row_total_int \g_@@_row_int - \int_compare:nNnT \g_@@_last_row_int > { -1 } + \int_compare:nNnT \l_@@_last_row_int > { -1 } { \int_gsub:Nn \g_@@_row_int \c_one_int } % \end{macrocode} % % In the user has used the option |last-row| without value, we write in the % |aux| file the number of that last row for the next run. % \begin{macrocode} - \bool_if:NT \g_@@_last_row_without_value_bool + \bool_if:NT \l_@@_last_row_without_value_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux @@ -4619,11 +4530,11 @@ c & c & b & a & e % because it's more reliable than a value based on the number of the % environment. % \begin{macrocode} - \str_if_empty:NF \g_@@_name_str + \str_if_empty:NF \l_@@_name_str { \iow_now:Nx \@mainaux { - \cs_gset:cpn { @@_last_row_ \g_@@_name_str } + \cs_gset:cpn { @@_last_row_ \l_@@_name_str } { \int_use:N \g_@@_row_total_int } } } @@ -4675,7 +4586,7 @@ c & c & b & a & e % If the option |small| is used, the values |\l_@@_radius_dim| and % |\l_@@_inter_dots_dim| (used to draw the dotted lines) are changed. % \begin{macrocode} - \bool_if:NT \g_@@_small_bool + \bool_if:NT \l_@@_small_bool { \dim_set:Nn \l_@@_radius_dim { 0.37 pt } \dim_set:Nn \l_@@_inter_dots_dim { 0.25 em } @@ -5025,8 +4936,7 @@ c & c & b & a & e \bool_if:NTF \l_@@_initial_open_bool { % \end{macrocode} -% If a |w| node exists (created when the key |columns-width| is used), we use -% the |w| node for the extremity. +% If a |w| node exists we use the |w| node for the extremity. % \begin{macrocode} \cs_if_exist:cTF { @@ -5405,8 +5315,9 @@ c & c & b & a & e { ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * \dim_ratio:nn - { \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } { \l_@@_l_dim * 2 } * - \l_tmpb_int + { \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } + { \l_@@_l_dim * 2 } + * \l_tmpb_int } % \end{macrocode} % (In a multiplication of a dimension and an integer, the integer must always be @@ -5714,7 +5625,7 @@ c & c & b & a & e \cs_set:Npn \@@_dotfill: { % \end{macrocode} -% If the option |small| is used, we change the space between two dots (we can't +% If the option |small| is used, we change the space between dots (we can't % use |\l_@@_inter_dots_dim| which will be set after the construction of the % array). We can't put the |\bool_if:NT| in the first argument of % |\hbox_to_wd:nn| because |\cleaders| is a special TeX primitive. @@ -5751,7 +5662,7 @@ c & c & b & a & e \hbox_to_wd:nn { \l_tmpa_dim + 2 \arraycolsep - - \l_@@_left_margin_dim - \g_@@_right_margin_dim + - \l_@@_left_margin_dim - \l_@@_right_margin_dim } \@@_dotfill: } @@ -5759,8 +5670,6 @@ c & c & b & a & e } % \end{macrocode} % -% -% % \bigskip % \begin{macrocode} \cs_new_protected:Nn \@@_vdottedline:n @@ -5795,14 +5704,8 @@ c & c & b & a & e \dim_gset:Nn \g_@@_y_final_dim \pgf@y \end { tikzpicture } % \end{macrocode} -% However, if the |w|-nodes are created in the previous column (that is if the -% previous column was constructed explicitly or implicitly\footnote{A column is -% constructed implicitly with the letter |w| if the option |columns-width| is -% used or if the environment |{NiceMatrixBlock}| is used with the option -% |auto-columns-width|.} with a letter |w|), we use the |w|-nodes to change the -% $x$-value of the nodes in order to have the dotted lines perfectly aligned -% when we use the environment |{NiceMatrixBlock}| with the option -% |auto-columns-width|. +% However, if the previous column was constructed with a letter |w|, we use the +% |w|-nodes to change the $x$-value of the nodes. % \begin{macrocode} \cs_if_exist:cT { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - 1 - #1 - w } @@ -5818,6 +5721,20 @@ c & c & b & a & e \dim_gadd:Nn \g_@@_x_initial_dim \arraycolsep \dim_gadd:Nn \g_@@_x_final_dim \arraycolsep } +% \end{macrocode} +% However, if a node of column exists (if the array has been constructed with a +% fixed width of column), we use it. +% \begin{macrocode} + \cs_if_exist:cT + { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - col - #1 } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( col - #1 ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \end { tikzpicture } + } \@@_draw_tikz_line: } } @@ -5938,9 +5855,17 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } { + \int_gincr:N \g_@@_NiceMatrixBlock_int + \dim_zero:N \l_@@_columns_width_dim \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } - \int_zero_new:N \l_@@_first_env_block_int - \int_set:Nn \l_@@_first_env_block_int { \g_@@_env_int + 1 } + \bool_if:NT \l_@@_block_auto_columns_width_bool + { + \cs_if_exist:cT { @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int } + { + \dim_set:Nx \l_@@_columns_width_dim + { \use:c { @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int } } + } + } } % \end{macrocode} % @@ -5954,13 +5879,11 @@ c & c & b & a & e \bool_if:NT \l_@@_block_auto_columns_width_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn - \int_step_inline:nnnn \l_@@_first_env_block_int 1 \g_@@_env_int + \iow_now:Nx \@mainaux { - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@ _ max _ cell _ width _ ##1 } - { \dim_use:N \g_@@_max_cell_width_dim } - } + \cs_gset:cpn + { @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int } + { \dim_use:N \g_@@_max_cell_width_dim } } \iow_now:Nn \@mainaux \ExplSyntaxOff } @@ -6002,14 +5925,14 @@ c & c & b & a & e \cs_new_protected:Nn \@@_create_extra_nodes: { \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { \dim_zero_new:c { l_@@_row_\@@_i: _min_dim } \dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim \dim_zero_new:c { l_@@_row_\@@_i: _max_dim } \dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim } } - \int_step_variable:nnNn \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: { \dim_zero_new:c { l_@@_column_\@@_j: _min_dim } \dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim @@ -6019,10 +5942,10 @@ c & c & b & a & e % \end{macrocode} % We begin the two nested loops over the rows and the columns of the array. % \begin{macrocode} - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { \int_step_variable:nnNn - \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \l_@@_first_col_int \g_@@_col_total_int \@@_j: % \end{macrocode} % Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after % implicit ampersands |&|). In this case, of course, we don't update the @@ -6075,8 +5998,8 @@ c & c & b & a & e % That's why the loop over the rows will start at 1 and the loop over the columns % will stop at $|\g_@@_col_int|$ (and not |\g_@@_col_total_int|). Idem for the rows. % \begin{macrocode} - \int_set:Nn \g_@@_first_row_int 1 - \int_set:Nn \g_@@_first_col_int 1 + \int_set:Nn \l_@@_first_row_int 1 + \int_set:Nn \l_@@_first_col_int 1 % \end{macrocode} % We have to change the values of all the dimensions % \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, @@ -6113,10 +6036,10 @@ c & c & b & a & e } \dim_sub:cn { l_@@_column _ 1 _ min _ dim } - \g_@@_left_margin_dim + \l_@@_left_margin_dim \dim_add:cn { l_@@_column _ \int_use:N \g_@@_col_int _ max _ dim } - \g_@@_right_margin_dim + \l_@@_right_margin_dim % \end{macrocode} % Now, we can actually create the ``large nodes''. % \begin{macrocode} @@ -6167,9 +6090,9 @@ c & c & b & a & e % \begin{macrocode} \cs_new_protected:Nn \@@_create_nodes: { - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { - \int_step_variable:nnNn \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: % \end{macrocode} % We create two ponctual nodes for the extremities of a diagonal of the % rectangular node we want to create. These nodes |(@@~south~west)| and @@ -6196,8 +6119,8 @@ c & c & b & a & e inner~sep = \c_zero_dim , name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: , alias = - \str_if_empty:NF \g_@@_name_str - { \g_@@_name_str - \@@_i: - \@@_j: } + \str_if_empty:NF \l_@@_name_str + { \l_@@_name_str - \@@_i: - \@@_j: } ] ; } @@ -6208,7 +6131,7 @@ c & c & b & a & e % |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in % |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$. % \begin{macrocode} - \@@_seq_mapthread_function:NNN + \seq_mapthread_function:NNN \g_@@_multicolumn_cells_seq \g_@@_multicolumn_sizes_seq \@@_node_for_multicolumn:nn @@ -6249,7 +6172,7 @@ c & c & b & a & e inner~sep = \c_zero_dim , name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: , alias = - \str_if_empty:NF \g_@@_name_str { \g_@@_name_str - \@@_i: - \@@_j: } + \str_if_empty:NF \l_@@_name_str { \l_@@_name_str - \@@_i: - \@@_j: } ] ; } @@ -6385,6 +6308,29 @@ c & c & b & a & e } % \end{macrocode} % +% % \subsection{How to draw the dotted lines transparently} +% \begin{macrocode} +\cs_set_protected:Npn \@@_renew_matrix: + { + \RenewDocumentEnvironment { pmatrix } { } + { \pNiceMatrix } + { \endpNiceMatrix } + \RenewDocumentEnvironment { vmatrix } { } + { \vNiceMatrix } + { \endvNiceMatrix } + \RenewDocumentEnvironment { Vmatrix } { } + { \VNiceMatrix } + { \endVNiceMatrix } + \RenewDocumentEnvironment { bmatrix } { } + { \bNiceMatrix } + { \endbNiceMatrix } + \RenewDocumentEnvironment { Bmatrix } { } + { \BNiceMatrix } + { \endBNiceMatrix } + } +% \end{macrocode} +% +% % % \subsection{We process the options} % @@ -6398,12 +6344,41 @@ c & c & b & a & e % Of course, the command |\NiceMatrix| must be defined before such an % instruction is executed. % \begin{macrocode} -\ProcessKeysOptions { NiceMatrix } +\keys_define:nn { NiceMatrix / Package } + { + renew-dots .bool_set:N = \l_@@_renew_dots_bool , + renew-dots .value_forbidden:n = true , + renew-matrix .code:n = \@@_renew_matrix: , + renew-matrix .value_forbidden:n = true , + transparent .meta:n = { renew-dots , renew-matrix } , + transparent .value_forbidden:n = true, + } +\ProcessKeysOptions { NiceMatrix / Package } % \end{macrocode} % % \subsection{Error messages of the package} % % \begin{macrocode} +\@@_msg_new:nn { last-col~non~empty~for~NiceArray } + { + In~the~environment~\{\g_@@_type_env_str\},~you~must~use~the~option~ + 'last-col'~without~value~(the~number~of~columns~is~known~by~the~ + preamble~of~the~environment).\\ + However,~you~can~go~on~for~this~time~ + (the~value~'\l_keys_value_tl'~will~be~ignored). + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { last-col~empty~for~NiceMatrix } + { + In~the~environment~\{\g_@@_type_env_str\}~you~can't~use~the~option~ + 'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\ + If~you~go~on~this~option~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { Block~too~large } { You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ @@ -6425,7 +6400,7 @@ c & c & b & a & e % \begin{macrocode} \@@_msg_new:nn { Wrong~last~row } { - You~have~used~'last-row=\int_use:N \g_@@_last_row_int'~but~your~environment~ + You~have~used~'last-row=\int_use:N \l_@@_last_row_int'~but~your~environment~ \{\g_@@_type_env_str\}~seems~to~have~\int_use:N \g_@@_row_int\ rows.~If~you~go~on,~the~value~of~\int_use:N \g_@@_row_int\ will~be~used~for~last~row.~You~can~avoid~this~problem~by~using~'last-row'~ @@ -6502,7 +6477,7 @@ c & c & b & a & e renew-dots,~ renew-matrix,~ right-margin,~ - small,~ + small~ and~transparent } % \end{macrocode} @@ -6528,50 +6503,28 @@ c & c & b & a & e create-extra-nodes,~ extra-left-margin,~ extra-right-margin,~ + first-col,~ + first-row,~ hlines,~ + last-col,~ + last-row,~ left-margin,~ name,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ right-margin,~ - small,~ + small~ and~t. } % \end{macrocode} % -% -% \begin{macrocode} -\@@_msg_new:nnn { Unknown~option~for~NiceMatrix } - { - The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ - \{NiceMatrix\}~and~its~variants. \\ - If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. - } - { - The~available~options~are~(in~alphabetic~order):~ - code-after,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - hlines,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - right-margin~ - and~small. - } -% \end{macrocode} -% % \medskip -% Despite its name, the following set of keys will be used for |{pNiceArray}| -% but also |{vNiceArray}|, |{VNiceArray}|, etc. but not for |{NiceArray}|. +% This error message is used for the set of keys |NiceMatrix/NiceMatrix| and +% |NiceMatrix/pNiceArray| (but not by |NiceMatrix/NiceArray| (because, for this +% set of keys, there is also the options |t|, |c| and~|b|). % \begin{macrocode} -\@@_msg_new:nnn { Unknown~option~for~pNiceArray } +\@@_msg_new:nnn { Unknown~option~for~NiceMatrix } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{\g_@@_type_env_str\}. \\ @@ -6591,9 +6544,9 @@ c & c & b & a & e extra-right-margin,~ first-col,~ first-row,~ + hlines,~ last-col,~ last-row,~ - hlines,~ left-margin,~ name,~ nullify-dots,~ @@ -6646,54 +6599,7 @@ c & c & b & a & e first~position~of~the~preamble~of~the~environment~\{\g_@@_type_env_str\}. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } -% \end{macrocode} -% -% -% \subsection{Code for \textbackslash seq_mapthread_function:NNN} -% -% In |\@@_create_nodes:| (used twice in |\@@_create_extra_nodes:| to create the -% ``medium nodes'' and ``large nodes''), we want to use -% |\seq_mapthread_function:NNN| which is in \pkg{l3candidates}). For security, -% we define a function |\@@_seq_mapthread_function:NNN|. We will delete the -% following code when |\seq_mapthread_function:NNN| will be in \pkg{l3seq}. -% \begin{macrocode} -\cs_new:Npn \@@_seq_mapthread_function:NNN #1 #2 #3 - { - \group_begin: -% \end{macrocode} -% In the group, we can use |\seq_pop:NN| safely. -% \begin{macrocode} - \int_step_inline:nn { \seq_count:N #1 } - { - \seq_pop:NN #1 \l_tmpa_tl - \seq_pop:NN #2 \l_tmpb_tl - \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl - } - \group_end: - } -% \end{macrocode} -% -% \begin{macrocode} -\cs_set_protected:Npn \@@_renew_matrix: - { - \RenewDocumentEnvironment { pmatrix } { } - { \pNiceMatrix } - { \endpNiceMatrix } - \RenewDocumentEnvironment { vmatrix } { } - { \vNiceMatrix } - { \endvNiceMatrix } - \RenewDocumentEnvironment { Vmatrix } { } - { \VNiceMatrix } - { \endVNiceMatrix } - \RenewDocumentEnvironment { bmatrix } { } - { \bNiceMatrix } - { \endbNiceMatrix } - \RenewDocumentEnvironment { Bmatrix } { } - { \BNiceMatrix } - { \endBNiceMatrix } - } -% \end{macrocode} -% +% \end{macrocode} % % % \subsection{Obsolete environments} @@ -6701,7 +6607,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \pNiceArray } { \endpNiceArray } @@ -6710,7 +6616,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \bNiceArray } { \endbNiceArray } @@ -6719,7 +6625,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \BNiceArray } { \endBNiceArray } @@ -6728,7 +6634,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { vNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \vNiceArray } { \endvNiceArray } @@ -6737,7 +6643,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \VNiceArray } { \endVNiceArray } @@ -6746,7 +6652,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \pNiceArray } @@ -6756,7 +6662,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \bNiceArray } @@ -6766,7 +6672,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \BNiceArray } @@ -6786,7 +6692,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \VNiceArray } @@ -6796,7 +6702,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceArrayCwithDelims } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \NiceArrayWithDelims } { \endNiceArrayWithDelims } @@ -6805,7 +6711,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceArrayRCwithDelims } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \NiceArrayWithDelims } @@ -6972,7 +6878,20 @@ c & c & b & a & e % % Option |small|. % +% \subsection*{Changes between version 3.2 and 3.3} +% +% The options |first-row|, |last-row|, |first-col| and |last-col| are now +% available in the environments |{NiceMatrix}|, |{pNiceMatrix}|, +% |{bNiceMatrix}|, etc. +% +% The option |columns-width=auto| doesn't need any more a second compilation. +% +% The options |renew-dots|, |renew-matrix| and |transparent| are now available +% as package options (as said in the documentation). % +% The previous version of \pkg{nicematrix} was incompatible with a recent +% version of \pkg{expl3} (released 2019/09/30). This version is compatible. +% % \PrintIndex % % \tableofcontents @@ -6983,3 +6902,4 @@ c & c & b & a & e % TeX-fold-preserve-comments: nil % fill-column: 80 % End: + diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf Binary files differindex 690f05bce7..b635371dec 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.pdf +++ b/macros/latex/contrib/nicematrix/nicematrix.pdf diff --git a/macros/latex/contrib/practicalreports/practicalreports.pdf b/macros/latex/contrib/practicalreports/practicalreports.pdf Binary files differindex 70784e70d8..6aee7762b1 100644 --- a/macros/latex/contrib/practicalreports/practicalreports.pdf +++ b/macros/latex/contrib/practicalreports/practicalreports.pdf diff --git a/macros/latex/contrib/practicalreports/practicalreports.sty b/macros/latex/contrib/practicalreports/practicalreports.sty index 174892e902..d574797bcf 100644 --- a/macros/latex/contrib/practicalreports/practicalreports.sty +++ b/macros/latex/contrib/practicalreports/practicalreports.sty @@ -2,8 +2,8 @@ %%License: LPPL 1.3c \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{practicalreports}[26/09/2019 v2.0.1 Practical Report Package] -\RequirePackage{mathtools, array, longtable, scrextend, float, fancyhdr, lastpage, tikzducks} +\ProvidesPackage{practicalreports}[01/10/2019 v2.0.2 Practical Report Package] +\RequirePackage{mathtools, array, longtable, scrextend, float, fancyhdr, lastpage, tikzducks, pdfpages, pgffor} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -187,8 +187,13 @@ tshirt=brown!50!black, jacket=brown!30!gray, speech={of},bubblecolour=cyan!20!wh \end{tikzpicture} } } - +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Make sure yor filenames are all one word, this can include underscores and each report is separated by a comma. +\newcommand{\joinreports}[1]{ +\foreach \report in {#1} { +\includepdfmerge{\report, -} +} }
\ No newline at end of file diff --git a/macros/latex/contrib/practicalreports/practicalreports.tex b/macros/latex/contrib/practicalreports/practicalreports.tex index f16cc4299b..de97a6c2f8 100644 --- a/macros/latex/contrib/practicalreports/practicalreports.tex +++ b/macros/latex/contrib/practicalreports/practicalreports.tex @@ -14,8 +14,8 @@ \vspace*{\fill} \begin{center} {\Huge Practical Reports Documentation}\\[0.5cm] -{\Large Version: 2.0.1}\\[0.4cm] -{\Large Date: $26^{th}$ of September 2019}\\[0.2cm] +{\Large Version: 2.0.2}\\[0.4cm] +{\Large Date: $1^{st}$ of October 2019}\\[0.2cm] {\small Author: Justin Cawood} \end{center} \vspace*{\fill} @@ -312,6 +312,15 @@ Tables can be shifted. The $\backslash$goodfoot macro will do the footer for you in the form "Page x of n". The page mus be set to fancy first though using the $\backslash$setpagefancy macro. +\subsection{Join Multiple Reports} +To combine multiple pdf files together into one single pdf file use the macro $\backslash$joinreports\{\}. You don't need the file extension just list all the pdf files that you wish to join as follows. + +$\backslash$joinreports\{pdf\_1, pdf\_2, pdf\_3, pdf\_4, .....\}. + +This macro should be used in a new tex file because the pdf files will be joined as one file with the name of the tex file this macro is used in. + +The pdf files being joined must be in the same directory as the tex file this macro is used in. + \section{Appendices} \subsection{Appendix A - List of Figures} diff --git a/macros/latex/contrib/scratch3/README b/macros/latex/contrib/scratch3/README index ce8855fe01..889216c0cb 100644 --- a/macros/latex/contrib/scratch3/README +++ b/macros/latex/contrib/scratch3/README @@ -3,9 +3,9 @@ ___________________________________ L'extension scratch3 - v0.13 + v0.14 - 1er juillet 2019 + 1er octobre 2019 ___________________________________ Author : Christian Tellechea diff --git a/macros/latex/contrib/scratch3/scratch3-fr.pdf b/macros/latex/contrib/scratch3/scratch3-fr.pdf Binary files differindex 31b8a5fc74..aea57a0510 100644 --- a/macros/latex/contrib/scratch3/scratch3-fr.pdf +++ b/macros/latex/contrib/scratch3/scratch3-fr.pdf diff --git a/macros/latex/contrib/scratch3/scratch3-fr.tex b/macros/latex/contrib/scratch3/scratch3-fr.tex index 0717232b53..e6c4786f03 100644 --- a/macros/latex/contrib/scratch3/scratch3-fr.tex +++ b/macros/latex/contrib/scratch3/scratch3-fr.tex @@ -320,6 +320,14 @@ Un booléen : \boollist{liste \selectmenu{malist} contient \ovalnum{foobar}}.\par Un autre : \booloperator{\booloperator{\ovalvariable{varx} > \ovalnum{1}} et \booloperator{\ovalvariable{varx} < \ovalnum{5}}}./ +La macro \verb|\boolempty[<dimension>]| permet de tracer un losange vide. L'argument optionnel est une \verb|<dimension>| qui vaut \verb|2em| par défaut. + +\exemple/\begin{scratch} + \blockifelse{si \boolempty[3em] alors} + {\blocklook{dire \ovalnum{le test est vrai}}} + {\blocklook{dire \ovalnum{le test est faux}}} +\end{scratch}/ + \section{Les blocs de fin} Ces blocs sont susceptibles de clore un algorithme et n'ont donc pas d'encoche mâle dans leur partie basse. Ils ne peuvent être que du type \suffixe{control} et sont dessinés avec la macro \verb|\blockstop{<texte>}| @@ -437,6 +445,12 @@ Représente la largeur des encoches. La valeur est ramenée si nécessaire dans l'i \cleval{scale}{coefficient}\label{cle-scale} Représente l'échelle à laquelle est représenté le dessin. La valeur est ramenée si nécessaire dans l'intervalle [0.2 ; 5]. +Les blocs ovales ou losanges, qui peuvent se trouver à l'extérieur de l'environnement scrtach, sont affectés par la valeur de \texttt{scale} : + +\exemple/\setscratch{scale=1}Échelle 1 : \ovalvariable{var} et \booloperator{\ovalmove{abscisse x} < \ovalnum{7}}\par +Échelle 0.75 :\setscratch{scale=.75} : \ovalvariable{var} et \booloperator{\ovalmove{abscisse x} < \ovalnum{7}}\par +Échelle 1.25 :\setscratch{scale=1.25} : \ovalvariable{var} et \booloperator{\ovalmove{abscisse x} < \ovalnum{7}}/ + \cleval{init arcangle}{angle} Représente l'angle avec l'horizontale de l'arc de cercle tracé dans la partie haute des blocs de départ. La valeur est ramenée si nécessaire dans l'intervalle [20 ; 40]. @@ -579,7 +593,7 @@ centré \end{scratch}/ \section{Mot de la fin} -Le code de cette extension démontre mon immense ignorance de ti\textit kz/pgf et les méthodes de programmation qui lui sont propres que, décidément, je ne comprendrai jamais! C'est sans doute le trop grand éloignement avec la logique de \TeX{} et la documentation de ti\textit kz/pgf, aussi indigeste qu'illisible, qui explique cette incompatibilité d'humeur et mon désintérêt à l'égard de ti\textit kz. Toujours est-il que cette extension fonctionne, avec une lenteur certaine que j'attribue à ma programmation hasardeuse ainsi qu'à la lenteur intrinsèque de ti\textit kz. +Le code de cette extension démontre mon immense ignorance de ti\textit kz/pgf et les méthodes de programmation qui lui sont propres que décidément, je ne comprendrai jamais! C'est sans doute le trop grand éloignement avec la logique de \TeX{} et la documentation de ti\textit kz/pgf, aussi indigeste qu'illisible, qui explique cette incompatibilité d'humeur et mon désintérêt à l'égard de ti\textit kz. Toujours est-il que cette extension fonctionne, avec une lenteur certaine que j'attribue autant à ma programmation hasardeuse qu'à la lenteur intrinsèque de ti\textit kz. Toute remarque, remontée de bug ---~je n'ose pas dire amélioration du code~---, demande d'implémentation de fonctionnalité est bien évidemment bienvenue; j'invite les utilisateurs à m'en faire part \emph{via} email à \texttt{unbonpetit@netc.fr} @@ -595,7 +609,13 @@ Toute remarque, remontée de bug ---~je n'ose pas dire amélioration du code~---, >Correction d'un bug dans \verb|\ovalnum|; >Correction d'un bug dans \verb|\scr_ovalbox|. \end{version} -\begin{version}{0.12}{01/07/2019} +\begin{version}{0.13}{01/07/2019} >Mise en place de \verb|\relax| pour éviter le bug de \verb|\lastkern| avec Xe\LaTeX. \end{version} +\begin{version}{0.14}{01/10/2019} + >Gestion de l'échelle (via clé "\texttt{scale}") améliorée. + >Hors de l'environnement, les ovales et les losanges sont affectés par la clé "\texttt{scale}" si elle est spécifiée via \verb|\setscratch|. + >Erreur de tracé corrigée dans \verb|\scr_blockloop|. + >Nouveau losange vide : \verb|\boolempty[<dimension>]|. +\end{version} \end{document}
\ No newline at end of file diff --git a/macros/latex/contrib/scratch3/scratch3.sty b/macros/latex/contrib/scratch3/scratch3.sty index dfcacb8957..e23d7ca7ec 100644 --- a/macros/latex/contrib/scratch3/scratch3.sty +++ b/macros/latex/contrib/scratch3/scratch3.sty @@ -1,12 +1,13 @@ +% !BIB TS-program = % !TeX encoding = ISO-8859-1 % Ce fichier contient le code de l'extension "scratch3" % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \def\scrname{ scratch3 }% -\def\scrver { 0.13 }% +\def\scrver { 0.14 }% % % -\def\scrdate{ 2019/07/01 }% +\def\scrdate{ 2019/10/01 }% % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -19,7 +20,7 @@ % Repository : https://framagit.org/unbonpetit/scratch3/tree/master % Copyright : Christian Tellechea 2019 % Licence : Released under the LaTeX Project Public License v1.3c -% or later, see http://www.latex-project.org/lppl.txt +% or later, see http://www.latex-project.org/lppl.txtf % Files : 1) scratch3.sty % 2) scratch3-fr.tex % 3) scratch3-fr.pdf @@ -70,7 +71,12 @@ num start = 1 ,% numéro de départ baseline = 1 ,% alignement sur le 1er bloc (en partant du haut) } -\newcommand*\numblock[1]{\color{black}\footnotesize\bfseries#1} +\newcommand*\numblock[1]{% + \color{black}% + \footnotesize + \bfseries + #1% +} \newcommand*\resetscratch{\csname skv_[\scrname]\endcsname\scr_setcolors} \newcommand*\setscratch[1]{\setKV[\scrname]{#1}\scr_setcolors} \newcommand*\setdefaultscratch[1]{\setKVdefault[\scrname]{#1}\scr_setcolors} @@ -111,6 +117,8 @@ \fi \fi } +\newif\if_inpicture +\_inpicturefalse \newcount\scr_loopnest \newcount\scr_blocknum \newbox \scr_box @@ -135,6 +143,7 @@ \kern.6em \fi \useKV[\scrname]{pre text}% + \_inpicturetrue #2% \scr_blockstrut }% @@ -147,16 +156,27 @@ \edef\scr_boxht{\the\ht\scr_box}% \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% \draw[ - draw={\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{#1dd}}, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray!\scr_contrast!black} + {#1dd} + }, line width=\scr_linewidth, - rounded corners=0.4*\scr_ex, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{#1}}, + rounded corners=0.4*\scr_ex*\scr_scale, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray} + {none}% + } + {#1}% + }, yshift=\scr_yoffset, xshift=\scr_xoffset ] (0,0)--++(0.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\scr_boxwd+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666,0)% ligne sup --++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est - --++(-\scr_boxwd-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-0.66666*\scr_notch,0)% logne sud + --++(-\scr_boxwd-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-0.66666*\scr_notch,0)% ligne sud --cycle; \node[ at=(origin), @@ -164,7 +184,11 @@ anchor=base west, xshift=\scr_xoffset+\scr_xsep, yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\number\scr_blocknum) {\scr_currentstuff}; @@ -205,10 +229,21 @@ \edef\scr_boxht{\the\ht\scr_box}% \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% \draw[ - draw={\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{\scr_current_blockcolor dd}}, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray!\scr_contrast!black} + {\scr_current_blockcolor dd}% + }, line width=\scr_linewidth, - rounded corners=0.4*\scr_ex, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{\scr_current_blockcolor}}, + rounded corners=0.4*\scr_ex*\scr_scale, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray} + {none}% + } + {\scr_current_blockcolor}% + }, yshift=\scr_yoffset, xshift=\scr_xoffset ] @@ -220,7 +255,11 @@ anchor=base west, xshift=\scr_xoffset+\scr_xsep, yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\number\scr_blocknum) {\scr_currentstuff}; @@ -247,6 +286,7 @@ \def\scr_current_blockcolor{#1}% \def\scr_currentstuff{% \useKV[\scrname]{pre text}% + \_inpicturetrue #2% \scr_blockstrut }% @@ -259,10 +299,21 @@ \edef\scr_boxht{\the\ht\scr_box}% \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% \draw[ - draw={\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{#1dd}}, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray!\scr_contrast!black} + {#1dd}% + }, line width=\scr_linewidth, - rounded corners=0.4*\scr_ex, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{\scr_current_blockcolor}}, + rounded corners=0.4*\scr_ex*\scr_scale, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray} + {none}% + } + {\scr_current_blockcolor}% + }, yshift=\scr_yoffset, xshift=\scr_xoffset ] @@ -275,7 +326,11 @@ anchor=base west, xshift=\scr_xoffset+\scr_xsep, yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\number\scr_blocknum) {\scr_currentstuff}; @@ -301,6 +356,7 @@ \newcommand*\initmoreblocks[1]{% \def\scr_currentstuff{% \useKV[\scrname]{pre text}% + \_inpicturetrue #1% \scr_blockstrut }% @@ -314,14 +370,25 @@ \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% \def\scr_current_blockcolor{scrmoreblocks}% \draw[ - draw={\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{\scr_current_blockcolor dd}}, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{\scr_current_blockcolor}}, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray!\scr_contrast!black} + {\scr_current_blockcolor dd}% + }, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray} + {none}% + } + {\scr_current_blockcolor}% + }, yshift=\scr_yoffset, xshift=\scr_xoffset, - rounded corners=0.4*\scr_ex + rounded corners=0.4*\scr_ex*\scr_scale ] - (0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)[rounded corners=2*\scr_ex]--(0,0)--(\scr_boxwd+2*\scr_xsep,0)% ligne sup - [rounded corners=0.4*\scr_ex]--++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est + (0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)[rounded corners=2*\scr_ex*\scr_scale]--(0,0)--(\scr_boxwd+2*\scr_xsep,0)% ligne sup + [rounded corners=0.4*\scr_ex*\scr_scale]--++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est --++(-\scr_boxwd-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-.66666*\scr_notch,0)% ligne sud --cycle node[ @@ -330,7 +397,11 @@ anchor=base west, xshift=\scr_xoffset+\scr_xsep, yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\number\scr_blocknum) {\scr_currentstuff}; @@ -370,6 +441,7 @@ \setbox\scr_box\hbox{% \pgfinterruptpicture \useKV[\scrname]{pre text}% + \_inpicturetrue #1% \scr_blockstrut \endpgfinterruptpicture @@ -435,8 +507,15 @@ \draw[ draw=\scr_current_linecolor, line width=\scr_linewidth, - rounded corners=0.4*\scr_ex, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{\scr_current_blockcolor}} + rounded corners=0.4*\scr_ex*\scr_scale, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray} + {none}% + } + {\scr_current_blockcolor}% + } ] (\csname toploopx\number\scr_loopnest\endcsname,\csname toploopy\number\scr_loopnest\endcsname)--++(0.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666,0)% ligne sup --++(0,-\csname scr_txtlooptotht\number\scr_loopnest\endcsname-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est "|" @@ -463,7 +542,7 @@ \else --++(-\csname scr_txtloopwd\number\scr_loopnest\endcsname-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-.66666*\scr_notch,0)% ligne Sud "\--\__/---------" \fi - --(\csname toploopx\number\scr_loopnest\endcsname,\csname toploopy\number\scr_loopnest\endcsname-\scr_corner)--cycle;% remontée tout en haut et cycle + --cycle;% remontée tout en haut et cycle ## bugfix 0.14 \advance\scr_xoffset\dimexpr-\scr_loopblockwidth\relax \csname scr_numblockif\number\scr_loopnest\endcsname% numérote ou pas le texte dans le bandeau du haut \node[ @@ -472,10 +551,19 @@ anchor=base west, xshift=\csname toploopx\number\scr_loopnest\endcsname+\scr_xsep, yshift=\csname toploopy\number\scr_loopnest\endcsname-\csname scr_txtloopht\number\scr_loopnest\endcsname-\scr_corner-\scr_ysepsup, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\csname blocnum\number\scr_loopnest\endcsname) - {\useKV[\scrname]{pre text}#1\scr_blockstrut}; + {% + \useKV[\scrname]{pre text}% + \_inpicturetrue + #1% + \scr_blockstrut + }; \ifcat\relax\detokenize{#3}\relax\else \node[ at=(origin), @@ -483,10 +571,17 @@ anchor=base west, xshift=\csname toploopx\number\scr_loopnest\endcsname+\scr_xsep, yshift=\csname bottomify\number\scr_loopnest\endcsname-\scr_loopblockheight-\scr_corner, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (txt\csname blocelsenum\number\scr_loopnest\endcsname) - {\useKV[\scrname]{pre text}\useKV[\scrname]{else word}}; + {% + \useKV[\scrname]{pre text}% + \useKV[\scrname]{else word}% + }; \csname scr_numblockelse\number\scr_loopnest\endcsname% numérotation bloc else ou pas \fi \ifnum#5=1 %fleche @@ -495,7 +590,7 @@ \scr_arrowcolor, line width=1.5pt, -{Triangle[length=\scr_scale*1.25ex,width=\scr_scale*1.5ex]}, - rounded corners=1pt + rounded corners=1pt*\scr_scale ] (\scr_xoffset+\scr_xsep*2+\csname scr_txtloopwd\number\scr_loopnest\endcsname-\scr_ex*3.5+1pt,\scr_yoffset+\scr_linewidth+\scr_ysepinf-1.25pt)--++(\scr_loopblockheight,0)--++(0,\scr_loopblockheight+\scr_corner*0.5); \edef\scr_arrowcolor{\ifboolKV[\scrname]{print}{scr_flaggray}{white}}% colmeur de la flèche @@ -503,7 +598,7 @@ \scr_arrowcolor, line width=\scr_scale*1.5pt, -{Triangle[length=\scr_scale*1.25ex,width=\scr_scale*1.5ex]}, - rounded corners=1pt + rounded corners=1pt*\scr_scale ] (\scr_xoffset+\scr_xsep*2+\csname scr_txtloopwd\number\scr_loopnest\endcsname-\scr_ex*3.5,\scr_yoffset+\scr_linewidth+\scr_ysepinf)--++(\scr_loopblockheight,0)--++(0,\scr_loopblockheight+\scr_corner*0.5); \fi @@ -525,24 +620,45 @@ \scr_normalizedec\scr_contrast contrast[0,100]% \edef\scr_contrast{\number\numexpr100-\scr_contrast}% \fi + \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi \begin{tikzpicture}[ baseline=(x.base), x=1ex, y=1ex, inner ysep=0.25ex, inner xsep=0.1ex, - line width={\the\dimexpr\useKV[\scrname]{line width}\relax} + line width={\the\dimexpr\useKV[\scrname]{line width}\relax}, + scale=\scr_scale, + every node/.style={scale=\scr_scale} ] \node[ line width={\the\dimexpr\useKV[\scrname]{line width}\relax}, rounded rectangle, - draw={\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{#2dd}}, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray\if1#1!85!black\fi}{none}}{\scr_current_blockcolor\if1#1d\fi}}, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray!\scr_contrast!black} + {#2dd}% + }, + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray\if1#1!85!black\fi} + {none}% + } + {\scr_current_blockcolor\if1#1d\fi}% + }, + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (x) {% - \useKV[\scrname]{pre text}\relax\scr_ovalstrut\kern\scr_ovalsentinel sp + \useKV[\scrname]{pre text}\relax + \scr_ovalstrut + \kern\scr_ovalsentinel sp + \_inpicturetrue #3% \relax% pour contourner bug dans XeLaTeX \if1#1% si triangle de sélection @@ -565,7 +681,7 @@ baseline=-1ex, x=1.5ex, y=1.5ex, - rounded corners=1.5pt + rounded corners=1.5pt*\scr_scale ] \draw[ fill=white, @@ -577,24 +693,43 @@ % dessine un menu % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand*\selectmenu[1]{% #1=texte du menu (sera composé et suivi du triangle de sélection) + \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi \begin{tikzpicture}[ anchor=base west, baseline=(textmenu.base west), outer sep=0pt, inner sep=0pt, - minimum size=0pt + minimum size=0pt, + scale=\scr_scale, + every node/.style={scale=\scr_scale} ] \node[ rectangle, - rounded corners=1.5pt, - draw={\ifboolKV[\scrname]{print}{scr_linegray}{\scr_current_blockcolor dd}}, + rounded corners=1.5pt*\scr_scale, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray} + {\scr_current_blockcolor dd}% + }, inner sep=0.2em, - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray!85!black}{none}}{\scr_current_blockcolor}}, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray!85!black} + {none}% + } + {\scr_current_blockcolor}% + }, + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (textmenu) {% \useKV[\scrname]{pre text}% + \_inpicturetrue #1% \scr_ovalstrut \hskip.6666em @@ -613,20 +748,28 @@ \edef\_{\the\dimexpr.53033\dimexpr \scr_linewidth\relax\relax}% \def\scr_current_blockcolor{#1}% \edef\scr_boolsep{\useKV[\scrname]{bool sep}}% + \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi \begin{tikzpicture}[ inner sep=0pt, outer sep=0pt, minimum size=0pt, baseline=(x.base), line width=\scr_linewidth, - rounded corners=0pt% BUGFIX 0.11 + rounded corners=0pt,% BUGFIX 0.11 + scale=\scr_scale, + every node/.style={scale=\scr_scale} ] \setbox\scr_box\hbox{% \pgfinterruptpicture \useKV[\scrname]{pre text}% \scr_ovalstrut \kern\scr_boolsentinel sp - #2% + \_inpicturetrue + \if_boolempty + \vrule width#2 height0pt depth0pt\relax + \else + #2% + \fi \xdef\scr_endkern{\number\lastkern}% \endpgfinterruptpicture }% @@ -638,8 +781,19 @@ ] (\ifnum\scr_previouskern=\scr_boolsentinel-\scr_boolsep*.41421\else -\scr_totheight/2\fi,-\scr_boolsep)rectangle(\scr_retainedwd+\scr_totheight/2,\scr_totheight+\scr_boolsep);% \draw[ - fill={\ifboolKV[\scrname]{print}{\ifboolKV[\scrname]{fill blocks}{scr_fillgray}{none}}{\scr_current_blockcolor}}, - draw={\ifboolKV[\scrname]{print}{scr_linegray}{#1dd}} + fill={% + \ifboolKV[\scrname]{print} + {\ifboolKV[\scrname]{fill blocks} + {scr_fillgray\if_boolempty!85!black\fi} + {none}% + } + {\scr_current_blockcolor}% + }, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray} + {#1dd}% + } ] (\scr_boolsep,-\scr_boolsep)--++(\scr_retainedwd-\scr_boolsep*2,0)--++(\scr_totheight/2+\scr_boolsep,\scr_totheight/2+\scr_boolsep)--++(-\scr_totheight/2-\scr_boolsep,\scr_totheight/2+\scr_boolsep)--++(-\scr_retainedwd+\scr_boolsep*2,0)--++(-\scr_totheight/2-\scr_boolsep,-\scr_totheight/2-\scr_boolsep)--cycle;% \node[ @@ -648,7 +802,11 @@ minimum size=0pt, draw=none, anchor=south west, - text={\ifboolKV[\scrname]{print}{\useKV[\scrname]{text color}}{white}} + text={% + \ifboolKV[\scrname]{print} + {\useKV[\scrname]{text color}} + {white}% + } ] (x) {% @@ -656,11 +814,17 @@ \scr_ovalstrut \kern\_% \kern\scr_boolsentinel sp - #2% + \_inpicturetrue + \if_boolempty + \vrule width#2 height0pt depth0pt\relax + \else + #2% + \fi \kern\_% };% \end{tikzpicture}% \endgroup + \_boolemptyfalse \kern\scr_boolsentinel sp } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -704,40 +868,51 @@ \definecolor{penline} {HTML}{595e73}% \definecolor{penblue} {HTML}{4c8eea}% \definecolor{penvline} {HTML}{0da57a}% +\definecolor{boolempty} {HTML}{cf8b17}% new 0.14 +\definecolor{boolemptyd} {HTML}{cf8b17}% new 0.14 +\definecolor{boolemptydd} {HTML}{cf8b17}% new 0.14 \newenvironment{scratch}[1][] {\skv_ifempty{#1}{}{\setscratch{#1}}% \sffamily \edef\scr_ex{\the\dimexpr1ex\relax}% valeur d'1ex pour le tracé de la flèche \edef\scr_em{\the\dimexpr1em\relax}% - \scr_normalizedim\scr_corner corner[\scr_ex/3,\scr_ex]% - \scr_normalizedim\scr_notch notch[\scr_em/3,\scr_em*3]% - \scr_normalizedec\scr_scale scale[0.2,5]% échelle - \scr_normalizedim\scr_xsep x sep[0pt,\scr_em]% - \scr_normalizedim\scr_ysepsup y sepsup[1pt,\scr_ex*3]% - \scr_normalizedim\scr_ysepinf y sepinf[1pt,\scr_ex*3]% - \scr_normalizedim\scr_linewidth line width[0pt,5pt]% épaisseur des lignes soumises à l'échelle - \scr_normalizedim\scr_loopblockwidth loop width[3pt,\scr_em*3]% - \scr_normalizedim\scr_loopblockheight loop height[3pt,\scr_ex*3]% - \scr_normalizedec\scr_initarcangle init arcangle[20,40]% - \scr_normalizedim\scr_initarclength init arclength[\scr_em*3,\scr_em*8]% - \scr_normalizedim\scr_numsep num sep[0pt,\scr_em*3/2]% - \scr_normalizedec\scr_contrast contrast[0,100]% + \scr_normalizedim\scr_corner corner [\scr_ex/3,\scr_ex]% + \scr_normalizedim\scr_notch notch [\scr_em/3,\scr_em*3]% + \scr_normalizedec\scr_scale scale [0.2,5]% échelle + \scr_normalizedim\scr_xsep x sep [0pt,\scr_em]% + \scr_normalizedim\scr_ysepsup y sepsup [1pt,\scr_ex*3]% + \scr_normalizedim\scr_ysepinf y sepinf [1pt,\scr_ex*3]% + \scr_normalizedim\scr_linewidth line width [0pt,5pt]% épaisseur des lignes soumises à l'échelle + \scr_normalizedim\scr_loopblockwidth loop width [3pt,\scr_em*3]% + \scr_normalizedim\scr_loopblockheight loop height [3pt,\scr_ex*3]% + \scr_normalizedec\scr_initarcangle init arcangle [20,40]% + \scr_normalizedim\scr_initarclength init arclength [\scr_em*3,\scr_em*8]% + \scr_normalizedim\scr_numsep num sep [0pt,\scr_em*3/2]% + \scr_normalizedec\scr_contrast contrast [0,100]% \edef\scr_contrast{\number\numexpr100-\scr_contrast}% \edef\scr_minwd{\the\dimexpr\scr_corner*4+\scr_notch*3-\scr_xsep*2}% \edef\scr_valign{\useKV[\scrname]{baseline}}% \scr_blocknum\number\numexpr\useKV[\scrname]{num start}\relax\relax \setbox\scr_box\hbox{\scr_blockstrut}\edef\scr_blockstruttotht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% haut totale du strut \def\turnleft{\turn_arrow{}}\def\turnright{\turn_arrow{xscale=-1}}% - \let\blockmove \scr_blockmove \let\blocklook \scr_blocklook - \let\blocksound \scr_blocksound \let\blocklist \scr_blocklist - \let\blockpen \scr_blockpen \let\blockvariable \scr_blockvariable - \let\blockevent \scr_blockevent \let\blockinit \scr_blockinit - \let\blockrepeat \scr_blockrepeat \let\blockinfloop \scr_blockinfloop - \let\blockifelse \scr_blockifelse \let\blockif \scr_blockif - \let\blockinitclone\scr_blockinitclone \let\blockcontrol \scr_blockcontrol - \let\blocksensing \scr_blocksensing \let\blockmoreblocks\scr_blockmoreblocks - \let\namemoreblocks\scr_namemoreblocks + \let\blockmove \scr_blockmove + \let\blocklook \scr_blocklook + \let\blocksound \scr_blocksound + \let\blocklist \scr_blocklist + \let\blockpen \scr_blockpen + \let\blockvariable \scr_blockvariable + \let\blockevent \scr_blockevent + \let\blockinit \scr_blockinit + \let\blockrepeat \scr_blockrepeat + \let\blockinfloop \scr_blockinfloop + \let\blockifelse \scr_blockifelse + \let\blockif \scr_blockif + \let\blockinitclone \scr_blockinitclone + \let\blockcontrol \scr_blockcontrol + \let\blocksensing \scr_blocksensing + \let\blockmoreblocks\scr_blockmoreblocks + \let\namemoreblocks \scr_namemoreblocks \scr_xoffset0pt \scr_yoffset0pt \catcode`\:12 \catcode`\;12 \catcode`\!12 \catcode`\?12 \catcode`\_12 \csname skv_\if c\expandafter\scr_firsttonil\scr_valign c\_nil first\else second\fi\endcsname @@ -750,19 +925,21 @@ \begin{tikzpicture}[ baseline=(txt\scr_valign.base), }% - transform shape, + scale=\scr_scale, + every node/.style={scale=\scr_scale}, line width=\scr_linewidth, inner sep=0pt, outer sep=0pt, minimum size=0pt, - line cap=round, - scale=\scr_scale + line cap=round ] + \_inpicturetrue \node[shape=coordinate](origin){};% origine }% {% \end{tikzpicture}% \scr_scratchend + \_inpicturefalse% par pure sécurité } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -786,18 +963,25 @@ \else \def\scr_current_blockcolor{black}% \fi + \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi \begin{tikzpicture}[ baseline=(x.base), x=1ex, y=1ex, inner ysep=0.25ex, inner xsep=0.1ex, - line width=\scr_linewidth + line width=\scr_linewidth, + scale=\scr_scale, + every node/.style={scale=\scr_scale} ] \node[ line width=\scr_linewidth, rounded rectangle, - draw={\ifboolKV[\scrname]{print}{scr_linegray}{\scr_current_blockcolor}}, + draw={% + \ifboolKV[\scrname]{print} + {scr_linegray} + {\scr_current_blockcolor}% + }, fill=white, text=black ] @@ -806,6 +990,7 @@ \useKV[\scrname]{pre text}\relax \scr_ovalstrut \kern\scr_ovalsentinel sp + \_inpicturetrue #1% \relax% pour contourner bug dans XeLaTeX \ifnum\lastkern=\scr_ovalsentinel\relax\expandafter\scr_execfirst\else\expandafter\scr_execsecond\fi @@ -818,7 +1003,10 @@ \endgroup \kern\scr_ovalsentinel sp } -\def\turn_arrow#1{\tikz[baseline=.25ex,x=6.5ex,y=6.5ex,#1]\draw[-{Triangle[angle=45:0.5ex 0.5ex,flex]},line width=.3333ex](0,0) arc[start angle=-80,end angle=190,radius=1ex];} +\def\turn_arrow#1{% + \tikz[baseline=.25ex,x=6.5ex,y=6.5ex,#1] + \draw[-{Triangle[angle=45:0.5ex 0.5ex,flex]},line width=.3333ex](0,0) arc[start angle=-80,end angle=190,radius=1ex];% +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % menu apparence % @@ -847,7 +1035,7 @@ \def\scr_drawpen{% dessin du crayon \begin{tikzpicture}[ rotate=45, - rounded corners=.4pt, + rounded corners=.4pt*\scr_scale, line width=.5pt, x=5ex, y=5ex, @@ -858,19 +1046,27 @@ ] \draw[ penline, - fill={\ifboolKV[\scrname]{print}{scr_linegray}{penblue}} + fill={% + \ifboolKV[\scrname]{print} + {scr_linegray} + {penblue}% + } ] (0,0)--(22:0.1)..controls(0.13,0.04)and(0.13,-0.04)..(-22:0.1)[sharp corners]--cycle; \draw[ penline, fill=white, - rounded corners=.2pt + rounded corners=.2pt*\scr_scale ] - (22:0.1)--(22:0.2)[rounded corners=0.05pt]--(.56,.07492)..controls(.62,0.04)and(.62,-0.04)..(.56,-.07492)[rounded corners=2pt]--(-22:.2)[rounded corners=0.05pt]--(-22:0.1)..controls(0.13,-0.04)and(0.13,0.04)..(22:0.1); + (22:0.1)--(22:0.2)[rounded corners=0.05pt*\scr_scale]--(.56,.07492)..controls(.62,0.04)and(.62,-0.04)..(.56,-.07492)[rounded corners=2pt*\scr_scale]--(-22:.2)[rounded corners=0.05pt*\scr_scale]--(-22:0.1)..controls(0.13,-0.04)and(0.13,0.04)..(22:0.1); \draw[ penline, - fill={\ifboolKV[\scrname]{print}{scr_linegray}{penblue}}, - rounded corners=.2pt + fill={% + \ifboolKV[\scrname]{print} + {scr_linegray} + {penblue}% + }, + rounded corners=.2pt*\scr_scale ] (.56,.07492)--(.88,.07492)..controls(.92,0.04)and(.92,-0.04)..(0.88,-.07492)[sharp corners]--(.56,-.07492)..controls(.62,-0.04)and(.62,0.04)..cycle; \draw[penline](.84,0.07492)..controls(.7,.24)and(.58,0.02)..(.5,0.16); @@ -923,7 +1119,9 @@ }% } \newcommand*\boollist{\scr_boolbox{scrlist}} - +\newif\if_boolempty +\_boolemptyfalse +\newcommand*\boolempty[1][2em]{\_boolemptytrue\scr_boolbox{boolempty}{#1}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % menu événement % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -938,8 +1136,16 @@ ] \draw[ line width=\scr_linewidth, - draw={\ifboolKV[\scrname]{print}{scr_flaggray}{flagcontour}}, - fill={\ifboolKV[\scrname]{print}{scr_flaggray!85!white}{greenflag}} + draw={% + \ifboolKV[\scrname]{print} + {scr_flaggray} + {flagcontour}% + }, + fill={% + \ifboolKV[\scrname]{print} + {scr_flaggray!85!white} + {greenflag}% + } ] (0,0.95)..controls(.4,1.4) and (.7,.7)..(1,1)--(1,.4)..controls(.7,0.1)and(.4,.8)..(0,.4)--cycle; \filldraw[{\ifboolKV[\scrname]{print}{scr_flaggray}{flagcontour}}] @@ -1017,4 +1223,12 @@ Versions : | | | * bug corrigé dans \scr_ovalbox | |---------+------------+------------------------------------------------------| | 0.13 | 01/07/2019 | * \relax ajoutés pour éviter le bug de XeLaTeX | -| | | concernant \lastkern |
\ No newline at end of file +| | | concernant \lastkern | +|---------+------------+------------------------------------------------------| +| 0.14 | 01/10/2019 | * gestion de l'échelle (via clé "scale") améliorée | +| | | * hors de l'environnement, les ovales et les losanges| +| | | sont affectés par la clé scale si elle est | +| | | spécifiée via \setscratch | +| | | * erreur de tracé corrigée dans \scr_blockloop | +| | | * nouveau losange vide : \boolempty[<dimension>] | +|---------+------------+------------------------------------------------------|
\ No newline at end of file |