diff options
author | Karl Berry <karl@freefriends.org> | 2023-08-24 20:18:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-08-24 20:18:25 +0000 |
commit | 00f24b5cfdc3eb679c5e50a928c4c122107d3966 (patch) | |
tree | ed41e9b6bd3539ba8a808717c1b657d4cdff99d7 /Master/texmf-dist/source | |
parent | f1b9b4783cb4fbbb47f0f27b2c9d2147970a9888 (diff) |
witharrows (24aug23)
git-svn-id: svn://tug.org/texlive/trunk@68047 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/generic/witharrows/witharrows.dtx | 230 |
1 files changed, 150 insertions, 80 deletions
diff --git a/Master/texmf-dist/source/generic/witharrows/witharrows.dtx b/Master/texmf-dist/source/generic/witharrows/witharrows.dtx index 80573b1d6fc..6f6ea4bf0e3 100644 --- a/Master/texmf-dist/source/generic/witharrows/witharrows.dtx +++ b/Master/texmf-dist/source/generic/witharrows/witharrows.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{2.8a} -\def\myfiledate{2023/02/14} +\def\myfileversion{2.8b} +\def\myfiledate{2023/08/24} % % %<*batchfile> @@ -119,7 +119,7 @@ version 2005/12/01 or later. % \medskip % The arrows are drawn with Tikz and that's why \textbf{several compilations may % be necessary}.\footnote{If you use Overleaf, Overleaf will do automatically -% the right number of compilations.} +% a number compilations sufficient (by using |latexmk|).} % % \bigskip % This package provides an environment |{WithArrows}| to construct alignments of @@ -1999,17 +1999,36 @@ version 2005/12/01 or later. % The extension \pkg{witharrows} provides a command |\WithArrowsNewStyle| to % define styles in a way similar to the ``styles'' of Tikz. % +% \smallskip % The command |\WithArrowsNewStyle| takes two mandatory arguments. The first is % the name of the style and the second is a list of key-value pairs. The scope -% of the definition done by |\WithArrowsNewStyle| is the current TeX scope. +% of the definition done by |\WithArrowsNewStyle| is the current TeX +% scope.\footnote{We recall that, in particular, every LaTeX environment is a +% TeX group.} % +% \smallskip % The style can be used as a key at the document level (with % |\WithArrowsOptions|) or at the environment level (in the optional arguments % of |{WithArrows}| and |{DispWithArrows}|). The style can also be used in % another command |\WithArrowsNewStyle|. % +% \smallskip % For an example of use, see p.~\pageref{example-WithArrowsRightX}. % +% \bigskip +% At this time, there is no style for indivual arrows. However, it's, of course, +% possible to define new commands based upton the command |\Arrow|. For example : +% +% \begin{Verbatim} +% \newcommand{\ThickArrow}{\Arrow[tikz=thick]} +% \end{Verbatim} +% +% This new command |\ThickArrow| still accepts options between square brackets. +% It's possible to write |\ThickArrow[jump=2]| because, in fact, +% |\Arrow[tikz=thick][jump=2]| is an allowed syntax for the command |\Arrow| +% (it's possible to put an arbitrary number of optional arguments between square +% brackets after |\Arrow|). +% % \subsection{The key right-overlap} % % \colorbox{yellow!50}{\textbf{New 2.8}} @@ -2687,7 +2706,7 @@ version 2005/12/01 or later. % \bigskip % First, \pkg{tikz} and some Tikz libraries are loaded before the % |\ProvidesExplPackage|. They are loaded this way because |\usetikzlibrary| in -% |expl3| code fails.\footnote{cf. +% |L3| code fails.\footnote{cf. % |tex.stackexchange.com/questions/57424/using-of-usetikzlibrary-in-an-expl3-package-fails|} % % @@ -2699,7 +2718,8 @@ version 2005/12/01 or later. \input tikz.tex \input expl3-generic.tex %</plain-TeX> -\usetikzlibrary{arrows.meta,bending} +\usetikzlibrary{arrows.meta} +\usepgfmodule{bending} % https://texnique.fr/osqa/questions/12199 % \end{macrocode} % % \bigskip @@ -2908,6 +2928,56 @@ version 2005/12/01 or later. %</LaTeX> % \end{macrocode} % +% \bigskip +% \subsection{Collecting options} +% +% The following technic allows to create user commands with the ability to put +% an arbitrary number of |[|\textsl{list of (key=val)}|]| after the name of the +% command. +% +% \medskip +% \emph{Exemple} :\par\nobreak +% +% |\@@_collect_options:n { \F } [x=a,y=b] [z=c,t=d] { arg }| +% +% will be transformed in :\quad |\F{x=a,y=b,z=c,t=d}{arg}| +% +% \smallskip +% Therefore, by writing : |\def\G{\@@_collect_options:n{\F}}|, +% +% the command |\G| takes in an arbitrary number of optional arguments between +% square brackets. +% +% \bigskip +% \begin{macrocode} +%<*LaTeX> +\cs_new_protected:Npn \@@_collect_options:n #1 + { + \peek_meaning:NTF [ + { \@@_collect_options:nw { #1 } } + { #1 { } } + } +% \end{macrocode} +% +% \bigskip +% We use |\NewDocumentCommand| in order to be able to allow nested brackets +% within the argument between |[| and |]|. +% \begin{macrocode} +\NewDocumentCommand \@@_collect_options:nw { m r[] } + { \@@_collect_options:nn { #1 } { #2 } } + +\cs_new_protected:Npn \@@_collect_options:nn #1 #2 + { + \peek_meaning:NTF [ + { \@@_collect_options:nnw { #1 } { #2 } } + { #1 { #2 } } + } + +\cs_new_protected:Npn \@@_collect_options:nnw #1#2[#3] + { \@@_collect_options:nn { #1 } { #2 , #3 } } +%</LaTeX> +% \end{macrocode} +% % % % \bigskip @@ -2918,33 +2988,6 @@ version 2005/12/01 or later. \cs_generate_variant:Nn \seq_set_split:Nnn { N x x } % \end{macrocode} % -% \medskip -% We create booleans in order to know if some packages are loaded. For example, -% for the package \pkg{amsmath}, the boolean is called -% |\c_@@_amsmath_loaded_bool|.\footnote{It's not possible to use -% |\@ifpackageloaded| in the core of the functions because |\@ifpackageloaded| -% is available only in the preamble.} -% \begin{macrocode} -\AtBeginDocument - { - \clist_map_inline:nn - { - amsmath, amsthm, autonum, cleveref, hyperref, mathtools, showlabels, - typedref, unicode-math - } - { - \bool_new:c { c_@@_#1_loaded_bool } -%<*LaTeX> - \@ifpackageloaded { #1 } - { \bool_set_true:c { c_@@_#1_loaded_bool } } - { } -%</LaTeX> -%<*plain-TeX> - \bool_set_false:c { c_@@_#1_loaded_bool } -%</plain-TeX> - } - } -% \end{macrocode} % % \bigskip % We define a command |\@@_sort_seq:N| which will sort a sequence. @@ -2953,15 +2996,10 @@ version 2005/12/01 or later. { \seq_sort:Nn #1 { - \int_compare:nNnTF - { - \tex_strcmp:D - { \str_lower_case:n { ##1 } } - { \str_lower_case:n { ##2 } } - } - > 0 - \sort_return_swapped: + \str_compare:eNeTF + { \str_lowercase:n { ##1 } } < { \str_lowercase:n { ##2 } } \sort_return_same: + \sort_return_swapped: } } % \end{macrocode} @@ -3060,9 +3098,26 @@ version 2005/12/01 or later. remember~picture , overlay , name~prefix = wa - \l_@@_prefix_str - + } , + @@_standard_arrow / .style = + { + @@_standard , + every~path / .style = WithArrows / arrow } } % \end{macrocode} +% The following line is a security when using |xelatex| and RTL language (cf. +% question~683570 on TeX StackExchange). +% \begin{macrocode} +\sys_if_engine_xetex:T + { + \tikzset + { + @@_standard_arrow / .append~style = + { every~node / .append~style = { text = . } } + } + } +% \end{macrocode} % % \bigskip % We also define a style for the tips of arrow. The final user of the extension @@ -3112,7 +3167,7 @@ version 2005/12/01 or later. %<*LaTeX> \AtBeginDocument { - \bool_if:NTF \c_@@_amsmath_loaded_bool + \IfPackageLoadedTF { amsmath } { \seq_put_right:Nn \l_@@_options_WithArrowsOptions_seq { subequations } \seq_put_right:Nn \l_@@_options_DispWithArrows_seq { subequations } @@ -3128,9 +3183,7 @@ version 2005/12/01 or later. % % Nevertheless, we want the extension \pkg{witharrows} available without % \pkg{amsmath}. That's why we give a definition of |\spread@equation| if -% \pkg{amsmath} is not loaded (we put the code in the hook |begindocument| -% because the flag |\c_@@_amsmath_loaded_bool| is itself set in the hook -% |begindocument|). +% \pkg{amsmath} is not loaded. % \begin{macrocode} { %</LaTeX> @@ -3558,20 +3611,19 @@ version 2005/12/01 or later. % The following list of the (left) extensible delimiters of LaTeX is only for % the validation of the key |replace-left-brace-by|. % \begin{macrocode} -\clist_new:N \c_@@_extensible_delimiters_clist -\clist_set:Nn \c_@@_extensible_delimiters_clist +\clist_new:N \c_@@_ext_delimiters_clist +\clist_set:Nn \c_@@_ext_delimiters_clist { ., \{, (, [, \lbrace, \lbrack, \lgroup, \langle, \lmoustache, \lceil, \lfloor } %<*LaTeX> \AtBeginDocument { - \bool_lazy_or:nnT - \c_@@_amsmath_loaded_bool - { \use:c { c_@@_unicode-math_loaded_bool } } - { - \clist_put_right:Nn \c_@@_extensible_delimiters_clist { \lvert, \lVert } - } + \bool_set_false:N \l_tmpa_bool + \IfPackageLoadedTF { amsmath } { \bool_set_true:N \l_tmpa_bool } { } + \IfPackageLoadedTF { unicode-math } { \bool_set_true:N \l_tmpa_bool } { } + \bool_if:NT \l_tmpa_bool + { \clist_put_right:Nn \c_@@_ext_delimiters_clist { \lvert, \lVert } } } %</LaTeX> % \end{macrocode} @@ -3601,7 +3653,7 @@ version 2005/12/01 or later. % must test whether the package \pkg{amsmath} is loaded. % \begin{macrocode} subequations .code:n = - \bool_if:NTF \c_@@_amsmath_loaded_bool + \IfPackageLoadedTF { amsmath } { \bool_set_true:N \l_@@_subequations_bool } { \@@_error:n { amsmath~not~loaded } @@ -3631,7 +3683,7 @@ version 2005/12/01 or later. { \tl_set:Nx \l_tmpa_tl { \tl_head:n { #1 } } \clist_if_in:NVTF - \c_@@_extensible_delimiters_clist + \c_@@_ext_delimiters_clist \l_tmpa_tl { \tl_set:Nn \l_@@_replace_left_brace_by_tl { #1 } } { \@@_error:n { Bad~value~for~replace~brace~by } } @@ -4025,7 +4077,9 @@ version 2005/12/01 or later. % \medskip % \begin{macrocode} %<*LaTeX> -\NewDocumentCommand \@@_Arrow { O { } m ! O { } } +\cs_new_protected:Npn \@@_Arrow + { \@@_collect_options:n { \@@_Arrow_i } } +\NewDocumentCommand \@@_Arrow_i { m m ! O { } } %</LaTeX> %<*plain-TeX> \cs_new_protected:Npn \@@_Arrow @@ -4102,7 +4156,7 @@ version 2005/12/01 or later. % % \item The label of the arrow (it's also a token list): % \begin{macrocode} - \prop_put:Nnn \l_tmpa_prop { label } { #2 } + \prop_put:Nnn \l_tmpa_prop { label } { #2 } % \end{macrocode} % % \item The number of the line where the command |\Arrow| is issued in the TeX @@ -4175,7 +4229,12 @@ version 2005/12/01 or later. \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } % \end{macrocode} -% +% +% \bigskip +% \begin{macrocode} + \tikzset { arrows = [ flex ] } % https://texnique.fr/osqa/questions/12199 +% \end{macrocode} +% % \bigskip % The token list |\l_@@_name_str| will contain the potential name of the % environment (given with the option |name|). This name will be used to create @@ -4505,7 +4564,7 @@ version 2005/12/01 or later. % The command |\@@_set_qedhere:| will do a redefinition of |\qedhere| in each % cell of the last column. % \begin{macrocode} - \bool_if:NT \c_@@_amsthm_loaded_bool \@@_set_qedhere: + \IfPackageLoadedTF { amsmath } { \@@_set_qedhere: } { } } %</LaTeX> } @@ -4986,19 +5045,20 @@ version 2005/12/01 or later. % Then, an action done by \pkg{hyperref} in its redefinition of % |\refstepcounter|. % \begin{macrocode} - \bool_if:NT \c_@@_hyperref_loaded_bool + \IfPackageLoadedTF { hyperref } { - % the following line is probably useless (2022/05/16) + % the following line is probably pointless (2022/05/16) % \str_set:Nn \This@name { equation } \hyper@refstepcounter { equation } } + { } % \end{macrocode} % Then, an action done by \pkg{cleveref} in its redefinition of % |\refstepcounter|. The package \pkg{cleveref} creates in the |aux| file a % command |\cref@currentlabel| similar to |\@currentlabel| but with more % informations. % \begin{macrocode} - \bool_if:NT \c_@@_cleveref_loaded_bool + \IfPackageLoadedTF { cleveref } { \cref@constructprefix { equation } \cref@result \protected@edef \cref@currentlabel @@ -5012,6 +5072,7 @@ version 2005/12/01 or later. \p@equation \g_tmpa_tl } } + { } % \end{macrocode} % Now, we can issue the command |\label| (some packages may have redefined % |\label|, for example \pkg{typedref}) for each item in the sequence of the @@ -5219,7 +5280,7 @@ version 2005/12/01 or later. % environment). % \begin{macrocode} %<*LaTeX> - \bool_if:nT \c_@@_mathtools_loaded_bool + \IfPackageLoadedTF { mathtools } { \MH_if_boolean:nT { show_only_refs } { @@ -5232,19 +5293,22 @@ version 2005/12/01 or later. \MH_set_boolean_T:n { show_only_refs } } } + { } % \end{macrocode} % % An action done by \pkg{typedref} in its redefinition of |\refstepcounter|. The % command |\sr@name| is a prefix added to the name of the label by the % redefinition of |\label| done by \pkg{typedref}. % \begin{macrocode} - \bool_if:NT \c_@@_typedref_loaded_bool { \str_set:Nn \sr@name { equation } } + \IfPackageLoadedTF { typedref } + { \str_set:Nn \sr@name { equation } } + { } % \end{macrocode} % % The command |\intertext@| is a command of \pkg{amsmath} which loads the % definition of |\intertext|. % \begin{macrocode} - \bool_if:NT \c_@@_amsmath_loaded_bool \intertext@ + \IfPackageLoadedTF { amsmath } { \intertext@ } { } %</LaTeX> \exp_args:No \tl_if_novalue:nF { #1 } { \tl_set:Nn \l_@@_left_brace_tl { #1 } } \@@_pre_halign:n { #2 } @@ -5513,8 +5577,9 @@ version 2005/12/01 or later. % the environment). % \begin{macrocode} %<*LaTeX> - \bool_if:nT \c_@@_mathtools_loaded_bool + \IfPackageLoadedTF { mathtools } { \MH_if_boolean:nT { show_only_refs } \MT_showonlyrefs_true: } + { } \bool_if:NTF \l_@@_in_label_or_minipage_bool { \c_math_toggle_token @@ -5617,7 +5682,7 @@ version 2005/12/01 or later. \tl_if_empty:NF \l_@@_tag_tl { \@@_error:nn { Multiple~tags } { #2 } } \clist_set:Nn \l_@@_tags_clist { all } - \bool_if:nT \c_@@_mathtools_loaded_bool + \IfPackageLoadedTF { mathtools } { \MH_if_boolean:nT { show_only_refs } { @@ -5625,6 +5690,7 @@ version 2005/12/01 or later. { \clist_clear:N \l_@@_tags_clist } } } + { } \tl_set:Nn \l_@@_tag_tl { #2 } \bool_set:Nn \l_@@_tag_star_bool { #1 } % \end{macrocode} @@ -5634,8 +5700,12 @@ version 2005/12/01 or later. % |\@eqnnum|.\footnote{There are two versions of |@eqnnum|, a standard version % and a version for the option |leqno|.} % \begin{macrocode} - \bool_if:nT { #1 && ! \bool_if_p:N \c_@@_amsmath_loaded_bool } - { \@@_error:n { tag*~without~amsmath } } + \bool_if:nT { #1 } + { + \IfPackageLoadedTF { amsmath } + { } + { \@@_error:n { tag*~without~amsmath } } + } } } % \end{macrocode} @@ -5653,12 +5723,12 @@ version 2005/12/01 or later. { \seq_if_empty:NF \l_@@_labels_seq { - \bool_if:NTF \c_@@_cleveref_loaded_bool + \IfPackageLoadedTF { cleveref } { \@@_error:n { Multiple~labels~with~cleveref } } { \@@_error:n { Multiple~labels } } } \seq_put_right:Nn \l_@@_labels_seq { #1 } - \bool_if:nT \c_@@_mathtools_loaded_bool + \IfPackageLoadedTF { mathtools } { \MH_if_boolean:nT { show_only_refs } { @@ -5667,12 +5737,14 @@ version 2005/12/01 or later. { \clist_clear:N \l_@@_tags_clist } } } - \bool_if:nT \c_@@_autonum_loaded_bool + { } + \IfPackageLoadedTF { autonum } { \cs_if_exist:cTF { autonum@#1Referenced } { \clist_set:Nn \l_@@_tags_clist { all } } { \clist_clear:N \l_@@_tags_clist } } + { } } } % \end{macrocode} @@ -6333,10 +6405,7 @@ version 2005/12/01 or later. %<*plain-TeX> \tikzpicture %</plain-TeX> - [ - @@_standard , - every~path / .style = WithArrows / arrow - ] + [ @@_standard_arrow ] % \end{macrocode} % You keep track of the bounding box because we want to compute the total width % of the arrow (with the label) for the arrows of type |over| and also for the @@ -7329,7 +7398,7 @@ version 2005/12/01 or later. % \begin{macrocode} \@@_msg_new:nn { Incompatible~options a} { - Incompatible~options. + Incompatible~options.\\ You~try~to~use~the~option~'\l_keys_key_str'~but~ this~option~is~incompatible~or~redundant~with~the~option~ '\l_@@_previous_key_str'~set~in~the~same~command~ @@ -7345,7 +7414,7 @@ version 2005/12/01 or later. % \begin{macrocode} \@@_msg_new:nnn { Arrow~not~in~last~column } { - Bad~use~of~\l_@@_string_Arrow_for_msg_str. + Bad~use~of~\l_@@_string_Arrow_for_msg_str.\\ You~should~use~the~command~\l_@@_string_Arrow_for_msg_str\ only~in~the~last~column~(column~\int_use:N\l_@@_nb_cols_int)~ in~the~row~\int_use:N \g_@@_line_int\ @@ -7448,8 +7517,8 @@ version 2005/12/01 or later. Normally,~we~can't~use~the~command~\token_to_str:N\label\ twice~in~a~line~of~the~environment~\{\l_@@_type_env_str\}. \\ However,~you~can~go~on.~ - \bool_if:NT \c_@@_showlabels_loaded_bool - { However,~only~the~last~label~will~be~shown~by~showlabels.~ } + \IfPackageLoadedTF { showlabels } + { However,~only~the~last~label~will~be~shown~by~showlabels.~ } { } If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~ 'allow-multiple-labels'~at~the~global~or~environment~level. } @@ -7982,6 +8051,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \section{History} +% % % \subsection*{Changes between 2.7 and 2.8} % |