diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/witharrows/witharrows.pdf | bin | 370552 -> 375892 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/witharrows/witharrows.dtx | 1539 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 1976 |
3 files changed, 1816 insertions, 1699 deletions
diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf Binary files differindex bb04ca45928..edaa0772c37 100644 --- a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf +++ b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx index 09e887cd57d..d8993abebd4 100644 --- a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx +++ b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{1.15} -\def\myfiledate{2019/02/20} +\def\myfileversion{1.16} +\def\myfiledate{2019/03/11} % % %<*batchfile> @@ -44,7 +44,7 @@ version 2005/12/01 or later. \endgroup %</batchfile> % -%<@@=witharrows> +%<@@=wa> %<*driver> \documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz, loaded by witharrows) \usepackage{xltxtra} @@ -69,8 +69,9 @@ version 2005/12/01 or later. %</driver> % \fi % \VerbatimFootnotes -% \title{The package \pkg{witharrows}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{witharrows}, -% at the date of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} +% \title{The package \pkg{witharrows}\thanks{This document corresponds to the +% version~\myfileversion\space of \pkg{witharrows}, at the date +% of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} % % \maketitle % @@ -83,12 +84,12 @@ version 2005/12/01 or later. % \end{abstract} % % -% \vskip1cm -% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by -% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two -% compilations may be necessary. This package requires the packages \pkg{expl3}, -% \pkg{xparse} and \pkg{tikz}. The Tikz libraries \pkg{arrows.meta} and -% \pkg{bending} are also required. +% \vspace{1cm} +% This package can be used with |xelatex|, |lualatex|, |pdflatex| +% but also by the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe +% Distiller). Several compilations may be necessary. This package requires the +% packages \pkg{expl3}, \pkg{xparse} and \pkg{tikz}. The Tikz libraries +% \pkg{arrows.meta} and \pkg{bending} are also required. % % \bigskip % This package provides an environment |{WithArrows}| to construct alignments of @@ -528,7 +529,8 @@ version 2005/12/01 or later. % & = \int_0^{\frac{\pi}4} \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)d u \\ % & = \int_0^{\frac{\pi}4}\ln\left(1+\frac{1-\tan u}{1+\tan u}\right)\, d u \\ % & =\int_0^{\frac{\pi}4}\ln\left(\frac{1+\tan u+1-\tan u}{1+\tan u}\right) d u -% \Arrow[ll,jump=2,tikz={text width = 5cm}]{This arrow uses a \texttt{ll} option and a \texttt{jump} equal to $2$}\\ +% \Arrow[ll,jump=2,tikz={text width = 5cm}]{This arrow uses a \texttt{ll} option +% and a \texttt{jump} equal to $2$}\\ % & =\int_0^{\frac{\pi}4} \ln\left(\frac2{1+\tan u}\right)\, d u\\ % & =\int_0^{\frac{\pi}4}\bigl(\ln2-\ln(1+\tan u)\bigr)\, d u \\ % & =\frac{\pi}4\ln2-\int_0^{\frac{\pi}4}\ln(1+\tan u)\, d u \\ @@ -1025,7 +1027,7 @@ version 2005/12/01 or later. % for the command~|\Arrow| in |CodeAfter|. However, it's always possible to % translate an arrow with |xoffset| (or |xshift| of Tikz). % \begin{Verbatim} -% $\begin{WithArrows}[CodeAfter = \Arrow~emphase#[v]@{1-2}{2-2}{division by $2$} ] +% $\begin{WithArrows}[CodeAfter=\Arrow~emphase#[v]@{1-2}{2-2}{division by $2$}] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % ......... @@ -1409,7 +1411,8 @@ version 2005/12/01 or later. % \begin{DispWithArrows}[displaystyle] % S_{2(p+1)} % & =\sum_{k=1}^{2(p+1)} (-1)^k k^2 \\ -% & \smash[b]{=\sum_{k=1}^{2p}(-1)^kk^2+(-1)^{2p+1}(2p+1)^2+(-1)^{2p+2}(2p+2)^2} \tagnextline \\ +% & \smash[b]{=\sum_{k=1}^{2p}(-1)^kk^2+(-1)^{2p+1}(2p+1)^2+(-1)^{2p+2}(2p+2)^2} +% \tagnextline \\ % &= S_{2p}-(2p+1)^2+(2p+2)^2\\ % &= 2p^2+p-4p^2-4p-1+4p^2+8p+4\\ % &= 2p^2+5p+3 @@ -1419,39 +1422,6 @@ version 2005/12/01 or later. % \end{center} % % -% \bigskip -% The environment |{DispWithArrows}| is similar to the environment |{align}| of -% \pkg{amsmath}. However, |{DispWithArrows}| is not constructed upon |{align}| -% (in fact, it's possible to use \pkg{witharrows} without \pkg{amsmath}). -% -% There are differences between |{DispWithArrows}| and |{align}|. -% \begin{itemize} -% \item The environment |{DispWithArrows}| allows only two columns. -% \item The environment |{DispWithArrows}| can not be inserted in an environment -% |{gather}| of \pkg{amsmath}. -% \item An environment |{DispWithArrows}| is always unbreakable (even with -% |\allowdisplaybreaks| of \pkg{amsmath}). -% \item The commands |\label|, |\tag|, |\notag| and |\nonumber| are allowed only -% in the second column. -% \item -% \begin{bfseries} -% Last but not least, by default, the elements of a \texttt{\{DispWithArrows\}} -% are composed in \texttt{textstyle} and not in \texttt{displaystyle} (it's -% possible to change this point with the option \texttt{displaystyle}). -% \end{bfseries} -% \end{itemize} -% -% \bigskip -% Concerning the references, the package \pkg{witharrows} is compatible with the -% extensions \pkg{autonum}, \pkg{cleveref}, \pkg{fancyref}, \pkg{fncylab}, -% \pkg{hyperref}, \pkg{listlbls}, \pkg{prettyref}, \pkg{refcheck}, -% \pkg{refstyle}, \pkg{showlabels}, \pkg{smartref}, \pkg{typedref} and -% \pkg{varioref}, and with the options |showonlyrefs| and |showmanualtags| of -% \pkg{mathtools}.\footnote{We recall that \pkg{varioref}, \pkg{hyperref}, -% \pkg{cleveref} and \pkg{autonum} must be loaded in this order. The package -% \pkg{witharrows} can be loaded anywhere.} -% -% It is not compatible with \pkg{showkeys} (not all the labels are shown). % % \bigskip % The environments |{DispWithArrows}| and |{DispWithArrows*}| provide an option @@ -1474,7 +1444,8 @@ version 2005/12/01 or later. % S_n % & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right) % \Arrow{sum of terms of a geometric progression of ratio $e^{i\frac{2\pi}n}$}\\ -% & = \frac1n \Re \left( \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}{1-e^{i\frac{\pi}{2n}}}\right) +% & = \frac1n \Re \left( +% \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}{1-e^{i\frac{\pi}{2n}}} \right) % \Arrow{This line has been wrapped automatically.} \\ % & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right) % \end{DispWithArrows*} @@ -1485,8 +1456,83 @@ version 2005/12/01 or later. % it applies to the instructions |\Arrow| and |\MultiArrow| of the |CodeAfter| % of the environments |{DispWithArrows}| or |{DispWithArrows*}|. % +% \vspace{1cm} +% We have said that the environments |{DispWithArrows}| and |{DispWithArrows*}| +% should be used in horizontal mode and not in vertical mode. However, there is +% an exception. These environments can be used directly after a |\item| of a +% LaTeX list. In this case, no vertical space is added before the +% environment.\footnote{It's possible to disable this feature with the option |standard-behaviour-with-items|.} +% +% \medskip +% Here is an example. The use of |{DispWithArrows}| gives the ability to tag an +% equation (and also to use |wrap-lines|). +% +% \begin{Verbatim} +% ~emphase#\begin{enumerate}@ +% ~emphase#\item @ +% \begin{DispWithArrows}% +% [displaystyle, wrap-lines, tagged-lines = last, fleqn, mathindent = 0 pt] +% S_n +% & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right) +% \Arrow{we use the formula for a sum of terms of a geometric progression of +% ratio $e^{i\frac{2\pi}n}$}\\ +% & = \frac1n \Re \left( \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n} +% {1-e^{i\frac{\pi}{2n}}}\right) +% \Arrow{$\bigl(e^{i\frac{\pi}{2n}}\bigr)^n = e^{i\frac{\pi}2}=i$} \\ +% & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right) +% \end{DispWithArrows} +% ~emphase#\end{enumerate}@ +% \end{Verbatim} +% \begin{enumerate} +% \item +% \begin{DispWithArrows}[displaystyle, wrap-lines, tagged-lines = last, fleqn, mathindent = 0 pt] +% S_n +% & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right) +% \Arrow{we use the formula for a sum of terms of a geometric progression of +% ratio $e^{i\frac{2\pi}n}$}\\ +% & = \frac1n \Re \left( +% \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}{1-e^{i\frac{\pi}{2n}}} \right) +% \Arrow{$\bigl(e^{i\frac{\pi}{2n}}\bigr)^n = e^{i\frac{\pi}2}=i$} \\ +% & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right) +% \end{DispWithArrows} +% \end{enumerate} +% +% \vspace{1cm} +% The environment |{DispWithArrows}| is similar to the environment |{align}| of +% \pkg{amsmath}. However, |{DispWithArrows}| is not constructed upon |{align}| +% (in fact, it's possible to use \pkg{witharrows} without \pkg{amsmath}). +% +% There are differences between |{DispWithArrows}| and |{align}|. +% \begin{itemize} +% \item The environment |{DispWithArrows}| allows only two columns. +% \item The environment |{DispWithArrows}| can not be inserted in an environment +% |{gather}| of \pkg{amsmath}. +% \item An environment |{DispWithArrows}| is always unbreakable (even with +% |\allowdisplaybreaks| of \pkg{amsmath}). +% \item The commands |\label|, |\tag|, |\notag| and |\nonumber| are allowed only +% in the second column. +% \item After an |\item| of a LaTeX list, no vertical space is added. +% \item +% \begin{bfseries} +% Last but not least, by default, the elements of a \texttt{\{DispWithArrows\}} +% are composed in \texttt{textstyle} and not in \texttt{displaystyle} (it's +% possible to change this point with the option \texttt{displaystyle}). +% \end{bfseries} +% \end{itemize} +% +% \bigskip +% Concerning the references, the package \pkg{witharrows} is compatible with the +% extensions \pkg{autonum}, \pkg{cleveref}, \pkg{fancyref}, \pkg{fncylab}, +% \pkg{hyperref}, \pkg{listlbls}, \pkg{prettyref}, \pkg{refcheck}, +% \pkg{refstyle}, \pkg{showlabels}, \pkg{smartref}, \pkg{typedref} and +% \pkg{varioref}, and with the options |showonlyrefs| and |showmanualtags| of +% \pkg{mathtools}.\footnote{We recall that \pkg{varioref}, \pkg{hyperref}, +% \pkg{cleveref} and \pkg{autonum} must be loaded in this order. The package +% \pkg{witharrows} can be loaded anywhere.} % +% It is not compatible with \pkg{showkeys} (not all the labels are shown). % +% % \section{Advanced features} % % @@ -1714,6 +1760,15 @@ version 2005/12/01 or later. % \end{WithArrows}$ % % \bigskip +% \subsection{Option no-arrows} +% +% The option |no-arrows| is a convenience given to the user. With this option +% the arrows are not drawn. However, an analyse of the arrows is done and some +% errors can be raised, for example if an arrow would arrive after the last row +% of the environment. +% +% +% \bigskip % \subsection{Note for developpers} % % If you want to construct an environment upon an environment of @@ -1750,7 +1805,9 @@ version 2005/12/01 or later. % \DispWithArrows} % {\endDispWithArrows} % \end{Verbatim} -% +% +% +% % \section{Examples} % % \subsection{With only one column} @@ -2296,14 +2353,6 @@ version 2005/12/01 or later. \cs_generate_variant:Nn \@@_error:nn { n x } % \end{macrocode} % -% \begin{macrocode} -\cs_new_protected:Nn \@@_bool_new:N - { - \bool_if_exist:NTF #1 - { \bool_set_false:N #1 } - { \bool_new:N #1 } - } -% \end{macrocode} % % \medskip % We create booleans in order to know if some packages are loaded. For example, @@ -2334,29 +2383,32 @@ version 2005/12/01 or later. % \begin{macrocode} \sys_if_engine_luatex:TF { - \cs_new_protected:Nn \@@_strcmp:nn + \cs_new_protected:Npn \@@_strcmp:nn #1 #2 { \lua_now:e { l3kernel.strcmp('#1','#2') } } } - { \cs_new_protected:Nn \@@_strcmp:nn { \pdftex_strcmp:D { #1 } { #2 } } } + { + \cs_new_protected:Npn \@@_strcmp:nn #1 #2 + { \pdftex_strcmp:D { #1 } { #2 } } + } % \end{macrocode} % % \bigskip % We can now define a command |\@@_sort_seq:N| which will sort a sequence. % \begin{macrocode} -\cs_new_protected:Nn \@@_sort_seq:N +\cs_new_protected:Npn \@@_sort_seq:N #1 { \seq_sort:Nn #1 - { - \int_compare:nNnTF - { - \@@_strcmp:nn - { \str_lower_case:n { ##1 } } - { \str_lower_case:n { ##2 } } - } - > 0 - \sort_return_swapped: - \sort_return_same: - } + { + \int_compare:nNnTF + { + \@@_strcmp:nn + { \str_lower_case:n { ##1 } } + { \str_lower_case:n { ##2 } } + } + > 0 + \sort_return_swapped: + \sort_return_same: + } } % \end{macrocode} % @@ -2374,7 +2426,7 @@ version 2005/12/01 or later. % variable is determinated by the suffix \texttt{\slshape type} and is used to % apply the corresponding \pkg{expl3} commands. % \begin{macrocode} -\cs_new_protected:Nn \@@_save:N +\cs_new_protected:Npn \@@_save:N #1 { \seq_set_split:Nxx \l_tmpa_seq { \char_generate:nn { `_ } { 12 } } @@ -2399,7 +2451,7 @@ version 2005/12/01 or later. % The command |\@@_restore:N| affects to the \pkg{expl3} variable the value of % the (previously) set value of the corresponding \emph{global} variable. % \begin{macrocode} -\cs_new_protected:Nn \@@_restore:N +\cs_new_protected:Npn \@@_restore:N #1 { \seq_set_split:Nxx \l_tmpa_seq { \char_generate:nn { `_ } { 12 } } @@ -2471,8 +2523,10 @@ version 2005/12/01 or later. % it will be passed to |every~path|). % \begin{macrocode} \tikzset - { WithArrows / arrow / .style = - { align = left , + { + WithArrows / arrow / .style = + { + align = left , % \end{macrocode} % % We have put the option |align = left| because we want to give the user the @@ -2526,6 +2580,7 @@ version 2005/12/01 or later. \bool_new:N \l_@@_in_CodeAfter_bool % \end{macrocode} % +% \bigskip % The following sequence is the position of the last environment |{WithArrows}| % in the tree of the nested environments |{WithArrows}|. % \begin{macrocode} @@ -2542,27 +2597,14 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following skip (=glue) is the vertical space inserted between two lines -% (=rows) of the |\halign|. -% \begin{macrocode} -\skip_new:N \l_@@_interline_skip -% \end{macrocode} -% -% \bigskip -% The following integer indicates the position of the box that will be created: +% The following integer indicates the position of the box that will be created +% for an environment |{WithArrows}| (not an environment |{DispWithArrows}|) : % 0 (=|t|=|\vtop|), 1~(=|c|=|\vcenter|) or 2 (=|b|=|\vbox|). % \begin{macrocode} \int_new:N \l_@@_pos_env_int % \end{macrocode} % % \bigskip -% \begin{macrocode} -\dim_new:N \l_@@_xoffset_dim -\dim_set:Nn \l_@@_xoffset_dim { 3 mm } -% \end{macrocode} -% -% -% \bigskip % The integer |\l_@@_pos_arrow_int| indicates the position of the arrow with the % following code (the option |v| is accessible only for the arrows in % |CodeAfter| where the options |i|, |group| et |groups| are not available). @@ -2581,29 +2623,11 @@ version 2005/12/01 or later. % \end{tabular} % \end{center} % -% % \begin{macrocode} \int_new:N \l_@@_pos_arrow_int \int_set:Nn \l_@@_pos_arrow_int 3 % \end{macrocode} % -% \medskip -% The variable |\l_@@_input_line_str| will be used only to store, for each -% command |\Arrow| the line (in the TeX file) where the command is issued. This -% information will be stored in the field |input-line| of the arrow. As of now, -% This information is used only in the error message of a arrow impossible to -% draw because after the last row of the environment. -% \begin{macrocode} -\str_new:N \l_@@_input_line_str -% \end{macrocode} -% -% \bigskip -% The dimension |\l_@@_x_dim| will be used to compute the $x$-value for some -% vertical arrows when one of the options |i|, |group| and |groups| (values 5, 6 -% and 7 of |\l_@@_pos_arrow_int|) is used. -% \begin{macrocode} -\dim_new:N \l_@@_x_dim -% \end{macrocode} % % \bigskip % In the |\halign| of an environment |{WithArrows}| or |{DispWithArrows}|, we @@ -2625,33 +2649,8 @@ version 2005/12/01 or later. \int_new:N \g_@@_line_int % \end{macrocode} % -% -% -% \bigskip -% The boolean |\l_@@_fleqn_bool| indicates wether the environments -% |{DispWithArrows}| must be composed flush left or centered. It corresponds to -% the option |fleqn|. -% \begin{macrocode} -\bool_new:N \l_@@_fleqn_bool -% \end{macrocode} % % \bigskip -% The dimension |\l_@@_mathindent_dim| is used only by the environments -% |{DispWithArrows}|: it's the left margin of the environments -% |{DispWithArrows}| if the environment |{DispWithArrows}| is composed flush -% left (option |fleqn|). -% \begin{macrocode} -\dim_new:N \l_@@_mathindent_dim -\dim_set:Nn \l_@@_mathindent_dim { 25 pt } -% \end{macrocode} -% -% \bigskip -% The boolean |\l_@@_wrap_lines_bool| corresponds to the option |wrap-lines|. -% \begin{macrocode} -\bool_new:N \l_@@_wrap_lines_bool -% \end{macrocode} -% -% \bigskip % For the environment |{DispWithArrows}|, the comma list |\l_@@_tags_clist| will % be the list of the numbers of lines to be tagged (with the counter |equation| % of LaTeX). In fact, |\l_@@_tags_clist| may contain non negative integers but @@ -2661,50 +2660,6 @@ version 2005/12/01 or later. \clist_set:Nn \l_@@_tags_clist { all } % \end{macrocode} % -% \bigskip -% The token list |\l_@@_tag_tl| will contain the argument of the command |\tag|. -% \begin{macrocode} -\tl_new:N \l_@@_tag_tl -% \end{macrocode} -% -% \bigskip -% The boolean |\l_@@_tag_star_bool| will be raised if the user uses the command -% |\tag| with a star. -% \begin{macrocode} -\bool_new:N \l_@@_tag_star_bool -% \end{macrocode} -% -% -% \bigskip -% The boolean |\l_@@_in_first_column_bool| will be used to know wether we are in -% the first column of the environment |{WithArrows}| or |{DispWithArrows}|. -% \begin{macrocode} -\bool_new:N \l_@@_in_first_column_bool -% \end{macrocode} -% -% \bigskip -% \begin{macrocode} -\bool_new:N \l_@@_initial_r_bool -\bool_new:N \l_@@_initial_l_bool -% \end{macrocode} -% -% \bigskip -% The dimension |\l_@@_start_adjust_dim| and |\l_@@_end_adjust_dim| correspond -% to the options |start-adjust| and |end-adjust|. -% \begin{macrocode} -\dim_new:N \l_@@_start_adjust_dim -\dim_set:Nn \l_@@_start_adjust_dim { 0.4 ex } -\dim_new:N \l_@@_end_adjust_dim -\dim_set:Nn \l_@@_end_adjust_dim { 0.4 ex } -% \end{macrocode} -% -% \bigskip -% The parameter |\l_@@_status_arrow_str| will be used to store the ``status'' of -% an individual arrow. It will be used to fill the field ``status'' in the -% property list describing an arrow. -% \begin{macrocode} -\str_new:N \l_@@_status_arrow_str -% \end{macrocode} % % \bigskip % \begin{macrocode} @@ -2714,18 +2669,31 @@ version 2005/12/01 or later. % \bigskip % The string |\l_@@_string_Arrow_for_msg_str| is only a string that will be % displayed in some error messages. For example, if |CommandName| is defined to -% be |Explanation|, the string |\l_@@_string_Arrow_for_msg_str| will contain -% ``|\Arrow alias \Explanation|''. +% be |Explanation|, this string will contain ``|\Arrow alias \Explanation|''. % \begin{macrocode} \str_set:Nx \l_@@_string_Arrow_for_msg_str { \token_to_str:N \Arrow } % \end{macrocode} % +% \bigskip +% The sequence |\g_@@_names_seq| will be the list of all the names of +% environments used (via the option |name|) in the document: two environments +% must not have the same name. However, it's possible to use the option +% |allow-duplicate-names|. % \begin{macrocode} -\bool_new:N \l_@@_displaystyle_bool -\bool_new:N \l_@@_show_node_names_bool +\seq_new:N \g_@@_names_seq % \end{macrocode} % -% +% \bigskip +% The boolean |\l_@@_sbwi_bool| corresponds to the option +% |standard-behaviour-with-items|. Since the version 1.16 of \pkg{witharrows}, +% no vertical space is added between an |\item| of a LaTeX list and an +% environment |{DispWithArrows}|. With the option +% |standard-behaviour-with-items|, it's possible to restore the previous +% behaviour (which corresponds to the standard behaviour of |{align}| of +% \pkg{amsmath}). |\l_@@_sbwi_bool| is the boolean corresponding to this option. +% \begin{macrocode} +\bool_new:N \l_@@_sbwi_bool +% \end{macrocode} % % \bigskip % \subsection{The definition of the options} @@ -2749,9 +2717,11 @@ version 2005/12/01 or later. % When we scan a list of options, we want to be able to raise an error if two % options of position of the arrows are present. That's why we keep % the first option of position in a variable called |\l_@@_previous_key_str|. +% The following function |\@@_eval_if_allowed:n| will execute its argument only +% if a first key of position has not been set (and raise an error elsewhere). % % \begin{macrocode} -\cs_new_protected:Nn \@@_eval_if_allowed:n +\cs_new_protected:Npn \@@_eval_if_allowed:n #1 { \str_if_empty:NTF \l_@@_previous_key_str { @@ -2764,7 +2734,7 @@ version 2005/12/01 or later. % % % \begin{macrocode} -\cs_new_protected:Nn \@@_fix_pos_option:n +\cs_new_protected:Npn \@@_fix_pos_option:n #1 { \@@_eval_if_allowed:n { \int_set:Nn \l_@@_pos_arrow_int { #1 } } } % \end{macrocode} % @@ -2833,18 +2803,35 @@ version 2005/12/01 or later. i .code:n = \@@_fix_pos_option:n 5 , xoffset .dim_set:N = \l_@@_xoffset_dim , xoffset .value_required:n = true , + xoffset .initial:n = 3 mm , jot .dim_set:N = \jot , jot .value_required:n = true , interline .skip_set:N = \l_@@_interline_skip , interline .value_required:n = true , start-adjust .dim_set:N = \l_@@_start_adjust_dim , start-adjust .value_required:n = true , + start-adjust .initial:n = 0.4 ex , end-adjust .dim_set:N = \l_@@_end_adjust_dim , end-adjust .value_required:n = true , + end-adjust .initial:n = 0.4 ex , adjust .code:n = + \dim_zero_new:N \l_@@_start_adjust_dim \dim_set:Nn \l_@@_start_adjust_dim { #1 } + \dim_zero_new:N \l_@@_end_adjust_dim \dim_set:Nn \l_@@_end_adjust_dim { #1 } , - adjust .value_required:n = true + adjust .value_required:n = true , +% \end{macrocode} +% +% \medskip +% With the option |no-arrows|, the arrows won't be drawn. However, the ``first +% pass'' of the arrows is done and some errors may be detected. The +% nullification of |\@@_draw_arrows:nn| is for the standard arrows and the +% nullification of |\@@_draw_arrow:nnn| is for ``Arrow in CodeAfter''. +% \begin{macrocode} + no-arrows .code:n = + \cs_set_eq:NN \@@_draw_arrows:nn \use_none:nn + \cs_set_eq:NN \@@_draw_arrow:nnn \use_none:nnn , + no-arrows .value_forbidden:n = true , } % \end{macrocode} % @@ -2855,7 +2842,7 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { WithArrows / WithArrowsSpecific } { - t .code:n = \int_set:Nn \l_@@_pos_env_int 0 , + t .code:n = \int_set:Nn \l_@@_pos_env_int O , t .value_forbidden:n = true , c .code:n = \int_set:Nn \l_@@_pos_env_int 1 , c .value_forbidden:n = true , @@ -2875,6 +2862,7 @@ version 2005/12/01 or later. fleqn .default:n = true , mathindent .dim_set:N = \l_@@_mathindent_dim , mathindent .value_required:n = true , + mathindent .initial:n = 25 pt , notag .code:n = \str_if_eq:nnTF { #1 } { true } { \clist_clear:N \l_@@_tags_clist } @@ -2893,39 +2881,77 @@ version 2005/12/01 or later. \clist_remove_all:Nn \l_@@_tags_clist { first } \clist_put_left:Nn \l_@@_tags_clist \c_one_int } , - tagged-lines .value_required:n = true + tagged-lines .value_required:n = true , +% \end{macrocode} +% +% Since the version 1.16 of \pkg{witharrows}, no vertical space is added between +% an |\item| of a LaTeX list and an environment |{DispWithArrows}|. With the +% option |standard-behaviour-with-items|, it's possible to restore the previous +% behaviour (which corresponds to the standard behaviour of |{align}| of +% \pkg{amsmath}). +% \begin{macrocode} + standard-behaviour-with-items .bool_set:N = \l_@@_sbwi_bool , + standard-behaviour-with-items .default:n = true } % \end{macrocode} % +% \bigskip +% Now a set of keys which will be used in all the environments (but not in +% |\WithArrowsOptions}|). % +% \begin{macrocode} +\keys_define:nn { WithArrows / Env } + { + name .code:n = + \seq_if_in:NnTF \g_@@_names_seq { #1 } + { \@@_error:n { Duplicate~name } } + { \seq_gput_left:Nn \g_@@_names_seq { #1 } } + \str_set:Nn \l_@@_name_str { #1 } , + name .value_required:n = true , + CodeBefore .code:n = \tl_put_right:Nn \l_@@_code_before_tl { #1 } , + CodeBefore .value_required:n = true, + CodeAfter .code:n = \tl_put_right:Nn \l_@@_code_after_tl { #1 } , + CodeAfter .value_required:n = true + } +% \end{macrocode} +% % \bigskip -% Now, we begin the construction of the set of keys that will be used in the -% environments |{WithArrows}|. +% Now, we begin the construction of the major sets of keys which are named +% ``|WithArrows / WithArrows|'', ``|WithArrows / DispWithArrows|'' and +% ``|WithArrows / WithArrowsOptions|''. Each of these sets of keys will be +% completed after. % \begin{macrocode} \keys_define:nn { WithArrows } { WithArrows .inherit:n = { WithArrows / Global , - WithArrows / WithArrowsSpecific - } + WithArrows / WithArrowsSpecific , + WithArrows / Env + } , + DispWithArrows .inherit:n = + { + WithArrows / DispWithArrowsSpecific , + WithArrows / Global , + WithArrows / Env , + } , + WithArrowsOptions .inherit:n = + { + WithArrows / Global , + WithArrows / WithArrowsSpecific , + WithArrows / DispWithArrowsSpecific + } } % \end{macrocode} % % \medskip % \begin{macrocode} \keys_define:nn { WithArrows / WithArrows } - { - name .tl_set:N = \l_@@_name_str , - name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l_@@_code_before_tl { #1 } , - CodeBefore .value_required:n = true, - CodeAfter .code:n = \tl_put_right:Nn \l_@@_code_after_tl { #1 } , - CodeAfter .value_required:n = true , - unknown .code:n = - \@@_sort_seq:N \l_@@_options_WithArrows_seq - \@@_error:n { Unknown~option~WithArrows } - } + { + unknown .code:n = + \@@_sort_seq:N \l_@@_options_WithArrows_seq + \@@_error:n { Unknown~option~WithArrows } + } % \end{macrocode} % % \bigskip @@ -2935,36 +2961,17 @@ version 2005/12/01 or later. \seq_set_from_clist:Nn \l_@@_options_WithArrows_seq { adjust, b, c, CodeAfter, CodeBefore, CommandName, displaystyle, end-adjust, - group, groups, i, interline, jot, ll, lr, more-columns, name, rl, rr, - show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, ygap, - ystart + group, groups, i, interline, jot, ll, lr, more-columns, name, no-arrows, rl, + rr, show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, + ygap, ystart } % \end{macrocode} % -% \bigskip -% Now, we construct the keys set which will be used in the environments -% |{DispWithArrows}| and |{DispWithArrows*}|. -% \begin{macrocode} -\keys_define:nn { WithArrows } - { - DispWithArrows .inherit:n = - { - WithArrows / DispWithArrowsSpecific , - WithArrows / Global - } - } -% \end{macrocode} % % \bigskip % \begin{macrocode} \keys_define:nn { WithArrows / DispWithArrows } { - name .tl_set:N = \l_@@_name_str , - name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l_@@_code_before_tl { #1 } , - CodeBefore .value_required:n = true , - CodeAfter .code:n = \tl_put_right:Nn \l_@@_code_after_tl { #1 } , - CodeAfter .value_required:n = true , unknown .code:n = \@@_sort_seq:N \l_@@_options_DispWithArrows_seq \@@_error:n { Unknown~option~DispWithArrows } @@ -2979,28 +2986,19 @@ version 2005/12/01 or later. { allow-multiple-labels, CodeAfter, CodeBefore, CommandName, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, name, nonumber, notag, rl, rr, show-node-names, show-nodes, - start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart + mathindent, name, no-arrows, nonumber, notag, rl, rr, show-node-names, + show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, + ystart } % \end{macrocode} % -% \bigskip -% Now, we construct the keys set which will be used with the command |\WithArrowsOptions|. -% \begin{macrocode} -\keys_define:nn { WithArrows } - { - WithArrowsOptions .inherit:n = - { - WithArrows / Global , - WithArrows / WithArrowsSpecific , - WithArrows / DispWithArrowsSpecific - } - } -% \end{macrocode} % % \begin{macrocode} \keys_define:nn { WithArrows / WithArrowsOptions } { + allow-duplicate-names .code:n = + \@@_msg_redirect_name:nn { Duplicate~name } { none } , + allow-duplicate-names .value_forbidden:n = true , unknown .code:n = \@@_sort_seq:N \l_@@_options_WithArrowsOptions_seq \@@_error:n { Unknown~option~WithArrowsOptions } @@ -3014,10 +3012,11 @@ version 2005/12/01 or later. % \begin{macrocode} \seq_set_from_clist:Nn \l_@@_options_WithArrowsOptions_seq { - allow-multiple-labels, b, c, CommandName, more-columns, TikzCode, adjust, - displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, nonumber, notag, rl, rr, show-node-names, show-nodes, - start-adjust, t, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart + allow-duplicate-names, allow-multiple-labels, b, c, CommandName, + more-columns, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, + groups, i, interline, jot, ll, lr, mathindent, no-arrows, nonumber, notag, + rl, rr, show-node-names, show-nodes, standard-behaviour-with-items, + start-adjust, t, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart } % \end{macrocode} % @@ -3028,7 +3027,7 @@ version 2005/12/01 or later. % the field ``status'' of the arrow. Another value of the field ``status'' is % ``new-group''. % \begin{macrocode} -\cs_new_protected:Nn \@@_set_independent: +\cs_new_protected:Npn \@@_set_independent: { \str_if_empty:NTF \l_@@_previous_key_str { @@ -3047,7 +3046,7 @@ version 2005/12/01 or later. % (after the end of the environment |{WithArrows}| or |{DispWithArrows}|). Now, % we present the keys set for the first pass. The main goal is to extract % informations which will be necessary during the scan of the arrows. For -% instance, we have to known if some arrows are ``independent'' or use the +% instance, we have to know if some arrows are ``independent'' or use the % option ``new-group''. % \begin{macrocode} \keys_define:nn { WithArrows / Arrow / FirstPass } @@ -3120,7 +3119,7 @@ version 2005/12/01 or later. % % \bigskip % \begin{macrocode} -\cs_new_protected:Nn \@@_fix_pos_arrow:n +\cs_new_protected:Npn \@@_fix_pos_arrow:n #1 { \str_if_empty:NT \l_@@_previous_key_str { @@ -3132,9 +3131,9 @@ version 2005/12/01 or later. % % \bigskip % The options of the individual commands |\Arrows| are scanned twice. The second -% pass is just before the drawing of the arrow. In this set of keys, we don't put -% an item for the unknown keys because an unknown key would have been already -% detected during the first pass. +% pass is just before the drawing of the arrow. In this set of keys, we don't +% put an item for the unknown keys because an unknown key would have been +% already detected during the first pass. % % \begin{macrocode} \keys_define:nn {WithArrows / Arrow / SecondPass } @@ -3281,7 +3280,7 @@ version 2005/12/01 or later. % % \medskip % \begin{macrocode} -\cs_new_protected:Nn \@@_Arrow_first_column: +\cs_new_protected:Npn \@@_Arrow_first_column: { \@@_error:n { Arrow~in~first~column } \@@_Arrow } % \end{macrocode} % @@ -3293,7 +3292,7 @@ version 2005/12/01 or later. % |{WithArrows}| and |{DispWithArrows}|. The argument is the list of options % given to the environment. % \begin{macrocode} -\cs_new_protected:Nn \@@_pre_environment:n +\cs_new_protected:Npn \@@_pre_environment:n #1 % \end{macrocode} % % First the initialisation of |\l_@@_type_env_str| which is the name of the @@ -3321,6 +3320,33 @@ version 2005/12/01 or later. % \begin{macrocode} \str_clear_new:N \l_@@_name_str % \end{macrocode} +% +% \bigskip +% The parameter |\l_@@_status_arrow_str| will be used to store the ``status'' of +% an individual arrow. It will be used to fill the field ``status'' in the +% property list describing an arrow. +% \begin{macrocode} + \str_clear_new:N \l_@@_status_arrow_str +% \end{macrocode} +% +% \bigskip +% The dimension |\l_@@_x_dim| will be used to compute the $x$-value for some +% vertical arrows when one of the options |i|, |group| and |groups| (values 5, 6 +% and 7 of |\l_@@_pos_arrow_int|) is used. +% \begin{macrocode} + \dim_zero_new:N \l_@@_x_dim +% \end{macrocode} +% +% \medskip +% The variable |\l_@@_input_line_str| will be used only to store, for each +% command |\Arrow| the line (in the TeX file) where the command is issued. This +% information will be stored in the field ``input-line'' of the arrow. As of +% now, this information is used only in the error message of a arrow impossible +% to draw (because it arrives after the last row of the environment). +% \begin{macrocode} + \str_clear_new:N \l_@@_input_line_str +% \end{macrocode} +% % % The initialisation of the counters |\g_@@_arrow_int| and |\g_@@_line_int|. % However, we have to save their previous values with the two stacks created for @@ -3371,6 +3397,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The boolean |\l_@@_in_first_column_bool| will be used to know wether we are in +% the first column of the environment |{WithArrows}| or |{DispWithArrows}|. +% \begin{macrocode} + \bool_set_false:N \l_@@_in_first_column_bool +% \end{macrocode} +% +% \bigskip % In (the second column of) |{DispWithArrows}|, it's possible to put several % labels (for the same number of equation). That's why these labels will be % stored in a sequence |\l_@@_labels_seq|. @@ -3379,7 +3412,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} - \@@_bool_new:N \l_@@_tag_next_line_bool + \bool_set_false:N \l_@@_tag_next_line_bool % \end{macrocode} % % \bigskip @@ -3402,7 +3435,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% We process the options given to the environment |{WithArrows}| or |{DispWithArrows}|. +% We process the options given to the environment |{WithArrows}| or +% |{DispWithArrows}|. % \begin{macrocode} \str_clear_new:N \l_@@_previous_key_str \bool_if:NT \l_@@_in_WithArrows_bool @@ -3437,6 +3471,12 @@ version 2005/12/01 or later. % will be |\Arrow|. % \begin{macrocode} \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow + \cs_set_eq:NN \notag \@@_notag: + \cs_set_eq:NN \nonumber \@@_notag: + \cs_set_eq:NN \tag \@@_tag + \cs_set_eq:NN \@@_old_label \label + \cs_set_eq:NN \label \@@_label:n + \cs_set_eq:NN \tagnextline \@@_tagnextline: } % \end{macrocode} % This is the end of |\@@_pre_environment:n|. @@ -3453,11 +3493,6 @@ version 2005/12/01 or later. \if_mode_math: \else: \@@_error:n { WithArrows~outside~math~mode } \fi: - \cs_set_eq:NN \notag \@@_notag: - \cs_set_eq:NN \nonumber \@@_notag: - \cs_set_eq:NN \tag \@@_tag - \cs_set_eq:NN \label \@@_label:n - \cs_set_eq:NN \tagnextline \@@_tagnextline: % \end{macrocode} % \bigskip % The environment begins with a |\vtop|, a |\vcenter| or a @@ -3599,7 +3634,7 @@ version 2005/12/01 or later. % The command |\@@_post_environment:| is a code common to the second part of the % environment |{WithArrows}| and the environment |{DispWithArrows}|. % \begin{macrocode} -\cs_new_protected:Nn \@@_post_environment: +\cs_new_protected:Npn \@@_post_environment: % \end{macrocode} % % \bigskip @@ -3677,14 +3712,15 @@ version 2005/12/01 or later. % We give now the definition of |\@@_cr:| which is the definition of |\\| in an % environment |{WithArrows}|. The two \pkg{expl3} commands % |\group_align_safe_begin:| and |\group_align_safe_end:| are specifically -% designed for this purpose: test the token that follows in a |\halign| +% designed for this purpose: test the token that follows in an |\halign| % structure. % -% First, we remove an eventual token |*| since the commands |\\| and |\\*| are -% equivalent in an environment |{WithArrows}| (an environment |{WithArrows}|, -% like an environment |{aligned}| of \pkg{amsmath}, is always unbreakable). +% First, we remove an eventual token |*| (just after the |\\|: there should not +% be space between the two) since the commands |\\| and |\\*| are equivalent in +% an environment |{WithArrows}| (an environment |{WithArrows}|, like an +% environment |{aligned}| of \pkg{amsmath}, is always unbreakable). % \begin{macrocode} -\cs_new_protected:Nn \@@_cr: +\cs_new_protected:Npn \@@_cr: { \scan_stop: \bool_if:NT \l_@@_in_first_column_bool { & { } } @@ -3697,7 +3733,7 @@ version 2005/12/01 or later. % Then, we peek the next token to see if it's a |[|. In this case, the command % |\\| has an optional argument which is the vertical skip (=glue) to put. % \begin{macrocode} -\cs_new_protected:Nn \@@_cr_i: +\cs_new_protected:Npn \@@_cr_i: { \peek_meaning:NTF [ \@@_cr_ii: { \@@_cr_ii: [ \c_zero_dim ] } } % \end{macrocode} % @@ -3761,10 +3797,10 @@ version 2005/12/01 or later. % |\refstepcounter|. % \begin{macrocode} \bool_if:NT \c_@@_hyperref_loaded_bool - { - \cs_set:Npn \This@name { equation } - \hyper@refstepcounter { equation } - } + { + \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 @@ -3772,31 +3808,24 @@ version 2005/12/01 or later. % informations. % \begin{macrocode} \bool_if:NT \c_@@_cleveref_loaded_bool - { - \cref@constructprefix { equation } { \cref@result } - \protected@edef \cref@currentlabel - { - [ - \cs_if_exist:NTF \cref@equation@alias - \cref@equation@alias - { equation } - ] - [ \arabic { equation } ] [ \cref@result ] - \p@equation \g_tmpa_tl - } - } -% \end{macrocode} -% Then, 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 - { \cs_set:Npn \sr@name { equation } } + { + \cref@constructprefix { equation } \cref@result + \protected@edef \cref@currentlabel + { + [ + \cs_if_exist:NTF \cref@equation@alias + \cref@equation@alias + { equation } + ] + [ \arabic { equation } ] [ \cref@result ] + \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 -% labels (it's possible to put several labels to the same line and that's why -% the labels are in the sequence |\l_@@_labels_seq|). +% labels (it's possible with \pkg{witharrows} to put several labels to the same +% line and that's why the labels are in the sequence |\l_@@_labels_seq|). % \begin{macrocode} \seq_map_function:NN \l_@@_labels_seq \@@_old_label } @@ -3820,7 +3849,7 @@ version 2005/12/01 or later. { \hbox_overlap_left:n \@@_qedhere_i: } \cs_set_eq:NN \theequation \g_tmpa_tl \bool_if:NT \l_@@_tag_star_bool - { \cs_set_eq:NN \tagform@ \prg_do_nothing: } + { \cs_set_eq:NN \tagform@ \prg_do_nothing: } % \end{macrocode} % We use |\@eqnnum| (we recall that there are two definitions of |\@eqnnum|, a % standard definition and another, loaded if the class option |leqno| is used). @@ -3853,7 +3882,7 @@ version 2005/12/01 or later. \tikz [ @@_standard ] \coordinate ( \int_use:N \g_@@_line_int - v ) ; } - } + } \cr \noalign { \skip_vertical:n { #1 + \l_@@_interline_skip } \scan_stop: } } % \end{macrocode} @@ -3873,7 +3902,7 @@ version 2005/12/01 or later. % |\@@_if_in_second_col_of_disp:Nn| is the name of the command used in the error % message and the second is the code to execute. % \begin{macrocode} -\cs_new_protected:Nn \@@_if_in_second_col_of_disp:Nn +\cs_new_protected:Npn \@@_if_in_second_col_of_disp:Nn #1 #2 { \bool_if:NTF \l_@@_in_WithArrows_bool { \@@_error:nn { Not~allowed~in~WithArrows } { #1 } } @@ -3889,7 +3918,7 @@ version 2005/12/01 or later. % The command |\@@_notag:| will be linked to |\notag| and |\nonumber| in the % environments |{WithArrows}| and |{DispWithArrows}|. % \begin{macrocode} -\cs_new_protected:Nn \@@_notag: +\cs_new_protected:Npn \@@_notag: { \@@_if_in_second_col_of_disp:Nn \notag { \clist_clear:N \l_@@_tags_clist } } % \end{macrocode} % @@ -3904,7 +3933,7 @@ version 2005/12/01 or later. \@@_if_in_second_col_of_disp:Nn \tag { \tl_if_empty:NF \l_@@_tag_tl - { \@@_error:nn { Multiple~tags } { #2 } } + { \@@_error:nn { Multiple~tags } { #2 } } \clist_set:Nn \l_@@_tags_clist { all } \bool_if:nT \c_@@_mathtools_loaded_bool { @@ -3936,7 +3965,7 @@ version 2005/12/01 or later. % \pkg{amsmath}). That's why we store the differents labels of a same line in a % sequence |\l_@@_labels_seq|. % \begin{macrocode} -\cs_new_protected:Nn \@@_label:n +\cs_new_protected:Npn \@@_label:n #1 { \@@_if_in_second_col_of_disp:Nn \label { @@ -3948,14 +3977,14 @@ version 2005/12/01 or later. } \seq_put_right:Nn \l_@@_labels_seq { #1 } \bool_if:nT \c_@@_mathtools_loaded_bool - { - \MH_if_boolean:nT { show_only_refs } - { - \cs_if_exist:cTF { MT_r_#1 } - { \clist_set:Nn \l_@@_tags_clist { all } } - { \clist_clear:N \l_@@_tags_clist } - } - } + { + \MH_if_boolean:nT { show_only_refs } + { + \cs_if_exist:cTF { MT_r_#1 } + { \clist_set:Nn \l_@@_tags_clist { all } } + { \clist_clear:N \l_@@_tags_clist } + } + } \bool_if:nT \c_@@_autonum_loaded_bool { \cs_if_exist:cTF { autonum@#1Referenced } @@ -3970,7 +3999,7 @@ version 2005/12/01 or later. % The command |\@@_tagnextline:| will be linked to |\tagnextline| in the % environments |{WithArrows}| and |{DispWithArrows}|. % \begin{macrocode} -\cs_new_protected:Nn \@@_tagnextline: +\cs_new_protected:Npn \@@_tagnextline: { \@@_if_in_second_col_of_disp:Nn \tagnextline { \bool_set_true:N \l_@@_tag_next_line_bool } @@ -3988,8 +4017,7 @@ version 2005/12/01 or later. % the package \pkg{amsthm} has been loaded). |\@@_qedhere:| raises the boolean % |\l_@@_qedhere_bool|. % \begin{macrocode} -\bool_new:N \l_@@_qedhere_bool -\cs_new_protected:Nn \@@_qedhere: { \bool_set_true:N \l_@@_qedhere_bool } +\cs_new_protected:Npn \@@_qedhere: { \bool_set_true:N \l_@@_qedhere_bool } % \end{macrocode} % % In the third column of the |\halign| of |{DispWithArrows}|, a command @@ -3997,7 +4025,7 @@ version 2005/12/01 or later. % raised. The code of this command is an adaptation of the code of |\qedhere| in % \pkg{amsthm}. % \begin{macrocode} -\cs_new_protected:Nn \@@_qedhere_i: +\cs_new_protected:Npn \@@_qedhere_i: { \group_begin: \cs_set_eq:NN \qed \qedsymbol @@ -4021,12 +4049,13 @@ version 2005/12/01 or later. % For the environment |{DispWithArrows}|, the construction is a construction of % the type: % -% |\[\vcenter{\halign to \displaywith {...}}\]| +% |\[\vcenter{\halign to \displaywidth {...}}\]| % % The purpose of the |\vcenter| is to have an environment unbreakable. % % \bigskip % \begin{macrocode} +\bool_new:N \l_@@_inlabel_bool \NewDocumentEnvironment { DispWithArrows } { ! O { } } { % \end{macrocode} @@ -4049,40 +4078,88 @@ version 2005/12/01 or later. } } % \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 } } +% \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@ \bool_set_true:N \l_@@_in_DispWithArrows_bool \@@_pre_environment:n { #1 } +% \end{macrocode} +% +% Since the version 1.16 of \pkg{witharrows}, no space is added between an +% |\item| of a LaTeX list and an environment |{DispWithArrows}| except with the +% option |standard-behaviour-with-items| stored in the boolean +% |\l_@@_sbwi_bool|. We have to know if we are just after an |\item| and this +% information will be stored in |\l_@@_inlabel_bool|. +% \begin{macrocode} + \bool_if:NF \l_@@_sbwi_bool + { + \if@inlabel + \bool_set_true:N \l_@@_inlabel_bool + \fi + } +% \end{macrocode} +% +% \bigskip +% The token list |\l_@@_tag_tl| will contain the argument of the command |\tag|. +% \begin{macrocode} + \tl_clear_new:N \l_@@_tag_tl +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} + \bool_set_false:N \l_@@_qedhere_bool +% \end{macrocode} +% +% \bigskip +% The boolean |\l_@@_tag_star_bool| will be raised if the user uses the command +% |\tag| with a star. +% \begin{macrocode} + \bool_set_false:N \l_@@_tag_star_bool +% \end{macrocode} +% +% \begin{macrocode} \if_mode_math: \@@_error:n { DispWithArrows~in~math~mode } \fi: % \end{macrocode} +% +% \bigskip +% The construction is not exactly the same wether we are just after an |\item| +% of a LaTeX list or not. We know if we are after un |\item| thanks to the +% boolean |\l_@@_inlabel_bool|. +% \begin{macrocode} + \bool_if:NTF \l_@@_inlabel_bool + { $ } % $ + { +% \end{macrocode} % We don't use |\[| of LaTeX because some extensions, like \pkg{autonum}, do a % redefinition of |\[|. However, we put the following lines which are in the % definition of |\[| even though they are in case of misuse. % \begin{macrocode} - \if_mode_vertical: - \nointerlineskip - \makebox [ .6 \linewidth ] { } - \fi: - $$ + \if_mode_vertical: + \nointerlineskip + \hbox_to_wd:nn { .6 \linewidth } { } + \fi: + $$ + } % \end{macrocode} % We use a |\vcenter| in order to prevent page breaks in the environment. % \begin{macrocode} - \vcenter \bgroup + \bool_if:NTF \l_@@_inlabel_bool \vtop \vcenter \bgroup \spread@equation \bool_if:NTF \l_@@_fleqn_bool { \tabskip = \c_zero_skip } { \tabskip = 0 pt plus 1000 pt minus 1000 pt } - \cs_set_eq:NN \@@_old_label \label - \cs_set_eq:NN \notag \@@_notag: - \cs_set_eq:NN \nonumber \@@_notag: - \cs_set_eq:NN \tag \@@_tag - \cs_set_eq:NN \label \@@_label:n - \cs_set_eq:NN \tagnextline \@@_tagnextline: - \halign to \displaywidth + \halign to \bool_if:NTF \l_@@_inlabel_bool \linewidth \displaywidth \bgroup \int_gincr:N \g_@@_line_int \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow_first_column: @@ -4097,7 +4174,7 @@ version 2005/12/01 or later. \tabskip = \c_zero_skip & \clist_if_in:NVT \l_@@_tags_clist \g_@@_line_int - { \clist_set:Nn \l_@@_tags_clist { all } } + { \clist_set:Nn \l_@@_tags_clist { all } } % \end{macrocode} % The command |\qedhere| of \pkg{amsthm} is redefined here. % \begin{macrocode} @@ -4136,16 +4213,22 @@ version 2005/12/01 or later. ] ; \bool_if:NT \l_@@_show_node_names_bool - { - \hbox_overlap_right:n - { \small wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int } - } + { + \hbox_overlap_right:n + { \small wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int } + } & - ## +% \end{macrocode} +% +% We put now the contents of the third column in math mode because because we +% don't want an error if the user uses a third column with contents in math +% mode: the error will be in the next cell. +% \begin{macrocode} + $ ## $ \tabskip = \c_zero_skip && \@@_error:n { Third~column~in~DispWithArrows } - \iffalse ## \fi + \bool_if:nT \c_false_bool { ## } \cr } % \end{macrocode} @@ -4179,17 +4262,17 @@ version 2005/12/01 or later. \dim_gset_eq:NN \g_@@_right_x_dim \c_max_dim \begin { tikzpicture } [ @@_standard ] \int_step_variable:nNn \g_@@_line_int \l_tmpa_int - { - \cs_if_free:cTF - { pgf@sh@ns@wa - \l_@@_prefix_str - \l_tmpa_int - v } - { \@@_error:n { Inexistent~v-node } } - { - \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) - \dim_set:Nn \l_tmpa_dim \pgf@x - \dim_compare:nNnT \l_tmpa_dim < \g_@@_right_x_dim - { \dim_gset:Nn \g_@@_right_x_dim \l_tmpa_dim } - } - } + { + \cs_if_free:cTF + { pgf@sh@ns@wa - \l_@@_prefix_str - \l_tmpa_int - v } + { \@@_error:n { Inexistent~v-node } } + { + \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) + \dim_set:Nn \l_tmpa_dim \pgf@x + \dim_compare:nNnT \l_tmpa_dim < \g_@@_right_x_dim + { \dim_gset:Nn \g_@@_right_x_dim \l_tmpa_dim } + } + } \end { tikzpicture } } % \end{macrocode} @@ -4207,7 +4290,11 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:nT \c_@@_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } \MT_showonlyrefs_true: } - $$ + \bool_if:NTF \l_@@_inlabel_bool + { $ % $ + \skip_vertical:N \belowdisplayskip + } + { $$ } % \end{macrocode} % % \bigskip @@ -4225,12 +4312,12 @@ version 2005/12/01 or later. % don't put |\begin{DispWithArrows}| and |\end{DispWithArrows}| because there is % a |\@currenvir| in some error messages. % \begin{macrocode} -\NewDocumentEnvironment { DispWithArrows* } {} - { - \WithArrowsOptions { notag } - \DispWithArrows - } - { \endDispWithArrows } +\NewDocumentEnvironment { DispWithArrows* } { } + { + \WithArrowsOptions { notag } + \DispWithArrows + } + \endDispWithArrows % \end{macrocode} % % @@ -4239,8 +4326,8 @@ version 2005/12/01 or later. % \bigskip % The arrows are divided in groups. There is two reasons for this division. % \begin{itemize} -% \item If the option |group| or the option |groups| is used, all the arrows are -% drawn on a same vertical at an abscissa of |\l_@@_x_dim|. +% \item If the option |group| or the option |groups| is used, all the arrows of +% a group are drawn on a same vertical at an abscissa of |\l_@@_x_dim|. % \item For aesthetic reasons, the starting point of all the starting arrows of % a group is raised upwards by the value |\l_@@_start_adjust_dim|. Idem for the % ending arrows. @@ -4253,26 +4340,22 @@ version 2005/12/01 or later. % divide the arrows in groups (for the vertical adjustement) and we actually % draw the arrows. % \begin{macrocode} -\cs_new_protected:Nn \@@_scan_arrows: - { - \group_begin: - \int_compare:nNnT \l_@@_pos_arrow_int = 7 +\cs_new_protected:Npn \@@_scan_arrows: + { + \group_begin: + \int_compare:nNnT \l_@@_pos_arrow_int = 7 { \@@_scan_arrows_i: \int_set:Nn \l_@@_pos_arrow_int 8 } - \@@_scan_arrows_i: - \group_end: - } + \@@_scan_arrows_i: + \group_end: + } % \end{macrocode} % % \bigskip -% If an environment |{WithArrows}| is composed with the option |group| or the -% option |groups|, it's still possible to put arrows with their option of -% position (|ll|, |rr|, |rl|, |lr| or |i|). Such arrows will be said to be -% ``independent''. % \begin{macrocode} -\cs_new_protected:Nn \@@_scan_arrows_i: +\cs_new_protected:Npn \@@_scan_arrows_i: { % \end{macrocode} % @@ -4283,22 +4366,30 @@ version 2005/12/01 or later. % of arrows (equal to the initial line of the first arrow of the group because % the option |jump| is always positive). % -% |\l_@@_first_arrows_of_group_seq| will the list the arrows of the group -% starting at the first line of the group (we may have several arrows starting -% from the same line). We have to known all these arrows because of the -% adjustement by |\l_@@_start_adjust_dim|. +% |\l_@@_first_arrows_seq| will be the list the arrows of the group starting at +% the first line of the group (we may have several arrows starting from the same +% line). We have to know all these arrows because of the adjustement by +% |\l_@@_start_adjust_dim|. % % |\l_@@_last_line_of_group_int| will be the last line involved in the group % (impossible to guess in advance). % -% |\l_@@_last_arrows_of_group_seq| will the list of all the arrows of the group +% |\l_@@_last_arrows_seq| will the list of all the arrows of the group % ending at the last line of the group (impossible to guess in advance). % \begin{macrocode} \int_zero_new:N \l_@@_first_arrow_of_group_int \int_zero_new:N \l_@@_first_line_of_group_int \int_zero_new:N \l_@@_last_line_of_group_int - \seq_clear_new:N \l_@@_first_arrows_of_group_seq - \seq_clear_new:N \l_@@_last_arrows_of_group_seq + \seq_clear_new:N \l_@@_first_arrows_seq + \seq_clear_new:N \l_@@_last_arrows_seq +% \end{macrocode} +% +% \medskip +% The boolean |\l_@@_new_group_bool| is a switch that we will use the indicate +% that a group is finished (and the lines of that group have to be drawn). This +% boolean is not directed connected to the option |new-group| of an individual +% arrow. +% \begin{macrocode} \bool_set_true:N \l_@@_new_group_bool % \end{macrocode} % @@ -4313,9 +4404,8 @@ version 2005/12/01 or later. % % \bigskip % We extract from the property list of the current arrow the fields ``initial'', -% ``final'' and ``position'' and we store these values in |\l_@@_initial_int|, -% |\l_@@_final_int| and |\l_@@_pos_of_arrow_int|. However, we have to do a -% conversion because the components of a property list are token lists. +% ``final'', ``status'' and ``input-line''. For the two former, we have to do +% conversions to integers. % \begin{macrocode} \prop_get:cnN { g_@@_arrow _ \l_@@_prefix_str _ \int_use:N \l_@@_arrow_int _ prop } @@ -4334,67 +4424,99 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% If the arrow arrives after the last line of the environment we raise an error -% (we recall that, after the construction of the |\halign|, |\g_@@_line_int| is -% the total number of lines of the environment). The arrow will be completely +% We recall that, after the construction of the |\halign|, |\g_@@_line_int| is +% the total number of lines of the environment. Therefore, the conditionnal +% |\l_@@_final_int > \g_@@_line_int| tests wether an arrow arrives after the +% last line of the environment. In this case, we raise an error (except in the +% second step of treatment for the option |group|). The arrow will be completely % ignored, even for the computation of |\l_@@_x_dim|. % \begin{macrocode} \int_compare:nNnTF \l_@@_final_int > \g_@@_line_int - { \@@_error:n { Too~few~lines~for~an~arrow } } + { + \int_compare:nNnF \l_@@_pos_arrow_int = 8 + { \_@@_error:n { Too~few~lines~for~an~arrow } } + } + \@@_code_for_possible_arrow: +% \end{macrocode} +% +% \bigskip +% Incrementation of the index of the loop (and end of the loop). +% \begin{macrocode} + \int_incr:N \l_@@_arrow_int + } +% \end{macrocode} +% +% \bigskip +% After the last arrow of the environment, we have to draw the last group of +% arrows. If we are in option |group| and in the first step of treatment +% (|\l_@@_pos_arrow_int| = 7), we don't draw because, in the first step, we +% don't draw anything. If there is no arrow in the group, we don't draw (this +% situation occurs when all the arrows of the potential group arrives after the +% last line of the environment). +% \begin{macrocode} + \bool_if:nT + { + \int_compare_p:n { \l_@@_pos_arrow_int != 7 } + && + \int_compare_p:nNn \l_@@_first_arrow_of_group_int > 0 + } + { \@@_draw_arrows:nn \l_@@_first_arrow_of_group_int \g_@@_arrow_int } + } % \end{macrocode} % % \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_code_for_possible_arrow: + { +% \end{macrocode} % We test if the previous arrow was in fact the last arrow of a group. In this -% case, we have to draw all the arrows of that group, except if you are with the +% case, we have to draw all the arrows of that group, except if we are with the % option |group| and in the first step of treatment (|\l_@@_pos_arrow_int| = 7). % \begin{macrocode} - { - \bool_if:nT - { - \int_compare_p:nNn \l_@@_arrow_int > 1 - && - ( \int_compare_p:n - { \l_@@_initial_int > \l_@@_last_line_of_group_int } - && - \int_compare_p:n { \l_@@_pos_arrow_int != 7 } - || - \str_if_eq_p:Vn \l_@@_status_arrow_str { new-group } - ) - } - { - \int_compare:nNnF \l_@@_first_arrow_of_group_int = 0 - { - \@@_draw_arrows:nn - \l_@@_first_arrow_of_group_int - { \l_@@_arrow_int - 1 } - } - \bool_set_true:N \l_@@_new_group_bool - } + \bool_if:nT + { + \int_compare_p:nNn \l_@@_arrow_int > \c_one_int + && + ( \int_compare_p:n { \l_@@_initial_int > \l_@@_last_line_of_group_int } + && + \int_compare_p:n { \l_@@_pos_arrow_int != 7 } + || + \str_if_eq_p:Vn \l_@@_status_arrow_str { new-group } + ) + } + { + \int_compare:nNnF \l_@@_first_arrow_of_group_int = \c_zero_int + { + \@@_draw_arrows:nn + \l_@@_first_arrow_of_group_int + { \l_@@_arrow_int - 1 } + } + \bool_set_true:N \l_@@_new_group_bool + } % \end{macrocode} % -% \bigskip +% \bigskip % The flag |\l_@@_new_group_bool| indicates if we have to begin a new group of -% arrows. In fact, we have to begin a new group in two circonstancies: if we are -% at the first arrow of the environment (that's why the flag is raised before -% the beginning of the loop) and if we have just finished a group (that's why -% the flag is raised in the previous conditionnal). At the beginning of a group, -% we have to initialize the following variables: |\l_@@_first_arrow_int|, +% arrows. In fact, we have to begin a new group in three circonstancies: if we +% are at the first arrow of the environment (that's why the flag is raised +% before the beginning of the loop), if we have just finished a group (that's +% why the flag is raised in the previous conditionnal, for topological reasons +% or if the previous arrows had the status ``new-group''). At the beginning of a +% group, we have to initialize the following variables: |\l_@@_first_arrow_int|, % |\l_@@_first_line_of_group_int|, |\l_@@_last_line_of_group|, -% |\l_@@_first_arrows_of_group_seq|, |\l_@@_last_arrows_of_group_seq|. +% |\l_@@_first_arrows_seq|, |\l_@@_last_arrows_seq|. % % \begin{macrocode} - \bool_if:nTF \l_@@_new_group_bool - { - \bool_set_false:N \l_@@_new_group_bool - \int_set_eq:NN \l_@@_first_arrow_of_group_int \l_@@_arrow_int - \int_set_eq:NN \l_@@_first_line_of_group_int \l_@@_initial_int - \int_set_eq:NN \l_@@_last_line_of_group_int \l_@@_final_int - \seq_clear:N \l_@@_first_arrows_of_group_seq - \seq_put_left:NV \l_@@_first_arrows_of_group_seq - \l_@@_arrow_int - \seq_clear:N \l_@@_last_arrows_of_group_seq - \seq_put_left:NV \l_@@_last_arrows_of_group_seq - \l_@@_arrow_int + \bool_if:nTF \l_@@_new_group_bool + { + \bool_set_false:N \l_@@_new_group_bool + \int_set_eq:NN \l_@@_first_arrow_of_group_int \l_@@_arrow_int + \int_set_eq:NN \l_@@_first_line_of_group_int \l_@@_initial_int + \int_set_eq:NN \l_@@_last_line_of_group_int \l_@@_final_int + \seq_clear:N \l_@@_first_arrows_seq + \seq_put_left:NV \l_@@_first_arrows_seq \l_@@_arrow_int + \seq_clear:N \l_@@_last_arrows_seq + \seq_put_left:NV \l_@@_last_arrows_seq \l_@@_arrow_int % \end{macrocode} % % If we are in option |group| and in the second step of treatment @@ -4402,45 +4524,42 @@ version 2005/12/01 or later. % to use the same value of |\l_@@_x_dim| (computed during the first step) for % all the groups. % \begin{macrocode} - \int_compare:nT { \l_@@_pos_arrow_int != 8 } - { \dim_set:Nn \l_@@_x_dim { - \c_max_dim } } - } + \int_compare:nT { \l_@@_pos_arrow_int != 8 } + { \dim_set:Nn \l_@@_x_dim { - \c_max_dim } } + } % \end{macrocode} % % \bigskip -% If we are not at the beginning of a new group, we actualize -% |\l_@@_last_line_of_group_int|. If the arrow is independent, we don't take -% into account this arrow for the detection of the end of the group. +% If we are not at the beginning of a new group. % \begin{macrocode} - { - \bool_if:nF - { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } } - { - \int_compare:nT - { \l_@@_initial_int = \l_@@_first_line_of_group_int } - { - \seq_put_left:NV \l_@@_first_arrows_of_group_seq - \l_@@_arrow_int - } - \int_compare:nTF - { \l_@@_final_int > \l_@@_last_line_of_group_int } - { - \int_set_eq:NN \l_@@_last_line_of_group_int - \l_@@_final_int - \seq_clear:N \l_@@_last_arrows_of_group_seq - \seq_put_left:NV \l_@@_last_arrows_of_group_seq - \l_@@_arrow_int - } - { - \int_compare:nNnT - \l_@@_final_int = \l_@@_last_line_of_group_int - { - \seq_put_left:NV \l_@@_last_arrows_of_group_seq - \l_@@_arrow_int - } - } - } - } + { +% \end{macrocode} +% +% If the arrow is independent, we don't take into account this arrow for the +% detection of the end of the group. +% \begin{macrocode} + \bool_if:nF + { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } } + { +% \end{macrocode} +% If the arrow is not independant, the arrow belongs to the current group and we +% have to take it into account in some variables. +% \begin{macrocode} + \int_compare:nT + { \l_@@_initial_int = \l_@@_first_line_of_group_int } + { \seq_put_left:NV \l_@@_first_arrows_seq \l_@@_arrow_int } + \int_compare:nNnTF \l_@@_final_int > \l_@@_last_line_of_group_int + { + \int_set_eq:NN \l_@@_last_line_of_group_int \l_@@_final_int + \seq_clear:N \l_@@_last_arrows_seq + \seq_put_left:NV \l_@@_last_arrows_seq \l_@@_arrow_int + } + { + \int_compare:nNnT \l_@@_final_int = \l_@@_last_line_of_group_int + { \seq_put_left:NV \l_@@_last_arrows_seq \l_@@_arrow_int } + } + } + } % \end{macrocode} % % \bigskip @@ -4450,48 +4569,31 @@ version 2005/12/01 or later. % 8), we don't initialize |\l_@@_x_dim| because we want to use the same value of % |\l_@@_x_dim| (computed during the first step) for all the groups. % \begin{macrocode} - \bool_if:nF - { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } } - { - \int_compare:nT { \l_@@_pos_arrow_int != 8 } - { \@@_update_x:nn \l_@@_initial_int \l_@@_final_int } - } - } -% \end{macrocode} -% -% \bigskip -% Incrementation of the index of the loop (and end of the loop). -% \begin{macrocode} - \int_incr:N \l_@@_arrow_int - } -% \end{macrocode} -% -% \bigskip -% After the last arrow of the environment, we have to draw the last group of -% arrows. If we are in option |group| and in the first step of treatment -% (|\l_@@_pos_arrow_int| = 7), we don't draw because, in the first step, we -% don't draw anything. -% \begin{macrocode} - \int_compare:nT { \l_@@_pos_arrow_int != 7 } - { \@@_draw_arrows:nn \l_@@_first_arrow_of_group_int \g_@@_arrow_int } + \bool_if:nF { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } } + { + \int_compare:nT { \l_@@_pos_arrow_int != 8 } + { \@@_update_x:nn \l_@@_initial_int \l_@@_final_int } + } } % \end{macrocode} % +% % \bigskip % The following code is necessary because we will have to expand an argument % exactly 3 times. % \begin{macrocode} \cs_generate_variant:Nn \keys_set:nn { n o } -\cs_new_protected:Nn \@@_keys_set: +\cs_new_protected:Npn \@@_keys_set: { \keys_set_known:no { WithArrows / Arrow / SecondPass } } % \end{macrocode} % % \bigskip % The macro |\@@_draw_arrows:nn| draws all the arrows whose numbers are between % |#1| and |#2|. |#1| and |#2| must be expressions that expands to an integer -% (they are expanded in the beginning of the macro). +% (they are expanded in the beginning of the macro). This macro is nullified by +% the option |no-arrows|. % \begin{macrocode} -\cs_new_protected:Nn \@@_draw_arrows:nn +\cs_new_protected:Npn \@@_draw_arrows:nn #1 #2 { \group_begin: \int_zero_new:N \l_@@_first_arrow_int @@ -4545,7 +4647,7 @@ version 2005/12/01 or later. % options |ll|, |rr|, |rl|, |lr|, |i| and |jump| have already been extracted and % are not present in the field |options| of the property list of the arrow). % \begin{macrocode} -\cs_new_protected:Nn \@@_draw_arrows_i: +\cs_new_protected:Npn \@@_draw_arrows_i: { \group_begin: % \end{macrocode} @@ -4573,7 +4675,8 @@ version 2005/12/01 or later. { 0 { \bool_set_true:N \l_@@_final_r_bool } 2 { \bool_set_true:N \l_@@_initial_r_bool } - 3 { + 3 + { \bool_set_true:N \l_@@_initial_r_bool \bool_set_true:N \l_@@_final_r_bool } @@ -4585,9 +4688,9 @@ version 2005/12/01 or later. % \begin{tabular}{l} % \begin{tabular}{@{}l*8c@{}} % \toprule -% option & |lr| & |ll| & |rl| & |rr| & |v| & |i| & |groups| & |group| \\ +% option & |lr| & |ll| & |rl| & |rr| & |v| & |i| & |groups| & |group| \\ % \midrule -% |\l_@@_pos_arrow_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\ +% |\l_@@_pos_arrow_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\ % \bottomrule % \end{tabular} \\ % \footnotesize The option |v| can be used only in |\Arrow| in |CodeAfter| (see @@ -4602,10 +4705,10 @@ version 2005/12/01 or later. % option |group| or the option |groups| is used). % \begin{macrocode} \int_compare:nNnT \l_@@_pos_arrow_int = 5 - { - \dim_set:Nn \l_@@_x_dim { - \c_max_dim } - \@@_update_x:nn \l_@@_initial_int \l_@@_final_int - } + { + \dim_set:Nn \l_@@_x_dim { - \c_max_dim } + \@@_update_x:nn \l_@@_initial_int \l_@@_final_int + } % \end{macrocode} % % \bigskip @@ -4615,9 +4718,12 @@ version 2005/12/01 or later. % $x$-value --- but always the same $y$-value). Idem for |\l_@@_final_tl|. % \begin{macrocode} \tl_set:Nx \l_@@_initial_tl - { \int_use:N \l_@@_initial_int - \bool_if:NTF \l_@@_initial_r_bool rl .south } + { + \int_use:N \l_@@_initial_int - \bool_if:NTF \l_@@_initial_r_bool rl + .south + } \tl_set:Nx \l_@@_final_tl - { \int_use:N \l_@@_final_int - \bool_if:NTF \l_@@_final_r_bool rl .north } + { \int_use:N \l_@@_final_int - \bool_if:NTF \l_@@_final_r_bool rl .north } % \end{macrocode} % We use ``|.south|'' and ``|.north|'' because we want a small gap between two % consecutive arrows (and the Tikz nodes created have the shape of small @@ -4635,26 +4741,26 @@ version 2005/12/01 or later. % \bigskip % Now, we have to know if the arrow starts at the first line of the group and/or % ends at the last line of the group. That's the reason why we have stored in -% |\l_@@_first_arrows_of_group_seq| the list of all the arrows starting at the -% first line of the group and in |\l_@@_last_arrows_of_group_seq| the list of +% |\l_@@_first_arrows_seq| the list of all the arrows starting at the +% first line of the group and in |\l_@@_last_arrows_seq| the list of % all the arrows ending at the last line of the group. We compute these values % in the booleans |\l_tmpa_bool| and |\l_tmpb_bool|. These computations can't be % done in the following |{tikzpicture}| because the command |\seq_if_in:NTF| % which is \emph{not} expandable. % \begin{macrocode} - \seq_if_in:NxTF \l_@@_first_arrows_of_group_seq - { \int_use:N \l_@@_arrow_int } - { \bool_set_true:N \l_tmpa_bool } - { \bool_set_false:N \l_tmpa_bool } - \seq_if_in:NxTF \l_@@_last_arrows_of_group_seq - { \int_use:N \l_@@_arrow_int } - { \bool_set_true:N \l_tmpb_bool } - { \bool_set_false:N \l_tmpb_bool } + \seq_if_in:NxTF \l_@@_first_arrows_seq + { \int_use:N \l_@@_arrow_int } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + \seq_if_in:NxTF \l_@@_last_arrows_seq + { \int_use:N \l_@@_arrow_int } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } \int_compare:nNnT \l_@@_pos_arrow_int = 5 - { - \bool_set_true:N \l_tmpa_bool - \bool_set_true:N \l_tmpb_bool - } + { + \bool_set_true:N \l_tmpa_bool + \bool_set_true:N \l_tmpb_bool + } % \end{macrocode} % % \bigskip @@ -4672,26 +4778,26 @@ version 2005/12/01 or later. % % \begin{macrocode} \begin { tikzpicture } [ @@_standard ] - \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_initial_tl ) - \tl_gset:Nx \g_tmpa_tl - { - \int_compare:nNnTF \l_@@_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l_@@_x_dim } , - \bool_if:NTF \l_tmpa_bool - { \dim_eval:n { \pgf@y + \l_@@_start_adjust_dim } } - { \dim_use:N \pgf@y } - } - \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_final_tl ) - \tl_gset:Nx \g_tmpb_tl - { - \int_compare:nNnTF \l_@@_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l_@@_x_dim } , - \bool_if:NTF \l_tmpb_bool - { \dim_eval:n { \pgf@y - \l_@@_end_adjust_dim } } - { \dim_use:N \pgf@y } - } + \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_initial_tl ) + \tl_gset:Nx \g_tmpa_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \pgf@x } + { \dim_use:N \l_@@_x_dim } , + \bool_if:NTF \l_tmpa_bool + { \dim_eval:n { \pgf@y + \l_@@_start_adjust_dim } } + { \dim_use:N \pgf@y } + } + \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_final_tl ) + \tl_gset:Nx \g_tmpb_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \pgf@x } + { \dim_use:N \l_@@_x_dim } , + \bool_if:NTF \l_tmpb_bool + { \dim_eval:n { \pgf@y - \l_@@_end_adjust_dim } } + { \dim_use:N \pgf@y } + } \end { tikzpicture } % \end{macrocode} % @@ -4729,7 +4835,7 @@ version 2005/12/01 or later. % That's why we create a function |\@@_def_function_tmpa:n| which will create % the function |\@@_tmpa:nnn|. % \begin{macrocode} -\cs_new_protected:Nn \@@_def_function_tmpa:n +\cs_new_protected:Npn \@@_def_function_tmpa:n #1 { \cs_set:Npn \@@_tmpa:nnn ##1 ##2 ##3 { @@ -4748,7 +4854,7 @@ version 2005/12/01 or later. % When we draw the arrow (with |\@@_draw_arrow:nnn|), we first create the % function |\@@_tmpa:nnn| and, then, we use the function |\@@_tmpa:nnn| : % \begin{macrocode} -\cs_new_protected:Nn \@@_draw_arrow:nnn +\cs_new_protected:Npn \@@_draw_arrow:nnn #1 #2 #3 { % \end{macrocode} % @@ -4805,11 +4911,11 @@ version 2005/12/01 or later. % |\l_tmpa_dim|). % \begin{macrocode} \tl_if_empty:NF \g_tmpa_tl - { - \dim_set:Nn \l_tmpb_dim \g_tmpa_tl - \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim - { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } - } + { + \dim_set:Nn \l_tmpb_dim \g_tmpa_tl + \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim + { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } + } % \end{macrocode} % Now, we can put the label with the right value for ``|text width|''. % \begin{macrocode} @@ -4830,16 +4936,16 @@ version 2005/12/01 or later. % (for options |group| and |groups|) and in |\@@_draw_arrows:nn| (for option % |i|). % \begin{macrocode} -\cs_new_protected:Nn \@@_update_x:nn +\cs_new_protected:Npn \@@_update_x:nn #1 #2 { \int_step_inline:nnn { #1 } { #2 } - { - \begin { tikzpicture } [ @@_standard ] - \tikz@scan@one@point \pgfutil@firstofone ( ##1 - l ) - \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \l_@@_x_dim \pgf@x } - \end { tikzpicture } - \dim_set_eq:NN \l_@@_x_dim \g_tmpa_dim - } + { + \begin { tikzpicture } [ @@_standard ] + \tikz@scan@one@point \pgfutil@firstofone ( ##1 - l ) + \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \l_@@_x_dim \pgf@x } + \end { tikzpicture } + \dim_set_eq:NN \l_@@_x_dim \g_tmpa_dim + } } % \end{macrocode} % @@ -4886,7 +4992,7 @@ version 2005/12/01 or later. unknown .code:n = \@@_sort_seq:N \l_@@_options_Arrow_CodeAfter_seq \@@_error:n { Unknown~option~Arrow~in~CodeAfter } - } + } % \end{macrocode} % % \bigskip @@ -4894,7 +5000,7 @@ version 2005/12/01 or later. % will be used in the error messages and can be modified dynamically. % \begin{macrocode} \seq_set_from_clist:Nn \l_@@_options_Arrow_CodeAfter_seq - { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } + { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } % \end{macrocode} % % \bigskip @@ -4975,7 +5081,7 @@ version 2005/12/01 or later. % |CodeAfter| is executed. % % \begin{macrocode} -\cs_new_protected:Nn \@@_MultiArrow:nn +\cs_new_protected:Npn \@@_MultiArrow:nn #1 #2 { % \end{macrocode} % The user of the command |\MultiArrow| (in |CodeAfter|) will be able to specify @@ -4996,26 +5102,26 @@ version 2005/12/01 or later. % the maximum. % \begin{macrocode} \int_compare:nTF { \clist_count:N \g_tmpa_clist < 2 } - { \@@_error:n { Too~small~specification~for~MultiArrow } } - { - \clist_sort:Nn \g_tmpa_clist - { - \int_compare:nTF { ##1 > ##2 } - \sort_return_swapped: - \sort_return_same: - } + { \@@_error:n { Too~small~specification~for~MultiArrow } } + { + \clist_sort:Nn \g_tmpa_clist + { + \int_compare:nTF { ##1 > ##2 } + \sort_return_swapped: + \sort_return_same: + } % \end{macrocode} % We extract the minimum in |\l_tmpa_tl| (it must be an integer but we store it % in a token list of \pkg{expl3}). % \begin{macrocode} - \clist_pop:NN \g_tmpa_clist \l_tmpa_tl + \clist_pop:NN \g_tmpa_clist \l_tmpa_tl % \end{macrocode} % % We extract the maximum in |\l_tmpb_tl|. The remaining list (in % |\g_tmpa_clist|) will be sorted in decreasing order but never mind... % \begin{macrocode} - \clist_reverse:N \g_tmpa_clist - \clist_pop:NN \g_tmpa_clist \l_tmpb_tl + \clist_reverse:N \g_tmpa_clist + \clist_pop:NN \g_tmpa_clist \l_tmpb_tl % \end{macrocode} % % We draw the teeth of the rak (except the first one and the last one) with the @@ -5024,41 +5130,41 @@ version 2005/12/01 or later. % the last teeth of the rak can't be drawn the same way as the others (think, % for example, to the case of the option ``|rounded corners|'' is used). % \begin{macrocode} - \exp_args:NV \@@_MultiArrow_i:n \g_tmpa_clist + \exp_args:NV \@@_MultiArrow_i:n \g_tmpa_clist % \end{macrocode} % % Now, we draw the rest of the structure. % \begin{macrocode} - \begin { tikzpicture } - [ - @@_standard , - every~path /.style = { WithArrows / arrow } - ] - \draw [<->] ([xshift = \l_@@_xoffset_dim]\l_tmpa_tl-r.south) - -- ++(5mm,0) - -- node (@@_label) {} - ([xshift = \l_@@_xoffset_dim+5mm]\l_tmpb_tl-r.south) - -- ([xshift = \l_@@_xoffset_dim]\l_tmpb_tl-r.south) ; - \tikz@parse@node \pgfutil@firstofone (@@_label.west) - \dim_set:Nn \l_tmpa_dim { 20 cm } - \path \pgfextra { \tl_gset:Nx \g_tmpa_tl \tikz@text@width } ; - \tl_if_empty:NF \g_tmpa_tl { \dim_set:Nn \l_tmpa_dim \g_tmpa_tl } - \bool_if:nT { \l_@@_wrap_lines_bool && \l_@@_in_DispWithArrows_bool } - { - \dim_set:Nn \l_tmpb_dim - { \g_@@_right_x_dim - \pgf@x - 0.3333 em } - \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim - { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } - } - \path (@@_label.west) - node [ anchor = west, text~width = \dim_use:N \l_tmpa_dim ] { #2 } ; - \end{tikzpicture} + \begin { tikzpicture } + [ + @@_standard , + every~path / .style = { WithArrows / arrow } + ] + \draw [<->] ([xshift = \l_@@_xoffset_dim]\l_tmpa_tl-r.south) + -- ++(5mm,0) + -- node (@@_label) {} + ([xshift = \l_@@_xoffset_dim+5mm]\l_tmpb_tl-r.south) + -- ([xshift = \l_@@_xoffset_dim]\l_tmpb_tl-r.south) ; + \tikz@parse@node \pgfutil@firstofone (@@_label.west) + \dim_set:Nn \l_tmpa_dim { 20 cm } + \path \pgfextra { \tl_gset:Nx \g_tmpa_tl \tikz@text@width } ; + \tl_if_empty:NF \g_tmpa_tl { \dim_set:Nn \l_tmpa_dim \g_tmpa_tl } + \bool_if:nT { \l_@@_wrap_lines_bool && \l_@@_in_DispWithArrows_bool } + { + \dim_set:Nn \l_tmpb_dim + { \g_@@_right_x_dim - \pgf@x - 0.3333 em } + \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim + { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } + } + \path (@@_label.west) + node [ anchor = west, text~width = \dim_use:N \l_tmpa_dim ] { #2 } ; + \end{tikzpicture} } - } + } % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Nn \@@_MultiArrow_i:n +\cs_new_protected:Npn \@@_MultiArrow_i:n #1 { \begin {tikzpicture } [ @@ -5085,10 +5191,10 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn { Value~for~a~key } - { - The~key~'\l_keys_key_tl'~should~be~used~without~value. \\ - However,~you~can~go~on~for~this~time. - } + { + The~key~'\l_keys_key_tl'~should~be~used~without~value. \\ + However,~you~can~go~on~for~this~time. + } % \end{macrocode} % % \begin{macrocode} @@ -5166,14 +5272,14 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn { Third~column~in~WithArrows } - { - By~default,~an~environment~\{\l_@@_type_env_str\}~can~only~have~ - two~columns.~Maybe~you~have~forgotten~a~ - \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ - two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ - level~or~for~an~environment. \\ - However,~you~can~go~one~for~this~time. - } + { + By~default,~an~environment~\{\l_@@_type_env_str\}~can~only~have~ + two~columns.~Maybe~you~have~forgotten~a~ + \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ + two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ + level~or~for~an~environment. \\ + However,~you~can~go~one~for~this~time. + } % \end{macrocode} % % \begin{macrocode} @@ -5188,14 +5294,14 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn { Negative~jump } - { - You~can't~use~a~negative~value~for~the~option~'jump'~of~command~ - \l_@@_string_Arrow_for_msg_str\ - in~the~row~\int_use:N \g_@@_line_int\ - of~your~environment~\{\l_@@_type_env_str\}.~ - You~can~create~an~arrow~going~backwards~with~the~option~'<-'~of~Tikz. \\ - \c_@@_option_ignored_str - } + { + You~can't~use~a~negative~value~for~the~option~'jump'~of~command~ + \l_@@_string_Arrow_for_msg_str\ + in~the~row~\int_use:N \g_@@_line_int\ + of~your~environment~\{\l_@@_type_env_str\}.~ + You~can~create~an~arrow~going~backwards~with~the~option~'<-'~of~Tikz. \\ + \c_@@_option_ignored_str + } % \end{macrocode} % % \begin{macrocode} @@ -5212,28 +5318,29 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn - { Too~few~lines~for~an~arrow } - { Line~\l_@@_input_line_str\ - :~an~arrow~specified~in~the~row~\int_use:N \l_@@_initial_int\ - of~your~environment~\{\l_@@_type_env_str\}~can't~be~drawn~ - because~it~arrives~after~the~last~row~of~the~environment. \\ - If~you~go~on,~this~arrow~will~be~ignored. - } + { Too~few~lines~for~an~arrow } + { Line~\l_@@_input_line_str\ + :~an~arrow~specified~in~the~row~\int_use:N \l_@@_initial_int\ + of~your~environment~\{\l_@@_type_env_str\}~can't~be~drawn~ + because~it~arrives~after~the~last~row~of~the~environment. \\ + If~you~go~on,~this~arrow~will~be~ignored. + } % \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { WithArrows~outside~math~mode } - { - The~environment~\{\l_@@_type_env_str\}~should~be~used~only~in~math~mode. \\ - Nevertheless,~you~can~go~on. - } + { + The~environment~\{\l_@@_type_env_str\}~should~be~used~only~in~math~mode~ + like~the~environment~\{aligned\}~of~amsmath. \\ + Nevertheless,~you~can~go~on. + } % \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { DispWithArrows~in~math~mode } { - The~environment~\{\l_@@_type_env_str\}~should~be~used~only~ - outside~math~mode. \\ + The~environment~\{\l_@@_type_env_str\}~should~be~used~only~outside~math~ + mode~like~the~environment~\{align\}~of~amsmath. \\ If~you~go~on,~you~will~have~other~errors. } % \end{macrocode} @@ -5291,7 +5398,8 @@ version 2005/12/01 or later. draw~an~arrow~going~to~it~self~from~the~line~'#1'.~This~is~not~possible. \\ If~you~go~on,~this~command~will~be~ignored. } -% +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { Wrong~line~specification~in~MultiArrow } { @@ -5340,11 +5448,11 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn { Multiple~tags } - { - You~can't~use~twice~the~command~\token_to_str:N\tag\ - in~a~line~of~the~environment~\{\l_@@_type_env_str\}. \\ - If~you~go~on,~the~tag~'#1'~will~be~used. - } + { + You~can't~use~twice~the~command~\token_to_str:N\tag\ + in~a~line~of~the~environment~\{\l_@@_type_env_str\}. \\ + If~you~go~on,~the~tag~'#1'~will~be~used. + } % \end{macrocode} % % @@ -5384,12 +5492,13 @@ version 2005/12/01 or later. % % \begin{macrocode} \@@_msg_new:nn { Option~xoffset~forbidden } - { You~can't~use~the~option~'xoffset'~in~the~command~ + { + You~can't~use~the~option~'xoffset'~in~the~command~ \l_@@_string_Arrow_for_msg_str\ while~you~are~using~the~option~ ' \int_compare:nNnTF \l_@@_pos_arrow_int = 7 - { group } - { groups } '. \\ + { group } + { groups } '. \\ \c_@@_option_ignored_str } % \end{macrocode} @@ -5403,56 +5512,31 @@ version 2005/12/01 or later. % \begin{macrocode} \NewDocumentCommand \WithArrowsNewStyle { m m } { - \keys_if_exist:nnTF { WithArrows / WithArrows } { #1 } + \keys_if_exist:nnTF { WithArrows / Global } { #1 } { \@@_error:nn { Key~already~defined } { #1 } } { - \keys_define:nn { WithArrows / WithArrows } - { - #1 .code:n = - { - \keys_define:nn { WithArrows / WithArrows } - { unknown .code:n = \prg_do_nothing: } - \keys_set:nn { WithArrows / WithArrows } { #2 } - \keys_define:nn { WithArrows / WithArrows } - { unknown .code:n = - \@@_error:n { Unknown~option~WithArrows }} - } - } - \seq_put_right:Nn \l_@@_options_WithArrows_seq {#1} - \keys_define:nn { WithArrows / DispWithArrows } - { - #1 .code:n = - { - \keys_define:nn { WithArrows / DispWithArrows } - { unknown .code:n = \prg_do_nothing: } - \keys_set:nn { WithArrows / DispWithArrows } { #2 } - \keys_define:nn {WithArrows / DispWithArrows } - { unknown .code:n = - \@@_error:n { Unknown~option~DispWithArrows }} - } - } - \seq_put_right:Nn \l_@@_options_DispWithArrows_seq { #1 } - \keys_define:nn { WithArrows / WithArrowsOptions } - { - #1 .code:n = - { \keys_set:nn { WithArrows / WithArrowsOptions } { #2 } } - } - \seq_put_right:Nn \l_@@_options_WithArrowsOptions_seq { #1 } + \keys_define:nn { WithArrows / Global } + { + #1 .code:n = + { \keys_set_known:nn { WithArrows / WithArrowsOptions } { #2 } } + } + \seq_put_right:Nn \l_@@_options_WithArrows_seq {#1} + \seq_put_right:Nn \l_@@_options_DispWithArrows_seq { #1 } + \seq_put_right:Nn \l_@@_options_WithArrowsOptions_seq { #1 } % \end{macrocode} % We now set the options in a TeX group in order to detect if some keys in |#2| % are unknown. If a key is unknown, an error will be raised. However, the key -% will, even so, be stored in the definition of key~|#1|. When the key~|#1| will -% be used, the error will be raised again. +% will, even so, be stored in the definition of key~|#1|. % \begin{macrocode} - \group_begin: - \msg_set:nnn { witharrows } { Unknown~option~WithArrowsOptions } - { - The~option~'\l_keys_key_tl'~can't~be~set~in~the~ - definition~of~a~style. \\ - If~you~go~on,~this~key~will~not~be~written~in~the~style~'#1'. - } - \WithArrowsOptions { #2 } - \group_end: + \group_begin: + \msg_set:nnn { witharrows } { Unknown~option~WithArrowsOptions } + { + The~option~'\l_keys_key_tl'~can't~be~set~in~the~ + definition~of~a~style.~You~can~go~on~for~this~time~ + but~you~should~suppress~this~key. + } + \WithArrowsOptions { #2 } + \group_end: } } % \end{macrocode} @@ -5503,18 +5587,18 @@ version 2005/12/01 or later. % \begin{macrocode} \tl_const:Nn \c_@@_tikz_code_down_tl { - \draw [ rounded~corners ] - let \p1 = (#1) , - \p2 = (#2) - in (\p1) -- (\x1,\y2) -- - node { - \dim_set:Nn \l_tmpa_dim { \x1 - \x2 } - \begin { varwidth } \l_tmpa_dim - \raggedright - #3 - \end { varwidth } - } - (\p2) ; + \draw [ rounded~corners ] + let \p1 = (#1) , + \p2 = (#2) + in (\p1) -- (\x1,\y2) -- + node { + \dim_set:Nn \l_tmpa_dim { \x1 - \x2 } + \begin { varwidth } \l_tmpa_dim + \raggedright + #3 + \end { varwidth } + } + (\p2) ; } % \end{macrocode} % @@ -5531,45 +5615,47 @@ version 2005/12/01 or later. % \bigskip % \begin{macrocode} \keys_define:nn { WithArrows / Arrow / SecondPass } - { - up .code:n = \str_if_empty:NT \l_@@_previous_key_str - { - \str_set:Nn \l_@@_previous_key_str { up } - \bool_if:NTF \c_@@_varwidth_loaded_bool - { - \cs_if_exist:cTF { tikz@library@calc@loaded } - { - \int_set:Nn \l_@@_pos_arrow_int \c_one_int + { + up .code:n = + \str_if_empty:NT \l_@@_previous_key_str + { + \str_set:Nn \l_@@_previous_key_str { up } + \bool_if:NTF \c_@@_varwidth_loaded_bool + { + \cs_if_exist:cTF { tikz@library@calc@loaded } + { + \int_set:Nn \l_@@_pos_arrow_int \c_one_int % \end{macrocode} % We have to set |\l_@@_wrap_lines_bool| to |false| because, otherwise, if the % option |wrap_lines| is used at a higher level (global or environment), we will % have a special affectation to |TikzCode| that will overwrite our affectation. % \begin{macrocode} - \bool_set_false:N \l_@@_wrap_lines_bool - \tl_set_eq:NN \l_@@_tikz_code_tl - \c_@@_tikz_code_up_tl - } - { \@@_error:n { calc~not~loaded } } - } - { \@@_error:n { varwidth~not~loaded } } - } , - down .code:n = \str_if_empty:NT \l_@@_previous_key_str - { - \str_set:Nn \l_@@_previous_key_str { down } - \bool_if:NTF \c_@@_varwidth_loaded_bool - { - \cs_if_exist:cTF { tikz@library@calc@loaded } - { - \int_set:Nn \l_@@_pos_arrow_int \c_one_int - \bool_set_false:N \l_@@_wrap_lines_bool - \tl_set_eq:NN \l_@@_tikz_code_tl - \c_@@_tikz_code_down_tl - } - { \@@_error:n { calc~not~loaded } } - } - { \@@_error:n { varwidth~not~loaded } } - } - } + \bool_set_false:N \l_@@_wrap_lines_bool + \tl_set_eq:NN \l_@@_tikz_code_tl + \c_@@_tikz_code_up_tl + } + { \@@_error:n { calc~not~loaded } } + } + { \@@_error:n { varwidth~not~loaded } } + } , + down .code:n = + \str_if_empty:NT \l_@@_previous_key_str + { + \str_set:Nn \l_@@_previous_key_str { down } + \bool_if:NTF \c_@@_varwidth_loaded_bool + { + \cs_if_exist:cTF { tikz@library@calc@loaded } + { + \int_set:Nn \l_@@_pos_arrow_int \c_one_int + \bool_set_false:N \l_@@_wrap_lines_bool + \tl_set_eq:NN \l_@@_tikz_code_tl + \c_@@_tikz_code_down_tl + } + { \@@_error:n { calc~not~loaded } } + } + { \@@_error:n { varwidth~not~loaded } } + } + } % \end{macrocode} % % \begin{macrocode} @@ -5597,6 +5683,23 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nnn { Duplicate~name } + { + The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ + the~same~environment~name~twice.~You~can~go~on,~but,~ + maybe,~you~will~have~incorrect~results. \\ + For~a~list~of~the~names~already~used,~type~H~<return>. \\ + If~you~don't~want~to~see~this~message~again,~use~the~option~ + 'allow-duplicate-names'. + } + { + The~names~already~defined~in~this~document~are:~ + \seq_use:Nnnn \g_@@_names_seq { ,~ } { ,~ } { ~and~ }. + } +% \end{macrocode} +% +% % \section{History} % % \subsection*{Changes between versions 1.0 and 1.1} @@ -5746,6 +5849,18 @@ version 2005/12/01 or later. % possible to externalize the Tikz elements constructed by \pkg{witharrows} % because they use the options |overlay| and |remember picture|.} % +% \subsection*{Changes between 1.15 et 1.16} +% +% Option |no-arrows| +% +% The behaviour of |{DispWithArrows}| after an |\item| of a LaTeX list has been +% changed : no vertical is added. The previous behaviour can be restored with +% the option |standard-behaviour-with-items|. +% +% A given name can no longer be used for two distinct environments. However, +% it's possible to deactivate this control with the option +% |allow-duplicate-names|. +% % \endinput % Local Variables: % TeX-fold-mode: nil diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index fe205670990..291cd84469e 100644 --- a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty +++ b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{1.15} -\def\myfiledate{2019/02/20} +\def\myfileversion{1.16} +\def\myfiledate{2019/03/11} \RequirePackage{tikz} \usetikzlibrary{arrows.meta,bending} \RequirePackage{expl3}[2019/02/15] @@ -30,32 +30,32 @@ {\myfileversion} {Draws arrows for explanations on the right} \RequirePackage { xparse } [ 2018-10-17 ] -\bool_new:N \g__witharrows_footnotehyper_bool -\bool_new:N \g__witharrows_footnote_bool -\cs_new_protected:Npn \__witharrows_msg_new:nn { \msg_new:nnn { witharrows } } -\cs_new_protected:Npn \__witharrows_msg_new:nnn { \msg_new:nnnn { witharrows } } -\cs_new_protected:Npn \__witharrows_msg_redirect_name:nn +\bool_new:N \g__wa_footnotehyper_bool +\bool_new:N \g__wa_footnote_bool +\cs_new_protected:Npn \__wa_msg_new:nn { \msg_new:nnn { witharrows } } +\cs_new_protected:Npn \__wa_msg_new:nnn { \msg_new:nnnn { witharrows } } +\cs_new_protected:Npn \__wa_msg_redirect_name:nn { \msg_redirect_name:nnn { witharrows } } \keys_define:nn { WithArrows / package } { - footnote .bool_gset:N = \g__witharrows_footnote_bool , - footnotehyper .bool_gset:N = \g__witharrows_footnotehyper_bool , + footnote .bool_gset:N = \g__wa_footnote_bool , + footnotehyper .bool_gset:N = \g__wa_footnotehyper_bool , unknown .code:n = \msg_fatal:nn { witharrows } { Option~unknown~for~package } } -\__witharrows_msg_new:nn { Option~unknown~for~package } +\__wa_msg_new:nn { Option~unknown~for~package } { You~can't~use~the~option~'\l_keys_key_tl'~when~loading~the~ package~witharrows.~Try~to~use~the~command~ \token_to_str:N\WithArrowsOptions. } \ProcessKeysOptions { WithArrows / package } -\__witharrows_msg_new:nn { Option~incompatible~with~Beamer } +\__wa_msg_new:nn { Option~incompatible~with~Beamer } { The~option~'\l_keys_key_tl'\ is~incompatible~ with~Beamer~because~Beamer~has~its~own~system~to~extract~footnotes. } -\__witharrows_msg_new:nn { footnote~with~footnotehyper~package } +\__wa_msg_new:nn { footnote~with~footnotehyper~package } { You~can't~use~the~option~'footnote'~because~the~package~ footnotehyper~has~already~been~loaded.~ @@ -63,7 +63,7 @@ within~the~environments~of~witharrows~will~be~extracted~with~the~tools~ of~the~package~footnotehyper. } -\__witharrows_msg_new:nn { footnotehyper~with~footnote~package } +\__wa_msg_new:nn { footnotehyper~with~footnote~package } { You~can't~use~the~option~'footnotehyper'~because~the~package~ footnote~has~already~been~loaded.~ @@ -71,7 +71,7 @@ within~the~environments~of~witharrows~will~be~extracted~with~the~tools~ of~the~package~footnote. } -\bool_if:NT \g__witharrows_footnote_bool +\bool_if:NT \g__wa_footnote_bool { \@ifclassloaded { beamer } { \msg_fatal:nn { witharrows } { Option~incompatible~with~Beamer } } @@ -81,7 +81,7 @@ { } \usepackage { footnote } } -\bool_if:NT \g__witharrows_footnotehyper_bool +\bool_if:NT \g__wa_footnotehyper_bool { \@ifclassloaded { beamer } { \msg_fatal:nn { witharrows } { Option~incompatible~with~Beamer } } @@ -90,21 +90,15 @@ { \msg_fatal:nn { witharrows } { footnotehyper~with~footnote~package } } { } \usepackage { footnotehyper } - \bool_gset_true:N \g__witharrows_footnote_bool + \bool_gset_true:N \g__wa_footnote_bool } -\bool_new:N \c__witharrows_leqno_bool -\DeclareOption { leqno } { \bool_set_true:N \c__witharrows_leqno_bool } +\bool_new:N \c__wa_leqno_bool +\DeclareOption { leqno } { \bool_set_true:N \c__wa_leqno_bool } \DeclareOption* { } \ProcessOptions* -\cs_new_protected:Npn \__witharrows_error:n { \msg_error:nn { witharrows } } -\cs_new_protected:Npn \__witharrows_error:nn { \msg_error:nnn { witharrows } } -\cs_generate_variant:Nn \__witharrows_error:nn { n x } -\cs_new_protected:Nn \__witharrows_bool_new:N - { - \bool_if_exist:NTF #1 - { \bool_set_false:N #1 } - { \bool_new:N #1 } - } +\cs_new_protected:Npn \__wa_error:n { \msg_error:nn { witharrows } } +\cs_new_protected:Npn \__wa_error:nn { \msg_error:nnn { witharrows } } +\cs_generate_variant:Nn \__wa_error:nn { n x } \AtBeginDocument { \clist_map_inline:nn @@ -113,35 +107,38 @@ typedref, varwidth } { - \bool_new:c { c__witharrows_#1_loaded_bool } + \bool_new:c { c__wa_#1_loaded_bool } \@ifpackageloaded { #1 } - { \bool_set_true:c { c__witharrows_#1_loaded_bool } } + { \bool_set_true:c { c__wa_#1_loaded_bool } } { } } } \sys_if_engine_luatex:TF { - \cs_new_protected:Nn \__witharrows_strcmp:nn + \cs_new_protected:Npn \__wa_strcmp:nn #1 #2 { \lua_now:e { l3kernel.strcmp('#1','#2') } } } - { \cs_new_protected:Nn \__witharrows_strcmp:nn { \pdftex_strcmp:D { #1 } { #2 } } } -\cs_new_protected:Nn \__witharrows_sort_seq:N + { + \cs_new_protected:Npn \__wa_strcmp:nn #1 #2 + { \pdftex_strcmp:D { #1 } { #2 } } + } +\cs_new_protected:Npn \__wa_sort_seq:N #1 { \seq_sort:Nn #1 - { - \int_compare:nNnTF - { - \__witharrows_strcmp:nn - { \str_lower_case:n { ##1 } } - { \str_lower_case:n { ##2 } } - } - > 0 - \sort_return_swapped: - \sort_return_same: - } + { + \int_compare:nNnTF + { + \__wa_strcmp:nn + { \str_lower_case:n { ##1 } } + { \str_lower_case:n { ##2 } } + } + > 0 + \sort_return_swapped: + \sort_return_same: + } } \cs_generate_variant:Nn \seq_set_split:Nnn { N x x } -\cs_new_protected:Nn \__witharrows_save:N +\cs_new_protected:Npn \__wa_save:N #1 { \seq_set_split:Nxx \l_tmpa_seq { \char_generate:nn { `_ } { 12 } } @@ -157,7 +154,7 @@ \use:c { \l_tmpa_str _gset_eq:cN } { g _\seq_use:Nnnn \l_tmpa_seq _ _ _ } #1 } -\cs_new_protected:Nn \__witharrows_restore:N +\cs_new_protected:Npn \__wa_restore:N #1 { \seq_set_split:Nxx \l_tmpa_seq { \char_generate:nn { `_ } { 12 } } @@ -169,21 +166,21 @@ } \tikzset { - __witharrows_node_style / .style = + __wa_node_style / .style = { - above = \l__witharrows_ystart_dim , + above = \l__wa_ystart_dim , inner~sep = \c_zero_dim , minimum~width = \c_zero_dim , - minimum~height = \l__witharrows_ygap_dim + minimum~height = \l__wa_ygap_dim } } \tikzset { - __witharrows_standard / .style = + __wa_standard / .style = { remember~picture , overlay , - name~prefix = wa - \l__witharrows_prefix_str - + name~prefix = wa - \l__wa_prefix_str - } } \tikzset @@ -192,8 +189,10 @@ { > = { Straight~Barb [ scale = 1.2 , bend ] } } } \tikzset - { WithArrows / arrow / .style = - { align = left , + { + WithArrows / arrow / .style = + { + align = left , auto = left , font = \small \itshape , WithArrows / arrow / tips , @@ -203,7 +202,7 @@ } \AtBeginDocument { - \bool_if:NF \c__witharrows_amsmath_loaded_bool + \bool_if:NF \c__wa_amsmath_loaded_bool { \cs_set_protected:Npn \spread@equation { @@ -212,263 +211,258 @@ } } } -\bool_new:N \l__witharrows_in_WithArrows_bool -\bool_new:N \l__witharrows_in_DispWithArrows_bool -\bool_new:N \l__witharrows_in_CodeAfter_bool -\seq_new:N \g__witharrows_position_in_the_tree_seq -\seq_gput_right:Nn \g__witharrows_position_in_the_tree_seq 1 -\int_new:N \g__witharrows_last_env_int -\skip_new:N \l__witharrows_interline_skip -\int_new:N \l__witharrows_pos_env_int -\dim_new:N \l__witharrows_xoffset_dim -\dim_set:Nn \l__witharrows_xoffset_dim { 3 mm } -\int_new:N \l__witharrows_pos_arrow_int -\int_set:Nn \l__witharrows_pos_arrow_int 3 -\str_new:N \l__witharrows_input_line_str -\dim_new:N \l__witharrows_x_dim -\seq_new:N \g__witharrows_arrow_int_seq -\int_new:N \g__witharrows_arrow_int -\seq_new:N \g__witharrows_line_int_seq -\int_new:N \g__witharrows_line_int -\bool_new:N \l__witharrows_fleqn_bool -\dim_new:N \l__witharrows_mathindent_dim -\dim_set:Nn \l__witharrows_mathindent_dim { 25 pt } -\bool_new:N \l__witharrows_wrap_lines_bool -\clist_new:N \l__witharrows_tags_clist -\clist_set:Nn \l__witharrows_tags_clist { all } -\tl_new:N \l__witharrows_tag_tl -\bool_new:N \l__witharrows_tag_star_bool -\bool_new:N \l__witharrows_in_first_column_bool -\bool_new:N \l__witharrows_initial_r_bool -\bool_new:N \l__witharrows_initial_l_bool -\dim_new:N \l__witharrows_start_adjust_dim -\dim_set:Nn \l__witharrows_start_adjust_dim { 0.4 ex } -\dim_new:N \l__witharrows_end_adjust_dim -\dim_set:Nn \l__witharrows_end_adjust_dim { 0.4 ex } -\str_new:N \l__witharrows_status_arrow_str -\str_set:Nn \l__witharrows_CommandName_str { Arrow } -\str_set:Nx \l__witharrows_string_Arrow_for_msg_str { \token_to_str:N \Arrow } -\bool_new:N \l__witharrows_displaystyle_bool -\bool_new:N \l__witharrows_show_node_names_bool -\cs_new_protected:Nn \__witharrows_eval_if_allowed:n - { - \str_if_empty:NTF \l__witharrows_previous_key_str +\bool_new:N \l__wa_in_WithArrows_bool +\bool_new:N \l__wa_in_DispWithArrows_bool +\bool_new:N \l__wa_in_CodeAfter_bool +\seq_new:N \g__wa_position_in_the_tree_seq +\seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 +\int_new:N \g__wa_last_env_int +\int_new:N \l__wa_pos_env_int +\int_new:N \l__wa_pos_arrow_int +\int_set:Nn \l__wa_pos_arrow_int 3 +\seq_new:N \g__wa_arrow_int_seq +\int_new:N \g__wa_arrow_int +\seq_new:N \g__wa_line_int_seq +\int_new:N \g__wa_line_int +\clist_new:N \l__wa_tags_clist +\clist_set:Nn \l__wa_tags_clist { all } +\str_set:Nn \l__wa_CommandName_str { Arrow } +\str_set:Nx \l__wa_string_Arrow_for_msg_str { \token_to_str:N \Arrow } +\seq_new:N \g__wa_names_seq +\bool_new:N \l__wa_sbwi_bool +\cs_new_protected:Npn \__wa_eval_if_allowed:n #1 + { + \str_if_empty:NTF \l__wa_previous_key_str { - \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_tl + \str_set_eq:NN \l__wa_previous_key_str \l_keys_key_tl #1 } - { \__witharrows_error:n { Incompatible~options } } + { \__wa_error:n { Incompatible~options } } } -\cs_new_protected:Nn \__witharrows_fix_pos_option:n - { \__witharrows_eval_if_allowed:n { \int_set:Nn \l__witharrows_pos_arrow_int { #1 } } } +\cs_new_protected:Npn \__wa_fix_pos_option:n #1 + { \__wa_eval_if_allowed:n { \int_set:Nn \l__wa_pos_arrow_int { #1 } } } \keys_define:nn { WithArrows / Global } { - ygap .dim_set:N = \l__witharrows_ygap_dim , + ygap .dim_set:N = \l__wa_ygap_dim , ygap .value_required:n = true , ygap .initial:n = 0.4 ex , - ystart .dim_set:N = \l__witharrows_ystart_dim , + ystart .dim_set:N = \l__wa_ystart_dim , ystart .value_required:n = true , ystart .initial:n = 0.4 ex , more-columns .code:n = - \__witharrows_msg_redirect_name:nn { Third~column~in~WithArrows } { none } , + \__wa_msg_redirect_name:nn { Third~column~in~WithArrows } { none } , more-columns .value_forbidden:n = true, CommandName .code:n = - \str_set:Nn \l__witharrows_CommandName_str { #1 } - \str_set:Nx \l__witharrows_string_Arrow_for_msg_str + \str_set:Nn \l__wa_CommandName_str { #1 } + \str_set:Nx \l__wa_string_Arrow_for_msg_str { \c_backslash_str Arrow~alias~\c_backslash_str #1 } , CommandName .value_required:n = true , - TikzCode .tl_set:N = \l__witharrows_tikz_code_tl, + TikzCode .tl_set:N = \l__wa_tikz_code_tl, TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , TikzCode .value_required:n = true , - displaystyle .bool_set:N = \l__witharrows_displaystyle_bool , + displaystyle .bool_set:N = \l__wa_displaystyle_bool , displaystyle .default:n = true , show-nodes .code:n = - \tikzset { __witharrows_node_style / .append~style = { draw , red } } , + \tikzset { __wa_node_style / .append~style = { draw , red } } , show-nodes .value_forbidden:n = true, - show-node-names .bool_set:N = \l__witharrows_show_node_names_bool , + show-node-names .bool_set:N = \l__wa_show_node_names_bool , show-node-names .default:n = true , group .code:n = - \str_if_empty:NTF \l__witharrows_previous_key_str + \str_if_empty:NTF \l__wa_previous_key_str { - \str_set:Nn \l__witharrows_previous_key_str { group } - \seq_remove_all:Nn \l__witharrows_options_Arrow_seq { xoffset } - \int_set:Nn \l__witharrows_pos_arrow_int 7 + \str_set:Nn \l__wa_previous_key_str { group } + \seq_remove_all:Nn \l__wa_options_Arrow_seq { xoffset } + \int_set:Nn \l__wa_pos_arrow_int 7 } - { \__witharrows_error:n { Incompatible~options } } , + { \__wa_error:n { Incompatible~options } } , group .value_forbidden:n = true , groups .code:n = - \str_if_empty:NTF \l__witharrows_previous_key_str + \str_if_empty:NTF \l__wa_previous_key_str { - \str_set:Nn \l__witharrows_previous_key_str { groups } - \seq_if_in:NnF \l__witharrows_options_Arrow_seq { new-group } - { \seq_put_right:Nn \l__witharrows_options_Arrow_seq { new-group } } - \seq_remove_all:Nn \l__witharrows_options_Arrow_seq { xoffset } - \int_set:Nn \l__witharrows_pos_arrow_int 6 + \str_set:Nn \l__wa_previous_key_str { groups } + \seq_if_in:NnF \l__wa_options_Arrow_seq { new-group } + { \seq_put_right:Nn \l__wa_options_Arrow_seq { new-group } } + \seq_remove_all:Nn \l__wa_options_Arrow_seq { xoffset } + \int_set:Nn \l__wa_pos_arrow_int 6 } - { \__witharrows_error:n { Incompatible~options } } , + { \__wa_error:n { Incompatible~options } } , groups .value_forbidden:n = true , tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , tikz .initial:n = \c_empty_tl , tikz .value_required:n = true , rr .value_forbidden:n = true , - rr .code:n = \__witharrows_fix_pos_option:n 3 , + rr .code:n = \__wa_fix_pos_option:n 3 , ll .value_forbidden:n = true , - ll .code:n = \__witharrows_fix_pos_option:n 1 , + ll .code:n = \__wa_fix_pos_option:n 1 , rl .value_forbidden:n = true , - rl .code:n = \__witharrows_fix_pos_option:n 2 , + rl .code:n = \__wa_fix_pos_option:n 2 , lr .value_forbidden:n = true , - lr .code:n = \__witharrows_fix_pos_option:n 0 , + lr .code:n = \__wa_fix_pos_option:n 0 , i .value_forbidden:n = true , - i .code:n = \__witharrows_fix_pos_option:n 5 , - xoffset .dim_set:N = \l__witharrows_xoffset_dim , + i .code:n = \__wa_fix_pos_option:n 5 , + xoffset .dim_set:N = \l__wa_xoffset_dim , xoffset .value_required:n = true , + xoffset .initial:n = 3 mm , jot .dim_set:N = \jot , jot .value_required:n = true , - interline .skip_set:N = \l__witharrows_interline_skip , + interline .skip_set:N = \l__wa_interline_skip , interline .value_required:n = true , - start-adjust .dim_set:N = \l__witharrows_start_adjust_dim , + start-adjust .dim_set:N = \l__wa_start_adjust_dim , start-adjust .value_required:n = true , - end-adjust .dim_set:N = \l__witharrows_end_adjust_dim , + start-adjust .initial:n = 0.4 ex , + end-adjust .dim_set:N = \l__wa_end_adjust_dim , end-adjust .value_required:n = true , + end-adjust .initial:n = 0.4 ex , adjust .code:n = - \dim_set:Nn \l__witharrows_start_adjust_dim { #1 } - \dim_set:Nn \l__witharrows_end_adjust_dim { #1 } , - adjust .value_required:n = true + \dim_zero_new:N \l__wa_start_adjust_dim + \dim_set:Nn \l__wa_start_adjust_dim { #1 } + \dim_zero_new:N \l__wa_end_adjust_dim + \dim_set:Nn \l__wa_end_adjust_dim { #1 } , + adjust .value_required:n = true , + no-arrows .code:n = + \cs_set_eq:NN \__wa_draw_arrows:nn \use_none:nn + \cs_set_eq:NN \__wa_draw_arrow:nnn \use_none:nnn , + no-arrows .value_forbidden:n = true , } \keys_define:nn { WithArrows / WithArrowsSpecific } { - t .code:n = \int_set:Nn \l__witharrows_pos_env_int 0 , + t .code:n = \int_set:Nn \l__wa_pos_env_int O , t .value_forbidden:n = true , - c .code:n = \int_set:Nn \l__witharrows_pos_env_int 1 , + c .code:n = \int_set:Nn \l__wa_pos_env_int 1 , c .value_forbidden:n = true , - b .code:n = \int_set:Nn \l__witharrows_pos_env_int 2 , + b .code:n = \int_set:Nn \l__wa_pos_env_int 2 , b .value_forbidden:n = true } \keys_define:nn { WithArrows / DispWithArrowsSpecific } { - fleqn .bool_set:N = \l__witharrows_fleqn_bool , + fleqn .bool_set:N = \l__wa_fleqn_bool , fleqn .default:n = true , - mathindent .dim_set:N = \l__witharrows_mathindent_dim , + mathindent .dim_set:N = \l__wa_mathindent_dim , mathindent .value_required:n = true , + mathindent .initial:n = 25 pt , notag .code:n = \str_if_eq:nnTF { #1 } { true } - { \clist_clear:N \l__witharrows_tags_clist } - { \clist_set:Nn \l__witharrows_tags_clist { all } } , + { \clist_clear:N \l__wa_tags_clist } + { \clist_set:Nn \l__wa_tags_clist { all } } , notag .default:n = true , nonumber .meta:n = notag , allow-multiple-labels .code:n = - \__witharrows_msg_redirect_name:nn { Multiple~labels } { none } , + \__wa_msg_redirect_name:nn { Multiple~labels } { none } , allow-multiple-labels .value_forbidden:n = true , - wrap-lines .bool_set:N = \l__witharrows_wrap_lines_bool , + wrap-lines .bool_set:N = \l__wa_wrap_lines_bool , wrap-lines .default:n = true , tagged-lines .code:n = - \clist_set:Nn \l__witharrows_tags_clist { #1 } - \clist_if_in:NnT \l__witharrows_tags_clist { first } + \clist_set:Nn \l__wa_tags_clist { #1 } + \clist_if_in:NnT \l__wa_tags_clist { first } { - \clist_remove_all:Nn \l__witharrows_tags_clist { first } - \clist_put_left:Nn \l__witharrows_tags_clist \c_one_int + \clist_remove_all:Nn \l__wa_tags_clist { first } + \clist_put_left:Nn \l__wa_tags_clist \c_one_int } , - tagged-lines .value_required:n = true + tagged-lines .value_required:n = true , + standard-behaviour-with-items .bool_set:N = \l__wa_sbwi_bool , + standard-behaviour-with-items .default:n = true + } +\keys_define:nn { WithArrows / Env } + { + name .code:n = + \seq_if_in:NnTF \g__wa_names_seq { #1 } + { \__wa_error:n { Duplicate~name } } + { \seq_gput_left:Nn \g__wa_names_seq { #1 } } + \str_set:Nn \l__wa_name_str { #1 } , + name .value_required:n = true , + CodeBefore .code:n = \tl_put_right:Nn \l__wa_code_before_tl { #1 } , + CodeBefore .value_required:n = true, + CodeAfter .code:n = \tl_put_right:Nn \l__wa_code_after_tl { #1 } , + CodeAfter .value_required:n = true } \keys_define:nn { WithArrows } { WithArrows .inherit:n = { WithArrows / Global , - WithArrows / WithArrowsSpecific + WithArrows / WithArrowsSpecific , + WithArrows / Env + } , + DispWithArrows .inherit:n = + { + WithArrows / DispWithArrowsSpecific , + WithArrows / Global , + WithArrows / Env , + } , + WithArrowsOptions .inherit:n = + { + WithArrows / Global , + WithArrows / WithArrowsSpecific , + WithArrows / DispWithArrowsSpecific } } \keys_define:nn { WithArrows / WithArrows } - { - name .tl_set:N = \l__witharrows_name_str , - name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l__witharrows_code_before_tl { #1 } , - CodeBefore .value_required:n = true, - CodeAfter .code:n = \tl_put_right:Nn \l__witharrows_code_after_tl { #1 } , - CodeAfter .value_required:n = true , - unknown .code:n = - \__witharrows_sort_seq:N \l__witharrows_options_WithArrows_seq - \__witharrows_error:n { Unknown~option~WithArrows } - } -\seq_set_from_clist:Nn \l__witharrows_options_WithArrows_seq { - adjust, b, c, CodeAfter, CodeBefore, CommandName, displaystyle, end-adjust, - group, groups, i, interline, jot, ll, lr, more-columns, name, rl, rr, - show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, ygap, - ystart + unknown .code:n = + \__wa_sort_seq:N \l__wa_options_WithArrows_seq + \__wa_error:n { Unknown~option~WithArrows } } -\keys_define:nn { WithArrows } +\seq_set_from_clist:Nn \l__wa_options_WithArrows_seq { - DispWithArrows .inherit:n = - { - WithArrows / DispWithArrowsSpecific , - WithArrows / Global - } + adjust, b, c, CodeAfter, CodeBefore, CommandName, displaystyle, end-adjust, + group, groups, i, interline, jot, ll, lr, more-columns, name, no-arrows, rl, + rr, show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, + ygap, ystart } \keys_define:nn { WithArrows / DispWithArrows } { - name .tl_set:N = \l__witharrows_name_str , - name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l__witharrows_code_before_tl { #1 } , - CodeBefore .value_required:n = true , - CodeAfter .code:n = \tl_put_right:Nn \l__witharrows_code_after_tl { #1 } , - CodeAfter .value_required:n = true , unknown .code:n = - \__witharrows_sort_seq:N \l__witharrows_options_DispWithArrows_seq - \__witharrows_error:n { Unknown~option~DispWithArrows } + \__wa_sort_seq:N \l__wa_options_DispWithArrows_seq + \__wa_error:n { Unknown~option~DispWithArrows } } -\seq_set_from_clist:Nn \l__witharrows_options_DispWithArrows_seq +\seq_set_from_clist:Nn \l__wa_options_DispWithArrows_seq { allow-multiple-labels, CodeAfter, CodeBefore, CommandName, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, name, nonumber, notag, rl, rr, show-node-names, show-nodes, - start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart - } -\keys_define:nn { WithArrows } - { - WithArrowsOptions .inherit:n = - { - WithArrows / Global , - WithArrows / WithArrowsSpecific , - WithArrows / DispWithArrowsSpecific - } + mathindent, name, no-arrows, nonumber, notag, rl, rr, show-node-names, + show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, + ystart } \keys_define:nn { WithArrows / WithArrowsOptions } { + allow-duplicate-names .code:n = + \__wa_msg_redirect_name:nn { Duplicate~name } { none } , + allow-duplicate-names .value_forbidden:n = true , unknown .code:n = - \__witharrows_sort_seq:N \l__witharrows_options_WithArrowsOptions_seq - \__witharrows_error:n { Unknown~option~WithArrowsOptions } + \__wa_sort_seq:N \l__wa_options_WithArrowsOptions_seq + \__wa_error:n { Unknown~option~WithArrowsOptions } } -\seq_set_from_clist:Nn \l__witharrows_options_WithArrowsOptions_seq +\seq_set_from_clist:Nn \l__wa_options_WithArrowsOptions_seq { - allow-multiple-labels, b, c, CommandName, more-columns, TikzCode, adjust, - displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, nonumber, notag, rl, rr, show-node-names, show-nodes, + allow-duplicate-names, allow-multiple-labels, b, c, CommandName, + more-columns, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, + groups, i, interline, jot, ll, lr, mathindent, no-arrows, nonumber, notag, + rl, rr, show-node-names, show-nodes, standard-behaviour-with-items, start-adjust, t, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart } -\cs_new_protected:Nn \__witharrows_set_independent: +\cs_new_protected:Npn \__wa_set_independent: { - \str_if_empty:NTF \l__witharrows_previous_key_str + \str_if_empty:NTF \l__wa_previous_key_str { - \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_tl - \str_set:Nn \l__witharrows_status_arrow_str { independent } + \str_set_eq:NN \l__wa_previous_key_str \l_keys_key_tl + \str_set:Nn \l__wa_status_arrow_str { independent } \str_if_eq:VnF \l_keys_value_tl { NoValue } - { \__witharrows_error:n { Value~for~a~key } } + { \__wa_error:n { Value~for~a~key } } } - { \__witharrows_error:n { Incompatible~options~in~Arrow } } + { \__wa_error:n { Incompatible~options~in~Arrow } } } \keys_define:nn { WithArrows / Arrow / FirstPass } { jump .code:n = \int_compare:nTF { #1 > 0 } - { \int_set:Nn \l__witharrows_jump_int { #1 } } - { \__witharrows_error:n { Negative~jump } } , + { \int_set:Nn \l__wa_jump_int { #1 } } + { \__wa_error:n { Negative~jump } } , jump .value_required:n = true, - rr .code:n = \__witharrows_set_independent: , - ll .code:n = \__witharrows_set_independent: , - rl .code:n = \__witharrows_set_independent: , - lr .code:n = \__witharrows_set_independent: , - i .code:n = \__witharrows_set_independent: , + rr .code:n = \__wa_set_independent: , + ll .code:n = \__wa_set_independent: , + rl .code:n = \__wa_set_independent: , + lr .code:n = \__wa_set_independent: , + i .code:n = \__wa_set_independent: , rr .default:n = NoValue , ll .default:n = NoValue , rl .default:n = NoValue , @@ -476,16 +470,16 @@ i .default:n = NoValue , new-group .value_forbidden:n = true, new-group .code:n = - \int_compare:nTF { \l__witharrows_pos_arrow_int = 6 } - { \str_set:Nn \l__witharrows_status_arrow_str { new-group } } - { \__witharrows_error:n { new-group~without~groups } } , + \int_compare:nTF { \l__wa_pos_arrow_int = 6 } + { \str_set:Nn \l__wa_status_arrow_str { new-group } } + { \__wa_error:n { new-group~without~groups } } , TikzCode .code:n = \prg_do_nothing: , TikzCode .value_required:n = true , tikz .code:n = \prg_do_nothing: , tikz .value_required:n = true , xoffset .code:n = - \int_compare:nNnT \l__witharrows_pos_arrow_int > 5 - { \__witharrows_error:n { Option~xoffset~forbidden } } , + \int_compare:nNnT \l__wa_pos_arrow_int > 5 + { \__wa_error:n { Option~xoffset~forbidden } } , xoffset .value_required:n = true , start-adjust .code:n = \prg_do_nothing: , start-adjust .value_required:n = true , @@ -494,145 +488,150 @@ adjust .code:n = \prg_do_nothing: , adjust .value_required:n = true , unknown .code:n = - \__witharrows_sort_seq:N \l__witharrows_options_Arrow_seq - \__witharrows_error:n { Unknown~option~in~Arrow } + \__wa_sort_seq:N \l__wa_options_Arrow_seq + \__wa_error:n { Unknown~option~in~Arrow } } -\seq_set_from_clist:Nn \l__witharrows_options_Arrow_seq +\seq_set_from_clist:Nn \l__wa_options_Arrow_seq { adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, TikzCode, xoffset } -\cs_new_protected:Nn \__witharrows_fix_pos_arrow:n +\cs_new_protected:Npn \__wa_fix_pos_arrow:n #1 { - \str_if_empty:NT \l__witharrows_previous_key_str + \str_if_empty:NT \l__wa_previous_key_str { - \str_set_eq:NN \l__witharrows_previous_key_str \l_keys_key_tl - \int_set:Nn \l__witharrows_pos_arrow_int { #1 } + \str_set_eq:NN \l__wa_previous_key_str \l_keys_key_tl + \int_set:Nn \l__wa_pos_arrow_int { #1 } } } \keys_define:nn {WithArrows / Arrow / SecondPass } { - TikzCode .tl_set:N = \l__witharrows_tikz_code_tl , + TikzCode .tl_set:N = \l__wa_tikz_code_tl , TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , tikz .initial:n = \c_empty_tl , - rr .code:n = \__witharrows_fix_pos_arrow:n 3 , - ll .code:n = \__witharrows_fix_pos_arrow:n 1 , - rl .code:n = \__witharrows_fix_pos_arrow:n 2 , - lr .code:n = \__witharrows_fix_pos_arrow:n 0 , - i .code:n = \__witharrows_fix_pos_arrow:n 5 , + rr .code:n = \__wa_fix_pos_arrow:n 3 , + ll .code:n = \__wa_fix_pos_arrow:n 1 , + rl .code:n = \__wa_fix_pos_arrow:n 2 , + lr .code:n = \__wa_fix_pos_arrow:n 0 , + i .code:n = \__wa_fix_pos_arrow:n 5 , xoffset .code:n = - \int_compare:nNnF \l__witharrows_pos_arrow_int > 5 - { \dim_set:Nn \l__witharrows_xoffset_dim { #1 } } , - start-adjust .dim_set:N = \l__witharrows_start_adjust_dim, - end-adjust .dim_set:N = \l__witharrows_end_adjust_dim, + \int_compare:nNnF \l__wa_pos_arrow_int > 5 + { \dim_set:Nn \l__wa_xoffset_dim { #1 } } , + start-adjust .dim_set:N = \l__wa_start_adjust_dim, + end-adjust .dim_set:N = \l__wa_end_adjust_dim, adjust .code:n = - \dim_set:Nn \l__witharrows_start_adjust_dim { #1 } - \dim_set:Nn \l__witharrows_end_adjust_dim { #1 } , + \dim_set:Nn \l__wa_start_adjust_dim { #1 } + \dim_set:Nn \l__wa_end_adjust_dim { #1 } , } \NewDocumentCommand \WithArrowsOptions { m } { - \str_clear_new:N \l__witharrows_previous_key_str + \str_clear_new:N \l__wa_previous_key_str \keys_set:nn { WithArrows / WithArrowsOptions } { #1 } } -\NewDocumentCommand \__witharrows_Arrow { O { } m ! O { } } +\NewDocumentCommand \__wa_Arrow { O { } m ! O { } } { - \int_gincr:N \g__witharrows_arrow_int - \str_clear_new:N \l__witharrows_previous_key_str + \int_gincr:N \g__wa_arrow_int + \str_clear_new:N \l__wa_previous_key_str \keys_set:nn { WithArrows / Arrow / FirstPass } { #1 , #3 } - \prop_put:NnV \l_tmpa_prop { initial } \g__witharrows_line_int - \int_set:Nn \l_tmpa_int { \g__witharrows_line_int + \l__witharrows_jump_int } + \prop_put:NnV \l_tmpa_prop { initial } \g__wa_line_int + \int_set:Nn \l_tmpa_int { \g__wa_line_int + \l__wa_jump_int } \prop_put:NnV \l_tmpa_prop { final } \l_tmpa_int - \prop_put:NnV \l_tmpa_prop { status } \l__witharrows_status_arrow_str + \prop_put:NnV \l_tmpa_prop { status } \l__wa_status_arrow_str \prop_put:Nnn \l_tmpa_prop { options } { #1 , #3 } \prop_put:Nnn \l_tmpa_prop { label } { #2 } \prop_put:Nnx \l_tmpa_prop { input-line } \msg_line_number: \prop_gclear_new:c - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \g__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \g__wa_arrow_int _ prop } \prop_gset_eq:cN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \g__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \g__wa_arrow_int _ prop } \l_tmpa_prop } -\cs_new_protected:Nn \__witharrows_Arrow_first_column: - { \__witharrows_error:n { Arrow~in~first~column } \__witharrows_Arrow } -\cs_new_protected:Nn \__witharrows_pre_environment:n +\cs_new_protected:Npn \__wa_Arrow_first_column: + { \__wa_error:n { Arrow~in~first~column } \__wa_Arrow } +\cs_new_protected:Npn \__wa_pre_environment:n #1 { - \str_clear_new:N \l__witharrows_type_env_str - \str_set:NV \l__witharrows_type_env_str \@currenvir + \str_clear_new:N \l__wa_type_env_str + \str_set:NV \l__wa_type_env_str \@currenvir \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } - \str_clear_new:N \l__witharrows_name_str - \seq_gput_right:NV \g__witharrows_arrow_int_seq \g__witharrows_arrow_int - \int_gzero:N \g__witharrows_arrow_int - \seq_gput_right:NV \g__witharrows_line_int_seq \g__witharrows_line_int - \int_gzero:N \g__witharrows_line_int - \seq_gput_right:Nn \g__witharrows_position_in_the_tree_seq 1 - \seq_set_eq:NN \l_tmpa_seq \g__witharrows_position_in_the_tree_seq + \str_clear_new:N \l__wa_name_str + \str_clear_new:N \l__wa_status_arrow_str + \dim_zero_new:N \l__wa_x_dim + \str_clear_new:N \l__wa_input_line_str + \seq_gput_right:NV \g__wa_arrow_int_seq \g__wa_arrow_int + \int_gzero:N \g__wa_arrow_int + \seq_gput_right:NV \g__wa_line_int_seq \g__wa_line_int + \int_gzero:N \g__wa_line_int + \seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 + \seq_set_eq:NN \l_tmpa_seq \g__wa_position_in_the_tree_seq \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl - \str_clear_new:N \l__witharrows_prefix_str - \str_set:Nx \l__witharrows_prefix_str { \seq_use:Nnnn \l_tmpa_seq - - - } - \cs_set_eq:NN \\ \__witharrows_cr: + \str_clear_new:N \l__wa_prefix_str + \str_set:Nx \l__wa_prefix_str { \seq_use:Nnnn \l_tmpa_seq - - - } + \cs_set_eq:NN \\ \__wa_cr: \dim_zero:N \mathsurround - \int_zero_new:N \l__witharrows_initial_int - \int_zero_new:N \l__witharrows_final_int - \int_zero_new:N \l__witharrows_arrow_int - \int_zero_new:N \l__witharrows_pos_of_arrow_int - \int_zero_new:N \l__witharrows_jump_int - \int_set:Nn \l__witharrows_jump_int \c_one_int - \seq_clear_new:N \l__witharrows_labels_seq - \__witharrows_bool_new:N \l__witharrows_tag_next_line_bool - \skip_zero:N \l__witharrows_interline_skip - \tl_clear_new:N \l__witharrows_code_before_tl - \tl_clear_new:N \l__witharrows_code_after_tl - \str_clear_new:N \l__witharrows_previous_key_str - \bool_if:NT \l__witharrows_in_WithArrows_bool + \int_zero_new:N \l__wa_initial_int + \int_zero_new:N \l__wa_final_int + \int_zero_new:N \l__wa_arrow_int + \int_zero_new:N \l__wa_pos_of_arrow_int + \int_zero_new:N \l__wa_jump_int + \int_set:Nn \l__wa_jump_int \c_one_int + \bool_set_false:N \l__wa_in_first_column_bool + \seq_clear_new:N \l__wa_labels_seq + \bool_set_false:N \l__wa_tag_next_line_bool + \skip_zero:N \l__wa_interline_skip + \tl_clear_new:N \l__wa_code_before_tl + \tl_clear_new:N \l__wa_code_after_tl + \str_clear_new:N \l__wa_previous_key_str + \bool_if:NT \l__wa_in_WithArrows_bool { \keys_set:nn { WithArrows / WithArrows } { #1 } } - \bool_if:NT \l__witharrows_in_DispWithArrows_bool + \bool_if:NT \l__wa_in_DispWithArrows_bool { \keys_set:nn { WithArrows / DispWithArrows } { #1 } } - \bool_if:NT \g__witharrows_footnote_bool { \begin { savenotes } } - \l__witharrows_code_before_tl - \cs_set_eq:cN \l__witharrows_CommandName_str \__witharrows_Arrow + \bool_if:NT \g__wa_footnote_bool { \begin { savenotes } } + \l__wa_code_before_tl + \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow + \cs_set_eq:NN \notag \__wa_notag: + \cs_set_eq:NN \nonumber \__wa_notag: + \cs_set_eq:NN \tag \__wa_tag + \cs_set_eq:NN \__wa_old_label \label + \cs_set_eq:NN \label \__wa_label:n + \cs_set_eq:NN \tagnextline \__wa_tagnextline: } \NewDocumentEnvironment { WithArrows } { ! O { } } { - \bool_set_true:N \l__witharrows_in_WithArrows_bool - \bool_set_false:N \l__witharrows_in_DispWithArrows_bool - \__witharrows_pre_environment:n { #1 } + \bool_set_true:N \l__wa_in_WithArrows_bool + \bool_set_false:N \l__wa_in_DispWithArrows_bool + \__wa_pre_environment:n { #1 } \if_mode_math: \else: - \__witharrows_error:n { WithArrows~outside~math~mode } + \__wa_error:n { WithArrows~outside~math~mode } \fi: - \cs_set_eq:NN \notag \__witharrows_notag: - \cs_set_eq:NN \nonumber \__witharrows_notag: - \cs_set_eq:NN \tag \__witharrows_tag - \cs_set_eq:NN \label \__witharrows_label:n - \cs_set_eq:NN \tagnextline \__witharrows_tagnextline: - \int_case:nn \l__witharrows_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox } + \int_case:nn \l__wa_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox } \bgroup \spread@equation \ialign \bgroup - \int_gincr:N \g__witharrows_line_int - \cs_set_eq:cN \l__witharrows_CommandName_str \__witharrows_Arrow_first_column: - \bool_set_true:N \l__witharrows_in_first_column_bool + \int_gincr:N \g__wa_line_int + \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_first_column: + \bool_set_true:N \l__wa_in_first_column_bool \strut \hfil $ - \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle + \bool_if:NT \l__wa_displaystyle_bool \displaystyle { ## } $ & $ - \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle + \bool_if:NT \l__wa_displaystyle_bool \displaystyle { { } ## } $ \tikz [ remember~picture , overlay ] \node [ node~contents = { } , - __witharrows_node_style , - name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - l , + __wa_node_style , + name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - l , alias = { - \str_if_empty:NF \l__witharrows_name_str - { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - l } + \str_if_empty:NF \l__wa_name_str + { \l__wa_name_str - \int_use:N \g__wa_line_int - l } } ] ; @@ -641,24 +640,24 @@ \node [ node~contents = { } , - __witharrows_node_style , - name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - r , + __wa_node_style , + name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - r , alias = { - \str_if_empty:NF \l__witharrows_name_str - { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - r } + \str_if_empty:NF \l__wa_name_str + { \l__wa_name_str - \int_use:N \g__wa_line_int - r } } ] ; - \bool_if:NT \l__witharrows_show_node_names_bool + \bool_if:NT \l__wa_show_node_names_bool { \hbox_overlap_right:n - { \small wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int } + { \small wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int } } && - \__witharrows_error:n { Third~column~in~WithArrows } + \__wa_error:n { Third~column~in~WithArrows } $ - \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle + \bool_if:NT \l__wa_displaystyle_bool \displaystyle { ## } $ \cr @@ -667,190 +666,187 @@ \\ \egroup \egroup - \__witharrows_post_environment: - \bool_if:NT \g__witharrows_footnote_bool { \end { savenotes } } + \__wa_post_environment: + \bool_if:NT \g__wa_footnote_bool { \end { savenotes } } } -\cs_new_protected:Nn \__witharrows_post_environment: +\cs_new_protected:Npn \__wa_post_environment: { - \cs_set:Npn \WithArrowsRightX { \g__witharrows_right_x_dim } - \int_compare:nNnT \g__witharrows_arrow_int > 0 \__witharrows_scan_arrows: + \cs_set:Npn \WithArrowsRightX { \g__wa_right_x_dim } + \int_compare:nNnT \g__wa_arrow_int > 0 \__wa_scan_arrows: \group_begin: - \tikzset { every~picture / .style = __witharrows_standard } - \cs_set:Npn \WithArrowsNbLines { \int_use:N \g__witharrows_line_int } - \cs_set_eq:NN \MultiArrow \__witharrows_MultiArrow:nn - \cs_set_eq:cN \l__witharrows_CommandName_str \__witharrows_Arrow_code_after - \bool_set_true:N \l__witharrows_in_CodeAfter_bool - \l__witharrows_code_after_tl + \tikzset { every~picture / .style = __wa_standard } + \cs_set:Npn \WithArrowsNbLines { \int_use:N \g__wa_line_int } + \cs_set_eq:NN \MultiArrow \__wa_MultiArrow:nn + \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_code_after + \bool_set_true:N \l__wa_in_CodeAfter_bool + \l__wa_code_after_tl \group_end: - \seq_gpop_right:NN \g__witharrows_position_in_the_tree_seq \l_tmpa_tl - \seq_gpop_right:NN \g__witharrows_position_in_the_tree_seq \l_tmpa_tl - \seq_gput_right:Nx \g__witharrows_position_in_the_tree_seq + \seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl + \seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl + \seq_gput_right:Nx \g__wa_position_in_the_tree_seq { \int_eval:n { \l_tmpa_tl + 1 } } - \int_compare:nNnT { \seq_count:N \g__witharrows_position_in_the_tree_seq } = 1 - { \int_gincr:N \g__witharrows_last_env_int } - \seq_gpop_right:NN \g__witharrows_arrow_int_seq \l_tmpa_tl - \int_gset:Nn \g__witharrows_arrow_int \l_tmpa_tl - \seq_gpop_right:NN \g__witharrows_line_int_seq \l_tmpa_tl - \int_gset:Nn \g__witharrows_line_int \l_tmpa_tl + \int_compare:nNnT { \seq_count:N \g__wa_position_in_the_tree_seq } = 1 + { \int_gincr:N \g__wa_last_env_int } + \seq_gpop_right:NN \g__wa_arrow_int_seq \l_tmpa_tl + \int_gset:Nn \g__wa_arrow_int \l_tmpa_tl + \seq_gpop_right:NN \g__wa_line_int_seq \l_tmpa_tl + \int_gset:Nn \g__wa_line_int \l_tmpa_tl } -\cs_new_protected:Nn \__witharrows_cr: +\cs_new_protected:Npn \__wa_cr: { \scan_stop: - \bool_if:NT \l__witharrows_in_first_column_bool { & { } } + \bool_if:NT \l__wa_in_first_column_bool { & { } } \group_align_safe_begin: - \peek_meaning_remove:NTF * \__witharrows_cr_i: \__witharrows_cr_i: + \peek_meaning_remove:NTF * \__wa_cr_i: \__wa_cr_i: } -\cs_new_protected:Nn \__witharrows_cr_i: - { \peek_meaning:NTF [ \__witharrows_cr_ii: { \__witharrows_cr_ii: [ \c_zero_dim ] } } -\cs_new_protected:Npn \__witharrows_cr_ii: [ #1 ] +\cs_new_protected:Npn \__wa_cr_i: + { \peek_meaning:NTF [ \__wa_cr_ii: { \__wa_cr_ii: [ \c_zero_dim ] } } +\cs_new_protected:Npn \__wa_cr_ii: [ #1 ] { \group_align_safe_end: - \bool_if:NT \l__witharrows_in_DispWithArrows_bool + \bool_if:NT \l__wa_in_DispWithArrows_bool { - \clist_if_in:NnTF \l__witharrows_tags_clist { all } + \clist_if_in:NnTF \l__wa_tags_clist { all } { - \tl_if_empty:NT \l__witharrows_tag_tl { \int_gincr:N \c@equation } + \tl_if_empty:NT \l__wa_tag_tl { \int_gincr:N \c@equation } \cs_gset:Npx \g_tmpa_tl - { \tl_if_empty:NTF \l__witharrows_tag_tl \theequation \l__witharrows_tag_tl } - \seq_if_empty:NF \l__witharrows_labels_seq + { \tl_if_empty:NTF \l__wa_tag_tl \theequation \l__wa_tag_tl } + \seq_if_empty:NF \l__wa_labels_seq { \cs_set:Npx \@currentlabel { \p@equation \g_tmpa_tl } - \bool_if:NT \c__witharrows_hyperref_loaded_bool - { - \cs_set:Npn \This@name { equation } - \hyper@refstepcounter { equation } - } - \bool_if:NT \c__witharrows_cleveref_loaded_bool - { - \cref@constructprefix { equation } { \cref@result } - \protected@edef \cref@currentlabel - { - [ - \cs_if_exist:NTF \cref@equation@alias - \cref@equation@alias - { equation } - ] - [ \arabic { equation } ] [ \cref@result ] - \p@equation \g_tmpa_tl - } - } - \bool_if:NT \c__witharrows_typedref_loaded_bool - { \cs_set:Npn \sr@name { equation } } - \seq_map_function:NN \l__witharrows_labels_seq \__witharrows_old_label + \bool_if:NT \c__wa_hyperref_loaded_bool + { + \str_set:Nn \This@name { equation } + \hyper@refstepcounter { equation } + } + \bool_if:NT \c__wa_cleveref_loaded_bool + { + \cref@constructprefix { equation } \cref@result + \protected@edef \cref@currentlabel + { + [ + \cs_if_exist:NTF \cref@equation@alias + \cref@equation@alias + { equation } + ] + [ \arabic { equation } ] [ \cref@result ] + \p@equation \g_tmpa_tl + } + } + \seq_map_function:NN \l__wa_labels_seq \__wa_old_label } - \__witharrows_save:N \l__witharrows_tag_star_bool - \__witharrows_save:N \l__witharrows_qedhere_bool - \bool_if:NT \l__witharrows_tag_next_line_bool + \__wa_save:N \l__wa_tag_star_bool + \__wa_save:N \l__wa_qedhere_bool + \bool_if:NT \l__wa_tag_next_line_bool { \openup -\jot - \bool_set_false:N \l__witharrows_tag_next_line_bool + \bool_set_false:N \l__wa_tag_next_line_bool \notag \\ & } & - \__witharrows_restore:N \l__witharrows_tag_star_bool - \__witharrows_restore:N \l__witharrows_qedhere_bool - \bool_if:NT \l__witharrows_qedhere_bool - { \hbox_overlap_left:n \__witharrows_qedhere_i: } + \__wa_restore:N \l__wa_tag_star_bool + \__wa_restore:N \l__wa_qedhere_bool + \bool_if:NT \l__wa_qedhere_bool + { \hbox_overlap_left:n \__wa_qedhere_i: } \cs_set_eq:NN \theequation \g_tmpa_tl - \bool_if:NT \l__witharrows_tag_star_bool - { \cs_set_eq:NN \tagform@ \prg_do_nothing: } + \bool_if:NT \l__wa_tag_star_bool + { \cs_set_eq:NN \tagform@ \prg_do_nothing: } \hbox_overlap_left:n { - \bool_if:NF \c__witharrows_leqno_bool + \bool_if:NF \c__wa_leqno_bool { - \tikz [ __witharrows_standard ] - \coordinate ( \int_use:N \g__witharrows_line_int - v ) ; + \tikz [ __wa_standard ] + \coordinate ( \int_use:N \g__wa_line_int - v ) ; } \quad \@eqnnum } - \bool_if:NT \c__witharrows_leqno_bool + \bool_if:NT \c__wa_leqno_bool { - \tikz [ __witharrows_standard ] - \coordinate ( \int_use:N \g__witharrows_line_int - v ) ; + \tikz [ __wa_standard ] + \coordinate ( \int_use:N \g__wa_line_int - v ) ; } } { - \__witharrows_save:N \l__witharrows_qedhere_bool + \__wa_save:N \l__wa_qedhere_bool & - \__witharrows_restore:N \l__witharrows_qedhere_bool - \bool_if:NT \l__witharrows_qedhere_bool - { \hbox_overlap_left:n \__witharrows_qedhere_i: } - \tikz [ __witharrows_standard ] - \coordinate ( \int_use:N \g__witharrows_line_int - v ) ; + \__wa_restore:N \l__wa_qedhere_bool + \bool_if:NT \l__wa_qedhere_bool + { \hbox_overlap_left:n \__wa_qedhere_i: } + \tikz [ __wa_standard ] + \coordinate ( \int_use:N \g__wa_line_int - v ) ; } - } - \cr \noalign { \skip_vertical:n { #1 + \l__witharrows_interline_skip } \scan_stop: } + } + \cr \noalign { \skip_vertical:n { #1 + \l__wa_interline_skip } \scan_stop: } } -\cs_new_protected:Nn \__witharrows_if_in_second_col_of_disp:Nn +\cs_new_protected:Npn \__wa_if_in_second_col_of_disp:Nn #1 #2 { - \bool_if:NTF \l__witharrows_in_WithArrows_bool - { \__witharrows_error:nn { Not~allowed~in~WithArrows } { #1 } } + \bool_if:NTF \l__wa_in_WithArrows_bool + { \__wa_error:nn { Not~allowed~in~WithArrows } { #1 } } { - \bool_if:NTF \l__witharrows_in_first_column_bool - { \__witharrows_error:nn { Not~allowed~in~DispWithArrows } { #1 } } + \bool_if:NTF \l__wa_in_first_column_bool + { \__wa_error:nn { Not~allowed~in~DispWithArrows } { #1 } } { #2 } } } -\cs_new_protected:Nn \__witharrows_notag: - { \__witharrows_if_in_second_col_of_disp:Nn \notag { \clist_clear:N \l__witharrows_tags_clist } } -\NewDocumentCommand \__witharrows_tag { s m } +\cs_new_protected:Npn \__wa_notag: + { \__wa_if_in_second_col_of_disp:Nn \notag { \clist_clear:N \l__wa_tags_clist } } +\NewDocumentCommand \__wa_tag { s m } { - \__witharrows_if_in_second_col_of_disp:Nn \tag + \__wa_if_in_second_col_of_disp:Nn \tag { - \tl_if_empty:NF \l__witharrows_tag_tl - { \__witharrows_error:nn { Multiple~tags } { #2 } } - \clist_set:Nn \l__witharrows_tags_clist { all } - \bool_if:nT \c__witharrows_mathtools_loaded_bool + \tl_if_empty:NF \l__wa_tag_tl + { \__wa_error:nn { Multiple~tags } { #2 } } + \clist_set:Nn \l__wa_tags_clist { all } + \bool_if:nT \c__wa_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } { \MH_if_boolean:nF { show_manual_tags } - { \clist_clear:N \l__witharrows_tags_clist } + { \clist_clear:N \l__wa_tags_clist } } } - \tl_set:Nn \l__witharrows_tag_tl { #2 } - \bool_set:Nn \l__witharrows_tag_star_bool { #1 } - \bool_if:nT { #1 && ! \bool_if_p:N \c__witharrows_amsmath_loaded_bool } - { \__witharrows_error:n { tag*~without~amsmath } } + \tl_set:Nn \l__wa_tag_tl { #2 } + \bool_set:Nn \l__wa_tag_star_bool { #1 } + \bool_if:nT { #1 && ! \bool_if_p:N \c__wa_amsmath_loaded_bool } + { \__wa_error:n { tag*~without~amsmath } } } } -\cs_new_protected:Nn \__witharrows_label:n +\cs_new_protected:Npn \__wa_label:n #1 { - \__witharrows_if_in_second_col_of_disp:Nn \label + \__wa_if_in_second_col_of_disp:Nn \label { - \seq_if_empty:NF \l__witharrows_labels_seq + \seq_if_empty:NF \l__wa_labels_seq { - \bool_if:NTF \c__witharrows_cleveref_loaded_bool - { \__witharrows_error:n { Multiple~labels~with~cleveref } } - { \__witharrows_error:n { Multiple~labels } } + \bool_if:NTF \c__wa_cleveref_loaded_bool + { \__wa_error:n { Multiple~labels~with~cleveref } } + { \__wa_error:n { Multiple~labels } } } - \seq_put_right:Nn \l__witharrows_labels_seq { #1 } - \bool_if:nT \c__witharrows_mathtools_loaded_bool - { - \MH_if_boolean:nT { show_only_refs } - { - \cs_if_exist:cTF { MT_r_#1 } - { \clist_set:Nn \l__witharrows_tags_clist { all } } - { \clist_clear:N \l__witharrows_tags_clist } - } - } - \bool_if:nT \c__witharrows_autonum_loaded_bool + \seq_put_right:Nn \l__wa_labels_seq { #1 } + \bool_if:nT \c__wa_mathtools_loaded_bool + { + \MH_if_boolean:nT { show_only_refs } + { + \cs_if_exist:cTF { MT_r_#1 } + { \clist_set:Nn \l__wa_tags_clist { all } } + { \clist_clear:N \l__wa_tags_clist } + } + } + \bool_if:nT \c__wa_autonum_loaded_bool { \cs_if_exist:cTF { autonum@#1Referenced } - { \clist_set:Nn \l__witharrows_tags_clist { all } } - { \clist_clear:N \l__witharrows_tags_clist } + { \clist_set:Nn \l__wa_tags_clist { all } } + { \clist_clear:N \l__wa_tags_clist } } } } -\cs_new_protected:Nn \__witharrows_tagnextline: +\cs_new_protected:Npn \__wa_tagnextline: { - \__witharrows_if_in_second_col_of_disp:Nn \tagnextline - { \bool_set_true:N \l__witharrows_tag_next_line_bool } + \__wa_if_in_second_col_of_disp:Nn \tagnextline + { \bool_set_true:N \l__wa_tag_next_line_bool } } -\bool_new:N \l__witharrows_qedhere_bool -\cs_new_protected:Nn \__witharrows_qedhere: { \bool_set_true:N \l__witharrows_qedhere_bool } -\cs_new_protected:Nn \__witharrows_qedhere_i: +\cs_new_protected:Npn \__wa_qedhere: { \bool_set_true:N \l__wa_qedhere_bool } +\cs_new_protected:Npn \__wa_qedhere_i: { \group_begin: \cs_set_eq:NN \qed \qedsymbol @@ -858,9 +854,10 @@ \QED@stack \relax \relax \group_end: } +\bool_new:N \l__wa_inlabel_bool \NewDocumentEnvironment { DispWithArrows } { ! O { } } { - \bool_if:nT \c__witharrows_mathtools_loaded_bool + \bool_if:nT \c__wa_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } { @@ -868,48 +865,56 @@ \MH_set_boolean_T:n { show_only_refs } } } - \bool_if:NT \c__witharrows_amsmath_loaded_bool \intertext@ - \bool_set_true:N \l__witharrows_in_DispWithArrows_bool - \__witharrows_pre_environment:n { #1 } + \bool_if:NT \c__wa_typedref_loaded_bool { \str_set:Nn \sr@name { equation } } + \bool_if:NT \c__wa_amsmath_loaded_bool \intertext@ + \bool_set_true:N \l__wa_in_DispWithArrows_bool + \__wa_pre_environment:n { #1 } + \bool_if:NF \l__wa_sbwi_bool + { + \if@inlabel + \bool_set_true:N \l__wa_inlabel_bool + \fi + } + \tl_clear_new:N \l__wa_tag_tl + \bool_set_false:N \l__wa_qedhere_bool + \bool_set_false:N \l__wa_tag_star_bool \if_mode_math: - \__witharrows_error:n { DispWithArrows~in~math~mode } - \fi: - \if_mode_vertical: - \nointerlineskip - \makebox [ .6 \linewidth ] { } + \__wa_error:n { DispWithArrows~in~math~mode } \fi: - $$ - \vcenter \bgroup + \bool_if:NTF \l__wa_inlabel_bool + { $ } % $ + { + \if_mode_vertical: + \nointerlineskip + \hbox_to_wd:nn { .6 \linewidth } { } + \fi: + $$ + } + \bool_if:NTF \l__wa_inlabel_bool \vtop \vcenter \bgroup \spread@equation - \bool_if:NTF \l__witharrows_fleqn_bool + \bool_if:NTF \l__wa_fleqn_bool { \tabskip = \c_zero_skip } { \tabskip = 0 pt plus 1000 pt minus 1000 pt } - \cs_set_eq:NN \__witharrows_old_label \label - \cs_set_eq:NN \notag \__witharrows_notag: - \cs_set_eq:NN \nonumber \__witharrows_notag: - \cs_set_eq:NN \tag \__witharrows_tag - \cs_set_eq:NN \label \__witharrows_label:n - \cs_set_eq:NN \tagnextline \__witharrows_tagnextline: - \halign to \displaywidth + \halign to \bool_if:NTF \l__wa_inlabel_bool \linewidth \displaywidth \bgroup - \int_gincr:N \g__witharrows_line_int - \cs_set_eq:cN \l__witharrows_CommandName_str \__witharrows_Arrow_first_column: - \bool_set_true:N \l__witharrows_in_first_column_bool + \int_gincr:N \g__wa_line_int + \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_first_column: + \bool_set_true:N \l__wa_in_first_column_bool \strut - \bool_if:NT \l__witharrows_fleqn_bool { \skip_horizontal:n \l__witharrows_mathindent_dim } + \bool_if:NT \l__wa_fleqn_bool { \skip_horizontal:n \l__wa_mathindent_dim } \hfil $ - \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle + \bool_if:NT \l__wa_displaystyle_bool \displaystyle { ## } $ \tabskip = \c_zero_skip & - \clist_if_in:NVT \l__witharrows_tags_clist \g__witharrows_line_int - { \clist_set:Nn \l__witharrows_tags_clist { all } } - \bool_if:NT \c__witharrows_amsthm_loaded_bool - { \cs_set_eq:NN \qedhere \__witharrows_qedhere: } + \clist_if_in:NVT \l__wa_tags_clist \g__wa_line_int + { \clist_set:Nn \l__wa_tags_clist { all } } + \bool_if:NT \c__wa_amsthm_loaded_bool + { \cs_set_eq:NN \qedhere \__wa_qedhere: } $ - \bool_if:NT \l__witharrows_displaystyle_bool \displaystyle + \bool_if:NT \l__wa_displaystyle_bool \displaystyle { { } ## } $ \tabskip = 0 pt plus 1000 pt minus 1000 pt @@ -917,12 +922,12 @@ \node [ node~contents = { } , - __witharrows_node_style , - name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - l , + __wa_node_style , + name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - l , alias = { - \str_if_empty:NF \l__witharrows_name_str - { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - l } + \str_if_empty:NF \l__wa_name_str + { \l__wa_name_str - \int_use:N \g__wa_line_int - l } } ] ; @@ -931,386 +936,390 @@ \node [ node~contents = { } , - __witharrows_node_style , - name = wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int - r , + __wa_node_style , + name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - r , alias = { - \str_if_empty:NF \l__witharrows_name_str - { \l__witharrows_name_str - \int_use:N \g__witharrows_line_int - r } + \str_if_empty:NF \l__wa_name_str + { \l__wa_name_str - \int_use:N \g__wa_line_int - r } } ] ; - \bool_if:NT \l__witharrows_show_node_names_bool - { - \hbox_overlap_right:n - { \small wa - \l__witharrows_prefix_str - \int_use:N \g__witharrows_line_int } - } + \bool_if:NT \l__wa_show_node_names_bool + { + \hbox_overlap_right:n + { \small wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int } + } & - ## + $ ## $ \tabskip = \c_zero_skip && - \__witharrows_error:n { Third~column~in~DispWithArrows } - \iffalse ## \fi + \__wa_error:n { Third~column~in~DispWithArrows } + \bool_if:nT \c_false_bool { ## } \cr } { - \clist_if_in:NnT \l__witharrows_tags_clist { last } - { \clist_set:Nn \l__witharrows_tags_clist { all } } + \clist_if_in:NnT \l__wa_tags_clist { last } + { \clist_set:Nn \l__wa_tags_clist { all } } \\ \egroup \egroup - \bool_if:NT \l__witharrows_in_DispWithArrows_bool + \bool_if:NT \l__wa_in_DispWithArrows_bool { - \dim_gzero_new:N \g__witharrows_right_x_dim - \dim_gset_eq:NN \g__witharrows_right_x_dim \c_max_dim - \begin { tikzpicture } [ __witharrows_standard ] - \int_step_variable:nNn \g__witharrows_line_int \l_tmpa_int - { - \cs_if_free:cTF - { pgf@sh@ns@wa - \l__witharrows_prefix_str - \l_tmpa_int - v } - { \__witharrows_error:n { Inexistent~v-node } } - { - \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) - \dim_set:Nn \l_tmpa_dim \pgf@x - \dim_compare:nNnT \l_tmpa_dim < \g__witharrows_right_x_dim - { \dim_gset:Nn \g__witharrows_right_x_dim \l_tmpa_dim } - } - } + \dim_gzero_new:N \g__wa_right_x_dim + \dim_gset_eq:NN \g__wa_right_x_dim \c_max_dim + \begin { tikzpicture } [ __wa_standard ] + \int_step_variable:nNn \g__wa_line_int \l_tmpa_int + { + \cs_if_free:cTF + { pgf@sh@ns@wa - \l__wa_prefix_str - \l_tmpa_int - v } + { \__wa_error:n { Inexistent~v-node } } + { + \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) + \dim_set:Nn \l_tmpa_dim \pgf@x + \dim_compare:nNnT \l_tmpa_dim < \g__wa_right_x_dim + { \dim_gset:Nn \g__wa_right_x_dim \l_tmpa_dim } + } + } \end { tikzpicture } } - \__witharrows_post_environment: - \bool_if:nT \c__witharrows_mathtools_loaded_bool + \__wa_post_environment: + \bool_if:nT \c__wa_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } \MT_showonlyrefs_true: } - $$ - \bool_if:NT \g__witharrows_footnote_bool { \end {savenotes } } + \bool_if:NTF \l__wa_inlabel_bool + { $ % $ + \skip_vertical:N \belowdisplayskip + } + { $$ } + \bool_if:NT \g__wa_footnote_bool { \end {savenotes } } \ignorespacesafterend } -\NewDocumentEnvironment { DispWithArrows* } {} - { - \WithArrowsOptions { notag } - \DispWithArrows - } - { \endDispWithArrows } -\cs_new_protected:Nn \__witharrows_scan_arrows: - { - \group_begin: - \int_compare:nNnT \l__witharrows_pos_arrow_int = 7 +\NewDocumentEnvironment { DispWithArrows* } { } + { + \WithArrowsOptions { notag } + \DispWithArrows + } + \endDispWithArrows +\cs_new_protected:Npn \__wa_scan_arrows: + { + \group_begin: + \int_compare:nNnT \l__wa_pos_arrow_int = 7 { - \__witharrows_scan_arrows_i: - \int_set:Nn \l__witharrows_pos_arrow_int 8 + \__wa_scan_arrows_i: + \int_set:Nn \l__wa_pos_arrow_int 8 } - \__witharrows_scan_arrows_i: - \group_end: - } -\cs_new_protected:Nn \__witharrows_scan_arrows_i: - { - \int_zero_new:N \l__witharrows_first_arrow_of_group_int - \int_zero_new:N \l__witharrows_first_line_of_group_int - \int_zero_new:N \l__witharrows_last_line_of_group_int - \seq_clear_new:N \l__witharrows_first_arrows_of_group_seq - \seq_clear_new:N \l__witharrows_last_arrows_of_group_seq - \bool_set_true:N \l__witharrows_new_group_bool - \int_set:Nn \l__witharrows_arrow_int \c_one_int - \int_until_do:nNnn \l__witharrows_arrow_int > \g__witharrows_arrow_int + \__wa_scan_arrows_i: + \group_end: + } +\cs_new_protected:Npn \__wa_scan_arrows_i: + { + \int_zero_new:N \l__wa_first_arrow_of_group_int + \int_zero_new:N \l__wa_first_line_of_group_int + \int_zero_new:N \l__wa_last_line_of_group_int + \seq_clear_new:N \l__wa_first_arrows_seq + \seq_clear_new:N \l__wa_last_arrows_seq + \bool_set_true:N \l__wa_new_group_bool + \int_set:Nn \l__wa_arrow_int \c_one_int + \int_until_do:nNnn \l__wa_arrow_int > \g__wa_arrow_int { \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { initial } \l_tmpa_tl - \int_set:Nn \l__witharrows_initial_int \l_tmpa_tl + \int_set:Nn \l__wa_initial_int \l_tmpa_tl \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { final } \l_tmpa_tl - \int_set:Nn \l__witharrows_final_int \l_tmpa_tl + \int_set:Nn \l__wa_final_int \l_tmpa_tl \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } - { status } \l__witharrows_status_arrow_str + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } + { status } \l__wa_status_arrow_str \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } - { input-line } \l__witharrows_input_line_str - \int_compare:nNnTF \l__witharrows_final_int > \g__witharrows_line_int - { \__witharrows_error:n { Too~few~lines~for~an~arrow } } - { - \bool_if:nT - { - \int_compare_p:nNn \l__witharrows_arrow_int > 1 - && - ( \int_compare_p:n - { \l__witharrows_initial_int > \l__witharrows_last_line_of_group_int } - && - \int_compare_p:n { \l__witharrows_pos_arrow_int != 7 } - || - \str_if_eq_p:Vn \l__witharrows_status_arrow_str { new-group } - ) - } - { - \int_compare:nNnF \l__witharrows_first_arrow_of_group_int = 0 - { - \__witharrows_draw_arrows:nn - \l__witharrows_first_arrow_of_group_int - { \l__witharrows_arrow_int - 1 } - } - \bool_set_true:N \l__witharrows_new_group_bool - } - \bool_if:nTF \l__witharrows_new_group_bool - { - \bool_set_false:N \l__witharrows_new_group_bool - \int_set_eq:NN \l__witharrows_first_arrow_of_group_int \l__witharrows_arrow_int - \int_set_eq:NN \l__witharrows_first_line_of_group_int \l__witharrows_initial_int - \int_set_eq:NN \l__witharrows_last_line_of_group_int \l__witharrows_final_int - \seq_clear:N \l__witharrows_first_arrows_of_group_seq - \seq_put_left:NV \l__witharrows_first_arrows_of_group_seq - \l__witharrows_arrow_int - \seq_clear:N \l__witharrows_last_arrows_of_group_seq - \seq_put_left:NV \l__witharrows_last_arrows_of_group_seq - \l__witharrows_arrow_int - \int_compare:nT { \l__witharrows_pos_arrow_int != 8 } - { \dim_set:Nn \l__witharrows_x_dim { - \c_max_dim } } - } - { - \bool_if:nF - { \str_if_eq_p:Vn \l__witharrows_status_arrow_str { independent } } - { - \int_compare:nT - { \l__witharrows_initial_int = \l__witharrows_first_line_of_group_int } - { - \seq_put_left:NV \l__witharrows_first_arrows_of_group_seq - \l__witharrows_arrow_int - } - \int_compare:nTF - { \l__witharrows_final_int > \l__witharrows_last_line_of_group_int } - { - \int_set_eq:NN \l__witharrows_last_line_of_group_int - \l__witharrows_final_int - \seq_clear:N \l__witharrows_last_arrows_of_group_seq - \seq_put_left:NV \l__witharrows_last_arrows_of_group_seq - \l__witharrows_arrow_int - } - { - \int_compare:nNnT - \l__witharrows_final_int = \l__witharrows_last_line_of_group_int - { - \seq_put_left:NV \l__witharrows_last_arrows_of_group_seq - \l__witharrows_arrow_int - } - } - } - } - \bool_if:nF - { \str_if_eq_p:Vn \l__witharrows_status_arrow_str { independent } } - { - \int_compare:nT { \l__witharrows_pos_arrow_int != 8 } - { \__witharrows_update_x:nn \l__witharrows_initial_int \l__witharrows_final_int } - } - } - \int_incr:N \l__witharrows_arrow_int + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } + { input-line } \l__wa_input_line_str + \int_compare:nNnTF \l__wa_final_int > \g__wa_line_int + { + \int_compare:nNnF \l__wa_pos_arrow_int = 8 + { \__wa_error:n { Too~few~lines~for~an~arrow } } + } + \__wa_code_for_possible_arrow: + \int_incr:N \l__wa_arrow_int + } + \bool_if:nT + { + \int_compare_p:n { \l__wa_pos_arrow_int != 7 } + && + \int_compare_p:nNn \l__wa_first_arrow_of_group_int > 0 + } + { \__wa_draw_arrows:nn \l__wa_first_arrow_of_group_int \g__wa_arrow_int } + } +\cs_new_protected:Npn \__wa_code_for_possible_arrow: + { + \bool_if:nT + { + \int_compare_p:nNn \l__wa_arrow_int > \c_one_int + && + ( \int_compare_p:n { \l__wa_initial_int > \l__wa_last_line_of_group_int } + && + \int_compare_p:n { \l__wa_pos_arrow_int != 7 } + || + \str_if_eq_p:Vn \l__wa_status_arrow_str { new-group } + ) + } + { + \int_compare:nNnF \l__wa_first_arrow_of_group_int = \c_zero_int + { + \__wa_draw_arrows:nn + \l__wa_first_arrow_of_group_int + { \l__wa_arrow_int - 1 } + } + \bool_set_true:N \l__wa_new_group_bool + } + \bool_if:nTF \l__wa_new_group_bool + { + \bool_set_false:N \l__wa_new_group_bool + \int_set_eq:NN \l__wa_first_arrow_of_group_int \l__wa_arrow_int + \int_set_eq:NN \l__wa_first_line_of_group_int \l__wa_initial_int + \int_set_eq:NN \l__wa_last_line_of_group_int \l__wa_final_int + \seq_clear:N \l__wa_first_arrows_seq + \seq_put_left:NV \l__wa_first_arrows_seq \l__wa_arrow_int + \seq_clear:N \l__wa_last_arrows_seq + \seq_put_left:NV \l__wa_last_arrows_seq \l__wa_arrow_int + \int_compare:nT { \l__wa_pos_arrow_int != 8 } + { \dim_set:Nn \l__wa_x_dim { - \c_max_dim } } + } + { + \bool_if:nF + { \str_if_eq_p:Vn \l__wa_status_arrow_str { independent } } + { + \int_compare:nT + { \l__wa_initial_int = \l__wa_first_line_of_group_int } + { \seq_put_left:NV \l__wa_first_arrows_seq \l__wa_arrow_int } + \int_compare:nNnTF \l__wa_final_int > \l__wa_last_line_of_group_int + { + \int_set_eq:NN \l__wa_last_line_of_group_int \l__wa_final_int + \seq_clear:N \l__wa_last_arrows_seq + \seq_put_left:NV \l__wa_last_arrows_seq \l__wa_arrow_int + } + { + \int_compare:nNnT \l__wa_final_int = \l__wa_last_line_of_group_int + { \seq_put_left:NV \l__wa_last_arrows_seq \l__wa_arrow_int } + } + } + } + \bool_if:nF { \str_if_eq_p:Vn \l__wa_status_arrow_str { independent } } + { + \int_compare:nT { \l__wa_pos_arrow_int != 8 } + { \__wa_update_x:nn \l__wa_initial_int \l__wa_final_int } } - \int_compare:nT { \l__witharrows_pos_arrow_int != 7 } - { \__witharrows_draw_arrows:nn \l__witharrows_first_arrow_of_group_int \g__witharrows_arrow_int } } \cs_generate_variant:Nn \keys_set:nn { n o } -\cs_new_protected:Nn \__witharrows_keys_set: +\cs_new_protected:Npn \__wa_keys_set: { \keys_set_known:no { WithArrows / Arrow / SecondPass } } -\cs_new_protected:Nn \__witharrows_draw_arrows:nn +\cs_new_protected:Npn \__wa_draw_arrows:nn #1 #2 { \group_begin: - \int_zero_new:N \l__witharrows_first_arrow_int - \int_set:Nn \l__witharrows_first_arrow_int { #1 } - \int_zero_new:N \l__witharrows_last_arrow_int - \int_set:Nn \l__witharrows_last_arrow_int { #2 } - \int_set:Nn \l__witharrows_arrow_int \l__witharrows_first_arrow_int - \int_until_do:nNnn \l__witharrows_arrow_int > \l__witharrows_last_arrow_int + \int_zero_new:N \l__wa_first_arrow_int + \int_set:Nn \l__wa_first_arrow_int { #1 } + \int_zero_new:N \l__wa_last_arrow_int + \int_set:Nn \l__wa_last_arrow_int { #2 } + \int_set:Nn \l__wa_arrow_int \l__wa_first_arrow_int + \int_until_do:nNnn \l__wa_arrow_int > \l__wa_last_arrow_int { \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { initial } \l_tmpa_tl - \int_set:Nn \l__witharrows_initial_int \l_tmpa_tl + \int_set:Nn \l__wa_initial_int \l_tmpa_tl \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { final } \l_tmpa_tl - \int_set:Nn \l__witharrows_final_int \l_tmpa_tl - \int_compare:nT { \l__witharrows_final_int <= \g__witharrows_line_int } \__witharrows_draw_arrows_i: - \int_incr:N \l__witharrows_arrow_int + \int_set:Nn \l__wa_final_int \l_tmpa_tl + \int_compare:nT { \l__wa_final_int <= \g__wa_line_int } \__wa_draw_arrows_i: + \int_incr:N \l__wa_arrow_int } \group_end: } -\cs_new_protected:Nn \__witharrows_draw_arrows_i: +\cs_new_protected:Npn \__wa_draw_arrows_i: { \group_begin: \prop_get:cnN - { g__witharrows_arrow _\l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _\l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { options } \l_tmpa_tl - \str_clear_new:N \l__witharrows_previous_key_str + \str_clear_new:N \l__wa_previous_key_str \exp_args:NNo \exp_args:No - \__witharrows_keys_set: { \l_tmpa_tl , tikz = { xshift = \l__witharrows_xoffset_dim } } - \bool_set_false:N \l__witharrows_initial_r_bool - \bool_set_false:N \l__witharrows_final_r_bool - \int_case:nn \l__witharrows_pos_arrow_int + \__wa_keys_set: { \l_tmpa_tl , tikz = { xshift = \l__wa_xoffset_dim } } + \bool_set_false:N \l__wa_initial_r_bool + \bool_set_false:N \l__wa_final_r_bool + \int_case:nn \l__wa_pos_arrow_int { - 0 { \bool_set_true:N \l__witharrows_final_r_bool } - 2 { \bool_set_true:N \l__witharrows_initial_r_bool } - 3 { - \bool_set_true:N \l__witharrows_initial_r_bool - \bool_set_true:N \l__witharrows_final_r_bool + 0 { \bool_set_true:N \l__wa_final_r_bool } + 2 { \bool_set_true:N \l__wa_initial_r_bool } + 3 + { + \bool_set_true:N \l__wa_initial_r_bool + \bool_set_true:N \l__wa_final_r_bool } } - \int_compare:nNnT \l__witharrows_pos_arrow_int = 5 - { - \dim_set:Nn \l__witharrows_x_dim { - \c_max_dim } - \__witharrows_update_x:nn \l__witharrows_initial_int \l__witharrows_final_int - } - \tl_set:Nx \l__witharrows_initial_tl - { \int_use:N \l__witharrows_initial_int - \bool_if:NTF \l__witharrows_initial_r_bool rl .south } - \tl_set:Nx \l__witharrows_final_tl - { \int_use:N \l__witharrows_final_int - \bool_if:NTF \l__witharrows_final_r_bool rl .north } + \int_compare:nNnT \l__wa_pos_arrow_int = 5 + { + \dim_set:Nn \l__wa_x_dim { - \c_max_dim } + \__wa_update_x:nn \l__wa_initial_int \l__wa_final_int + } + \tl_set:Nx \l__wa_initial_tl + { + \int_use:N \l__wa_initial_int - \bool_if:NTF \l__wa_initial_r_bool rl + .south + } + \tl_set:Nx \l__wa_final_tl + { \int_use:N \l__wa_final_int - \bool_if:NTF \l__wa_final_r_bool rl .north } \prop_get:cnN - { g__witharrows_arrow _ \l__witharrows_prefix_str _ \int_use:N \l__witharrows_arrow_int _ prop } + { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \l__wa_arrow_int _ prop } { label } \l_tmpa_tl - \seq_if_in:NxTF \l__witharrows_first_arrows_of_group_seq - { \int_use:N \l__witharrows_arrow_int } - { \bool_set_true:N \l_tmpa_bool } - { \bool_set_false:N \l_tmpa_bool } - \seq_if_in:NxTF \l__witharrows_last_arrows_of_group_seq - { \int_use:N \l__witharrows_arrow_int } - { \bool_set_true:N \l_tmpb_bool } - { \bool_set_false:N \l_tmpb_bool } - \int_compare:nNnT \l__witharrows_pos_arrow_int = 5 - { - \bool_set_true:N \l_tmpa_bool - \bool_set_true:N \l_tmpb_bool - } - \begin { tikzpicture } [ __witharrows_standard ] - \tikz@scan@one@point \pgfutil@firstofone ( \l__witharrows_initial_tl ) - \tl_gset:Nx \g_tmpa_tl - { - \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l__witharrows_x_dim } , - \bool_if:NTF \l_tmpa_bool - { \dim_eval:n { \pgf@y + \l__witharrows_start_adjust_dim } } - { \dim_use:N \pgf@y } - } - \tikz@scan@one@point \pgfutil@firstofone ( \l__witharrows_final_tl ) - \tl_gset:Nx \g_tmpb_tl - { - \int_compare:nNnTF \l__witharrows_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l__witharrows_x_dim } , - \bool_if:NTF \l_tmpb_bool - { \dim_eval:n { \pgf@y - \l__witharrows_end_adjust_dim } } - { \dim_use:N \pgf@y } - } + \seq_if_in:NxTF \l__wa_first_arrows_seq + { \int_use:N \l__wa_arrow_int } + { \bool_set_true:N \l_tmpa_bool } + { \bool_set_false:N \l_tmpa_bool } + \seq_if_in:NxTF \l__wa_last_arrows_seq + { \int_use:N \l__wa_arrow_int } + { \bool_set_true:N \l_tmpb_bool } + { \bool_set_false:N \l_tmpb_bool } + \int_compare:nNnT \l__wa_pos_arrow_int = 5 + { + \bool_set_true:N \l_tmpa_bool + \bool_set_true:N \l_tmpb_bool + } + \begin { tikzpicture } [ __wa_standard ] + \tikz@scan@one@point \pgfutil@firstofone ( \l__wa_initial_tl ) + \tl_gset:Nx \g_tmpa_tl + { + \int_compare:nNnTF \l__wa_pos_arrow_int < 5 + { \dim_use:N \pgf@x } + { \dim_use:N \l__wa_x_dim } , + \bool_if:NTF \l_tmpa_bool + { \dim_eval:n { \pgf@y + \l__wa_start_adjust_dim } } + { \dim_use:N \pgf@y } + } + \tikz@scan@one@point \pgfutil@firstofone ( \l__wa_final_tl ) + \tl_gset:Nx \g_tmpb_tl + { + \int_compare:nNnTF \l__wa_pos_arrow_int < 5 + { \dim_use:N \pgf@x } + { \dim_use:N \l__wa_x_dim } , + \bool_if:NTF \l_tmpb_bool + { \dim_eval:n { \pgf@y - \l__wa_end_adjust_dim } } + { \dim_use:N \pgf@y } + } \end { tikzpicture } - \__witharrows_draw_arrow:nno \g_tmpa_tl \g_tmpb_tl \l_tmpa_tl + \__wa_draw_arrow:nno \g_tmpa_tl \g_tmpb_tl \l_tmpa_tl \group_end: } -\cs_new_protected:Nn \__witharrows_def_function_tmpa:n +\cs_new_protected:Npn \__wa_def_function_tmpa:n #1 { - \cs_set:Npn \__witharrows_tmpa:nnn ##1 ##2 ##3 + \cs_set:Npn \__wa_tmpa:nnn ##1 ##2 ##3 { \begin{tikzpicture} [ - __witharrows_standard , + __wa_standard , every~path / .style = WithArrows / arrow ] #1 \end{tikzpicture} } } -\cs_new_protected:Nn \__witharrows_draw_arrow:nnn +\cs_new_protected:Npn \__wa_draw_arrow:nnn #1 #2 #3 { - \bool_if:nT { \l__witharrows_wrap_lines_bool && \l__witharrows_in_DispWithArrows_bool } - { \tl_set_eq:NN \l__witharrows_tikz_code_tl \c__witharrows_tikz_code_wrap_lines_tl } - \exp_args:NV \__witharrows_def_function_tmpa:n \l__witharrows_tikz_code_tl - \__witharrows_tmpa:nnn { #1 } { #2 } { #3 } + \bool_if:nT { \l__wa_wrap_lines_bool && \l__wa_in_DispWithArrows_bool } + { \tl_set_eq:NN \l__wa_tikz_code_tl \c__wa_tikz_code_wrap_lines_tl } + \exp_args:NV \__wa_def_function_tmpa:n \l__wa_tikz_code_tl + \__wa_tmpa:nnn { #1 } { #2 } { #3 } } -\cs_generate_variant:Nn \__witharrows_draw_arrow:nnn { n n o } -\tl_const:Nn \c__witharrows_tikz_code_wrap_lines_tl +\cs_generate_variant:Nn \__wa_draw_arrow:nnn { n n o } +\tl_const:Nn \c__wa_tikz_code_wrap_lines_tl { - \draw ( #1 ) to node ( __witharrows_label ) { } ( #2 ) ; - \tikz@parse@node \pgfutil@firstofone ( __witharrows_label.west ) - \dim_set:Nn \l_tmpa_dim { \g__witharrows_right_x_dim - \pgf@x - 0.3333 em } + \draw ( #1 ) to node ( __wa_label ) { } ( #2 ) ; + \tikz@parse@node \pgfutil@firstofone ( __wa_label.west ) + \dim_set:Nn \l_tmpa_dim { \g__wa_right_x_dim - \pgf@x - 0.3333 em } \path \pgfextra { \tl_gset:Nx \g_tmpa_tl \tikz@text@width } ; \tl_if_empty:NF \g_tmpa_tl - { - \dim_set:Nn \l_tmpb_dim \g_tmpa_tl - \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim - { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } - } + { + \dim_set:Nn \l_tmpb_dim \g_tmpa_tl + \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim + { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } + } \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim { - \path ( __witharrows_label.west ) + \path ( __wa_label.west ) node [ anchor = west , text~width = \dim_use:N \l_tmpa_dim ] { #3 } ; } } -\cs_new_protected:Nn \__witharrows_update_x:nn +\cs_new_protected:Npn \__wa_update_x:nn #1 #2 { \int_step_inline:nnn { #1 } { #2 } - { - \begin { tikzpicture } [ __witharrows_standard ] - \tikz@scan@one@point \pgfutil@firstofone ( ##1 - l ) - \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \l__witharrows_x_dim \pgf@x } - \end { tikzpicture } - \dim_set_eq:NN \l__witharrows_x_dim \g_tmpa_dim - } - } -\cs_new:Npn \WithArrowsLastEnv { \int_use:N \g__witharrows_last_env_int } + { + \begin { tikzpicture } [ __wa_standard ] + \tikz@scan@one@point \pgfutil@firstofone ( ##1 - l ) + \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \l__wa_x_dim \pgf@x } + \end { tikzpicture } + \dim_set_eq:NN \l__wa_x_dim \g_tmpa_dim + } + } +\cs_new:Npn \WithArrowsLastEnv { \int_use:N \g__wa_last_env_int } \keys_define:nn { WithArrows / Arrow / CodeAfter } { tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , tikz .value_required:n = true , rr .value_forbidden:n = true , - rr .code:n = \__witharrows_fix_pos_option:n 0 , + rr .code:n = \__wa_fix_pos_option:n 0 , ll .value_forbidden:n = true, - ll .code:n = \__witharrows_fix_pos_option:n 1 , + ll .code:n = \__wa_fix_pos_option:n 1 , rl .value_forbidden:n = true , - rl .code:n = \__witharrows_fix_pos_option:n 2 , + rl .code:n = \__wa_fix_pos_option:n 2 , lr .value_forbidden:n = true , - lr .code:n = \__witharrows_fix_pos_option:n 3 , + lr .code:n = \__wa_fix_pos_option:n 3 , v .value_forbidden:n = true , - v .code:n = \__witharrows_fix_pos_option:n 4 , - TikzCode .tl_set:N = \l__witharrows_tikz_code_tl , + v .code:n = \__wa_fix_pos_option:n 4 , + TikzCode .tl_set:N = \l__wa_tikz_code_tl , TikzCode .value_required:n = true , - xoffset .dim_set:N = \l__witharrows_xoffset_dim , + xoffset .dim_set:N = \l__wa_xoffset_dim , xoffset .value_required:n = true , unknown .code:n = - \__witharrows_sort_seq:N \l__witharrows_options_Arrow_CodeAfter_seq - \__witharrows_error:n { Unknown~option~Arrow~in~CodeAfter } - } -\seq_set_from_clist:Nn \l__witharrows_options_Arrow_CodeAfter_seq - { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } -\NewDocumentCommand \__witharrows_Arrow_code_after { O { } m m m ! O { } } + \__wa_sort_seq:N \l__wa_options_Arrow_CodeAfter_seq + \__wa_error:n { Unknown~option~Arrow~in~CodeAfter } + } +\seq_set_from_clist:Nn \l__wa_options_Arrow_CodeAfter_seq + { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } +\NewDocumentCommand \__wa_Arrow_code_after { O { } m m m ! O { } } { - \int_set:Nn \l__witharrows_pos_arrow_int 1 - \str_clear_new:N \l__witharrows_previous_key_str + \int_set:Nn \l__wa_pos_arrow_int 1 + \str_clear_new:N \l__wa_previous_key_str \group_begin: \keys_set:nn { WithArrows / Arrow / CodeAfter } - { #1, #5, tikz = { xshift = \l__witharrows_xoffset_dim } } - \bool_set_false:N \l__witharrows_initial_r_bool - \bool_set_false:N \l__witharrows_final_r_bool - \int_case:nn \l__witharrows_pos_arrow_int + { #1, #5, tikz = { xshift = \l__wa_xoffset_dim } } + \bool_set_false:N \l__wa_initial_r_bool + \bool_set_false:N \l__wa_final_r_bool + \int_case:nn \l__wa_pos_arrow_int { 0 { - \bool_set_true:N \l__witharrows_initial_r_bool - \bool_set_true:N \l__witharrows_final_r_bool + \bool_set_true:N \l__wa_initial_r_bool + \bool_set_true:N \l__wa_final_r_bool } - 2 { \bool_set_true:N \l__witharrows_initial_r_bool } - 3 { \bool_set_true:N \l__witharrows_final_r_bool } + 2 { \bool_set_true:N \l__wa_initial_r_bool } + 3 { \bool_set_true:N \l__wa_final_r_bool } } \tl_if_eq:nnTF { #2 } { #3 } - { \__witharrows_error:nn { Both~lines~are~equal } { #2 } } + { \__wa_error:nn { Both~lines~are~equal } { #2 } } { - \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - #2 - l } - { \__witharrows_error:nx { Wrong~line~in~Arrow } { #2 } } + \cs_if_free:cTF { pgf@sh@ns@wa - \l__wa_prefix_str - #2 - l } + { \__wa_error:nx { Wrong~line~in~Arrow } { #2 } } { - \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - #3 - l } - { \__witharrows_error:nx { Wrong~line~in~Arrow } { #3 } } + \cs_if_free:cTF { pgf@sh@ns@wa - \l__wa_prefix_str - #3 - l } + { \__wa_error:nx { Wrong~line~in~Arrow } { #3 } } { - \int_compare:nNnTF \l__witharrows_pos_arrow_int = 4 + \int_compare:nNnTF \l__wa_pos_arrow_int = 4 { - \begin { tikzpicture } [ __witharrows_standard ] + \begin { tikzpicture } [ __wa_standard ] \tikz@scan@one@point \pgfutil@firstofone (#2-l.south) \dim_set_eq:NN \l_tmpa_dim \pgf@x \dim_set_eq:NN \l_tmpb_dim \pgf@y @@ -1324,363 +1333,341 @@ \end { tikzpicture } } { - \begin { tikzpicture } [ __witharrows_standard ] + \begin { tikzpicture } [ __wa_standard ] \tikz@scan@one@point \pgfutil@firstofone - ( #2-\bool_if:NTF\l__witharrows_initial_r_bool rl .south ) + ( #2-\bool_if:NTF\l__wa_initial_r_bool rl .south ) \tl_gset:Nx \g_tmpa_tl { \dim_use:N \pgf@x , \dim_use:N \pgf@y } \tikz@scan@one@point \pgfutil@firstofone - ( #3-\bool_if:NTF\l__witharrows_final_r_bool rl .north ) + ( #3-\bool_if:NTF\l__wa_final_r_bool rl .north ) \tl_gset:Nx \g_tmpb_tl { \dim_use:N \pgf@x , \dim_use:N \pgf@y } \end { tikzpicture } } - \__witharrows_draw_arrow:nnn \g_tmpa_tl \g_tmpb_tl { #4 } + \__wa_draw_arrow:nnn \g_tmpa_tl \g_tmpb_tl { #4 } } } } \group_end: } -\cs_new_protected:Nn \__witharrows_MultiArrow:nn +\cs_new_protected:Npn \__wa_MultiArrow:nn #1 #2 { \foreach \x in { #1 } { - \cs_if_free:cTF { pgf@sh@ns@wa - \l__witharrows_prefix_str - \x - l } - { \__witharrows_error:nx { Wrong~line~specification~in~MultiArrow } \x } + \cs_if_free:cTF { pgf@sh@ns@wa - \l__wa_prefix_str - \x - l } + { \__wa_error:nx { Wrong~line~specification~in~MultiArrow } \x } { \clist_gput_right:Nx \g_tmpa_clist \x } } \int_compare:nTF { \clist_count:N \g_tmpa_clist < 2 } - { \__witharrows_error:n { Too~small~specification~for~MultiArrow } } - { - \clist_sort:Nn \g_tmpa_clist - { - \int_compare:nTF { ##1 > ##2 } - \sort_return_swapped: - \sort_return_same: - } - \clist_pop:NN \g_tmpa_clist \l_tmpa_tl - \clist_reverse:N \g_tmpa_clist - \clist_pop:NN \g_tmpa_clist \l_tmpb_tl - \exp_args:NV \__witharrows_MultiArrow_i:n \g_tmpa_clist - \begin { tikzpicture } - [ - __witharrows_standard , - every~path /.style = { WithArrows / arrow } - ] - \draw [<->] ([xshift = \l__witharrows_xoffset_dim]\l_tmpa_tl-r.south) - -- ++(5mm,0) - -- node (__witharrows_label) {} - ([xshift = \l__witharrows_xoffset_dim+5mm]\l_tmpb_tl-r.south) - -- ([xshift = \l__witharrows_xoffset_dim]\l_tmpb_tl-r.south) ; - \tikz@parse@node \pgfutil@firstofone (__witharrows_label.west) - \dim_set:Nn \l_tmpa_dim { 20 cm } - \path \pgfextra { \tl_gset:Nx \g_tmpa_tl \tikz@text@width } ; - \tl_if_empty:NF \g_tmpa_tl { \dim_set:Nn \l_tmpa_dim \g_tmpa_tl } - \bool_if:nT { \l__witharrows_wrap_lines_bool && \l__witharrows_in_DispWithArrows_bool } - { - \dim_set:Nn \l_tmpb_dim - { \g__witharrows_right_x_dim - \pgf@x - 0.3333 em } - \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim - { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } - } - \path (__witharrows_label.west) - node [ anchor = west, text~width = \dim_use:N \l_tmpa_dim ] { #2 } ; - \end{tikzpicture} + { \__wa_error:n { Too~small~specification~for~MultiArrow } } + { + \clist_sort:Nn \g_tmpa_clist + { + \int_compare:nTF { ##1 > ##2 } + \sort_return_swapped: + \sort_return_same: + } + \clist_pop:NN \g_tmpa_clist \l_tmpa_tl + \clist_reverse:N \g_tmpa_clist + \clist_pop:NN \g_tmpa_clist \l_tmpb_tl + \exp_args:NV \__wa_MultiArrow_i:n \g_tmpa_clist + \begin { tikzpicture } + [ + __wa_standard , + every~path / .style = { WithArrows / arrow } + ] + \draw [<->] ([xshift = \l__wa_xoffset_dim]\l_tmpa_tl-r.south) + -- ++(5mm,0) + -- node (__wa_label) {} + ([xshift = \l__wa_xoffset_dim+5mm]\l_tmpb_tl-r.south) + -- ([xshift = \l__wa_xoffset_dim]\l_tmpb_tl-r.south) ; + \tikz@parse@node \pgfutil@firstofone (__wa_label.west) + \dim_set:Nn \l_tmpa_dim { 20 cm } + \path \pgfextra { \tl_gset:Nx \g_tmpa_tl \tikz@text@width } ; + \tl_if_empty:NF \g_tmpa_tl { \dim_set:Nn \l_tmpa_dim \g_tmpa_tl } + \bool_if:nT { \l__wa_wrap_lines_bool && \l__wa_in_DispWithArrows_bool } + { + \dim_set:Nn \l_tmpb_dim + { \g__wa_right_x_dim - \pgf@x - 0.3333 em } + \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim + { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } + } + \path (__wa_label.west) + node [ anchor = west, text~width = \dim_use:N \l_tmpa_dim ] { #2 } ; + \end{tikzpicture} } - } -\cs_new_protected:Nn \__witharrows_MultiArrow_i:n + } +\cs_new_protected:Npn \__wa_MultiArrow_i:n #1 { \begin {tikzpicture } [ - __witharrows_standard , + __wa_standard , every~path / .style = { WithArrows / arrow } ] \foreach \k in { #1 } { \draw [ <- ] - ( [xshift = \l__witharrows_xoffset_dim]\k-r.south ) -- ++(5mm,0) ; + ( [xshift = \l__wa_xoffset_dim]\k-r.south ) -- ++(5mm,0) ; } ; \end { tikzpicture } } -\str_const:Nn \c__witharrows_option_ignored_str +\str_const:Nn \c__wa_option_ignored_str { If~you~go~on,~this~option~will~be~ignored. } -\__witharrows_msg_new:nn { Value~for~a~key } - { - The~key~'\l_keys_key_tl'~should~be~used~without~value. \\ - However,~you~can~go~on~for~this~time. - } -\__witharrows_msg_new:nnn { Unknown~option~in~Arrow } +\__wa_msg_new:nn { Value~for~a~key } + { + The~key~'\l_keys_key_tl'~should~be~used~without~value. \\ + However,~you~can~go~on~for~this~time. + } +\__wa_msg_new:nnn { Unknown~option~in~Arrow } { The~option~'\l_keys_key_tl'~ - is~unknown~for~the~command~\l__witharrows_string_Arrow_for_msg_str\ - in~the~row~\int_use:N \g__witharrows_line_int\ - of~your~environment~\{\l__witharrows_type_env_str\}. \\ - \c__witharrows_option_ignored_str \\ + is~unknown~for~the~command~\l__wa_string_Arrow_for_msg_str\ + in~the~row~\int_use:N \g__wa_line_int\ + of~your~environment~\{\l__wa_type_env_str\}. \\ + \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__witharrows_options_Arrow_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_Arrow_seq {~and~} {,~} {~and~}. } -\__witharrows_msg_new:nnn { Unknown~option~WithArrows } +\__wa_msg_new:nnn { Unknown~option~WithArrows } { - The~option~'\l_keys_key_tl'~is~unknown~in~\{\l__witharrows_type_env_str\}. \\ - \c__witharrows_option_ignored_str \\ + The~option~'\l_keys_key_tl'~is~unknown~in~\{\l__wa_type_env_str\}. \\ + \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__witharrows_options_WithArrows_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_WithArrows_seq {~and~} {,~} {~and~}. } -\__witharrows_msg_new:nnn { Unknown~option~DispWithArrows } +\__wa_msg_new:nnn { Unknown~option~DispWithArrows } { - The~option~'\l_keys_key_tl'~is~unknown~in~\{\l__witharrows_type_env_str\}. \\ - \c__witharrows_option_ignored_str \\ + The~option~'\l_keys_key_tl'~is~unknown~in~\{\l__wa_type_env_str\}. \\ + \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__witharrows_options_DispWithArrows_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_DispWithArrows_seq {~and~} {,~} {~and~}. } -\__witharrows_msg_new:nnn { Unknown~option~WithArrowsOptions } +\__wa_msg_new:nnn { Unknown~option~WithArrowsOptions } { The~option~'\l_keys_key_tl'~is~unknown~in~ \token_to_str:N \WithArrowsOptions. \\ - \c__witharrows_option_ignored_str \\ + \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__witharrows_options_WithArrowsOptions_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_WithArrowsOptions_seq {~and~} {,~} {~and~}. } -\__witharrows_msg_new:nnn { Unknown~option~Arrow~in~CodeAfter } +\__wa_msg_new:nnn { Unknown~option~Arrow~in~CodeAfter } { The~option~'\l_keys_key_tl'~is~unknown~in~ \token_to_str:N \Arrow\ in~\token_to_str:N \CodeAfter. \\ - \c__witharrows_option_ignored_str \\ + \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__witharrows_options_Arrow_CodeAfter_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_Arrow_CodeAfter_seq {~and~} {,~} {~and~}. } -\__witharrows_msg_new:nn { Third~column~in~WithArrows } - { - By~default,~an~environment~\{\l__witharrows_type_env_str\}~can~only~have~ - two~columns.~Maybe~you~have~forgotten~a~ - \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ - two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ - level~or~for~an~environment. \\ - However,~you~can~go~one~for~this~time. - } -\__witharrows_msg_new:nn { Third~column~in~DispWithArrows } +\__wa_msg_new:nn { Third~column~in~WithArrows } { - An~environment~\{\l__witharrows_type_env_str\}~can~only~have~two~columns.~ + By~default,~an~environment~\{\l__wa_type_env_str\}~can~only~have~ + two~columns.~Maybe~you~have~forgotten~a~ + \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ + two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ + level~or~for~an~environment. \\ + However,~you~can~go~one~for~this~time. + } +\__wa_msg_new:nn { Third~column~in~DispWithArrows } + { + An~environment~\{\l__wa_type_env_str\}~can~only~have~two~columns.~ Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str\ - at~the~end~of~row~\int_use:N \g__witharrows_line_int. \\ + at~the~end~of~row~\int_use:N \g__wa_line_int. \\ If~you~go~on,~you~may~have~other~errors. } -\__witharrows_msg_new:nn { Negative~jump } - { - You~can't~use~a~negative~value~for~the~option~'jump'~of~command~ - \l__witharrows_string_Arrow_for_msg_str\ - in~the~row~\int_use:N \g__witharrows_line_int\ - of~your~environment~\{\l__witharrows_type_env_str\}.~ - You~can~create~an~arrow~going~backwards~with~the~option~'<-'~of~Tikz. \\ - \c__witharrows_option_ignored_str - } -\__witharrows_msg_new:nn { new-group~without~groups } +\__wa_msg_new:nn { Negative~jump } + { + You~can't~use~a~negative~value~for~the~option~'jump'~of~command~ + \l__wa_string_Arrow_for_msg_str\ + in~the~row~\int_use:N \g__wa_line_int\ + of~your~environment~\{\l__wa_type_env_str\}.~ + You~can~create~an~arrow~going~backwards~with~the~option~'<-'~of~Tikz. \\ + \c__wa_option_ignored_str + } +\__wa_msg_new:nn { new-group~without~groups } { You~can't~use~the~option~'new-group'~for~the~command~ - \l__witharrows_string_Arrow_for_msg_str\ + \l__wa_string_Arrow_for_msg_str\ because~you~are~not~in~'groups'~mode.~Try~to~use~the~option~ - 'groups'~in~your~environment~\{\l__witharrows_type_env_str\}. \\ - \c__witharrows_option_ignored_str - } -\__witharrows_msg_new:nn - { Too~few~lines~for~an~arrow } - { Line~\l__witharrows_input_line_str\ - :~an~arrow~specified~in~the~row~\int_use:N \l__witharrows_initial_int\ - of~your~environment~\{\l__witharrows_type_env_str\}~can't~be~drawn~ - because~it~arrives~after~the~last~row~of~the~environment. \\ - If~you~go~on,~this~arrow~will~be~ignored. - } -\__witharrows_msg_new:nn { WithArrows~outside~math~mode } - { - The~environment~\{\l__witharrows_type_env_str\}~should~be~used~only~in~math~mode. \\ - Nevertheless,~you~can~go~on. - } -\__witharrows_msg_new:nn { DispWithArrows~in~math~mode } + 'groups'~in~your~environment~\{\l__wa_type_env_str\}. \\ + \c__wa_option_ignored_str + } +\__wa_msg_new:nn + { Too~few~lines~for~an~arrow } + { Line~\l__wa_input_line_str\ + :~an~arrow~specified~in~the~row~\int_use:N \l__wa_initial_int\ + of~your~environment~\{\l__wa_type_env_str\}~can't~be~drawn~ + because~it~arrives~after~the~last~row~of~the~environment. \\ + If~you~go~on,~this~arrow~will~be~ignored. + } +\__wa_msg_new:nn { WithArrows~outside~math~mode } + { + The~environment~\{\l__wa_type_env_str\}~should~be~used~only~in~math~mode~ + like~the~environment~\{aligned\}~of~amsmath. \\ + Nevertheless,~you~can~go~on. + } +\__wa_msg_new:nn { DispWithArrows~in~math~mode } { - The~environment~\{\l__witharrows_type_env_str\}~should~be~used~only~ - outside~math~mode. \\ + The~environment~\{\l__wa_type_env_str\}~should~be~used~only~outside~math~ + mode~like~the~environment~\{align\}~of~amsmath. \\ If~you~go~on,~you~will~have~other~errors. } -\__witharrows_msg_new:nn { Incompatible~options~in~Arrow } +\__wa_msg_new:nn { Incompatible~options~in~Arrow } { You~try~to~use~the~option~'\l_keys_key_tl'~but~ this~option~is~incompatible~or~redundant~with~the~option~ - '\l__witharrows_previous_key_str'~set~in~the~same~command~ - \l__witharrows_string_Arrow_for_msg_str. \\ - \c__witharrows_option_ignored_str + '\l__wa_previous_key_str'~set~in~the~same~command~ + \l__wa_string_Arrow_for_msg_str. \\ + \c__wa_option_ignored_str } -\__witharrows_msg_new:nn { Incompatible~options } +\__wa_msg_new:nn { Incompatible~options } { You~try~to~use~the~option~'\l_keys_key_tl'~but~ this~option~is~incompatible~or~redundant~with~the~option~ - '\l__witharrows_previous_key_str'~set~in~the~same~command~ - \bool_if:NT \l__witharrows_in_CodeAfter_bool + '\l__wa_previous_key_str'~set~in~the~same~command~ + \bool_if:NT \l__wa_in_CodeAfter_bool { - \l__witharrows_string_Arrow_for_msg_str\ - in~the~CodeAfter~of~your~environment~\{\l__witharrows_type_env_str\} + \l__wa_string_Arrow_for_msg_str\ + in~the~CodeAfter~of~your~environment~\{\l__wa_type_env_str\} }. \\ - \c__witharrows_option_ignored_str + \c__wa_option_ignored_str } -\__witharrows_msg_new:nn { Arrow~in~first~column } +\__wa_msg_new:nn { Arrow~in~first~column } { - You~should~not~use~the~command~\l__witharrows_string_Arrow_for_msg_str\ - in~the~first~column~of~your~environment~\{\l__witharrows_type_env_str\}~ + You~should~not~use~the~command~\l__wa_string_Arrow_for_msg_str\ + in~the~first~column~of~your~environment~\{\l__wa_type_env_str\}~ but~only~in~the~second~column. \\ However~you~can~go~on~for~this~time. } -\__witharrows_msg_new:nn { Wrong~line~in~Arrow } +\__wa_msg_new:nn { Wrong~line~in~Arrow } { The~specification~of~line~'#1'~you~use~in~the~command~ - \l__witharrows_string_Arrow_for_msg_str\ - in~the~'CodeAfter'~of~\{\l__witharrows_type_env_str\}~doesn't~exist. \\ + \l__wa_string_Arrow_for_msg_str\ + in~the~'CodeAfter'~of~\{\l__wa_type_env_str\}~doesn't~exist. \\ If~you~go~on,~this~command~will~be~ignored. } -\__witharrows_msg_new:nn { Both~lines~are~equal } +\__wa_msg_new:nn { Both~lines~are~equal } { - In~the~'CodeAfter'~of~\{\l__witharrows_type_env_str\}~you~try~to~ + In~the~'CodeAfter'~of~\{\l__wa_type_env_str\}~you~try~to~ draw~an~arrow~going~to~it~self~from~the~line~'#1'.~This~is~not~possible. \\ If~you~go~on,~this~command~will~be~ignored. } -\__witharrows_msg_new:nn { Wrong~line~specification~in~MultiArrow } +\__wa_msg_new:nn { Wrong~line~specification~in~MultiArrow } { The~specification~of~line~'#1'~doesn't~exist. \\ If~you~go~on,~it~will~be~ignored~for~\token_to_str:N \MultiArrow. } -\__witharrows_msg_new:nn { Too~small~specification~for~MultiArrow } +\__wa_msg_new:nn { Too~small~specification~for~MultiArrow } { The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\ is~too~small:~you~need~at~least~two~lines. \\ If~you~go~on,~this~command~will~be~ignored. } -\__witharrows_msg_new:nn { tag*~without~amsmath } +\__wa_msg_new:nn { tag*~without~amsmath } { We~can't~use~\token_to_str:N\tag*~because~you~haven't~loaded~amsmath~ (or~mathtools). \\ If~you~go~on,~the~command~\token_to_str:N\tag\ will~be~used~instead. } -\__witharrows_msg_new:nn { Not~allowed~in~DispWithArrows } +\__wa_msg_new:nn { Not~allowed~in~DispWithArrows } { The~command~\token_to_str:N #1 - is~not~allowed~in~the~first~column~of~\{\l__witharrows_type_env_str\}~but~ + is~not~allowed~in~the~first~column~of~\{\l__wa_type_env_str\}~but~ only~in~the~second~column. \\ If~you~go~on,~this~command~will~be~ignored. } -\__witharrows_msg_new:nn { Not~allowed~in~WithArrows } +\__wa_msg_new:nn { Not~allowed~in~WithArrows } { - The~command~\token_to_str:N #1 is~not~allowed~in~\{\l__witharrows_type_env_str\}~ + The~command~\token_to_str:N #1 is~not~allowed~in~\{\l__wa_type_env_str\}~ (it's~allowed~in~the~second~column~of~\{DispWithArrows\}). \\ If~you~go~on,~this~command~will~be~ignored. } -\__witharrows_msg_new:nn { Multiple~tags } - { - You~can't~use~twice~the~command~\token_to_str:N\tag\ - in~a~line~of~the~environment~\{\l__witharrows_type_env_str\}. \\ - If~you~go~on,~the~tag~'#1'~will~be~used. - } -\__witharrows_msg_new:nn { Multiple~labels } +\__wa_msg_new:nn { Multiple~tags } + { + You~can't~use~twice~the~command~\token_to_str:N\tag\ + in~a~line~of~the~environment~\{\l__wa_type_env_str\}. \\ + If~you~go~on,~the~tag~'#1'~will~be~used. + } +\__wa_msg_new:nn { Multiple~labels } { Normally,~we~can't~use~the~command~\token_to_str:N\label\ - twice~in~a~line~of~the~environment~\{\l__witharrows_type_env_str\}. \\ + twice~in~a~line~of~the~environment~\{\l__wa_type_env_str\}. \\ However,~you~can~go~on.~ - \bool_if:NT \c__witharrows_showlabels_loaded_bool + \bool_if:NT \c__wa_showlabels_loaded_bool { 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. } -\__witharrows_msg_new:nn { Multiple~labels~with~cleveref } +\__wa_msg_new:nn { Multiple~labels~with~cleveref } { Since~you~use~cleveref,~you~can't~use~the~command~\token_to_str:N\label\ - twice~in~a~line~of~the~environment~\{\l__witharrows_type_env_str\}. \\ + twice~in~a~line~of~the~environment~\{\l__wa_type_env_str\}. \\ If~you~go~on,~you~may~have~undefined~references. } -\__witharrows_msg_new:nn { Inexistent~v-node } +\__wa_msg_new:nn { Inexistent~v-node } { There~is~a~problem.~Maybe~you~have~put~a~command~\token_to_str:N\cr\ instead~of~a~command~\token_to_str:N\\~at~the~end~of~ the~row~\int_use:N \l_tmpa_int\ - of~your~environment~\{\l__witharrows_type_env_str\}. \\ + of~your~environment~\{\l__wa_type_env_str\}. \\ If~you~go~on,~you~may~have~an~incorrect~output. } -\__witharrows_msg_new:nn { Option~xoffset~forbidden } - { You~can't~use~the~option~'xoffset'~in~the~command~ - \l__witharrows_string_Arrow_for_msg_str\ +\__wa_msg_new:nn { Option~xoffset~forbidden } + { + You~can't~use~the~option~'xoffset'~in~the~command~ + \l__wa_string_Arrow_for_msg_str\ while~you~are~using~the~option~ - ' \int_compare:nNnTF \l__witharrows_pos_arrow_int = 7 - { group } - { groups } '. \\ - \c__witharrows_option_ignored_str + ' \int_compare:nNnTF \l__wa_pos_arrow_int = 7 + { group } + { groups } '. \\ + \c__wa_option_ignored_str } \NewDocumentCommand \WithArrowsNewStyle { m m } { - \keys_if_exist:nnTF { WithArrows / WithArrows } { #1 } - { \__witharrows_error:nn { Key~already~defined } { #1 } } + \keys_if_exist:nnTF { WithArrows / Global } { #1 } + { \__wa_error:nn { Key~already~defined } { #1 } } { - \keys_define:nn { WithArrows / WithArrows } - { - #1 .code:n = - { - \keys_define:nn { WithArrows / WithArrows } - { unknown .code:n = \prg_do_nothing: } - \keys_set:nn { WithArrows / WithArrows } { #2 } - \keys_define:nn { WithArrows / WithArrows } - { unknown .code:n = - \__witharrows_error:n { Unknown~option~WithArrows }} - } - } - \seq_put_right:Nn \l__witharrows_options_WithArrows_seq {#1} - \keys_define:nn { WithArrows / DispWithArrows } - { - #1 .code:n = - { - \keys_define:nn { WithArrows / DispWithArrows } - { unknown .code:n = \prg_do_nothing: } - \keys_set:nn { WithArrows / DispWithArrows } { #2 } - \keys_define:nn {WithArrows / DispWithArrows } - { unknown .code:n = - \__witharrows_error:n { Unknown~option~DispWithArrows }} - } - } - \seq_put_right:Nn \l__witharrows_options_DispWithArrows_seq { #1 } - \keys_define:nn { WithArrows / WithArrowsOptions } - { - #1 .code:n = - { \keys_set:nn { WithArrows / WithArrowsOptions } { #2 } } - } - \seq_put_right:Nn \l__witharrows_options_WithArrowsOptions_seq { #1 } - \group_begin: - \msg_set:nnn { witharrows } { Unknown~option~WithArrowsOptions } - { - The~option~'\l_keys_key_tl'~can't~be~set~in~the~ - definition~of~a~style. \\ - If~you~go~on,~this~key~will~not~be~written~in~the~style~'#1'. - } - \WithArrowsOptions { #2 } - \group_end: + \keys_define:nn { WithArrows / Global } + { + #1 .code:n = + { \keys_set_known:nn { WithArrows / WithArrowsOptions } { #2 } } + } + \seq_put_right:Nn \l__wa_options_WithArrows_seq {#1} + \seq_put_right:Nn \l__wa_options_DispWithArrows_seq { #1 } + \seq_put_right:Nn \l__wa_options_WithArrowsOptions_seq { #1 } + \group_begin: + \msg_set:nnn { witharrows } { Unknown~option~WithArrowsOptions } + { + The~option~'\l_keys_key_tl'~can't~be~set~in~the~ + definition~of~a~style.~You~can~go~on~for~this~time~ + but~you~should~suppress~this~key. + } + \WithArrowsOptions { #2 } + \group_end: } } -\__witharrows_msg_new:nn { Key~already~defined } +\__wa_msg_new:nn { Key~already~defined } { The~key~'#1'~is~already~defined. \\ If~you~go~on,~your~instruction~\token_to_str:N\WithArrowsNewStyle\ will~be~ignored. } -\tl_const:Nn \c__witharrows_tikz_code_up_tl +\tl_const:Nn \c__wa_tikz_code_up_tl { \draw [ rounded~corners ] let \p1 = (#1) , @@ -1694,77 +1681,92 @@ } (\x2,\y1) -- (\p2) ; } -\tl_const:Nn \c__witharrows_tikz_code_down_tl +\tl_const:Nn \c__wa_tikz_code_down_tl { - \draw [ rounded~corners ] - let \p1 = (#1) , - \p2 = (#2) - in (\p1) -- (\x1,\y2) -- - node { - \dim_set:Nn \l_tmpa_dim { \x1 - \x2 } - \begin { varwidth } \l_tmpa_dim - \raggedright - #3 - \end { varwidth } - } - (\p2) ; + \draw [ rounded~corners ] + let \p1 = (#1) , + \p2 = (#2) + in (\p1) -- (\x1,\y2) -- + node { + \dim_set:Nn \l_tmpa_dim { \x1 - \x2 } + \begin { varwidth } \l_tmpa_dim + \raggedright + #3 + \end { varwidth } + } + (\p2) ; } \keys_define:nn { WithArrows / Arrow / FirstPass } { - up .code:n = \__witharrows_set_independent: , - down .code:n = \__witharrows_set_independent: , + up .code:n = \__wa_set_independent: , + down .code:n = \__wa_set_independent: , up .default:n = NoValue , down .default:n = NoValue } \keys_define:nn { WithArrows / Arrow / SecondPass } - { - up .code:n = \str_if_empty:NT \l__witharrows_previous_key_str - { - \str_set:Nn \l__witharrows_previous_key_str { up } - \bool_if:NTF \c__witharrows_varwidth_loaded_bool - { - \cs_if_exist:cTF { tikz@library@calc@loaded } - { - \int_set:Nn \l__witharrows_pos_arrow_int \c_one_int - \bool_set_false:N \l__witharrows_wrap_lines_bool - \tl_set_eq:NN \l__witharrows_tikz_code_tl - \c__witharrows_tikz_code_up_tl - } - { \__witharrows_error:n { calc~not~loaded } } - } - { \__witharrows_error:n { varwidth~not~loaded } } - } , - down .code:n = \str_if_empty:NT \l__witharrows_previous_key_str - { - \str_set:Nn \l__witharrows_previous_key_str { down } - \bool_if:NTF \c__witharrows_varwidth_loaded_bool - { - \cs_if_exist:cTF { tikz@library@calc@loaded } - { - \int_set:Nn \l__witharrows_pos_arrow_int \c_one_int - \bool_set_false:N \l__witharrows_wrap_lines_bool - \tl_set_eq:NN \l__witharrows_tikz_code_tl - \c__witharrows_tikz_code_down_tl - } - { \__witharrows_error:n { calc~not~loaded } } - } - { \__witharrows_error:n { varwidth~not~loaded } } - } - } -\seq_put_right:Nn \l__witharrows_options_Arrow_seq { down } -\seq_put_right:Nn \l__witharrows_options_Arrow_seq { up } -\__witharrows_msg_new:nn { varwidth~not~loaded } + { + up .code:n = + \str_if_empty:NT \l__wa_previous_key_str + { + \str_set:Nn \l__wa_previous_key_str { up } + \bool_if:NTF \c__wa_varwidth_loaded_bool + { + \cs_if_exist:cTF { tikz@library@calc@loaded } + { + \int_set:Nn \l__wa_pos_arrow_int \c_one_int + \bool_set_false:N \l__wa_wrap_lines_bool + \tl_set_eq:NN \l__wa_tikz_code_tl + \c__wa_tikz_code_up_tl + } + { \__wa_error:n { calc~not~loaded } } + } + { \__wa_error:n { varwidth~not~loaded } } + } , + down .code:n = + \str_if_empty:NT \l__wa_previous_key_str + { + \str_set:Nn \l__wa_previous_key_str { down } + \bool_if:NTF \c__wa_varwidth_loaded_bool + { + \cs_if_exist:cTF { tikz@library@calc@loaded } + { + \int_set:Nn \l__wa_pos_arrow_int \c_one_int + \bool_set_false:N \l__wa_wrap_lines_bool + \tl_set_eq:NN \l__wa_tikz_code_tl + \c__wa_tikz_code_down_tl + } + { \__wa_error:n { calc~not~loaded } } + } + { \__wa_error:n { varwidth~not~loaded } } + } + } +\seq_put_right:Nn \l__wa_options_Arrow_seq { down } +\seq_put_right:Nn \l__wa_options_Arrow_seq { up } +\__wa_msg_new:nn { varwidth~not~loaded } { You~can't~use~the~option~'\l_keys_key_tl'~because~ you~don't~have~loaded~the~package~'varwidth'. \\ - \c__witharrows_option_ignored_str + \c__wa_option_ignored_str } -\__witharrows_msg_new:nn { calc~not~loaded } +\__wa_msg_new:nn { calc~not~loaded } { You~can't~use~the~option~'\l_keys_key_tl'~because~you~don't~have~loaded~the~ Tikz~library~'calc'.You~should~add~'\token_to_str:N\usetikzlibrary{calc}' ~in~your~preamble. \\ - \c__witharrows_option_ignored_str + \c__wa_option_ignored_str + } +\__wa_msg_new:nnn { Duplicate~name } + { + The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ + the~same~environment~name~twice.~You~can~go~on,~but,~ + maybe,~you~will~have~incorrect~results. \\ + For~a~list~of~the~names~already~used,~type~H~<return>. \\ + If~you~don't~want~to~see~this~message~again,~use~the~option~ + 'allow-duplicate-names'. + } + { + The~names~already~defined~in~this~document~are:~ + \seq_use:Nnnn \g__wa_names_seq { ,~ } { ,~ } { ~and~ }. } \endinput %% |