From 21b36d5502b9de93048e17982705bed736153408 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 26 Nov 2018 21:45:26 +0000 Subject: witharrows (26nov18) git-svn-id: svn://tug.org/texlive/trunk@49257 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/latex/witharrows/witharrows.pdf | Bin 328060 -> 346302 bytes .../source/latex/witharrows/witharrows.dtx | 988 +++++++++------ .../texmf-dist/tex/latex/witharrows/witharrows.sty | 1256 ++++++++++---------- 3 files changed, 1264 insertions(+), 980 deletions(-) diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf index 3c88afc583b..b3857d4f69a 100644 Binary files a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf and b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf differ diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx index 1b3ae26aa8b..9a3bdbdb2ec 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.11} -\def\myfiledate{2018/11/02} +\def\myfileversion{1.12} +\def\myfiledate{2018/11/26} % % %<*batchfile> @@ -44,7 +44,7 @@ version 2005/12/01 or later. \endgroup % % -%<@@=ww> +%<@@=wi> %<*driver> \documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz, loaded by witharrows) \usepackage{xltxtra} @@ -53,7 +53,7 @@ version 2005/12/01 or later. \usepackage[footnotehyper]{witharrows} \usetikzlibrary{calc} \usepackage{mathtools} -\usepackage{amsfonts} +\usepackage{amssymb} \usepackage[only,llbracket,rrbracket]{stmaryrd} \NewDocumentEnvironment {scope} {} {} {} \def\interitem{\vskip 7mm plus 2 mm minus 3mm} @@ -582,7 +582,7 @@ version 2005/12/01 or later. % 2xy'-3y=\sqrt x % & \Longleftrightarrow 2x(K'y_0+Ky_0')-3Ky_0 = \sqrt x \\ % & \Longleftrightarrow 2xK'y_0 + K(2xy_0'-3y_0) = \sqrt x \\ -% & \Longleftrightarrow 2x K'y_0 = \sqrt x \Arrow{We replace $y_0$ by its value.}\\ +% & \Longleftrightarrow 2x K'y_0 = \sqrt x \Arrow{we replace $y_0$ by its value}\\ % & \Longleftrightarrow 2xK'x^{\frac32} = x^{\frac12} \Arrow{simplification of the $x$}\\ % & \Longleftrightarrow K' = \tfrac1{2x^2} \Arrow{antiderivation}\\ % & \Longleftrightarrow K = -\tfrac1{2x} @@ -610,11 +610,40 @@ version 2005/12/01 or later. % \end{WithArrows}$ % % \bigskip +% In an environment which uses the option |group| or the option |groups|, it's still possible to give an option of +% position (|ll|, |lr|, |rl|, |rr| or |i|) to an individual arrow. Such arrow will be drawn irrespective of the groups. +% +% \bigskip % If desired, the option |group| or the option |groups| can be given to the command |\WithArrowsOptions| so that it will become % the default value. In this case, it's still possible to come back to the default behaviour for a given % environment |{WithArrows}| with the option |rr|: |\begin{WithArrows}[rr]| % % +% \vspace{1cm} +% In the following example, we have used the option |group| for the environment and the option |rr| for the last +% arrow (that's why the last arrow is not aligned with the others). +% +% $\begin{WithArrows}[interline=1mm,group] +% \sum\limits_{k=0}^n\frac{\cos kx}{\cos^k x} +% & = \sum\limits_{k=0}^n \frac{\Re (e^{ikx})}{(\cos x)^k} +% \Arrow{$(\cos x)^k$ is real} \\ +% & = \sum\limits_{k=0}^n \Re\left(\frac{e^{ikx}}{(\cos x)^k}\right) +% \Arrow{$\Re(z+z')=\Re(z)+\Re(z')$}\\ +% & = \Re \left(\sum\limits_{k=0}^n \left(\frac{e^{ix}}{\cos x}\right)^k\right) +% \Arrow{sum of terms of a geometric progression} \\ +% & = \Re \left(\frac{1-\left(\frac{e^{ix}}{\cos x}\right)^{n+1}}{1-\frac{e^{ix}}{\cos x}} \right) +% \Arrow{algebraic calculation} \\ +% & = \Re \left(\frac{1-\frac{e^{i(n+1)x}}{\cos^{n+1}x}}{1-\frac{e^{ix}}{\cos x}}\right) +% \Arrow{reduction to common denominator} \\ +% & = \Re \left(\frac{\frac{\cos^{n+1}x-e^{i(n+1)x}}{\cos^{n+1}x}}{\frac{\cos x-e^{ix}}{\cos x}}\right) +% \Arrow{$\Re(kz) = k\cdot\Re(z)$ if $k$ is real} \\ +% & = \frac1{\cos^n x}\Re \left(\frac{\cos^{n+1}x-e^{i(n+1)x}}{\cos x-e^{ix}}\right) +% \Arrow[rr]{algebraic form of the complexes} \\ +% & =\frac1{\cos^n x}\Re\left(\frac{\cos^{n+1}x-(\cos(n+1)x+i\sin(n+1)x)}{\cos x-(\cos x+i\sin x)}\right) \\ +% & =\frac1{\cos^n x}\Re\left(\frac{(\cos^{n+1}x-\cos(n+1)x)-i\sin(n+1)x}{-i\sin x}\right) \\ +% & = \frac1{\cos^nx}\cdot\frac{\sin(n+1)x}{\sin x} +% \end{WithArrows}$ +% % \section{Comparison with the environment \{aligned\}} % % |{WithArrows}| bears similarities with the environment |{aligned}| of the extension \pkg{amsmath}. These are only @@ -788,7 +817,7 @@ version 2005/12/01 or later. % % \medskip % The following is composed with |{WithArrows}[c,displaystyle]|. The results are strictly identical.\footnote{In -% versions of \pkg{amsmath} older than the 5~nov.~2016, an thin space was added on the left of an environment +% versions of \pkg{amsmath} older than the 5~nov.~2016, a thin space was added on the left of an environment % |{aligned}|. The new versions do not add this space and neither do |{WithArrows}|.}\par\nobreak % % \smallskip @@ -848,7 +877,7 @@ version 2005/12/01 or later. % to draw the following arrow : % % \bigskip -% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{Division by $2$}}] +% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{division by $2$}}] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -907,14 +936,14 @@ version 2005/12/01 or later. % specification is |1-2|) and ends in the row~$2$ of the sub-environment number~$2$ (and therefore, the % specification is |2-2|). We can draw the arrow with the following command |\Arrow| in |CodeAfter| : % \begin{Verbatim} -% $\begin{WithArrows}[~emphase#CodeAfter = {\Arrow{1-2}{2-2}{Division by $2$}}@] +% $\begin{WithArrows}[~emphase#CodeAfter = {\Arrow{1-2}{2-2}{division by $2$}}@] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % ......... % \end{WithArrows}$ % \end{Verbatim} % -% $\begin{WithArrows}[CodeAfter = {\Arrow{1-2}{2-2}{Division by $2$}}] +% $\begin{WithArrows}[CodeAfter = {\Arrow{1-2}{2-2}{division by $2$}}] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -940,14 +969,14 @@ version 2005/12/01 or later. % not available 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 \\ % ......... % \end{WithArrows}$ % \end{Verbatim} % -% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{Division by $2$}}] +% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{division by $2$}}] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -1174,9 +1203,7 @@ version 2005/12/01 or later. % \medskip % It's possible to use the command |\notag| (or |\nonumber|) to suppress a tag. % -% It's possible to use the command |\tag| to put a special tag (e.g. $\star$).\footnote{If \pkg{amsmath} (or -% \pkg{mathtools}) is loaded, it's also possible to use |\tag*| which, as in \pkg{amsmath}, typesets the tag -% without the parenthesis.} +% It's possible to use the command |\tag| to put a special tag (e.g. $\star$). % % It's also possible to put a label to the line of an equation with the command |\label|. % @@ -1195,7 +1222,22 @@ version 2005/12/01 or later. % |\eqref| is a command of \pkg{amsmath}). % % \medskip -% It's also possible to suppress all the autogenerated numbers with the option |notag| (or |nonumber|), at the +% If \pkg{amsmath} (or \pkg{mathtools}) is loaded, it's also possible to use |\tag*| which, as in \pkg{amsmath}, +% typesets the tag without the parenthesis. For example, it's possible to use it to put the symbol |\square| (of +% \pkg{amssymb}). This symbol is often used to mark the end of a proof. +% \begin{Verbatim} +% \begin{DispWithArrows} +% A & = (a+1)^2 \Arrow{we expand} \notag \\ +% & = a^2 + 2a + 1 ~emphase#\tag*{$\square$}@ +% \end{DispWithArrows} +% \end{Verbatim} +% \begin{DispWithArrows} +% A & = (a+1)^2 \Arrow{we expand} \notag \\ +% & = a^2 + 2a + 1 \tag*{$\square$} +% \end{DispWithArrows} +% +% \medskip +% It's also possible to suppress all the autogenerated numbers with the boolean option |notag| (or |nonumber|), at the % global or environment level. There is also an environment |{DispWithArrows*}| which suppresses all these % numbers.\footnote{Even in this case, it's possible to put a ``manual tag'' with the command |\tag|.} % \begin{Verbatim} @@ -1210,6 +1252,24 @@ version 2005/12/01 or later. % \end{DispWithArrows*} % % \medskip +% In fact, there is also another option |tagged-lines| which can be used to control the lines that will be tagged. +% The value of this option is a list of the numbers of the lines that must to be tagged. For example, with the +% option |tagged-lines = {first,3,last}|, only the first, the third and the last line of the environment will be +% tagged. There is also the special value |all| which means that all the lines will be tagged. +% \begin{Verbatim} +% \begin{DispWithArrows}[~emphase#tagged-lines = last@] +% A & = A_1 \Arrow{first stage} \\ +% & = A_2 \Arrow{second stage} \\ +% & = A_3 +% \end{DispWithArrows} +% \end{Verbatim} +% \begin{DispWithArrows}[tagged-lines = last] +% A & = A_1 \Arrow{first stage} \\ +% & = A_2 \Arrow{second stage} \\ +% & = A_3 +% \end{DispWithArrows} +% +% \bigskip % With the option |fleqn|, the environment is composed flush left (in a way similar to the option |fleqn| of the % standard classes of LaTeX). In this case, the left margin can be controlled with the option |mathindent| (with a % name inspired by the parameter |\mathindent| of standard LaTeX). The default value of this parameter is 25~pt. @@ -1241,6 +1301,37 @@ version 2005/12/01 or later. % but \pkg{witharrows}, of course, is not aware of that option: \pkg{witharrows} only checks the option |leqno| of % the document class.} % +% \bigskip +% If there is not enough space to put the tag at the end of a line, there is no automatic positioning of the label +% on the next line (as in the environments of \pkg{amsmath}). However, in |{DispWithArrows}|, the user can use the +% command |\tagnextline| to manually require the composition of the tag on the following line. +% \begin{Verbatim} +% \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˛ +% +(-1)^{2p+1}(2p+1)^2+(-1)^{2p+2}(2p+2)^2} ~emphase#\tagnextline@ \\ +% &= S_{2p}-(2p+1)^2+(2p+2)^2\\ +% &=p(2p+1)-(2p+1)^2+(2p+2)^2\\ +% &= 2p^2+5p+3 +% \end{DispWithArrows} +% \end{Verbatim} +% \begin{center} +% \color{gray}\vrule% +% \begin{minipage}{275pt}\color{black} +% \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 \\ +% &= S_{2p}-(2p+1)^2+(2p+2)^2\\ +% &= 2p^2+p-4p^2-4p-1+4p^2+8p+4\\ +% &= 2p^2+5p+3 +% \end{DispWithArrows} +% \end{minipage}% +% \color{gray}\vrule +% \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 @@ -1249,6 +1340,7 @@ version 2005/12/01 or later. % 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 @@ -1260,10 +1352,10 @@ version 2005/12/01 or later. % % \bigskip % Concerning the references, the package \pkg{witharrows} is compatible with the extensions \pkg{autonum}, -% \pkg{cleveref}, \pkg{fancyref}, \pkg{hyperref}, \pkg{prettyref}, \pkg{refstyle}, \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.} +% \pkg{cleveref}, \pkg{fancyref}, \pkg{fncylab}, \pkg{hyperref}, \pkg{listlbls}, \pkg{prettyref}, \pkg{refstyle}, +% \pkg{refcheck}, \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). % @@ -1362,7 +1454,7 @@ version 2005/12/01 or later. % \Arrow{$-4$}\\ % & \Longleftrightarrow 2x = -2 % \Arrow{$\div 2$} \\ -% & \Longleftrightarrow 2x = -1 +% & \Longleftrightarrow x = -1 % \end{WithArrows}\] % % @@ -1577,7 +1669,7 @@ version 2005/12/01 or later. % margin (in a way similar as the |wrap-lines| option) in the environments |{DispWithArrows}| % and |{DispWithArrows*}|. In the definition of |TikzCode|, we use the command |\WithArrowsRightX| which is the % $x$-value of the right margin of the current composition box (it's a TeX command and not a dimension). -% For lisibilit, we use a style. This example requires the Tikz library \pkg{calc}. +% For lisibility, we use a style. This example requires the Tikz library \pkg{calc}. % % \begin{Verbatim} % \WithArrowsNewStyle{MyStyle}% @@ -1922,7 +2014,7 @@ version 2005/12/01 or later. \bool_new:N \c_@@_leqno_bool \DeclareOption {leqno} {\bool_set_true:N \c_@@_leqno_bool} \DeclareOption* {} -\ProcessOptions \relax +\ProcessOptions* % \end{macrocode} % % @@ -1937,19 +2029,69 @@ version 2005/12/01 or later. {\msg_error:nnn {witharrows} {#1} {#2}} % \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, for the package \pkg{amsmath}, % the boolean is called |\c_@@_amsmath_loaded_bool|.\footnote{It's not possible to use |\@ifpackageloaded| in the % core of the functions because |\@ifpackageloaded| is available only in the preamble.} % \begin{macrocode} -\AtBeginDocument{\clist_map_inline:nn - {amsmath,mathtools,autonum,cleveref,hyperref,typedref} - {\bool_new:c {c_@@_#1_loaded_bool} - \@ifpackageloaded {#1} - {\bool_set_true:c {c_@@_#1_loaded_bool}} - {}}} +\AtBeginDocument + {\clist_map_inline:nn + {amsmath,mathtools,autonum,cleveref,hyperref,typedref,showlabels,amsthm} + {\bool_new:c {c_@@_#1_loaded_bool} + \@ifpackageloaded {#1} + {\bool_set_true:c {c_@@_#1_loaded_bool}} + {}}} % \end{macrocode} % +% +% \bigskip +% The following variant will be used in the following command. +% \begin{macrocode} +\cs_generate_variant:Nn \seq_set_split:Nnn {Nxx} +% \end{macrocode} +% +% \bigskip +% The command |\@@_save:N| saves a \pkg{expl3} variable by creating a global version of the variable. For a +% variable named |\l_|\texttt{\slshape name}|_|\texttt{\slshape type}, the corresponding global variable will be +% named |\g_|\texttt{\slshape name}|_|\texttt{\slshape type}. The type of the 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 + {\seq_set_split:Nxx \l_tmpa_seq {\char_generate:nn {`_} {12}} {\cs_to_str:N #1} + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl +% \end{macrocode} +% The string |\l_tmpa_str| will contains the \emph{type} of the variable. +% \begin{macrocode} + \str_set:Nx \l_tmpa_str {\seq_item:Nn \l_tmpa_seq {-1}} + \use:c {\l_tmpa_str _if_exist:cF} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } + {\use:c {\l_tmpa_str _new:c} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } } + \use:c {\l_tmpa_str _gset_eq:cN} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } #1 } +% \end{macrocode} +% +% \medskip +% 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 + {\seq_set_split:Nxx \l_tmpa_seq {\char_generate:nn {`_} {12}} {\cs_to_str:N #1} + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl + \str_set:Nx \l_tmpa_str {\seq_item:Nn \l_tmpa_seq {-1}} + \use:c {\l_tmpa_str _set_eq:Nc} + #1 {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } } +% \end{macrocode} +% +% +% \bigskip % We define a Tikz style |@@_node_style| for the |l|-nodes and |r|-nodes that will be created in the |\halign|. These % nodes are Tikz nodes of shape ``rectangle'' but with zero width. An arrow between two nodes starts from the % \emph{south} anchor of the first node and arrives at the \emph{north} anchor of the second node. @@ -1999,9 +2141,10 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% In order to increase the interline in the environments |{WithArrows}|, we will use the command |\spread@equation| -% of \pkg{amsmath}. When used, this command becomes no-op (in the current TeX group). Therefore, it will be -% possible to use the environments of \pkg{amsmath} (e.g. |{aligned}|) in an environment |{WithArrows}|. +% In order to increase the interline in the environments |{WithArrows}|, |{DispWithArrows}|, etc., we will use the +% command |\spread@equation| of \pkg{amsmath}. When used, this command becomes no-op (in the current TeX group). +% Therefore, it will be possible to use the environments of \pkg{amsmath} (e.g. |{aligned}|) in an environment +% |{WithArrows}|. % % Nevertheless, we want the extension \pkg{witharrows} available without \pkg{amsmath}. That's why we give a % definition of |\spread@equation| if \pkg{amsmath} is not loaded (you put the code in a |\AtBeginDocument| because @@ -2096,23 +2239,20 @@ version 2005/12/01 or later. % values will be appended on the right of this token list. % % \bigskip -% The dimension |\g_@@_x_dim| will be used to compute the $x$-value for some vertical arrows when one of the +% 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_arrows_int|) is used. % \begin{macrocode} -\dim_new:N \g_@@_x_dim +\dim_new:N \l_@@_x_dim % \end{macrocode} % % \bigskip -% In the |\halign| of an environment |{WithArrows}|, we will have to use three counters: +% In the |\halign| of an environment |{WithArrows}|, we will have to use two counters: % \begin{itemize} % \item |\g_@@_arrow_int| to count the arrows created in the environment ; -% \item |\g_@@_line_int| to count the lines of the |\halign| ; -% \item |\g_@@_line_bis_int| to count the lines of the |\halign| which have a second column.\footnote{This counter -% is used in order to raise an error if there is a line without the second column (such an situation could raise a -% \textsc{pgf} error for an undefined node).} +% \item |\g_@@_line_int| to count the lines of the |\halign|. % \end{itemize} % -% These three counters will be incremented in a cell of the |\halign| and, therefore, the incrementation must be +% These counters will be incremented in a cell of the |\halign| and, therefore, the incrementation must be % global. However, we want to be able to include a |{WithArrows}| in another |{WithArrows}|. To do so, we must % restore the previous value of these counters at the end of an environment |{WithArrows}| and we decide to manage % a stack for each of these counters. @@ -2121,8 +2261,6 @@ version 2005/12/01 or later. \int_new:N \g_@@_arrow_int \seq_new:N \g_@@_line_int_seq \int_new:N \g_@@_line_int -\seq_new:N \g_@@_line_bis_int_seq -\int_new:N \g_@@_line_bis_int % \end{macrocode} % % \bigskip @@ -2132,77 +2270,73 @@ version 2005/12/01 or later. \tl_new:N \l_@@_name_tl % \end{macrocode} % +% % \bigskip -% The boolean |\l_@@_notag_bool| will be used in |{DispWithArrows}|. In particular, it will be raised when the -% command |\notag| is used. +% 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_@@_notag_bool +\bool_new:N \l_@@_fleqn_bool % \end{macrocode} -% +% % \bigskip -% The token list |\l_@@_tag_tl| will contain the argument of the command |\tag|. +% 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} -\tl_new:N \l_@@_tag_tl +\dim_new:N \l_@@_mathindent_dim +\dim_set:Nn \l_@@_mathindent_dim {25pt} % \end{macrocode} % % \bigskip -% The boolean |\l_@@_tag_star_bool| will be raised if the user uses the command |\tag| with a star. +% The boolean |\l_@@_wrap_lines_bool| corresponds to the option |wrap-lines|. % \begin{macrocode} -\bool_new:N \l_@@_tag_star_bool +\bool_new:N \l_@@_wrap_lines_bool % \end{macrocode} % % \bigskip -% The command |\@@_label:n| will be linked to |\label| in the second column of the |\halign| of the environment -% |{DispWithArrows}|. It's possible to put several labels for the same line (it's not possible in the environments -% of \pkg{amsmath}). That's why we store the differents labels of a same line in a sequence |\l_@@_labels_seq|. +% 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 also three special values, |first|, |last| and |all|. % \begin{macrocode} -\seq_new:N \l_@@_labels_seq -\cs_set:Nn \@@_label:n {\seq_if_empty:NF \l_@@_labels_seq - {\@@_error:n {Multiple~labels}} - \seq_put_right:Nn \l_@@_labels_seq {#1} +\clist_new:N \l_@@_tags_clist +\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} - \bool_if:nT \c_@@_mathtools_loaded_bool - {\MH_if_boolean:nT {show_only_refs} - {\cs_if_exist:cTF {MT_r_#1} - {\bool_set_false:N \l_@@_notag_bool} - {\bool_set_true:N \l_@@_notag_bool}}} - \bool_if:nT \c_@@_autonum_loaded_bool - {\cs_if_exist:cTF {autonum@#1Referenced} - {\bool_set_false:N \l_@@_notag_bool} - {\bool_set_true:N \l_@@_notag_bool}}} +\tl_new:N \l_@@_tag_tl % \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|. +% 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_@@_fleqn_bool +\bool_new:N \l_@@_tag_star_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|). +% The boolean |\l_@@_in_first_column_bool| will be used to known wether we are in the first column of the +% environment |{WithArrows}| or |{DispWithArrows}|. % \begin{macrocode} -\dim_new:N \l_@@_mathindent_dim -\dim_set:Nn \l_@@_mathindent_dim {25pt} +\bool_new:N \l_@@_in_first_column_bool % \end{macrocode} -% +% % \bigskip -% The boolean |\l_@@_wrap_lines_bool| corresponds to the option |wrap-lines|. % \begin{macrocode} -\bool_new:N \l_@@_wrap_lines_bool +\bool_new:N \l_@@_initial_r_bool +\bool_new:N \l_@@_initial_l_bool % \end{macrocode} % +% % \bigskip % \subsection{The definition of the options} % % There are four levels where options can be set: % \begin{itemize} % \item with |\usepackage[...]{witharrows}|: this level will be called \emph{package} level (number~$0$); -% \item with |\WithArrowsOptions{...}|: this level will be called \emph{global} level (number~$1$); +% \item with |\WithArrowsOptions{...}|: this level will be called \emph{global} level\footnote{This level is called +% \emph{global level} but the settings done by |\WithArrowsOptions| are local in the TeX sense: their scope +% corresponds to the current TeX group.} (number~$1$); % \item with |\begin{WithArrows}[...]|: this level will be called \emph{environment} level (number~$2$); % \item with |\Arrow[...]| (included in |CodeAfter|): this level will be called \emph{local} level (number~$3$). % \end{itemize} @@ -2268,13 +2402,11 @@ version 2005/12/01 or later. % % % \bigskip -% By default, an error message is raised if there is a line without ampersand (|&|). However, it's possible to -% suppress this error with the option |AllowLineWithoutAmpersand|. +% The option |AllowLineWithoutAmpersand| is obsolete and will be deleted in a future version. % \begin{macrocode} - AllowLineWithoutAmpersand .code:n = { \msg_redirect_name:nnn + AllowLineWithoutAmpersand .code:n = { \msg_error:nn {witharrows} - {All~lines~must~have~an~ampersand} - {none} }, + {AllowLineWithoutAmpersand}}, AllowLineWithoutAmpersand .value_forbidden:n = true, % \end{macrocode} % @@ -2329,7 +2461,7 @@ version 2005/12/01 or later. % \bigskip % With the option |groups| (with a \emph{s}), the arrows of the environment are divided in groups by an argument of % connexity, and, in each group, the arrows are vertical with the same abscissa and at a leftmost position. When -% the option |group| or |groups| is used, it's not possible to another option of position like |ll|, |lr|, etc. +% the option |group| or |groups| is used, it's not possible to specify another option of position like |ll|, |lr|, etc. % for a individual key. % \begin{macrocode} groups .code:n = {\int_compare:nNnT \l_@@_previous_pos_arrows_int > {-1} @@ -2396,8 +2528,8 @@ version 2005/12/01 or later. notag .code:n = {\bool_if:NTF \l_@@_in_WithArrows_bool {\@@_error:n {Option~will~be~ignored}} {\tl_if_eq:nnTF {#1} {true} - {\bool_set_true:N \l_@@_notag_bool} - {\bool_set_false:N \l_@@_notag_bool}}}, + {\clist_clear:N \l_@@_tags_clist} + {\clist_set:Nn \l_@@_tags_clist {all}}}}, notag .default:n = true, nonumber .meta:n = notag, % \end{macrocode} @@ -2419,12 +2551,27 @@ version 2005/12/01 or later. % |{DispWithArrows*}| and, with this |TikzCode|, the lines of the labels are automatically wrapped on the right. % \begin{macrocode} wrap-lines .code:n = {\bool_if:NTF \l_@@_in_WithArrows_bool - {\@@_error:n {Option~will~be~ignored}} - {\tl_if_eq:nnTF {#1} {true} - {\bool_set_true:N \l_@@_wrap_lines_bool} - {\bool_set_false:N \l_@@_wrap_lines_bool}}}, + {\@@_error:n {Option~will~be~ignored}} + {\tl_if_eq:nnTF {#1} {true} + {\bool_set_true:N \l_@@_wrap_lines_bool} + {\bool_set_false:N \l_@@_wrap_lines_bool}}}, wrap-lines .default:n = true, % \end{macrocode} +% +% \bigskip +% \begin{macrocode} + tagged-lines .code:n = {\bool_if:NTF \l_@@_in_WithArrows_bool + {\@@_error:n {Option~will~be~ignored}} + {\clist_set:Nn \l_@@_tags_clist {#1} +% \end{macrocode} +% In the list given as value for the key |tagged-lines|, the user may use |first| as synonymous of |1|. We do the replacement. +% \begin{macrocode} + \clist_if_in:NnT \l_@@_tags_clist {first} + {\clist_remove_all:Nn \l_@@_tags_clist {first} + \clist_put_left:Nn \l_@@_tags_clist 1 }}}, + tagged-lines .value_required:n = true, +% \end{macrocode} +% % \begin{macrocode} unknown .code:n = \@@_error:n {Option~unknown} } @@ -2500,7 +2647,8 @@ version 2005/12/01 or later. % \bigskip % Eventually, a key |jump| (see below) and a key for unknown keys. % \begin{macrocode} - jump .code:n = \@@_error:n {Option~will~be~ignored} , + jump .code:n = {\int_compare:nNnF \l_@@_level_int = 3 + {\@@_error:n {Option~will~be~ignored}}} , unknown .code:n = \@@_error:n {Option~unknown} } % \end{macrocode} @@ -2511,11 +2659,21 @@ version 2005/12/01 or later. % extracted in the command |\Arrow| because we want to compute right away the final line of the arrow (this will be % useful for the options |group| and |groups|). % \begin{macrocode} -\keys_define:nn {WithArrows/jump} +\keys_define:nn {WithArrows/Arrow} {jump .code:n = {\int_set:Nn \l_@@_jump_int {#1} \int_compare:nNnF \l_@@_jump_int > 0 {\@@_error:n {The~option~"jump"~must~be~non~negative}}} , - jump .value_required:n = true} + jump .value_required:n = true, + rr .value_forbidden:n = true, + rr .code:n = \@@_analyze_option_position:n 0 , + ll .value_forbidden:n = true, + ll .code:n = \@@_analyze_option_position:n 1 , + rl .value_forbidden:n = true, + rl .code:n = \@@_analyze_option_position:n 2 , + lr .value_forbidden:n = true, + lr .code:n = \@@_analyze_option_position:n 3 , + i .value_forbidden:n = true, + i .code:n = \@@_analyze_option_position:n 5 } % \end{macrocode} % % \bigskip @@ -2526,17 +2684,7 @@ version 2005/12/01 or later. {\int_compare:nNnT \l_@@_previous_pos_arrows_int > {-1} {\@@_error:n {Two~options~are~incompatible}} \int_set:Nn \l_@@_previous_pos_arrows_int {#1} -% \end{macrocode} -% -% It's not possible to use one of the considered options at the level of an arrow (level~2) when the option |group| -% or the option |groups| is used. However, if we are at the level of an environment, it's possible to override a -% previous option |group| or |groups| (this previous option |group| or |groups| would necessarily have been set at -% a global level by |\WithArrowsOptions|). -% \begin{macrocode} - \bool_if:nTF { \int_compare_p:nNn \l_@@_level_int = 3 && - \int_compare_p:nNn \l_@@_pos_arrows_int > 5} - {\@@_error:n {Option~incompatible~with~"group(s)"}} - {\int_set:Nn \l_@@_pos_arrows_int {#1}}} + \int_set:Nn \l_@@_pos_arrows_int {#1}} % \end{macrocode} % % @@ -2571,18 +2719,27 @@ version 2005/12/01 or later. \int_gincr:N \g_@@_arrow_int % \end{macrocode} % -% We decide to extract immediatly the key |jump| in order to compute the end line. That's the reason why there is a -% module |WithArrows/jump| with this sole key. The remainded key-value pairs are stored in |\l_tmpa_tl| and will be -% stored further in the properly list of the arrow. +% We will extract immediately the options |ll|, |rr|, |lr|, |rl|, |i| and |jump|. For the position, we use the +% integer |\l_@@_pos_arrows_int| locally in the cell of the |\halign|: we won't change the exterior evalue of +% |\l_@@_pos_arrows_int| set by the environment |{WithArrows}| of by the command |\WithArrowsOptions|. The default +% value of |\l_@@_pos_arrows_int| will be $-1$ for an arrow without option of position. +% \begin{macrocode} + \int_set:Nn \l_@@_previous_pos_arrows_int {-1} + \int_set:Nn \l_@@_pos_arrows_int {-1} +% \end{macrocode} +% The level of options is set to 3 which is the level for the options in a command |\Arrow|. +% \begin{macrocode} + \int_set:Nn \l_@@_level_int 3 +% \end{macrocode} +% The options |ll|, |rr|, |lr|, |rl|, |i| and |jump| are extracted. The other options are stored in |\l_tmpa_tl| +% and will be stored in the field ``options'' of the property list later. % \begin{macrocode} - \int_zero_new:N \l_@@_jump_int - \int_set:Nn \l_@@_jump_int 1 - \keys_set_known:nnN {WithArrows/jump} {#1,#3} \l_tmpa_tl + \keys_set_known:nnN {WithArrows/Arrow} {#1,#3} \l_tmpa_tl % \end{macrocode} % % \medskip -% We will construct a global property list to store the informations of the considered arrow. The four fields of -% this property list are ``initial'', ``final'', ``options'' and ``label''. +% We will construct a global property list to store the informations of the considered arrow. The five fields of +% this property list are ``initial'', ``final'', ``position'', ``options'' and ``label''. % % \smallskip % \begin{enumerate} @@ -2597,7 +2754,13 @@ version 2005/12/01 or later. \prop_put:NnV \l_tmpa_prop {final} \l_tmpa_int % \end{macrocode} % -% \item All the options of the arrow (it's a token list): +% \item The ``position'' of the arrow. If the arrow has no option of position, the default value $-1$ is stored in +% that field. +% \begin{macrocode} + \prop_put:NnV \l_tmpa_prop {position} \l_@@_pos_arrows_int +% \end{macrocode} +% +% \item The other options of the arrow (it's a token list): % \begin{macrocode} \prop_put:NnV \l_tmpa_prop {options} \l_tmpa_tl % \end{macrocode} @@ -2637,21 +2800,18 @@ version 2005/12/01 or later. % \subsection{The environment \{WithArrows\}} % % The command |\@@_pre_environement:| is a code common to the environments |{WithArrows}| and |{DispWithArrows}|. -% The argument is the options given to the environment. +% The argument is the list of options given to the environment. % \begin{macrocode} \cs_new_protected:Nn \@@_pre_environment:n % \end{macrocode} % -% First the initialisation of the three counters |\g_@@_arrow_int|, -% |\g_@@_line_int| and |\g_@@_line_bis_int|. However, we have to save their previous values with the three stacks -% created for this end. +% First 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 this end. % \begin{macrocode} { \seq_gput_right:NV \g_@@_arrow_int_seq \g_@@_arrow_int \int_gzero:N \g_@@_arrow_int \seq_gput_right:NV \g_@@_line_int_seq \g_@@_line_int \int_gzero:N \g_@@_line_int - \seq_gput_right:NV \g_@@_line_bis_int_seq \g_@@_line_bis_int - \int_gzero:N \g_@@_line_bis_int % \end{macrocode} % % \bigskip @@ -2685,9 +2845,23 @@ version 2005/12/01 or later. \int_zero_new:N \l_@@_initial_int \int_zero_new:N \l_@@_final_int \int_zero_new:N \l_@@_arrow_int + \int_zero_new:N \l_@@_pos_of_arrow_int + \int_zero_new:N \l_@@_jump_int + \int_set:Nn \l_@@_jump_int 1 % \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|. +% \begin{macrocode} + \seq_clear_new:N \l_@@_labels_seq +% \end{macrocode} +% +% \begin{macrocode} + \@@_bool_new:N \l_@@_tag_next_line_bool +% \end{macrocode} +% +% \bigskip % The value corresponding to the key |interline| is put to zero before the treatment of the options of the % environment.\footnote{It's recalled that, by design, the option |interline| of an environment doesn't apply % in the nested environments.} @@ -2716,7 +2890,7 @@ version 2005/12/01 or later. % If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment % |{savenotes}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}). % \begin{macrocode} - \bool_if:NT \g_@@_footnote_bool {\begin{savenotes}} + \bool_if:NT \g_@@_footnote_bool {\savenotes} % \end{macrocode} % % \bigskip @@ -2743,22 +2917,16 @@ version 2005/12/01 or later. % \begin{macrocode} \NewDocumentEnvironment {WithArrows} {O{}} { \bool_set_true:N \l_@@_in_WithArrows_bool + \bool_set_false:N \l_@@_in_DispWithArrows_bool \reverse_if:N \if_mode_math: \@@_error:n {{WithArrows}~used~outside~math~mode} \fi: - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\label}} \@@_pre_environment:n {#1} + \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 |\vbox|\footnote{Notice that the use of @@ -2767,9 +2935,9 @@ version 2005/12/01 or later. % environment is used outside math mode.} and therefore, we can use |\vcenter|. % \begin{macrocode} \int_case:nn \l_@@_pos_env_int - {0 {\vtop} - 1 {\vcenter} - 2 {\vbox}} + {0 \vtop + 1 \vcenter + 2 \vbox} \bgroup % \end{macrocode} % @@ -2794,17 +2962,14 @@ version 2005/12/01 or later. % \begin{macrocode} \int_gincr:N \g_@@_line_int \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column: + \bool_set_true:N \l_@@_in_first_column_bool \strut\hfil $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$ & % \end{macrocode} % % \bigskip -% In the second column, we increment the counter |\g_@@_line_bis_int| because we want to count the lines with a -% second column and raise an error if there is lines without a second column. Once again, the incrementation must -% be global and it's recalled that we manage a stack for this counter too. % \begin{macrocode} - \int_gincr:N \g_@@_line_bis_int $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {{}##}$ % \end{macrocode} % @@ -2858,7 +3023,7 @@ version 2005/12/01 or later. % If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment % |{footnote}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}). % \begin{macrocode} - \bool_if:NT \g_@@_footnote_bool {\end{savenotes}} + \bool_if:NT \g_@@_footnote_bool {\endsavenotes} } % \end{macrocode} % This is the end of the environment |{WithArrows}|. @@ -2870,17 +3035,11 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Nn \@@_post_environment: % \end{macrocode} -% If there is a line without the second column, we raise an error (a line without the second column could generate -% an \textsc{pgf} error for an unknown node since the nodes are created in the second column). -% \begin{macrocode} - {\int_compare:nNnT \g_@@_line_bis_int < \g_@@_line_int - {\@@_error:n {All~lines~must~have~an~ampersand}} -% \end{macrocode} % % \bigskip % The command |\WithArrowsRightX| is not used by \pkg{witharrows}. It's only a convenience given to the user. % \begin{macrocode} - \cs_set:Npn \WithArrowsRightX {\g_@@_right_x_dim} + {\cs_set:Npn \WithArrowsRightX {\g_@@_right_x_dim} % \end{macrocode} % % \bigskip @@ -2919,13 +3078,13 @@ version 2005/12/01 or later. \group_end: % \end{macrocode} % -% % \bigskip % We update the position-in-the-tree. First, we drop the last component and then we increment the last element. % \begin{macrocode} \seq_gpop_right:NN \g_@@_position_in_the_tree_seq \l_tmpa_tl \seq_gpop_right:NN \g_@@_position_in_the_tree_seq \l_tmpa_tl - \seq_gput_right:Nx \g_@@_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl+1}} + \seq_gput_right:Nx \g_@@_position_in_the_tree_seq + {\int_eval:n {\l_tmpa_tl+1}} % \end{macrocode} % % \bigskip @@ -2937,15 +3096,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% Finally, we restore the previous values of the three counters |\g_@@_arrow_int|, |\g_@@_line_int| and -% |\g_@@_line_bis_int|. It is recalled that we manage three stacks in order to be able to do such a restoration. +% Finally, we restore the previous values of the counters |\g_@@_arrow_int| and |\g_@@_line_int| +% It is recalled that we manage three stacks in order to be able to do such a restoration. % \begin{macrocode} \seq_gpop_right:NN \g_@@_arrow_int_seq {\l_tmpa_tl} \int_gset:Nn \g_@@_arrow_int {\l_tmpa_tl} \seq_gpop_right:NN \g_@@_line_int_seq \l_tmpa_tl \int_gset:Nn \g_@@_line_int {\l_tmpa_tl} - \seq_gpop_right:NN \g_@@_line_bis_int_seq \l_tmpa_tl - \int_gset:Nn \g_@@_line_bis_int {\l_tmpa_tl} } % \end{macrocode} % That's the end of the command |\@@_post_environment:|. @@ -2960,6 +3117,9 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Nn \@@_cr: {\scan_stop: +% \bigskip +% \begin{macrocode} + \bool_if:NT \l_@@_in_first_column_bool {& {} } \group_align_safe_begin: \peek_meaning_remove:NTF * \@@_cr_i: \@@_cr_i:} % \end{macrocode} @@ -2974,21 +3134,22 @@ version 2005/12/01 or later. {\group_align_safe_end: % \end{macrocode} % For the environment |{DispWithArrows}|, the behaviour of |\\| is different because we add the third column which -% is the column for the tag (number of the equation). +% is the column for the tag (number of the equation). Even if there is no tag, the third column is used for the |v|-nodes. % \begin{macrocode} \bool_if:NT \l_@@_in_DispWithArrows_bool - {\bool_if:NTF \l_@@_notag_bool % \end{macrocode} -% If there is no tag to put, we use as well the third column because you want to raise an error if the user uses -% more than two columns. +% At this stage, we know that we have a tag to put if (and only if) the value of |\l_@@_tags_clist| is the comma +% list |all| (only one element). Maybe, previously, the value of |\l_@@_tags_clist| was, for example, |1,last| (which +% means that only the first line and the last line must be tagged). However, in this case, the comparison with the number of line has +% be done before and, now, if we are in a line to tag, the value of |\l_@@_tags_clist| is |all|. % \begin{macrocode} - {& \tikz [@@_standard] \coordinate (\int_use:N\g_@@_line_int-v) ; } + {\clist_if_in:NnTF \l_@@_tags_clist {all} { % \end{macrocode} % Here, we can't use |\refstepcounter{equation}| because if the user has issued a |\tag| command, we have to use % |\l_@@_tag_tl| and not |\theequation|. That's why we have to do the job done by |\refstepcounter| manually. % -% First, the incrementation of the counter (potentialy). +% First, the incrementation of the counter (potentially). % \begin{macrocode} \tl_if_empty:NT \l_@@_tag_tl {\int_gincr:N \c@equation} @@ -3011,7 +3172,8 @@ version 2005/12/01 or later. % Now, we do the job done by |\refstepcounter| and by the redefinitions of |\refstepcounter| done by some packages % (the incrementation of the counter has been done yet). % -% First an action which is in the definition of |\refstepcounter| in |source2e|. +% First an action which is in the definition of |\refstepcounter|. The command |\p@equation| is +% redefined by some extensions like \pkg{fncylab}. % \begin{macrocode} \cs_set:Npx \@currentlabel {\p@equation \g_tmpa_tl} % \end{macrocode} @@ -3041,18 +3203,27 @@ version 2005/12/01 or later. \bool_if:NT \c_@@_typedref_loaded_bool {\cs_set:Npn \sr@name {equation}} % \end{macrocode} -% Now, we can issue the command |\label| (some package may have redefined |\label|, for example \pkg{typedref}) for +% 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|). % \begin{macrocode} \seq_map_function:NN \l_@@_labels_seq \@@_old_label} % \end{macrocode} -% We store the boolean |\l_@@_tag_star_bool| in the global variable |\g_tmpa_bool| because we will use it in the -% \emph{next} cell (after the |&|). -% \begin{macrocode} - \bool_gset_eq:NN \g_tmpa_bool \l_@@_tag_star_bool - & \cs_set_eq:NN \theequation \g_tmpa_tl - \bool_if:NT \g_tmpa_bool {\cs_set:Npn \tagform@ {}} +% We save the booleans |\l_@@_tag_star_bool| and |\l_@@_qedhere_bool| because they will be used in the +% \emph{next} cell (after the |&|). We recall that the cells of a |\halign| are TeX groups. +% \begin{macrocode} + \@@_save:N \l_@@_tag_star_bool + \@@_save:N \l_@@_qedhere_bool + \bool_if:NT \l_@@_tag_next_line_bool + { \openup -\jot + \bool_set_false:N \l_@@_tag_next_line_bool + \notag \\ & } + & \@@_restore:N \l_@@_tag_star_bool + \@@_restore:N \l_@@_qedhere_bool + \bool_if:NT \l_@@_qedhere_bool + {\hbox_overlap_left:n {\@@_qedhere_i:}} + \cs_set_eq:NN \theequation \g_tmpa_tl + \bool_if:NT \l_@@_tag_star_bool {\cs_set:Npn \tagform@ {}} % \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). However, of course, the position of the |v|-node is not the same wether the @@ -3064,14 +3235,132 @@ version 2005/12/01 or later. \quad \@eqnnum } \bool_if:NT \c_@@_leqno_bool - {\tikz [@@_standard] \coordinate (\int_use:N \g_@@_line_int-v) ;} - }} + {\tikz [@@_standard] \coordinate (\int_use:N \g_@@_line_int-v) ;}} + {\@@_save:N \l_@@_qedhere_bool + & \@@_restore:N \l_@@_qedhere_bool + \bool_if:NT \l_@@_qedhere_bool + {\hbox_overlap_left:n {\@@_qedhere_i:}} + \tikz [@@_standard] \coordinate (\int_use:N\g_@@_line_int-v) ; } + } \cr\noalign{\skip_vertical:n {#1 + \l_@@_interline_skip} \scan_stop:}} % \end{macrocode} % According to the documentation of \pkg{expl3}, the previous addition in ``|#1 + \l_@@_interline_skip|'' is really % an addition of skips (=glues). % +% +% +% \bigskip +% \subsection{The commands tag, notag, label, tagnextline and qedhere for DispWithArrows} +% +% \begin{macrocode} +\cs_new_protected:Nn \@@_if_in_second_col_of_disp:nn + {\bool_if:NTF \l_@@_in_WithArrows_bool + {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{WithArrows}} + {#1}} + {\bool_if:NTF \l_@@_in_first_column_bool + {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {#1}} + {#2}}} +% \end{macrocode} +% The command |\@@_notag:| will be linked to |\notag| and |\nonumber| in the environments |{WithArrows}| and +% |{DispWithArrows}|. +% \begin{macrocode} +\cs_new_protected:Nn \@@_notag: + {\@@_if_in_second_col_of_disp:nn {\notag} + {\clist_clear:N \l_@@_tags_clist}} +% \end{macrocode} +% +% +% \bigskip +% The command |\@@_tag| will be linked to |\tag| in the environments |{WithArrows}| and |{DispWithArrows}|. We use +% |\NewDocumentCommand| because this command has a starred version. +% \begin{macrocode} +\NewDocumentCommand \@@_tag {sm} + {\@@_if_in_second_col_of_disp:nn {\tag} + {\tl_if_empty:NF \l_@@_tag_tl + {\msg_error:nnn {witharrows} {Multiple~tags} {#2}} + \clist_set:Nn \l_@@_tags_clist {all} + \bool_if:nT \c_@@_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\MH_if_boolean:nF {show_manual_tags} + {\clist_clear:N \l_@@_tags_clist}}} + \tl_set:Nn \l_@@_tag_tl {#2} + \bool_set:Nn \l_@@_tag_star_bool {#1} +% \end{macrocode} +% The starred version |\tag*| can't be used if \pkg{amsmath} has not been loaded because this version does the job +% by desactivating the command |\tagform@| inserted by \pkg{amsmath} in the (two versions of the) command +% |\@eqnnum|.\footnote{There are two versions of |@eqnnum|, a standard version and a version for the option |leqno|.} +% \begin{macrocode} + \bool_if:nT {#1 && ! \bool_if_p:N \c_@@_amsmath_loaded_bool} + { \@@_error:n {tag*~without~amsmath} }} + } +% \end{macrocode} +% +% \bigskip +% The command |\@@_label:n| will be linked to |\label| in the environments |{WithArrows}| and |{DispWithArrows}|. +% In these environments, it's possible to put several labels for the same line (it's not possible in the +% environments of \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 + {\@@_if_in_second_col_of_disp:nn {\label} + {\seq_if_empty:NF \l_@@_labels_seq + {\bool_if:NTF \c_@@_cleveref_loaded_bool + {\@@_error:n {Multiple~labels~with~cleveref}} + {\@@_error:n {Multiple~labels}}} + \seq_put_right:Nn \l_@@_labels_seq {#1} + \bool_if:nT \c_@@_mathtools_loaded_bool + {\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} + {\clist_set:Nn \l_@@_tags_clist {all}} + {\clist_clear:N \l_@@_tags_clist}}}} +% \end{macrocode} +% +% \bigskip +% The command |\@@_tagnextline:| will be linked to |\tagnextline| in the environments |{WithArrows}| and +% |{DispWithArrows}|. +% \begin{macrocode} +\cs_new_protected:Nn \@@_tagnextline: + {\@@_if_in_second_col_of_disp:nn {\tagnextline} + {\bool_set_true:N \l_@@_tag_next_line_bool}} +% \end{macrocode} +% +% +% \bigskip +% The environments |{DispWithArrows}| and |{DispWithArrows*}| are compliant with the command |\qedhere| of +% \pkg{amsthm}. However, this compatibility requires a special version of |\qedhere|. +% +% This special version is called |\@@_qedhere:| and will be linked with |\qedhere| in the second column of the +% environment |{DispWithArrows}| (only if 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} +% \end{macrocode} +% +% In the third column of the |\halign| of |{DispWithArrows}|, a command |\@@_qedhere_i:| will be +% issued if the flag |\l_@@_qedhere_bool| has been raised. The code of this command is a adaptation of the code of +% |\qedhere| in \pkg{amsthm}. +% \begin{macrocode} +\cs_new_protected:Nn \@@_qedhere_i: {\group_begin: + \cs_set_eq:NN \qed \qedsymbol +% \end{macrocode} +% The line |\cs_set_eq:NN \qed@elt \setQED@elt| is a preparation for an action on the \textsc{qed} stack. Despite +% its form, the instruction |\QED@stack| executes an operation on the stack. This operation prints the \textsc{qed} +% symbol and nullify the top of the stack. +% \begin{macrocode} + \cs_set_eq:NN \qed@elt \setQED@elt + \QED@stack\relax\relax + \group_end: } +% \end{macrocode} +% +% % \bigskip % \subsection{The environment \{DispWithArrows\}} % @@ -3098,8 +3387,7 @@ version 2005/12/01 or later. % However, we have to re-raise the flag |{show_only_refs}| of \pkg{mhsetup} because it has been switched off by % |\MT_showonlyrefs_false:| and we will use it in the code of the new version of |\label|. % \begin{macrocode} - \MH_set_boolean_T:n {show_only_refs} - \bool_set_true:N \l_@@_notag_bool}} + \MH_set_boolean_T:n {show_only_refs}}} % \end{macrocode} % The command |\intertext@| is a command of \pkg{amsmath} which loads the definition of |\intertext|. % \begin{macrocode} @@ -3126,28 +3414,16 @@ version 2005/12/01 or later. \bool_if:NTF \l_@@_fleqn_bool {\tabskip = \c_zero_skip} {\tabskip = 0 pt plus 1000 pt minus 1000 pt} -% \end{macrocode} -% If \pkg{amsmath} is loaded, the LaTeX version of |\label| is stored in |\ltx@label|. If not, it's, of course, -% stored in |\label|. We store this definition of |\label| because we will redefine |\label| in the environment. -% \begin{macrocode} - \bool_if:NTF \c_@@_amsmath_loaded_bool - {\cs_set_eq:NN \_@@_old_label \ltx@label} - {\cs_set_eq:NN \_@@_old_label \label} - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\label}} + \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 \bgroup \int_gincr:N \g_@@_line_int \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column: + \bool_set_true:N \l_@@_in_first_column_bool \strut \bool_if:NT \l_@@_fleqn_bool {\skip_horizontal:n \l_@@_mathindent_dim} @@ -3155,13 +3431,14 @@ version 2005/12/01 or later. $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$ \tabskip = \c_zero_skip & - \cs_set:Npn \notag {\bool_set_true:N \l_@@_notag_bool} - \cs_set_eq:NN \nonumber \notag - \cs_set_eq:NN \tag \@@_tag - \cs_set_eq:NN \label \@@_label:n + \clist_if_in:NVT \l_@@_tags_clist \g_@@_line_int + {\clist_set:Nn \l_@@_tags_clist {all}} +% \end{macrocode} +% The command |\qedhere| of \pkg{amsthm} is redefined here. +% \begin{macrocode} + \bool_if:NT \c_@@_amsthm_loaded_bool {\cs_set_eq:NN \qedhere \@@_qedhere:} $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {{}##}$ \tabskip = 0 pt plus 1000 pt minus 1000 pt - \int_gincr:N \g_@@_line_bis_int \tikz [remember~picture,overlay] \node [_@@_node_style, name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l, @@ -3181,7 +3458,12 @@ version 2005/12/01 or later. && \@@_error:n {Third~column~in~an~environment~{DispWithArrows}} \iffalse ## \fi \cr} - {\\ +% \end{macrocode} +% We begin the second part of the environment |{DispWithArrows}|. +% \begin{macrocode} + {\clist_if_in:NnT \l_@@_tags_clist {last} + {\clist_set:Nn \l_@@_tags_clist {all}} + \\ % \end{macrocode} % The following |\egroup| is for the |\halign|. % \begin{macrocode} @@ -3228,34 +3510,12 @@ version 2005/12/01 or later. % If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment % |{footnote}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}). % \begin{macrocode} - \bool_if:NT \g_@@_footnote_bool {\end{savenotes}} + \bool_if:NT \g_@@_footnote_bool {\endsavenotes} \ignorespacesafterend } % \end{macrocode} % % -% \bigskip -% The command |\@@_tag| will be linked to |\tag| in the environment |{DispWithArrows}|. -% \begin{macrocode} -\NewDocumentCommand \@@_tag {sm} - {\tl_if_empty:NF \l_@@_tag_tl - {\msg_error:nnn {witharrows} {Multiple~tags} {#2}} - \bool_set_false:N \l_@@_notag_bool - \bool_if:nT \c_@@_mathtools_loaded_bool - {\MH_if_boolean:nT {show_only_refs} - {\MH_if_boolean:nF {show_manual_tags} - {\bool_set_true:N \l_@@_notag_bool}}} - \tl_set:Nn \l_@@_tag_tl {#2} - \bool_set:Nn \l_@@_tag_star_bool {#1} -% \end{macrocode} -% The starred version |\tag*| can't be used if \pkg{amsmath} has not been loaded because this version does the job -% by desactivating the command |\tagform@| inserted by \pkg{amsmath} in the (two versions of the) command -% |\@eqnnum|.\footnote{There are two versions of |@eqnnum|, a standard version and a version for the option |leqno|.} -% \begin{macrocode} - \bool_if:nT {#1 && ! \bool_if_p:N \c_@@_amsmath_loaded_bool} - { \@@_error:n {tag*~without~amsmath} } - } -% \end{macrocode} % % % \bigskip @@ -3268,7 +3528,7 @@ version 2005/12/01 or later. {\endDispWithArrows} % \end{macrocode} % -% \bigskip +% % \subsection{We draw the arrows} % % \bigskip @@ -3276,6 +3536,9 @@ version 2005/12/01 or later. % to compute the $x$-value of a group of arrows before actually drawing the arrows of that group. The arrows will % actually be drawn by the macro |\@@_draw_arrows:nn|. % +% 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 +% ``independant''. % \begin{macrocode} \cs_new_protected:Nn \@@_draw_arrows: { \group_begin: @@ -3305,9 +3568,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% We extract from the property list of the current arrow the fields ``initial'' and ``final'' and we store these -% values in |\l_@@_initial_int| and |\l_@@_final_int|. However, we have to do a conversion because the components -% of a property list are token lists. +% 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. % \begin{macrocode} \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop} {initial} \l_tmpa_tl @@ -3315,54 +3578,64 @@ version 2005/12/01 or later. \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop} {final} \l_tmpa_tl \int_set:Nn \l_@@_final_int {\l_tmpa_tl} + \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop} + {position} \l_tmpa_tl + \int_set:Nn \l_@@_pos_of_arrow_int \l_tmpa_tl % \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 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}} +% \end{macrocode} +% \bigskip % 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 (with the $x$-value computed in |\g_@@_x_dim|). +% of that group (with the $x$-value computed in |\l_@@_x_dim|). % \begin{macrocode} - \bool_if:nT { \int_compare_p:nNn \l_@@_pos_arrows_int = 7 - && \int_compare_p:nNn \l_@@_arrow_int > 1 - && \int_compare_p:nNn - \l_@@_initial_int > \l_@@_last_line_of_group_int} - {\@@_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_@@_pos_arrows_int = 7 + && \int_compare_p:nNn \l_@@_arrow_int > 1 + && \int_compare_p:nNn + \l_@@_initial_int > \l_@@_last_line_of_group_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 % 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) an if we have just finished a group (that's why the flag is raised in the +% 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 four variables: -% |\l_@@_first_arrow_int|, |\l_@@_first_line_of_group_int|, |\l_@@_last_line_of_group| and |\g_@@_x_dim| (global -% for technical reasons). The last two will evolve during the construction of the group. +% |\l_@@_first_arrow_int|, |\l_@@_first_line_of_group_int|, |\l_@@_last_line_of_group| and |\l_@@_x_dim|. +% The last two will evolve during the construction of the group. % \begin{macrocode} - \bool_if:nTF \l_@@_new_group_bool - {\bool_set_false:N \l_@@_new_group_bool - \int_set:Nn \l_@@_first_arrow_of_group_int \l_@@_arrow_int - \int_set:Nn \l_@@_first_line_of_group_int \l_@@_initial_int - \int_set:Nn \l_@@_last_line_of_group_int \l_@@_final_int - \begin{tikzpicture} [@@_standard] - \tikz@parse@node\pgfutil@firstofone (\int_use:N\l_@@_initial_int-l) - \dim_gset:Nn \g_@@_x_dim \pgf@x - \end{tikzpicture} - } + \bool_if:nTF \l_@@_new_group_bool + {\bool_set_false:N \l_@@_new_group_bool + \int_set:Nn \l_@@_first_arrow_of_group_int \l_@@_arrow_int + \int_set:Nn \l_@@_first_line_of_group_int \l_@@_initial_int + \int_set:Nn \l_@@_last_line_of_group_int \l_@@_final_int + \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 we are not at the beginning of a new group, we actualize |\l_@@_last_line_of_group_int|. If the arrow is +% independant (|\l_@@_pos_of_arrow_int| non negative) we don't take into account this arrow for the detection of +% the end of the group. % \begin{macrocode} - {\int_set:Nn \l_@@_last_line_of_group_int - {\int_max:nn \l_@@_last_line_of_group_int \l_@@_final_int}} + {\int_compare:nNnT \l_@@_pos_of_arrow_int = {-1} + {\int_set:Nn \l_@@_last_line_of_group_int + {\int_max:nn \l_@@_last_line_of_group_int \l_@@_final_int}}} % \end{macrocode} % % \bigskip -% We update the current $x$-value (in |\g_@@_x_dim|) even if we are at the beginning of a group. Indeed, the -% previous initialisation of |\g_@@_x_dim| only considers the initial line of the arrows and now we consider all -% the lines between the initial and the final line. This is done with |\@@_update_x_value:nn|. We have written a -% command for this because it is also used with the option |i| (|\l_@@_pos_arrows_int| = 5). +% If the arrow is independant (|\l_@@_pos_of_arrow_int| non negative), you update the current $x$-value (in +% |\l_@@_x_dim|) with the dedicated command |\@@_update_x_value:nn|. % \begin{macrocode} - \@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int + \int_compare:nNnT \l_@@_pos_of_arrow_int = {-1} + {\@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int} } % \end{macrocode} % % \bigskip @@ -3426,18 +3699,14 @@ version 2005/12/01 or later. % % \bigskip % If the arrow ends 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). If the initial -% node or the final node doesn't exist, we also raise an error.\footnote{This case occurs if the considered line -% has no ampersand. In fact, we raise an error if there is such a line in the |\halign|, but, nonetheless, we consider -% the case where the user goes on and we try to avoid other errors.} +% construction of the |\halign|, |\g_@@_line_int| is the total number of lines of the environment). However, if the +% option |group| or the option |groups| is in force, we don't raise an error because the error has already been +% raised in |\@@_draw_arrows:|. % \begin{macrocode} \int_compare:nNnTF \l_@@_final_int > \g_@@_line_int - {\@@_error:n {Too~few~lines~for~an~arrow}} - {\cs_if_free:cTF{pgf@sh@ns@wa-\l_@@_prefix_str-\int_use:N\l_@@_initial_int-l} - { \@@_error:n {A~PGF~node~doesn't~exist} } - {\cs_if_free:cTF{pgf@sh@ns@wa-\l_@@_prefix_str-\int_use:N\l_@@_final_int-l} - { \@@_error:n {A~PGF~node~doesn't~exist} } - {\@@_draw_arrows_i:}}} + {\int_compare:nNnT \l_@@_pos_arrows_int < 6 + {\@@_error:n {Too~few~lines~for~an~arrow}}} + \@@_draw_arrows_i: \int_incr:N \l_@@_arrow_int } \group_end: @@ -3445,13 +3714,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The macro |\@@_draw_arrows_i:| is only for the lisibility of the code. This macro will draw the current arrow -% if the arrow is not impossible (that is to say if the Tikz nodes exist). The first |\group_begin:| is for the -% options of the arrow. +% The macro |\@@_draw_arrows_i:| is only for the lisibility of the code. The first |\group_begin:| is for the +% options of the arrows (but we remind that the 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:Nn \@@_draw_arrows_i: {\group_begin: - \int_set:Nn \l_@@_previous_pos_arrows_int {-1} \int_set:Nn \l_@@_level_int 3 % \end{macrocode} % @@ -3466,7 +3734,17 @@ version 2005/12/01 or later. \@@_keys_set: {\l_tmpa_tl,tikz={xshift = \l_@@_xoffset_dim}} % \end{macrocode} % -% +% We retrieve the value of the field |position| of the current arrow. If the arrow has no option of position, the +% value of this field is $-1$. If the arrow has a option of position, you modify the current value of +% |\l_@@_pos_arrows_int| to reflect this value. +% \begin{macrocode} + \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop} + {position} \l_tmpa_tl + \int_set:Nn \l_tmpa_int \l_tmpa_tl + \int_compare:nNnF \l_tmpa_int = {-1} + {\int_set_eq:NN \l_@@_pos_arrows_int \l_tmpa_int} +% \end{macrocode} +% % We create two booleans to indicate the position of the initial node and final node of the arrow in cases of % options |rr|, |rl|, |lr| or |ll|: % \begin{macrocode} @@ -3494,32 +3772,13 @@ version 2005/12/01 or later. % \end{center} % % \bigskip -% In case of option |i| (|\l_@@_pos_arrows_int| = 5), we have to compute the $x$-value of the arrow (which is -% vertical). The computed $x$-value is stored in |\g_@@_x_dim| (the same variable used when the option |group| or -% the option |groups| is used). This variable is global for technical reasons: we have to do assignments in a Tikz -% node. +% In case of option |i| at a local or global level (|\l_@@_pos_arrows_int| = 5), we have to compute the +% $x$-value of the arrow (which is vertical). The computed $x$-value is stored in |\l_@@_x_dim| (the same variable +% used when the option |group| or the option |groups| is used). % \begin{macrocode} \int_compare:nNnT \l_@@_pos_arrows_int = 5 - { -% \end{macrocode} -% -% \medskip -% First, we calculate the initial value for |\g_@@_x_dim|. We use a Tikz command, but, in fact, nothing is drawn. -% We use this Tikz command only to read the abscissa of a Tikz node. -% \begin{macrocode} - \begin{tikzpicture} [@@_standard] - \tikz@parse@node\pgfutil@firstofone (\int_use:N\l_@@_initial_int-l) - \dim_gset:Nn \g_@@_x_dim \pgf@x - \end{tikzpicture} -% \end{macrocode} -% A global assignment is necessary because of Tikz. -% -% Then, we will loop to determine the maximal length of the lines between the lines |\l_@@_initial_int| and -% |\l_@@_final_int|... but we have written a command dedicated to this work because it will also be used in -% |\@@_draw_arrows:|. -% \begin{macrocode} - \@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int - } + { \dim_set:Nn \l_@@_x_dim {-\c_max_dim} + \@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int } % \end{macrocode} % % \bigskip @@ -3558,13 +3817,13 @@ version 2005/12/01 or later. } % \end{macrocode} % -% If we use option |i| or |group| or |groups|, we use the abscissa specially computed in |\g_@@_x_dim|. +% If we use option |i| or |group| or |groups|, we use the abscissa specially computed in |\l_@@_x_dim|. % \begin{macrocode} {\begin{tikzpicture} [@@_standard] \tikz@scan@one@point\pgfutil@firstofone (\l_@@_initial_tl) - \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g_@@_x_dim , \dim_use:N \pgf@y} + \tl_gset:Nx \g_tmpa_tl {\dim_use:N \l_@@_x_dim , \dim_use:N \pgf@y} \tikz@scan@one@point\pgfutil@firstofone (\l_@@_final_tl) - \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g_@@_x_dim , \dim_use:N \pgf@y} + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l_@@_x_dim , \dim_use:N \pgf@y} \end{tikzpicture}} % \end{macrocode} % @@ -3575,7 +3834,7 @@ version 2005/12/01 or later. % the characters \emph{underscore} in the name |\l_tmpa_tl| : if the user uses the Tikz library |babel|, the third % argument of the command |\@@_draw_arrow:nno| will be rescanned because this third argument will be in the % argument of a command |node| of an instruction |\draw| of Tikz... and we will have an error because of the -% characters \emph{underscore}.\footnote{There were other solutions : use another name without \emph{underscore} +% characters \emph{underscore}.\footnote{There were other solutions: use another name without \emph{underscore} % (like \Verb|\ltmpatl|) or use the package \pkg{underscore} (with this package, the characters \emph{underscore} % will be rescanned without errors, even in text mode).} % \begin{macrocode} @@ -3669,20 +3928,18 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The command |\@@_update_x_value:nn| will analyze the lines\footnote{If a line has no ampersand, this line is -% ignored. In fact, we raise an error if there is a line without ampersand but, nonetheless, we consider the case -% where the user goes on and we try to avoid other errors.} between |#1| and |#2| in order to modify -% |\g_@@_x_dim| in consequence. More precisely, |\g_@@_x_dim| is increased if a line longer than the current value -% of |\g_@@_x_dim| is found. |\@@_update_x_value:nn| is used in |\@@_draw_arrows:| (for options |group| and +% The command |\@@_update_x_value:nn| will analyze the lines between |#1| and |#2| in order to modify +% |\l_@@_x_dim| in consequence. More precisely, |\l_@@_x_dim| is increased if a line longer than the current value +% of |\l_@@_x_dim| is found. |\@@_update_x_value:nn| is used in |\@@_draw_arrows:| (for options |group| and % |groups|) and in |\@@_draw_arrows:nn| (for option |i|). % \begin{macrocode} \cs_new_protected:Nn \@@_update_x_value:nn {\int_step_inline:nnnn {#1} 1 {#2} - {\cs_if_exist:cT {pgf@sh@ns@wa-\l_@@_prefix_str-##1-l} - {\begin{tikzpicture} [@@_standard] - \tikz@scan@one@point\pgfutil@firstofone (##1-l) - \dim_gset:Nn \g_@@_x_dim {\dim_max:nn \g_@@_x_dim \pgf@x} - \end{tikzpicture} } } } + {\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} % % @@ -3855,6 +4112,16 @@ version 2005/12/01 or later. % \bigskip % \subsection{The error messages of the package} % +% +% \begin{macrocode} +\msg_new:nnn {witharrows} + {AllowLineWithoutAmpersand} + {The~option~"AllowLineWithoutAmpersand"~is~deprecated~because~lines~ + without~ampersands~are~now~always~allowed.~The~option~ + "AllowLineWithoutAmpersand"~will~probably~be~deleted~in~a~future~version.~ + However,~you~can~go~on~for~this~time.} +% \end{macrocode} +% % \begin{macrocode} \msg_new:nnn {witharrows} {Option~unknown} @@ -3933,31 +4200,6 @@ version 2005/12/01 or later. If~you~go~on,~I~will~use~the~option~"\tl_use:N\l_keys_key_tl".} % \end{macrocode} % -% \begin{macrocode} -\msg_new:nnnn {witharrows} - {All~lines~must~have~an~ampersand} - {All~lines~of~an~environment~\{WithArrows\}~should~ - have~an~second~column~(because~the~nodes~are~created~ - in~the~second~column).~However,~you~can~go~on~but~you~will~ - have~an~error~if~one~of~your~arrows~needs~an~PGF~ - node~absent~by~lack~of~ampersand.~If~you~don't~want~to~ - see~this~message~again,~you~can~use~the~option~ - AllowLineWithoutAmpersand.} - {Moreover, the~ampersand~can~be~implicit~ - (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} -% \end{macrocode} -% -% \begin{macrocode} -\msg_new:nnn {witharrows} - {Option~incompatible~with~"group(s)"} - {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~while~ - you~are~using~the~option~" - \int_compare:nNnTF \l_@@_pos_arrows_int = 5 - {group} - {groups}".~ - It's~incompatible.~You~can~go~on~ignoring~this~option~ - "\tl_use:N\l_keys_key_tl"~but~you~should~correct~your~code.} -% \end{macrocode} % % \begin{macrocode} \msg_new:nnn {witharrows} @@ -4004,18 +4246,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\msg_new:nnn {witharrows} - {A~PGF~node~doesn't~exist} - {A~PGF~node~necessary~to~draw~an~arrow~doesn't~exist~ - because~you~didn't~put~an~ampersand~in~the~corresponding~line.~ - If~you~go~on,~the~arrow~will~be~ignored.} -% \end{macrocode} -% -% -% \begin{macrocode} \msg_new:nnn {witharrows} {tag*~without~amsmath} - {We~can't~use~\token_to_str:N\tag*~because~you~haven't~load~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.} % \end{macrocode} @@ -4026,8 +4259,7 @@ version 2005/12/01 or later. {Command~not~allowed~in~{DispWithArrows}} {The~command~\token_to_str:N #1 is~not~allowed~in~the~first~column~of~\{DispWithArrows\}~but~ - only~in~the~second~column~(and,~of~course,~in~the~ - environments~of~amsmath).~If~you~go~on,~this~command~will~be~ignored.} + only~in~the~second~column.~If~you~go~on,~this~command~will~be~ignored.} % \end{macrocode} % % \begin{macrocode} @@ -4035,8 +4267,7 @@ version 2005/12/01 or later. {Command~not~allowed~in~{WithArrows}} {The~command~\token_to_str:N #1 is~not~allowed~in~\{WithArrows\}~but~is~allowed~in~the~second~ - column~of~\{DispWithArrows\}~(and,~of~course,~in~the~ - environments~of~amsmath).~If~you~go~on,~this~command~will~be~ignored.} + column~of~\{DispWithArrows\}~If~you~go~on,~this~command~will~be~ignored.} % \end{macrocode} % % \begin{macrocode} @@ -4051,15 +4282,23 @@ version 2005/12/01 or later. % \begin{macrocode} \msg_new:nnn {witharrows} {Multiple~labels} - {Normaly,~we~can't~use~the~command~\token_to_str:N\label\ + {Normally,~we~can't~use~the~command~\token_to_str:N\label\ twice~in~a~line~of~the~environment~\{\@currenvir\}.~ However,~you~can~go~on.~ + \bool_if:NT \c_@@_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~ - "AllowMultipleLabels"~at~the~global~or~ - environment~level~(this~doesn't~work~if~you~use~cleveref).} + "AllowMultipleLabels"~at~the~global~or~environment~level.} % \end{macrocode} % -% +% \begin{macrocode} +\msg_new:nnn {witharrows} + {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~\{\@currenvir\}.~ + If~you~go~on,~you~may~have~undefined~references.} +% \end{macrocode} +% % \subsection{Environment \{CasesWithArrows\}} % % \begin{macrocode} @@ -4075,7 +4314,7 @@ version 2005/12/01 or later. {\MH_if_boolean:nT {show_only_refs} {\MT_showonlyrefs_false: \MH_set_boolean_T:n {show_only_refs} - \bool_set_true:N \l_@@_notag_bool}} + \clist_set:Nn \l_@@_tags_clist {all}}} \bool_if:NT \c_@@_amsmath_loaded_bool \intertext@ \if_mode_math: \@@_error:n {{DispWithArrows}~used~in~math~mode} @@ -4092,23 +4331,12 @@ version 2005/12/01 or later. {\tabskip = \c_zero_skip} {\tabskip = 0 pt plus 1000 pt minus 1000 pt} \bool_if:NTF \c_@@_amsmath_loaded_bool - {\cs_set_eq:NN \_@@_old_label \ltx@label} - {\cs_set_eq:NN \_@@_old_label \label} - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\label}} + {\cs_set_eq:NN \@@_old_label \ltx@label} + {\cs_set_eq:NN \@@_old_label \label} \halign to \displaywidth \bgroup \int_gincr:N \g_@@_line_int \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column: + \bool_set_true:N \l_@@_in_first_column_bool \strut \bool_if:NT \l_@@_fleqn_bool {\skip_horizontal:n \l_@@_mathindent_dim} @@ -4117,13 +4345,11 @@ version 2005/12/01 or later. $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$ \tabskip = \c_zero_skip & - \cs_set:Npn \notag {\bool_set_true:N \l_@@_notag_bool} - \cs_set_eq:NN \nonumber \notag - \cs_set_eq:NN \tag \@@_tag - \cs_set_eq:NN \label \@@_label:n + \clist_if_in:NVT \l_@@_tags_clist \g_@@_line_int + {\clist_set:Nn \l_@@_tags_clist {all}} + \cs_set:Npn \notag {\clist_clear:N \l_@@_tags_clist} $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {{}##}$ \tabskip = 0 pt plus 1000 pt minus 1000 pt - \int_gincr:N \g_@@_line_bis_int \tikz [remember~picture,overlay] \node [@@_node_style, name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l, @@ -4143,7 +4369,9 @@ version 2005/12/01 or later. && \@@_error:n {Third~column~in~an~environment~{DispWithArrows}} \if_false: ## \fi: \cr} - { \\ + {\clist_if_in:NnT {last} \l_@@_tags_clist + {\clist_set:Nn \l_@@_tags_clist {all}} + \\ \egroup \unskip\unpenalty\unskip\unpenalty \box_set_to_last:N \l_tmpa_box @@ -4206,7 +4434,8 @@ version 2005/12/01 or later. your~instruction~\token_to_str:N\WithArrowsNewStyle\ will~be~ignored.} % \end{macrocode} % -% +% +% % \section{History} % % \subsection{Changes between versions 1.0 and 1.1} @@ -4283,13 +4512,28 @@ version 2005/12/01 or later. % % The option |wrap-lines| is now fully compatible with the class option |leqno|. % -% Correction of a bug: |\nointerlineskip| and |\makebox[.6\linewidth]{}| should be inserted in |{DispWithArrows}|. +% Correction of a bug: |\nointerlineskip| and |\makebox[.6\linewidth]{}| should be inserted in |{DispWithArrows}| % only in vertical mode. % % \subsection{Changes between 1.10 and 1.11} % -% Commands |\WithArrowsNewStyle| and |\WithArrowsRightX|. +% New commands |\WithArrowsNewStyle| and |\WithArrowsRightX|. % +% \subsection{Changes between 1.11 and 1.12} +% +% New command |\tagnextline|. +% +% New option |tagged-lines|. +% +% An option of position (|ll|, |lr|, |rl|, |rr| or |i|) is now allowed at the local level even if the option +% |group| or the option |groups| is used at the global or environment level. +% +% Compatibility of |{DispWithArrows}| with |\qedhere| of \pkg{amsthm}. +% +% Compatibility with the packages \pkg{refcheck}, \pkg{showlabels} and \pkg{listlbls}. +% +% The option |\AllowLineWithoutAmpersand| is deprecated because lines without ampersands are now always allowed. +% % \endinput % % Local Variables: diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index bcfd92509d5..d363263a6c0 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.11} -\def\myfiledate{2018/11/02} +\def\myfileversion{1.12} +\def\myfiledate{2018/11/26} \RequirePackage{tikz} \usetikzlibrary{arrows.meta,bending} \RequirePackage{l3keys2e} @@ -29,12 +29,12 @@ {\myfileversion} {Draws arrows for explanations on the right} \RequirePackage{xparse} -\bool_new:N \g__ww_footnotehyper_bool -\bool_new:N \g__ww_footnote_bool -\int_new:N \l__ww_level_int +\bool_new:N \g__wi_footnotehyper_bool +\bool_new:N \g__wi_footnote_bool +\int_new:N \l__wi_level_int \keys_define:nn {WithArrows/package} - {footnote .bool_gset:N = \g__ww_footnote_bool, - footnotehyper .bool_gset:N = \g__ww_footnotehyper_bool, + {footnote .bool_gset:N = \g__wi_footnote_bool, + footnotehyper .bool_gset:N = \g__wi_footnotehyper_bool, unknown .code:n = \msg_fatal:nn {witharrows} {Option~unknown~for~package}} \msg_new:nnn {witharrows} @@ -60,7 +60,7 @@ If~you~want,~you~can~use~the~option~"footnote"~and~the~footnotes~ within~the~environments~{WithArrows}~will~be~extracted~with~the~tools~ of~the~package~footnote.} -\bool_if:NT \g__ww_footnote_bool +\bool_if:NT \g__wi_footnote_bool {\@ifclassloaded {beamer} {\msg_fatal:nn {witharrows} {Option~incompatible~with~Beamer}} @@ -70,7 +70,7 @@ {footnote~with~footnotehyper~package}} {} \usepackage{footnote}} -\bool_if:NT \g__ww_footnotehyper_bool +\bool_if:NT \g__wi_footnotehyper_bool {\@ifclassloaded {beamer} {\msg_fatal:nn {witharrows} {Option~incompatible~with~Beamer}} @@ -80,31 +80,53 @@ {footnotehyper~with~footnote~package}} {} \usepackage{footnotehyper} - \bool_gset_true:N \g__ww_footnote_bool} -\bool_new:N \c__ww_leqno_bool -\DeclareOption {leqno} {\bool_set_true:N \c__ww_leqno_bool} + \bool_gset_true:N \g__wi_footnote_bool} +\bool_new:N \c__wi_leqno_bool +\DeclareOption {leqno} {\bool_set_true:N \c__wi_leqno_bool} \DeclareOption* {} -\ProcessOptions \relax -\cs_new_protected:Nn \__ww_error:n +\ProcessOptions* +\cs_new_protected:Nn \__wi_error:n {\msg_error:nn {witharrows} {#1}} -\cs_new_protected:Nn \__ww_error:nn +\cs_new_protected:Nn \__wi_error:nn {\msg_error:nnn {witharrows} {#1} {#2}} -\AtBeginDocument{\clist_map_inline:nn - {amsmath,mathtools,autonum,cleveref,hyperref,typedref} - {\bool_new:c {c__ww_#1_loaded_bool} - \@ifpackageloaded {#1} - {\bool_set_true:c {c__ww_#1_loaded_bool}} - {}}} -\tikzset{__ww_node_style/.style= { - above = \l__ww_ystart_dim, +\cs_new_protected:Nn \__wi_bool_new:N + {\bool_if_exist:NTF #1 + {\bool_set_false:N #1} + {\bool_new:N #1}} +\AtBeginDocument + {\clist_map_inline:nn + {amsmath,mathtools,autonum,cleveref,hyperref,typedref,showlabels,amsthm} + {\bool_new:c {c__wi_#1_loaded_bool} + \@ifpackageloaded {#1} + {\bool_set_true:c {c__wi_#1_loaded_bool}} + {}}} +\cs_generate_variant:Nn \seq_set_split:Nnn {Nxx} +\cs_new_protected:Nn \__wi_save:N + {\seq_set_split:Nxx \l_tmpa_seq {\char_generate:nn {`_} {12}} {\cs_to_str:N #1} + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl + \str_set:Nx \l_tmpa_str {\seq_item:Nn \l_tmpa_seq {-1}} + \use:c {\l_tmpa_str _if_exist:cF} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } + {\use:c {\l_tmpa_str _new:c} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } } + \use:c {\l_tmpa_str _gset_eq:cN} + {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } #1 } +\cs_new_protected:Nn \__wi_restore:N + {\seq_set_split:Nxx \l_tmpa_seq {\char_generate:nn {`_} {12}} {\cs_to_str:N #1} + \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl + \str_set:Nx \l_tmpa_str {\seq_item:Nn \l_tmpa_seq {-1}} + \use:c {\l_tmpa_str _set_eq:Nc} + #1 {g_\seq_use:Nnnn \l_tmpa_seq _ _ _ } } +\tikzset{__wi_node_style/.style= { + above = \l__wi_ystart_dim, inner~sep = 0 pt, minimum~width = 0pt, - minimum~height = \l__ww_ygap_dim, + minimum~height = \l__wi_ygap_dim, red, - \bool_if:NT \l__ww_shownodes_bool {draw} }} -\tikzset{__ww_standard/.style= { remember~picture, + \bool_if:NT \l__wi_shownodes_bool {draw} }} +\tikzset{__wi_standard/.style= { remember~picture, overlay, - name~prefix = wa-\l__ww_prefix_str- }} + name~prefix = wa-\l__wi_prefix_str- }} \tikzset{WithArrows/arrow/tips/.style = { > = {Straight~Barb[scale=1.2,bend]} }} \tikzset{WithArrows/arrow/.style = { align = left, auto = left, @@ -113,67 +135,56 @@ bend~left = 45, -> }} \AtBeginDocument - {\bool_if:NF \c__ww_amsmath_loaded_bool + {\bool_if:NF \c__wi_amsmath_loaded_bool {\cs_set_protected:Npn \spread@equation {\openup\jot \cs_set_protected:Npn \spread@equation {}}}} -\bool_new:N \l__ww_in_WithArrows_bool -\bool_new:N \l__ww_in_DispWithArrows_bool -\seq_new:N \g__ww_position_in_the_tree_seq -\seq_gput_right:Nn \g__ww_position_in_the_tree_seq 1 -\int_new:N \g__ww_last_env_int -\skip_new:N \l__ww_interline_skip -\int_new:N \l__ww_pos_env_int -\dim_new:N \l__ww_xoffset_dim -\dim_set:Nn \l__ww_xoffset_dim {3mm} -\int_new:N \l__ww_pos_arrows_int -\int_new:N \l__ww_previous_pos_arrows_int -\dim_new:N \g__ww_x_dim -\seq_new:N \g__ww_arrow_int_seq -\int_new:N \g__ww_arrow_int -\seq_new:N \g__ww_line_int_seq -\int_new:N \g__ww_line_int -\seq_new:N \g__ww_line_bis_int_seq -\int_new:N \g__ww_line_bis_int -\tl_new:N \l__ww_name_tl -\bool_new:N \l__ww_notag_bool -\tl_new:N \l__ww_tag_tl -\bool_new:N \l__ww_tag_star_bool -\seq_new:N \l__ww_labels_seq -\cs_set:Nn \__ww_label:n {\seq_if_empty:NF \l__ww_labels_seq - {\__ww_error:n {Multiple~labels}} - \seq_put_right:Nn \l__ww_labels_seq {#1} - \bool_if:nT \c__ww_mathtools_loaded_bool - {\MH_if_boolean:nT {show_only_refs} - {\cs_if_exist:cTF {MT_r_#1} - {\bool_set_false:N \l__ww_notag_bool} - {\bool_set_true:N \l__ww_notag_bool}}} - \bool_if:nT \c__ww_autonum_loaded_bool - {\cs_if_exist:cTF {autonum@#1Referenced} - {\bool_set_false:N \l__ww_notag_bool} - {\bool_set_true:N \l__ww_notag_bool}}} -\bool_new:N \l__ww_fleqn_bool -\dim_new:N \l__ww_mathindent_dim -\dim_set:Nn \l__ww_mathindent_dim {25pt} -\bool_new:N \l__ww_wrap_lines_bool -\int_set:Nn \l__ww_level_int 1 +\bool_new:N \l__wi_in_WithArrows_bool +\bool_new:N \l__wi_in_DispWithArrows_bool +\seq_new:N \g__wi_position_in_the_tree_seq +\seq_gput_right:Nn \g__wi_position_in_the_tree_seq 1 +\int_new:N \g__wi_last_env_int +\skip_new:N \l__wi_interline_skip +\int_new:N \l__wi_pos_env_int +\dim_new:N \l__wi_xoffset_dim +\dim_set:Nn \l__wi_xoffset_dim {3mm} +\int_new:N \l__wi_pos_arrows_int +\int_new:N \l__wi_previous_pos_arrows_int +\dim_new:N \l__wi_x_dim +\seq_new:N \g__wi_arrow_int_seq +\int_new:N \g__wi_arrow_int +\seq_new:N \g__wi_line_int_seq +\int_new:N \g__wi_line_int +\tl_new:N \l__wi_name_tl +\bool_new:N \l__wi_fleqn_bool +\dim_new:N \l__wi_mathindent_dim +\dim_set:Nn \l__wi_mathindent_dim {25pt} +\bool_new:N \l__wi_wrap_lines_bool +\clist_new:N \l__wi_tags_clist +\clist_set:Nn \l__wi_tags_clist {all} +\tl_new:N \l__wi_tag_tl +\bool_new:N \l__wi_tag_star_bool +\bool_new:N \l__wi_in_first_column_bool +\bool_new:N \l__wi_initial_r_bool +\bool_new:N \l__wi_initial_l_bool +\int_set:Nn \l__wi_level_int 1 \keys_define:nn {WithArrows/GlobalOrEnv} - { t .code:n = {\bool_if:NTF \l__ww_in_DispWithArrows_bool - {\__ww_error:n {Option~will~be~ignored} - {\int_set:Nn \l__ww_pos_env_int 0}}}, + { t .code:n = {\bool_if:NTF \l__wi_in_DispWithArrows_bool + {\__wi_error:n {Option~will~be~ignored} + {\int_set:Nn \l__wi_pos_env_int 0}}}, t .value_forbidden:n = true, - c .code:n = {\bool_if:NTF \l__ww_in_DispWithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} - {\int_set:Nn \l__ww_pos_env_int 1}}, + c .code:n = {\bool_if:NTF \l__wi_in_DispWithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} + {\int_set:Nn \l__wi_pos_env_int 1}}, c .value_forbidden:n = true, - b .code:n = {\bool_if:NTF \l__ww_in_DispWithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} - {\int_set:Nn \l__ww_pos_env_int 2}}, + b .code:n = {\bool_if:NTF \l__wi_in_DispWithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} + {\int_set:Nn \l__wi_pos_env_int 2}}, b .value_forbidden:n = true, - ygap .dim_set:N = \l__ww_ygap_dim, + ygap .dim_set:N = \l__wi_ygap_dim, ygap .value_required:n = true, ygap .initial:n = 0.4 ex, - ystart .dim_set:N = \l__ww_ystart_dim, + ystart .dim_set:N = \l__wi_ystart_dim, ystart .value_required:n = true, ystart .initial:n = 0.4 ex, MoreColumns .code:n = { \msg_redirect_name:nnn @@ -181,279 +192,289 @@ {Third~column~in~an~environment~{WithArrows}} {none} }, MoreColumns .value_forbidden:n = true, - AllowLineWithoutAmpersand .code:n = { \msg_redirect_name:nnn + AllowLineWithoutAmpersand .code:n = { \msg_error:nn {witharrows} - {All~lines~must~have~an~ampersand} - {none} }, + {AllowLineWithoutAmpersand}}, AllowLineWithoutAmpersand .value_forbidden:n = true, - CommandName .tl_set:N = \l__ww_CommandName_tl, + CommandName .tl_set:N = \l__wi_CommandName_tl, CommandName .initial:n = Arrow , CommandName .value_required:n = true, - TikzCode .tl_set:N = \l__ww_tikz_code_tl, + TikzCode .tl_set:N = \l__wi_tikz_code_tl, TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , TikzCode .value_required:n = true, - displaystyle .bool_set:N = \l__ww_displaystyle_bool, + displaystyle .bool_set:N = \l__wi_displaystyle_bool, displaystyle .initial:n = false, - shownodes .bool_set:N = \l__ww_shownodes_bool, + shownodes .bool_set:N = \l__wi_shownodes_bool, shownodes .initial:n = false, - shownodenames .bool_set:N = \l__ww_shownodenames_bool, + shownodenames .bool_set:N = \l__wi_shownodenames_bool, shownodenames .initial:n = false, - group .code:n = {\int_compare:nNnT \l__ww_previous_pos_arrows_int > {-1} - {\__ww_error:n {Two~options~are~incompatible}} - \int_set:Nn \l__ww_previous_pos_arrows_int 6 - \int_set:Nn \l__ww_pos_arrows_int 6} , + group .code:n = {\int_compare:nNnT \l__wi_previous_pos_arrows_int > {-1} + {\__wi_error:n {Two~options~are~incompatible}} + \int_set:Nn \l__wi_previous_pos_arrows_int 6 + \int_set:Nn \l__wi_pos_arrows_int 6} , group .value_forbidden:n = true, - groups .code:n = {\int_compare:nNnT \l__ww_previous_pos_arrows_int > {-1} - {\__ww_error:n {Two~options~are~incompatible}} - \int_set:Nn \l__ww_previous_pos_arrows_int 7 - \int_set:Nn \l__ww_pos_arrows_int 7} , + groups .code:n = {\int_compare:nNnT \l__wi_previous_pos_arrows_int > {-1} + {\__wi_error:n {Two~options~are~incompatible}} + \int_set:Nn \l__wi_previous_pos_arrows_int 7 + \int_set:Nn \l__wi_pos_arrows_int 7} , groups .value_forbidden:n = true, - CodeBefore .code:n = {\int_compare:nNnTF \l__ww_level_int = 1 - {\__ww_error:n {Option~will~be~ignored}} - {\tl_put_right:Nn \l__ww_code_before_tl {#1}}} , + CodeBefore .code:n = {\int_compare:nNnTF \l__wi_level_int = 1 + {\__wi_error:n {Option~will~be~ignored}} + {\tl_put_right:Nn \l__wi_code_before_tl {#1}}} , CodeBefore .value_required:n = true, - CodeAfter .code:n = {\int_compare:nNnTF \l__ww_level_int = 1 - {\__ww_error:n {Option~will~be~ignored}} - {\tl_put_right:Nn \l__ww_code_after_tl {#1}}} , + CodeAfter .code:n = {\int_compare:nNnTF \l__wi_level_int = 1 + {\__wi_error:n {Option~will~be~ignored}} + {\tl_put_right:Nn \l__wi_code_after_tl {#1}}} , CodeAfter .value_required:n = true, - name .code:n = {\int_compare:nNnTF \l__ww_level_int = 1 - {\__ww_error:n {Option~will~be~ignored}} - {\tl_set:Nn \l__ww_name_tl {#1}}} , + name .code:n = {\int_compare:nNnTF \l__wi_level_int = 1 + {\__wi_error:n {Option~will~be~ignored}} + {\tl_set:Nn \l__wi_name_tl {#1}}} , name .value_required:n = true, - fleqn .code:n = {\bool_if:NTF \l__ww_in_WithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} + fleqn .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} {\tl_if_eq:nnTF {#1} {true} - {\bool_set_true:N \l__ww_fleqn_bool} - {\bool_set_false:N \l__ww_fleqn_bool}}}, + {\bool_set_true:N \l__wi_fleqn_bool} + {\bool_set_false:N \l__wi_fleqn_bool}}}, fleqn .default:n = true, - mathindent .code:n = {\bool_if:NTF \l__ww_in_WithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} - {\dim_set:Nn \l__ww_mathindent_dim {#1}}}, + mathindent .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} + {\dim_set:Nn \l__wi_mathindent_dim {#1}}}, mathindent .value_required:n = true, - notag .code:n = {\bool_if:NTF \l__ww_in_WithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} + notag .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} {\tl_if_eq:nnTF {#1} {true} - {\bool_set_true:N \l__ww_notag_bool} - {\bool_set_false:N \l__ww_notag_bool}}}, + {\clist_clear:N \l__wi_tags_clist} + {\clist_set:Nn \l__wi_tags_clist {all}}}}, notag .default:n = true, nonumber .meta:n = notag, - AllowMultipleLabels .code:n = {\bool_if:NTF \l__ww_in_WithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} + AllowMultipleLabels .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} {\msg_redirect_name:nnn {witharrows} {Multiple~labels} {none}}}, AllowMultipleLabels .value_forbidden:n = true, - wrap-lines .code:n = {\bool_if:NTF \l__ww_in_WithArrows_bool - {\__ww_error:n {Option~will~be~ignored}} - {\tl_if_eq:nnTF {#1} {true} - {\bool_set_true:N \l__ww_wrap_lines_bool} - {\bool_set_false:N \l__ww_wrap_lines_bool}}}, + wrap-lines .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} + {\tl_if_eq:nnTF {#1} {true} + {\bool_set_true:N \l__wi_wrap_lines_bool} + {\bool_set_false:N \l__wi_wrap_lines_bool}}}, wrap-lines .default:n = true, - unknown .code:n = \__ww_error:n {Option~unknown} + tagged-lines .code:n = {\bool_if:NTF \l__wi_in_WithArrows_bool + {\__wi_error:n {Option~will~be~ignored}} + {\clist_set:Nn \l__wi_tags_clist {#1} + \clist_if_in:NnT \l__wi_tags_clist {first} + {\clist_remove_all:Nn \l__wi_tags_clist {first} + \clist_put_left:Nn \l__wi_tags_clist 1 }}}, + tagged-lines .value_required:n = true, + unknown .code:n = \__wi_error:n {Option~unknown} } \keys_define:nn {WithArrows/General} {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}}, tikz .initial:n = {}, tikz .value_required:n = true, rr .value_forbidden:n = true, - rr .code:n = \__ww_analyze_option_position:n 0 , + rr .code:n = \__wi_analyze_option_position:n 0 , ll .value_forbidden:n = true, - ll .code:n = \__ww_analyze_option_position:n 1 , + ll .code:n = \__wi_analyze_option_position:n 1 , rl .value_forbidden:n = true, - rl .code:n = \__ww_analyze_option_position:n 2 , + rl .code:n = \__wi_analyze_option_position:n 2 , lr .value_forbidden:n = true, - lr .code:n = \__ww_analyze_option_position:n 3 , + lr .code:n = \__wi_analyze_option_position:n 3 , i .value_forbidden:n = true, - i .code:n = \__ww_analyze_option_position:n 5 , - xoffset .code:n = {\bool_if:nTF {\int_compare_p:nNn \l__ww_level_int = 3 && - \int_compare_p:nNn \l__ww_pos_arrows_int > 5} - {\__ww_error:n {Option~incompatible~with~"group(s)"}} - {\dim_set:Nn \l__ww_xoffset_dim {#1}}} , + i .code:n = \__wi_analyze_option_position:n 5 , + xoffset .code:n = {\bool_if:nTF {\int_compare_p:nNn \l__wi_level_int = 3 && + \int_compare_p:nNn \l__wi_pos_arrows_int > 5} + {\__wi_error:n {Option~incompatible~with~"group(s)"}} + {\dim_set:Nn \l__wi_xoffset_dim {#1}}} , xoffset .value_required:n = true, - jot .code:n = {\int_compare:nNnTF \l__ww_level_int = 2 + jot .code:n = {\int_compare:nNnTF \l__wi_level_int = 2 {\dim_set:Nn \jot {#1}} - {\__ww_error:n {Option~will~be~ignored}}} , + {\__wi_error:n {Option~will~be~ignored}}} , jot .value_required:n = true, - interline .code:n = {\int_compare:nNnTF \l__ww_level_int = 2 - {\skip_set:Nn \l__ww_interline_skip {#1}} - {\__ww_error:n {Option~will~be~ignored}}} , + interline .code:n = {\int_compare:nNnTF \l__wi_level_int = 2 + {\skip_set:Nn \l__wi_interline_skip {#1}} + {\__wi_error:n {Option~will~be~ignored}}} , interline .value_required:n = true, - jump .code:n = \__ww_error:n {Option~will~be~ignored} , - unknown .code:n = \__ww_error:n {Option~unknown} + jump .code:n = {\int_compare:nNnF \l__wi_level_int = 3 + {\__wi_error:n {Option~will~be~ignored}}} , + unknown .code:n = \__wi_error:n {Option~unknown} } -\keys_define:nn {WithArrows/jump} - {jump .code:n = {\int_set:Nn \l__ww_jump_int {#1} - \int_compare:nNnF \l__ww_jump_int > 0 - {\__ww_error:n {The~option~"jump"~must~be~non~negative}}} , - jump .value_required:n = true} -\cs_new_protected:Nn \__ww_analyze_option_position:n - {\int_compare:nNnT \l__ww_previous_pos_arrows_int > {-1} - {\__ww_error:n {Two~options~are~incompatible}} - \int_set:Nn \l__ww_previous_pos_arrows_int {#1} - \bool_if:nTF { \int_compare_p:nNn \l__ww_level_int = 3 && - \int_compare_p:nNn \l__ww_pos_arrows_int > 5} - {\__ww_error:n {Option~incompatible~with~"group(s)"}} - {\int_set:Nn \l__ww_pos_arrows_int {#1}}} +\keys_define:nn {WithArrows/Arrow} + {jump .code:n = {\int_set:Nn \l__wi_jump_int {#1} + \int_compare:nNnF \l__wi_jump_int > 0 + {\__wi_error:n {The~option~"jump"~must~be~non~negative}}} , + jump .value_required:n = true, + rr .value_forbidden:n = true, + rr .code:n = \__wi_analyze_option_position:n 0 , + ll .value_forbidden:n = true, + ll .code:n = \__wi_analyze_option_position:n 1 , + rl .value_forbidden:n = true, + rl .code:n = \__wi_analyze_option_position:n 2 , + lr .value_forbidden:n = true, + lr .code:n = \__wi_analyze_option_position:n 3 , + i .value_forbidden:n = true, + i .code:n = \__wi_analyze_option_position:n 5 } +\cs_new_protected:Nn \__wi_analyze_option_position:n + {\int_compare:nNnT \l__wi_previous_pos_arrows_int > {-1} + {\__wi_error:n {Two~options~are~incompatible}} + \int_set:Nn \l__wi_previous_pos_arrows_int {#1} + \int_set:Nn \l__wi_pos_arrows_int {#1}} \NewDocumentCommand \WithArrowsOptions {m} - {\int_set:Nn \l__ww_previous_pos_arrows_int {-1} + {\int_set:Nn \l__wi_previous_pos_arrows_int {-1} \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl \keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl} -\NewDocumentCommand \__ww_Arrow {O{} m O{}} +\NewDocumentCommand \__wi_Arrow {O{} m O{}} { - \int_gincr:N \g__ww_arrow_int - \int_zero_new:N \l__ww_jump_int - \int_set:Nn \l__ww_jump_int 1 - \keys_set_known:nnN {WithArrows/jump} {#1,#3} \l_tmpa_tl - \prop_put:NnV \l_tmpa_prop {initial} \g__ww_line_int - \int_set:Nn \l_tmpa_int {\g__ww_line_int + \l__ww_jump_int} + \int_gincr:N \g__wi_arrow_int + \int_set:Nn \l__wi_previous_pos_arrows_int {-1} + \int_set:Nn \l__wi_pos_arrows_int {-1} + \int_set:Nn \l__wi_level_int 3 + \keys_set_known:nnN {WithArrows/Arrow} {#1,#3} \l_tmpa_tl + \prop_put:NnV \l_tmpa_prop {initial} \g__wi_line_int + \int_set:Nn \l_tmpa_int {\g__wi_line_int + \l__wi_jump_int} \prop_put:NnV \l_tmpa_prop {final} \l_tmpa_int + \prop_put:NnV \l_tmpa_prop {position} \l__wi_pos_arrows_int \prop_put:NnV \l_tmpa_prop {options} \l_tmpa_tl \prop_put:Nnn \l_tmpa_prop {label} {#2} \prop_gclear_new:c - {g__ww_arrow_\l__ww_prefix_str _\int_use:N\g__ww_arrow_int _prop} + {g__wi_arrow_\l__wi_prefix_str _\int_use:N\g__wi_arrow_int _prop} \prop_gset_eq:cN - {g__ww_arrow_\l__ww_prefix_str _\int_use:N\g__ww_arrow_int _prop} + {g__wi_arrow_\l__wi_prefix_str _\int_use:N\g__wi_arrow_int _prop} \l_tmpa_prop } -\cs_new_protected:Nn \__ww_Arrow_first_column: +\cs_new_protected:Nn \__wi_Arrow_first_column: {\tl_set:Nn \l_tmpa_tl {Arrow} - \__ww_error:n {Arrow~in~first~column} - \__ww_Arrow} -\cs_new_protected:Nn \__ww_pre_environment:n - { \seq_gput_right:NV \g__ww_arrow_int_seq \g__ww_arrow_int - \int_gzero:N \g__ww_arrow_int - \seq_gput_right:NV \g__ww_line_int_seq \g__ww_line_int - \int_gzero:N \g__ww_line_int - \seq_gput_right:NV \g__ww_line_bis_int_seq \g__ww_line_bis_int - \int_gzero:N \g__ww_line_bis_int - \seq_gput_right:Nn \g__ww_position_in_the_tree_seq 1 - \seq_set_eq:NN \l_tmpa_seq \g__ww_position_in_the_tree_seq + \__wi_error:n {Arrow~in~first~column} + \__wi_Arrow} +\cs_new_protected:Nn \__wi_pre_environment:n + { \seq_gput_right:NV \g__wi_arrow_int_seq \g__wi_arrow_int + \int_gzero:N \g__wi_arrow_int + \seq_gput_right:NV \g__wi_line_int_seq \g__wi_line_int + \int_gzero:N \g__wi_line_int + \seq_gput_right:Nn \g__wi_position_in_the_tree_seq 1 + \seq_set_eq:NN \l_tmpa_seq \g__wi_position_in_the_tree_seq \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl - \str_clear_new:N \l__ww_prefix_str - \str_set:Nx \l__ww_prefix_str {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}} - \cs_set_eq:NN \\ \__ww_cr: + \str_clear_new:N \l__wi_prefix_str + \str_set:Nx \l__wi_prefix_str {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}} + \cs_set_eq:NN \\ \__wi_cr: \dim_zero:N \mathsurround - \int_zero_new:N \l__ww_initial_int - \int_zero_new:N \l__ww_final_int - \int_zero_new:N \l__ww_arrow_int - \skip_zero:N \l__ww_interline_skip - \tl_clear_new:N \l__ww_code_before_tl - \tl_clear_new:N \l__ww_code_after_tl - \int_set:Nn \l__ww_previous_pos_arrows_int {-1} - \int_set:Nn \l__ww_level_int 2 + \int_zero_new:N \l__wi_initial_int + \int_zero_new:N \l__wi_final_int + \int_zero_new:N \l__wi_arrow_int + \int_zero_new:N \l__wi_pos_of_arrow_int + \int_zero_new:N \l__wi_jump_int + \int_set:Nn \l__wi_jump_int 1 + \seq_clear_new:N \l__wi_labels_seq + \__wi_bool_new:N \l__wi_tag_next_line_bool + \skip_zero:N \l__wi_interline_skip + \tl_clear_new:N \l__wi_code_before_tl + \tl_clear_new:N \l__wi_code_after_tl + \int_set:Nn \l__wi_previous_pos_arrows_int {-1} + \int_set:Nn \l__wi_level_int 2 \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl \keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl - \bool_if:NT \g__ww_footnote_bool {\begin{savenotes}} - \l__ww_code_before_tl - \cs_set_eq:cN \l__ww_CommandName_tl \__ww_Arrow} + \bool_if:NT \g__wi_footnote_bool {\savenotes} + \l__wi_code_before_tl + \cs_set_eq:cN \l__wi_CommandName_tl \__wi_Arrow} \NewDocumentEnvironment {WithArrows} {O{}} - { \bool_set_true:N \l__ww_in_WithArrows_bool + { \bool_set_true:N \l__wi_in_WithArrows_bool + \bool_set_false:N \l__wi_in_DispWithArrows_bool \reverse_if:N \if_mode_math: - \__ww_error:n {{WithArrows}~used~outside~math~mode} + \__wi_error:n {{WithArrows}~used~outside~math~mode} \fi: - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{WithArrows}} - {\label}} - \__ww_pre_environment:n {#1} - \int_case:nn \l__ww_pos_env_int - {0 {\vtop} - 1 {\vcenter} - 2 {\vbox}} + \__wi_pre_environment:n {#1} + \cs_set_eq:NN \notag \__wi_notag: + \cs_set_eq:NN \nonumber \__wi_notag: + \cs_set_eq:NN \tag \__wi_tag + \cs_set_eq:NN \label \__wi_label:n + \cs_set_eq:NN \tagnextline \__wi_tagnextline: + \int_case:nn \l__wi_pos_env_int + {0 \vtop + 1 \vcenter + 2 \vbox} \bgroup \spread@equation \ialign\bgroup - \int_gincr:N \g__ww_line_int - \cs_set_eq:cN \l__ww_CommandName_tl \__ww_Arrow_first_column: + \int_gincr:N \g__wi_line_int + \cs_set_eq:cN \l__wi_CommandName_tl \__wi_Arrow_first_column: + \bool_set_true:N \l__wi_in_first_column_bool \strut\hfil - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {##}$ + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {##}$ & - \int_gincr:N \g__ww_line_bis_int - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {{}##}$ + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {{}##}$ \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-l, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-l}} ] {} ; + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-l, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-l}} ] {} ; \hfil \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-r, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-r}} ] {} ; - \bool_if:NT \l__ww_shownodenames_bool - {\hbox_overlap_right:n {\small wa-\l__ww_prefix_str - -\int_use:N\g__ww_line_int}} - && \__ww_error:n {Third~column~in~an~environment~{WithArrows}} - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {##}$ + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-r, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-r}} ] {} ; + \bool_if:NT \l__wi_shownodenames_bool + {\hbox_overlap_right:n {\small wa-\l__wi_prefix_str + -\int_use:N\g__wi_line_int}} + && \__wi_error:n {Third~column~in~an~environment~{WithArrows}} + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {##}$ \cr } {\crcr \egroup \egroup - \__ww_post_environment: - \bool_if:NT \g__ww_footnote_bool {\end{savenotes}} + \__wi_post_environment: + \bool_if:NT \g__wi_footnote_bool {\endsavenotes} } -\cs_new_protected:Nn \__ww_post_environment: - {\int_compare:nNnT \g__ww_line_bis_int < \g__ww_line_int - {\__ww_error:n {All~lines~must~have~an~ampersand}} - \cs_set:Npn \WithArrowsRightX {\g__ww_right_x_dim} - \int_compare:nNnT \g__ww_arrow_int > 0 - {\int_compare:nNnTF \l__ww_pos_arrows_int > 5 - \__ww_draw_arrows: - {\__ww_draw_arrows:nn 1 \g__ww_arrow_int}} +\cs_new_protected:Nn \__wi_post_environment: + {\cs_set:Npn \WithArrowsRightX {\g__wi_right_x_dim} + \int_compare:nNnT \g__wi_arrow_int > 0 + {\int_compare:nNnTF \l__wi_pos_arrows_int > 5 + \__wi_draw_arrows: + {\__wi_draw_arrows:nn 1 \g__wi_arrow_int}} \group_begin: - \tikzset{every~picture/.style = __ww_standard} - \cs_set:Npn \WithArrowsNbLines {\int_use:N \g__ww_line_int} - \cs_set_eq:NN \MultiArrow \__ww_MultiArrow:nn - \cs_set_eq:cN \l__ww_CommandName_tl \__ww_Arrow_code_after - \l__ww_code_after_tl + \tikzset{every~picture/.style = __wi_standard} + \cs_set:Npn \WithArrowsNbLines {\int_use:N \g__wi_line_int} + \cs_set_eq:NN \MultiArrow \__wi_MultiArrow:nn + \cs_set_eq:cN \l__wi_CommandName_tl \__wi_Arrow_code_after + \l__wi_code_after_tl \group_end: - \seq_gpop_right:NN \g__ww_position_in_the_tree_seq \l_tmpa_tl - \seq_gpop_right:NN \g__ww_position_in_the_tree_seq \l_tmpa_tl - \seq_gput_right:Nx \g__ww_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl+1}} - \int_compare:nNnT {\seq_count:N \g__ww_position_in_the_tree_seq} = 1 - {\int_gincr:N \g__ww_last_env_int} - \seq_gpop_right:NN \g__ww_arrow_int_seq {\l_tmpa_tl} - \int_gset:Nn \g__ww_arrow_int {\l_tmpa_tl} - \seq_gpop_right:NN \g__ww_line_int_seq \l_tmpa_tl - \int_gset:Nn \g__ww_line_int {\l_tmpa_tl} - \seq_gpop_right:NN \g__ww_line_bis_int_seq \l_tmpa_tl - \int_gset:Nn \g__ww_line_bis_int {\l_tmpa_tl} + \seq_gpop_right:NN \g__wi_position_in_the_tree_seq \l_tmpa_tl + \seq_gpop_right:NN \g__wi_position_in_the_tree_seq \l_tmpa_tl + \seq_gput_right:Nx \g__wi_position_in_the_tree_seq + {\int_eval:n {\l_tmpa_tl+1}} + \int_compare:nNnT {\seq_count:N \g__wi_position_in_the_tree_seq} = 1 + {\int_gincr:N \g__wi_last_env_int} + \seq_gpop_right:NN \g__wi_arrow_int_seq {\l_tmpa_tl} + \int_gset:Nn \g__wi_arrow_int {\l_tmpa_tl} + \seq_gpop_right:NN \g__wi_line_int_seq \l_tmpa_tl + \int_gset:Nn \g__wi_line_int {\l_tmpa_tl} } -\cs_new_protected:Nn \__ww_cr: +\cs_new_protected:Nn \__wi_cr: {\scan_stop: + \bool_if:NT \l__wi_in_first_column_bool {& {} } \group_align_safe_begin: - \peek_meaning_remove:NTF * \__ww_cr_i: \__ww_cr_i:} -\cs_new_protected:Nn \__ww_cr_i: - {\peek_meaning:NTF [ {\__ww_cr_ii:} {\__ww_cr_ii:[\c_zero_dim]} } -\cs_new_protected:Npn \__ww_cr_ii:[#1] + \peek_meaning_remove:NTF * \__wi_cr_i: \__wi_cr_i:} +\cs_new_protected:Nn \__wi_cr_i: + {\peek_meaning:NTF [ {\__wi_cr_ii:} {\__wi_cr_ii:[\c_zero_dim]} } +\cs_new_protected:Npn \__wi_cr_ii:[#1] {\group_align_safe_end: - \bool_if:NT \l__ww_in_DispWithArrows_bool - {\bool_if:NTF \l__ww_notag_bool - {& \tikz [__ww_standard] \coordinate (\int_use:N\g__ww_line_int-v) ; } + \bool_if:NT \l__wi_in_DispWithArrows_bool + {\clist_if_in:NnTF \l__wi_tags_clist {all} { - \tl_if_empty:NT \l__ww_tag_tl + \tl_if_empty:NT \l__wi_tag_tl {\int_gincr:N \c@equation} \cs_gset:Npx \g_tmpa_tl - {\tl_if_empty:NTF \l__ww_tag_tl + {\tl_if_empty:NTF \l__wi_tag_tl \theequation - \l__ww_tag_tl} - \seq_if_empty:NF \l__ww_labels_seq + \l__wi_tag_tl} + \seq_if_empty:NF \l__wi_labels_seq { \cs_set:Npx \@currentlabel {\p@equation \g_tmpa_tl} - \bool_if:NT \c__ww_hyperref_loaded_bool + \bool_if:NT \c__wi_hyperref_loaded_bool {\cs_set:Npn \This@name {equation} \hyper@refstepcounter{equation}} - \bool_if:NT \c__ww_cleveref_loaded_bool + \bool_if:NT \c__wi_cleveref_loaded_bool {\cref@constructprefix{equation}{\cref@result} \@ifundefined{cref@equation@alias} {\def\@tempa{equation}} @@ -461,35 +482,101 @@ \protected@edef\cref@currentlabel {[\@tempa][\arabic{equation}][\cref@result] \p@equation \g_tmpa_tl}} - \bool_if:NT \c__ww_typedref_loaded_bool + \bool_if:NT \c__wi_typedref_loaded_bool {\cs_set:Npn \sr@name {equation}} - \seq_map_function:NN \l__ww_labels_seq \__ww_old_label} - \bool_gset_eq:NN \g_tmpa_bool \l__ww_tag_star_bool - & \cs_set_eq:NN \theequation \g_tmpa_tl - \bool_if:NT \g_tmpa_bool {\cs_set:Npn \tagform@ {}} + \seq_map_function:NN \l__wi_labels_seq \__wi_old_label} + \__wi_save:N \l__wi_tag_star_bool + \__wi_save:N \l__wi_qedhere_bool + \bool_if:NT \l__wi_tag_next_line_bool + { \openup -\jot + \bool_set_false:N \l__wi_tag_next_line_bool + \notag \\ & } + & \__wi_restore:N \l__wi_tag_star_bool + \__wi_restore:N \l__wi_qedhere_bool + \bool_if:NT \l__wi_qedhere_bool + {\hbox_overlap_left:n {\__wi_qedhere_i:}} + \cs_set_eq:NN \theequation \g_tmpa_tl + \bool_if:NT \l__wi_tag_star_bool {\cs_set:Npn \tagform@ {}} \hbox_overlap_left:n - {\bool_if:NF \c__ww_leqno_bool - {\tikz [__ww_standard] \coordinate (\int_use:N\g__ww_line_int-v) ;} + {\bool_if:NF \c__wi_leqno_bool + {\tikz [__wi_standard] \coordinate (\int_use:N\g__wi_line_int-v) ;} \quad \@eqnnum } - \bool_if:NT \c__ww_leqno_bool - {\tikz [__ww_standard] \coordinate (\int_use:N \g__ww_line_int-v) ;} - }} - \cr\noalign{\skip_vertical:n {#1 + \l__ww_interline_skip} + \bool_if:NT \c__wi_leqno_bool + {\tikz [__wi_standard] \coordinate (\int_use:N \g__wi_line_int-v) ;}} + {\__wi_save:N \l__wi_qedhere_bool + & \__wi_restore:N \l__wi_qedhere_bool + \bool_if:NT \l__wi_qedhere_bool + {\hbox_overlap_left:n {\__wi_qedhere_i:}} + \tikz [__wi_standard] \coordinate (\int_use:N\g__wi_line_int-v) ; } + } + \cr\noalign{\skip_vertical:n {#1 + \l__wi_interline_skip} \scan_stop:}} +\cs_new_protected:Nn \__wi_if_in_second_col_of_disp:nn + {\bool_if:NTF \l__wi_in_WithArrows_bool + {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{WithArrows}} + {#1}} + {\bool_if:NTF \l__wi_in_first_column_bool + {\msg_error:nnn {witharrows} + {Command~not~allowed~in~{DispWithArrows}} + {#1}} + {#2}}} +\cs_new_protected:Nn \__wi_notag: + {\__wi_if_in_second_col_of_disp:nn {\notag} + {\clist_clear:N \l__wi_tags_clist}} +\NewDocumentCommand \__wi_tag {sm} + {\__wi_if_in_second_col_of_disp:nn {\tag} + {\tl_if_empty:NF \l__wi_tag_tl + {\msg_error:nnn {witharrows} {Multiple~tags} {#2}} + \clist_set:Nn \l__wi_tags_clist {all} + \bool_if:nT \c__wi_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\MH_if_boolean:nF {show_manual_tags} + {\clist_clear:N \l__wi_tags_clist}}} + \tl_set:Nn \l__wi_tag_tl {#2} + \bool_set:Nn \l__wi_tag_star_bool {#1} + \bool_if:nT {#1 && ! \bool_if_p:N \c__wi_amsmath_loaded_bool} + { \__wi_error:n {tag*~without~amsmath} }} + } +\cs_new_protected:Nn \__wi_label:n + {\__wi_if_in_second_col_of_disp:nn {\label} + {\seq_if_empty:NF \l__wi_labels_seq + {\bool_if:NTF \c__wi_cleveref_loaded_bool + {\__wi_error:n {Multiple~labels~with~cleveref}} + {\__wi_error:n {Multiple~labels}}} + \seq_put_right:Nn \l__wi_labels_seq {#1} + \bool_if:nT \c__wi_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\cs_if_exist:cTF {MT_r_#1} + {\clist_set:Nn \l__wi_tags_clist {all}} + {\clist_clear:N \l__wi_tags_clist}}} + \bool_if:nT \c__wi_autonum_loaded_bool + {\cs_if_exist:cTF {autonum@#1Referenced} + {\clist_set:Nn \l__wi_tags_clist {all}} + {\clist_clear:N \l__wi_tags_clist}}}} +\cs_new_protected:Nn \__wi_tagnextline: + {\__wi_if_in_second_col_of_disp:nn {\tagnextline} + {\bool_set_true:N \l__wi_tag_next_line_bool}} +\bool_new:N \l__wi_qedhere_bool +\cs_new_protected:Nn \__wi_qedhere: {\bool_set_true:N \l__wi_qedhere_bool} +\cs_new_protected:Nn \__wi_qedhere_i: {\group_begin: + \cs_set_eq:NN \qed \qedsymbol + \cs_set_eq:NN \qed@elt \setQED@elt + \QED@stack\relax\relax + \group_end: } \NewDocumentEnvironment {DispWithArrows} {O{}} { - \bool_if:nT \c__ww_mathtools_loaded_bool + \bool_if:nT \c__wi_mathtools_loaded_bool {\MH_if_boolean:nT {show_only_refs} {\MT_showonlyrefs_false: - \MH_set_boolean_T:n {show_only_refs} - \bool_set_true:N \l__ww_notag_bool}} - \bool_if:NT \c__ww_amsmath_loaded_bool \intertext@ + \MH_set_boolean_T:n {show_only_refs}}} + \bool_if:NT \c__wi_amsmath_loaded_bool \intertext@ \if_mode_math: - \__ww_error:n {{DispWithArrows}~used~in~math~mode} + \__wi_error:n {{DispWithArrows}~used~in~math~mode} \fi: - \bool_set_true:N \l__ww_in_DispWithArrows_bool - \__ww_pre_environment:n {#1} + \bool_set_true:N \l__wi_in_DispWithArrows_bool + \__wi_pre_environment:n {#1} \if_mode_vertical: \nointerlineskip \makebox[.6\linewidth]{} @@ -497,282 +584,261 @@ $$ \vcenter \bgroup \spread@equation - \bool_if:NTF \l__ww_fleqn_bool + \bool_if:NTF \l__wi_fleqn_bool {\tabskip = \c_zero_skip} {\tabskip = 0 pt plus 1000 pt minus 1000 pt} - \bool_if:NTF \c__ww_amsmath_loaded_bool - {\cs_set_eq:NN \__ww_old_label \ltx@label} - {\cs_set_eq:NN \__ww_old_label \label} - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\label}} + \cs_set_eq:NN \__wi_old_label \label + \cs_set_eq:NN \notag \__wi_notag: + \cs_set_eq:NN \nonumber \__wi_notag: + \cs_set_eq:NN \tag \__wi_tag + \cs_set_eq:NN \label \__wi_label:n + \cs_set_eq:NN \tagnextline \__wi_tagnextline: \halign to \displaywidth \bgroup - \int_gincr:N \g__ww_line_int - \cs_set_eq:cN \l__ww_CommandName_tl \__ww_Arrow_first_column: + \int_gincr:N \g__wi_line_int + \cs_set_eq:cN \l__wi_CommandName_tl \__wi_Arrow_first_column: + \bool_set_true:N \l__wi_in_first_column_bool \strut - \bool_if:NT \l__ww_fleqn_bool - {\skip_horizontal:n \l__ww_mathindent_dim} + \bool_if:NT \l__wi_fleqn_bool + {\skip_horizontal:n \l__wi_mathindent_dim} \hfil - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {##}$ + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {##}$ \tabskip = \c_zero_skip & - \cs_set:Npn \notag {\bool_set_true:N \l__ww_notag_bool} - \cs_set_eq:NN \nonumber \notag - \cs_set_eq:NN \tag \__ww_tag - \cs_set_eq:NN \label \__ww_label:n - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {{}##}$ + \clist_if_in:NVT \l__wi_tags_clist \g__wi_line_int + {\clist_set:Nn \l__wi_tags_clist {all}} + \bool_if:NT \c__wi_amsthm_loaded_bool {\cs_set_eq:NN \qedhere \__wi_qedhere:} + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {{}##}$ \tabskip = 0 pt plus 1000 pt minus 1000 pt - \int_gincr:N \g__ww_line_bis_int \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-l, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-l}} ] {} ; + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-l, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-l}} ] {} ; \hfil \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-r, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-r}} ] {} ; - \bool_if:NT \l__ww_shownodenames_bool - {\hbox_overlap_right:n {\small wa-\l__ww_prefix_str - -\int_use:N\g__ww_line_int}} + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-r, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-r}} ] {} ; + \bool_if:NT \l__wi_shownodenames_bool + {\hbox_overlap_right:n {\small wa-\l__wi_prefix_str + -\int_use:N\g__wi_line_int}} & ## \tabskip = \c_zero_skip - && \__ww_error:n {Third~column~in~an~environment~{DispWithArrows}} + && \__wi_error:n {Third~column~in~an~environment~{DispWithArrows}} \iffalse ## \fi \cr} - {\\ + {\clist_if_in:NnT \l__wi_tags_clist {last} + {\clist_set:Nn \l__wi_tags_clist {all}} + \\ \egroup \egroup - \bool_if:NT \l__ww_in_DispWithArrows_bool - {\dim_gzero_new:N \g__ww_right_x_dim - \dim_gset:Nn \g__ww_right_x_dim \c_max_dim - \begin{tikzpicture} [__ww_standard] - \int_step_variable:nnnNn 1 1 \g__ww_line_int \l_tmpa_int + \bool_if:NT \l__wi_in_DispWithArrows_bool + {\dim_gzero_new:N \g__wi_right_x_dim + \dim_gset:Nn \g__wi_right_x_dim \c_max_dim + \begin{tikzpicture} [__wi_standard] + \int_step_variable:nnnNn 1 1 \g__wi_line_int \l_tmpa_int {\tikz@parse@node\pgfutil@firstofone (\l_tmpa_int-v) \dim_set:Nn \l_tmpa_dim \pgf@x - \dim_compare:nNnT \l_tmpa_dim < \g__ww_right_x_dim - {\dim_gset:Nn \g__ww_right_x_dim \l_tmpa_dim} } + \dim_compare:nNnT \l_tmpa_dim < \g__wi_right_x_dim + {\dim_gset:Nn \g__wi_right_x_dim \l_tmpa_dim} } \end{tikzpicture}} - \__ww_post_environment: - \bool_if:nT \c__ww_mathtools_loaded_bool + \__wi_post_environment: + \bool_if:nT \c__wi_mathtools_loaded_bool {\MH_if_boolean:nT {show_only_refs} \MT_showonlyrefs_true:} $$ - \bool_if:NT \g__ww_footnote_bool {\end{savenotes}} + \bool_if:NT \g__wi_footnote_bool {\endsavenotes} \ignorespacesafterend } -\NewDocumentCommand \__ww_tag {sm} - {\tl_if_empty:NF \l__ww_tag_tl - {\msg_error:nnn {witharrows} {Multiple~tags} {#2}} - \bool_set_false:N \l__ww_notag_bool - \bool_if:nT \c__ww_mathtools_loaded_bool - {\MH_if_boolean:nT {show_only_refs} - {\MH_if_boolean:nF {show_manual_tags} - {\bool_set_true:N \l__ww_notag_bool}}} - \tl_set:Nn \l__ww_tag_tl {#2} - \bool_set:Nn \l__ww_tag_star_bool {#1} - \bool_if:nT {#1 && ! \bool_if_p:N \c__ww_amsmath_loaded_bool} - { \__ww_error:n {tag*~without~amsmath} } - } \NewDocumentEnvironment {DispWithArrows*} {} {\WithArrowsOptions{notag} \DispWithArrows} {\endDispWithArrows} -\cs_new_protected:Nn \__ww_draw_arrows: +\cs_new_protected:Nn \__wi_draw_arrows: { \group_begin: - \int_zero_new:N \l__ww_first_arrow_of_group_int - \int_zero_new:N \l__ww_first_line_of_group_int - \int_zero_new:N \l__ww_last_line_of_group_int - \bool_set_true:N \l__ww_new_group_bool - \int_set:Nn \l__ww_arrow_int 1 - \int_until_do:nNnn \l__ww_arrow_int > \g__ww_arrow_int + \int_zero_new:N \l__wi_first_arrow_of_group_int + \int_zero_new:N \l__wi_first_line_of_group_int + \int_zero_new:N \l__wi_last_line_of_group_int + \bool_set_true:N \l__wi_new_group_bool + \int_set:Nn \l__wi_arrow_int 1 + \int_until_do:nNnn \l__wi_arrow_int > \g__wi_arrow_int { - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str _\int_use:N\l__ww_arrow_int _prop} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} {initial} \l_tmpa_tl - \int_set:Nn \l__ww_initial_int {\l_tmpa_tl} - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str _\int_use:N\l__ww_arrow_int _prop} + \int_set:Nn \l__wi_initial_int {\l_tmpa_tl} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} {final} \l_tmpa_tl - \int_set:Nn \l__ww_final_int {\l_tmpa_tl} - \bool_if:nT { \int_compare_p:nNn \l__ww_pos_arrows_int = 7 - && \int_compare_p:nNn \l__ww_arrow_int > 1 - && \int_compare_p:nNn - \l__ww_initial_int > \l__ww_last_line_of_group_int} - {\__ww_draw_arrows:nn \l__ww_first_arrow_of_group_int {\l__ww_arrow_int - 1} - \bool_set_true:N \l__ww_new_group_bool} - \bool_if:nTF \l__ww_new_group_bool - {\bool_set_false:N \l__ww_new_group_bool - \int_set:Nn \l__ww_first_arrow_of_group_int \l__ww_arrow_int - \int_set:Nn \l__ww_first_line_of_group_int \l__ww_initial_int - \int_set:Nn \l__ww_last_line_of_group_int \l__ww_final_int - \begin{tikzpicture} [__ww_standard] - \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__ww_initial_int-l) - \dim_gset:Nn \g__ww_x_dim \pgf@x - \end{tikzpicture} - } - {\int_set:Nn \l__ww_last_line_of_group_int - {\int_max:nn \l__ww_last_line_of_group_int \l__ww_final_int}} - \__ww_update_x_value:nn \l__ww_initial_int \l__ww_final_int - \int_incr:N \l__ww_arrow_int + \int_set:Nn \l__wi_final_int {\l_tmpa_tl} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} + {position} \l_tmpa_tl + \int_set:Nn \l__wi_pos_of_arrow_int \l_tmpa_tl + \int_compare:nNnTF \l__wi_final_int > \g__wi_line_int + {\__wi_error:n {Too~few~lines~for~an~arrow}} + {\bool_if:nT { \int_compare_p:nNn \l__wi_pos_arrows_int = 7 + && \int_compare_p:nNn \l__wi_arrow_int > 1 + && \int_compare_p:nNn + \l__wi_initial_int > \l__wi_last_line_of_group_int} + {\__wi_draw_arrows:nn \l__wi_first_arrow_of_group_int {\l__wi_arrow_int - 1} + \bool_set_true:N \l__wi_new_group_bool} + \bool_if:nTF \l__wi_new_group_bool + {\bool_set_false:N \l__wi_new_group_bool + \int_set:Nn \l__wi_first_arrow_of_group_int \l__wi_arrow_int + \int_set:Nn \l__wi_first_line_of_group_int \l__wi_initial_int + \int_set:Nn \l__wi_last_line_of_group_int \l__wi_final_int + \dim_set:Nn \l__wi_x_dim {-\c_max_dim} + } + {\int_compare:nNnT \l__wi_pos_of_arrow_int = {-1} + {\int_set:Nn \l__wi_last_line_of_group_int + {\int_max:nn \l__wi_last_line_of_group_int \l__wi_final_int}}} + \int_compare:nNnT \l__wi_pos_of_arrow_int = {-1} + {\__wi_update_x_value:nn \l__wi_initial_int \l__wi_final_int} } + \int_incr:N \l__wi_arrow_int } - \__ww_draw_arrows:nn \l__ww_first_arrow_of_group_int \g__ww_arrow_int + \__wi_draw_arrows:nn \l__wi_first_arrow_of_group_int \g__wi_arrow_int \group_end: } \cs_generate_variant:Nn \keys_set:nn {no} -\cs_new_protected:Nn \__ww_keys_set: {\keys_set:no {WithArrows/General}} -\cs_new_protected:Nn \__ww_draw_arrows:nn +\cs_new_protected:Nn \__wi_keys_set: {\keys_set:no {WithArrows/General}} +\cs_new_protected:Nn \__wi_draw_arrows:nn {\group_begin: - \int_zero_new:N \l__ww_first_arrow_int - \int_set:Nn \l__ww_first_arrow_int {#1} - \int_zero_new:N \l__ww_last_arrow_int - \int_set:Nn \l__ww_last_arrow_int {#2} - \int_set:Nn \l__ww_arrow_int \l__ww_first_arrow_int - \int_until_do:nNnn \l__ww_arrow_int > \l__ww_last_arrow_int + \int_zero_new:N \l__wi_first_arrow_int + \int_set:Nn \l__wi_first_arrow_int {#1} + \int_zero_new:N \l__wi_last_arrow_int + \int_set:Nn \l__wi_last_arrow_int {#2} + \int_set:Nn \l__wi_arrow_int \l__wi_first_arrow_int + \int_until_do:nNnn \l__wi_arrow_int > \l__wi_last_arrow_int { - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str _\int_use:N\l__ww_arrow_int _prop} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} {initial} \l_tmpa_tl - \int_set:Nn \l__ww_initial_int {\l_tmpa_tl} - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str _\int_use:N\l__ww_arrow_int _prop} + \int_set:Nn \l__wi_initial_int {\l_tmpa_tl} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} {final} \l_tmpa_tl - \int_set:Nn \l__ww_final_int {\l_tmpa_tl} - \int_compare:nNnTF \l__ww_final_int > \g__ww_line_int - {\__ww_error:n {Too~few~lines~for~an~arrow}} - {\cs_if_free:cTF{pgf@sh@ns@wa-\l__ww_prefix_str-\int_use:N\l__ww_initial_int-l} - { \__ww_error:n {A~PGF~node~doesn't~exist} } - {\cs_if_free:cTF{pgf@sh@ns@wa-\l__ww_prefix_str-\int_use:N\l__ww_final_int-l} - { \__ww_error:n {A~PGF~node~doesn't~exist} } - {\__ww_draw_arrows_i:}}} - \int_incr:N \l__ww_arrow_int + \int_set:Nn \l__wi_final_int {\l_tmpa_tl} + \int_compare:nNnTF \l__wi_final_int > \g__wi_line_int + {\int_compare:nNnT \l__wi_pos_arrows_int < 6 + {\__wi_error:n {Too~few~lines~for~an~arrow}}} + \__wi_draw_arrows_i: + \int_incr:N \l__wi_arrow_int } \group_end: } -\cs_new:Nn \__ww_draw_arrows_i: +\cs_new:Nn \__wi_draw_arrows_i: {\group_begin: - \int_set:Nn \l__ww_previous_pos_arrows_int {-1} - \int_set:Nn \l__ww_level_int 3 - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str - _\int_use:N\l__ww_arrow_int _prop} {options} \l_tmpa_tl + \int_set:Nn \l__wi_level_int 3 + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str + _\int_use:N\l__wi_arrow_int _prop} {options} \l_tmpa_tl \exp_args:NNo \exp_args:No - \__ww_keys_set: {\l_tmpa_tl,tikz={xshift = \l__ww_xoffset_dim}} - \bool_set_false:N \l__ww_initial_r_bool - \bool_set_false:N \l__ww_final_r_bool - \int_case:nn \l__ww_pos_arrows_int - {0 {\bool_set_true:N \l__ww_initial_r_bool - \bool_set_true:N \l__ww_final_r_bool} - 2 {\bool_set_true:N \l__ww_initial_r_bool} - 3 {\bool_set_true:N \l__ww_final_r_bool}} - \int_compare:nNnT \l__ww_pos_arrows_int = 5 - { - \begin{tikzpicture} [__ww_standard] - \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__ww_initial_int-l) - \dim_gset:Nn \g__ww_x_dim \pgf@x - \end{tikzpicture} - \__ww_update_x_value:nn \l__ww_initial_int \l__ww_final_int - } - \tl_set:Nx \l__ww_initial_tl - {\int_use:N\l__ww_initial_int-\bool_if:NTF\l__ww_initial_r_bool rl .south} - \tl_set:Nx \l__ww_final_tl - {\int_use:N\l__ww_final_int-\bool_if:NTF\l__ww_final_r_bool rl .north} - \prop_get:cnN {g__ww_arrow_\l__ww_prefix_str _\int_use:N\l__ww_arrow_int _prop} + \__wi_keys_set: {\l_tmpa_tl,tikz={xshift = \l__wi_xoffset_dim}} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} + {position} \l_tmpa_tl + \int_set:Nn \l_tmpa_int \l_tmpa_tl + \int_compare:nNnF \l_tmpa_int = {-1} + {\int_set_eq:NN \l__wi_pos_arrows_int \l_tmpa_int} + \bool_set_false:N \l__wi_initial_r_bool + \bool_set_false:N \l__wi_final_r_bool + \int_case:nn \l__wi_pos_arrows_int + {0 {\bool_set_true:N \l__wi_initial_r_bool + \bool_set_true:N \l__wi_final_r_bool} + 2 {\bool_set_true:N \l__wi_initial_r_bool} + 3 {\bool_set_true:N \l__wi_final_r_bool}} + \int_compare:nNnT \l__wi_pos_arrows_int = 5 + { \dim_set:Nn \l__wi_x_dim {-\c_max_dim} + \__wi_update_x_value:nn \l__wi_initial_int \l__wi_final_int } + \tl_set:Nx \l__wi_initial_tl + {\int_use:N\l__wi_initial_int-\bool_if:NTF\l__wi_initial_r_bool rl .south} + \tl_set:Nx \l__wi_final_tl + {\int_use:N\l__wi_final_int-\bool_if:NTF\l__wi_final_r_bool rl .north} + \prop_get:cnN {g__wi_arrow_\l__wi_prefix_str _\int_use:N\l__wi_arrow_int _prop} {label} \l_tmpa_tl - \int_compare:nNnTF \l__ww_pos_arrows_int < 5 - {\begin{tikzpicture} [__ww_standard] - \tikz@scan@one@point\pgfutil@firstofone(\l__ww_initial_tl) + \int_compare:nNnTF \l__wi_pos_arrows_int < 5 + {\begin{tikzpicture} [__wi_standard] + \tikz@scan@one@point\pgfutil@firstofone(\l__wi_initial_tl) \tl_gset:Nx \g_tmpa_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y} - \tikz@scan@one@point\pgfutil@firstofone(\l__ww_final_tl) + \tikz@scan@one@point\pgfutil@firstofone(\l__wi_final_tl) \tl_gset:Nx \g_tmpb_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y} \end{tikzpicture} } - {\begin{tikzpicture} [__ww_standard] - \tikz@scan@one@point\pgfutil@firstofone (\l__ww_initial_tl) - \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g__ww_x_dim , \dim_use:N \pgf@y} - \tikz@scan@one@point\pgfutil@firstofone (\l__ww_final_tl) - \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g__ww_x_dim , \dim_use:N \pgf@y} + {\begin{tikzpicture} [__wi_standard] + \tikz@scan@one@point\pgfutil@firstofone (\l__wi_initial_tl) + \tl_gset:Nx \g_tmpa_tl {\dim_use:N \l__wi_x_dim , \dim_use:N \pgf@y} + \tikz@scan@one@point\pgfutil@firstofone (\l__wi_final_tl) + \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l__wi_x_dim , \dim_use:N \pgf@y} \end{tikzpicture}} - \__ww_draw_arrow:nno {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl} + \__wi_draw_arrow:nno {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl} \group_end: } -\cs_new_protected:Nn \__ww_def_function_tmpa:n - {\cs_set:Nn \__ww_tmpa:nnn - {\begin{tikzpicture}[__ww_standard,every~path/.style = {WithArrows/arrow}] +\cs_new_protected:Nn \__wi_def_function_tmpa:n + {\cs_set:Nn \__wi_tmpa:nnn + {\begin{tikzpicture}[__wi_standard,every~path/.style = {WithArrows/arrow}] #1 \end{tikzpicture}}} -\cs_new_protected:Nn \__ww_draw_arrow:nnn +\cs_new_protected:Nn \__wi_draw_arrow:nnn { - \bool_if:nT {\l__ww_wrap_lines_bool && \l__ww_in_DispWithArrows_bool} - { \tl_set_eq:NN \l__ww_tikz_code_tl \c__ww_tikz_code_wrap_lines_tl } - \exp_args:No \__ww_def_function_tmpa:n \l__ww_tikz_code_tl - \__ww_tmpa:nnn {#1} {#2} {#3} } -\cs_generate_variant:Nn \__ww_draw_arrow:nnn {nno} -\tl_set:Nn \c__ww_tikz_code_wrap_lines_tl + \bool_if:nT {\l__wi_wrap_lines_bool && \l__wi_in_DispWithArrows_bool} + { \tl_set_eq:NN \l__wi_tikz_code_tl \c__wi_tikz_code_wrap_lines_tl } + \exp_args:No \__wi_def_function_tmpa:n \l__wi_tikz_code_tl + \__wi_tmpa:nnn {#1} {#2} {#3} } +\cs_generate_variant:Nn \__wi_draw_arrow:nnn {nno} +\tl_set:Nn \c__wi_tikz_code_wrap_lines_tl { - \draw (#1) to node (__ww_label) {} (#2) ; - \tikz@parse@node \pgfutil@firstofone (__ww_label.west) - \dim_set:Nn \l_tmpa_dim {\g__ww_right_x_dim - \pgf@x - 0.3333 em} + \draw (#1) to node (__wi_label) {} (#2) ; + \tikz@parse@node \pgfutil@firstofone (__wi_label.west) + \dim_set:Nn \l_tmpa_dim {\g__wi_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_compare:nNnT \l_tmpa_dim > \c_zero_dim - {\path (__ww_label.west) + {\path (__wi_label.west) node [anchor = west, text~width = \dim_use:N \l_tmpa_dim] {#3} ; } } -\cs_new_protected:Nn \__ww_update_x_value:nn +\cs_new_protected:Nn \__wi_update_x_value:nn {\int_step_inline:nnnn {#1} 1 {#2} - {\cs_if_exist:cT {pgf@sh@ns@wa-\l__ww_prefix_str-##1-l} - {\begin{tikzpicture} [__ww_standard] - \tikz@scan@one@point\pgfutil@firstofone (##1-l) - \dim_gset:Nn \g__ww_x_dim {\dim_max:nn \g__ww_x_dim \pgf@x} - \end{tikzpicture} } } } -\cs_new:Npn \WithArrowsLastEnv {\int_use:N \g__ww_last_env_int} + {\begin{tikzpicture} [__wi_standard] + \tikz@scan@one@point\pgfutil@firstofone (##1-l) + \dim_gset:Nn \g_tmpa_dim {\dim_max:nn \l__wi_x_dim \pgf@x} + \end{tikzpicture} + \dim_set_eq:NN \l__wi_x_dim \g_tmpa_dim } } +\cs_new:Npn \WithArrowsLastEnv {\int_use:N \g__wi_last_env_int} \keys_define:nn {WithArrows/CodeAfter} {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}} , tikz .value_required:n = true, rr .value_forbidden:n = true, - rr .code:n = \__ww_analyze_option_position:n 0 , + rr .code:n = \__wi_analyze_option_position:n 0 , ll .value_forbidden:n = true, - ll .code:n = \__ww_analyze_option_position:n 1 , + ll .code:n = \__wi_analyze_option_position:n 1 , rl .value_forbidden:n = true, - rl .code:n = \__ww_analyze_option_position:n 2 , + rl .code:n = \__wi_analyze_option_position:n 2 , lr .value_forbidden:n = true, - lr .code:n = \__ww_analyze_option_position:n 3 , + lr .code:n = \__wi_analyze_option_position:n 3 , v .value_forbidden:n = true, - v .code:n = \__ww_analyze_option_position:n 4 , - TikzCode .tl_set:N = \l__ww_tikz_code_tl, + v .code:n = \__wi_analyze_option_position:n 4 , + TikzCode .tl_set:N = \l__wi_tikz_code_tl, TikzCode .value_required:n = true, - xoffset .dim_set:N = \l__ww_xoffset_dim, + xoffset .dim_set:N = \l__wi_xoffset_dim, xoffset .value_required:n = true} -\NewDocumentCommand \__ww_Arrow_code_after {O{} mmm O{}} - {\int_set:Nn \l__ww_pos_arrows_int 1 - \int_set:Nn \l__ww_previous_pos_arrows_int {-1} +\NewDocumentCommand \__wi_Arrow_code_after {O{} mmm O{}} + {\int_set:Nn \l__wi_pos_arrows_int 1 + \int_set:Nn \l__wi_previous_pos_arrows_int {-1} \group_begin: - \int_set:Nn \l__ww_level_int 3 + \int_set:Nn \l__wi_level_int 3 \keys_set:nn {WithArrows/CodeAfter} - {#1,#5,tikz={xshift = \l__ww_xoffset_dim}} - \bool_set_false:N \l__ww_initial_r_bool - \bool_set_false:N \l__ww_final_r_bool - \int_case:nn \l__ww_pos_arrows_int - {0 {\bool_set_true:N \l__ww_initial_r_bool - \bool_set_true:N \l__ww_final_r_bool} - 2 {\bool_set_true:N \l__ww_initial_r_bool} - 3 {\bool_set_true:N \l__ww_final_r_bool}} - \cs_if_free:cTF {pgf@sh@ns@wa-\l__ww_prefix_str-#2-l} + {#1,#5,tikz={xshift = \l__wi_xoffset_dim}} + \bool_set_false:N \l__wi_initial_r_bool + \bool_set_false:N \l__wi_final_r_bool + \int_case:nn \l__wi_pos_arrows_int + {0 {\bool_set_true:N \l__wi_initial_r_bool + \bool_set_true:N \l__wi_final_r_bool} + 2 {\bool_set_true:N \l__wi_initial_r_bool} + 3 {\bool_set_true:N \l__wi_final_r_bool}} + \cs_if_free:cTF {pgf@sh@ns@wa-\l__wi_prefix_str-#2-l} {\msg_error:nnx {witharrows} {Wrong~line~specification~in~Arrow} {#2}} - {\cs_if_free:cTF {pgf@sh@ns@wa-\l__ww_prefix_str-#3-l} + {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wi_prefix_str-#3-l} {\msg_error:nnx {witharrows} {Wrong~line~specification~in~Arrow} {#3}} - {\int_compare:nNnTF \l__ww_pos_arrows_int = 4 - {\begin{tikzpicture} [__ww_standard] + {\int_compare:nNnTF \l__wi_pos_arrows_int = 4 + {\begin{tikzpicture} [__wi_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 @@ -783,26 +849,26 @@ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \pgf@y} \end{tikzpicture} } - {\begin{tikzpicture} [__ww_standard] + {\begin{tikzpicture} [__wi_standard] \tikz@scan@one@point\pgfutil@firstofone - (#2-\bool_if:NTF\l__ww_initial_r_bool rl .south) + (#2-\bool_if:NTF\l__wi_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__ww_final_r_bool rl .north) + (#3-\bool_if:NTF\l__wi_final_r_bool rl .north) \tl_gset:Nx \g_tmpb_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y} \end{tikzpicture}} - \__ww_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }} + \__wi_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }} \group_end: } -\cs_new_protected:Nn \__ww_MultiArrow:nn +\cs_new_protected:Nn \__wi_MultiArrow:nn { - \foreach \x in {#1} {\cs_if_free:cTF {pgf@sh@ns@wa-\l__ww_prefix_str-\x-l} + \foreach \x in {#1} {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wi_prefix_str-\x-l} {\msg_error:nnx {witharrows} {Wrong~line~specification~in~MultiArrow} {\x}} {\clist_gput_right:Nx \g_tmpa_clist {\x}}} \int_compare:nNnTF {\clist_count:N \g_tmpa_clist} < 2 - {\__ww_error:n {Too~small~specification~for~MultiArrow}} + {\__wi_error:n {Too~small~specification~for~MultiArrow}} {\clist_sort:Nn \g_tmpa_clist {\int_compare:nNnTF {##1} > {##2} {\sort_return_swapped:} @@ -810,30 +876,36 @@ \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:Nx \__ww_MultiArrow_i:n {\g_tmpa_clist} - \begin{tikzpicture}[__ww_standard,every~path/.style={WithArrows/arrow}] - \draw [<->] ([xshift = \l__ww_xoffset_dim]\l_tmpa_tl-r.south) + \exp_args:Nx \__wi_MultiArrow_i:n {\g_tmpa_clist} + \begin{tikzpicture}[__wi_standard,every~path/.style={WithArrows/arrow}] + \draw [<->] ([xshift = \l__wi_xoffset_dim]\l_tmpa_tl-r.south) -- ++(5mm,0) - -- node (__ww_label) {} - ([xshift = \l__ww_xoffset_dim+5mm]\l_tmpb_tl-r.south) - -- ([xshift = \l__ww_xoffset_dim]\l_tmpb_tl-r.south) ; - \tikz@parse@node \pgfutil@firstofone (__ww_label.west) + -- node (__wi_label) {} + ([xshift = \l__wi_xoffset_dim+5mm]\l_tmpb_tl-r.south) + -- ([xshift = \l__wi_xoffset_dim]\l_tmpb_tl-r.south) ; + \tikz@parse@node \pgfutil@firstofone (__wi_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__ww_wrap_lines_bool && \l__ww_in_DispWithArrows_bool} - {\dim_set:Nn \l_tmpb_dim {\g__ww_right_x_dim - \pgf@x - 0.3333 em} + \bool_if:nT {\l__wi_wrap_lines_bool && \l__wi_in_DispWithArrows_bool} + {\dim_set:Nn \l_tmpb_dim {\g__wi_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 (__ww_label.west) + \path (__wi_label.west) node [anchor = west, text~width = \dim_use:N \l_tmpa_dim] {#2} ; \end{tikzpicture} } } -\cs_new_protected:Nn \__ww_MultiArrow_i:n - {\begin{tikzpicture}[__ww_standard,every~path/.style={WithArrows/arrow}] +\cs_new_protected:Nn \__wi_MultiArrow_i:n + {\begin{tikzpicture}[__wi_standard,every~path/.style={WithArrows/arrow}] \foreach \k in {#1} - {\draw[<-] ([xshift = \l__ww_xoffset_dim]\k-r.south) -- ++(5mm,0) ;} ; + {\draw[<-] ([xshift = \l__wi_xoffset_dim]\k-r.south) -- ++(5mm,0) ;} ; \end{tikzpicture}} +\msg_new:nnn {witharrows} + {AllowLineWithoutAmpersand} + {The~option~"AllowLineWithoutAmpersand"~is~deprecated~because~lines~ + without~ampersands~are~now~always~allowed.~The~option~ + "AllowLineWithoutAmpersand"~will~probably~be~deleted~in~a~future~version.~ + However,~you~can~go~on~for~this~time.} \msg_new:nnn {witharrows} {Option~unknown} {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~ @@ -856,7 +928,7 @@ the~option~"<-"~of~Tikz.} \msg_new:nnn {witharrows} {Too~few~lines~for~an~arrow} - {An~arrow~specified~in~line~\int_use:N \l__ww_initial_int\ can't~be~drawn~ + {An~arrow~specified~in~line~\int_use:N \l__wi_initial_int\ can't~be~drawn~ because~it~arrives~after~the~last~line~of~the~environment~(remind~that~ the~command~\token_to_str:N\Arrow\ must~be~in~the~*start*~line~ of~the~arrow).~If~you~go~on,~this~arrow~will~be~ignored.} @@ -872,7 +944,7 @@ {Two~options~are~incompatible} {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~ this~option~is~incompatible~or~redundant~with~the~option~" - \int_case:nn\l__ww_previous_pos_arrows_int + \int_case:nn\l__wi_previous_pos_arrows_int {0 {rr} 1 {ll} 2 {rl} @@ -882,32 +954,12 @@ 6 {group} 7 {groups}}"~ set~in~the~same~ - \int_case:nn\l__ww_level_int + \int_case:nn\l__wi_level_int {1 {command~\token_to_str:N\WithArrowsOptions} 2 {declaration~of~options~of~the~environment~ \{\@currenvir\}} 3 {command~\token_to_str:N\Arrow}}.~ If~you~go~on,~I~will~use~the~option~"\tl_use:N\l_keys_key_tl".} -\msg_new:nnnn {witharrows} - {All~lines~must~have~an~ampersand} - {All~lines~of~an~environment~\{WithArrows\}~should~ - have~an~second~column~(because~the~nodes~are~created~ - in~the~second~column).~However,~you~can~go~on~but~you~will~ - have~an~error~if~one~of~your~arrows~needs~an~PGF~ - node~absent~by~lack~of~ampersand.~If~you~don't~want~to~ - see~this~message~again,~you~can~use~the~option~ - AllowLineWithoutAmpersand.} - {Moreover, the~ampersand~can~be~implicit~ - (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} -\msg_new:nnn {witharrows} - {Option~incompatible~with~"group(s)"} - {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~while~ - you~are~using~the~option~" - \int_compare:nNnTF \l__ww_pos_arrows_int = 5 - {group} - {groups}".~ - It's~incompatible.~You~can~go~on~ignoring~this~option~ - "\tl_use:N\l_keys_key_tl"~but~you~should~correct~your~code.} \msg_new:nnn {witharrows} {Option~will~be~ignored} {The~option~"\tl_use:N\l_keys_key_tl"~can't~be~used~here.~ @@ -915,9 +967,9 @@ \msg_new:nnn {witharrows} {Arrow~in~first~column} {You~should~not~use~the~command~\token_to_str:N\Arrow\ - \tl_if_eq:NNF \l__ww_CommandName_tl \l_tmpa_tl + \tl_if_eq:NNF \l__wi_CommandName_tl \l_tmpa_tl {(renamed~in~\str_use:N \c_backslash_str - \tl_use:N \l__ww_CommandName_tl)~} + \tl_use:N \l__wi_CommandName_tl)~} ~in~the~first~column~but~only~in~the~second~column.\\ However~you~can~go~on~for~this~time.} \msg_new:nnn {witharrows} @@ -934,28 +986,21 @@ {The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\ is~too~small:~we~need~at~least~two~lines.~If~you~go~on,~the~ command~\token_to_str:N\MultiArrow\ ~will~be~ignored.} -\msg_new:nnn {witharrows} - {A~PGF~node~doesn't~exist} - {A~PGF~node~necessary~to~draw~an~arrow~doesn't~exist~ - because~you~didn't~put~an~ampersand~in~the~corresponding~line.~ - If~you~go~on,~the~arrow~will~be~ignored.} \msg_new:nnn {witharrows} {tag*~without~amsmath} - {We~can't~use~\token_to_str:N\tag*~because~you~haven't~load~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.} \msg_new:nnn {witharrows} {Command~not~allowed~in~{DispWithArrows}} {The~command~\token_to_str:N #1 is~not~allowed~in~the~first~column~of~\{DispWithArrows\}~but~ - only~in~the~second~column~(and,~of~course,~in~the~ - environments~of~amsmath).~If~you~go~on,~this~command~will~be~ignored.} + only~in~the~second~column.~If~you~go~on,~this~command~will~be~ignored.} \msg_new:nnn {witharrows} {Command~not~allowed~in~{WithArrows}} {The~command~\token_to_str:N #1 is~not~allowed~in~\{WithArrows\}~but~is~allowed~in~the~second~ - column~of~\{DispWithArrows\}~(and,~of~course,~in~the~ - environments~of~amsmath).~If~you~go~on,~this~command~will~be~ignored.} + column~of~\{DispWithArrows\}~If~you~go~on,~this~command~will~be~ignored.} \msg_new:nnn {witharrows} {Multiple~tags} {You~can't~use~twice~the~command~\token_to_str:N\tag\ @@ -963,132 +1008,127 @@ '#1'~will~be~used.} \msg_new:nnn {witharrows} {Multiple~labels} - {Normaly,~we~can't~use~the~command~\token_to_str:N\label\ + {Normally,~we~can't~use~the~command~\token_to_str:N\label\ twice~in~a~line~of~the~environment~\{\@currenvir\}.~ However,~you~can~go~on.~ + \bool_if:NT \c__wi_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~ - "AllowMultipleLabels"~at~the~global~or~ - environment~level~(this~doesn't~work~if~you~use~cleveref).} -\coffin_new:N \l__ww_halign_coffin + "AllowMultipleLabels"~at~the~global~or~environment~level.} +\msg_new:nnn {witharrows} + {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~\{\@currenvir\}.~ + If~you~go~on,~you~may~have~undefined~references.} +\coffin_new:N \l__wi_halign_coffin \NewDocumentEnvironment {CasesWithArrows} {m O{}} {\hbox_set:Nn \l_tmpa_box {$\left\{\vcenter to 1cm {} \right.$} - \dim_zero_new:N \l__ww_delim_wd_dim - \dim_set:Nn \l__ww_delim_wd_dim {\box_wd:N \l_tmpa_box} - \box_clear_new:N \l__ww_left_part_box - \hbox_set:Nn \l__ww_left_part_box - {$\bool_if:NT \l__ww_displaystyle_bool \displaystyle #1 {}$} - \bool_if:nT \c__ww_mathtools_loaded_bool + \dim_zero_new:N \l__wi_delim_wd_dim + \dim_set:Nn \l__wi_delim_wd_dim {\box_wd:N \l_tmpa_box} + \box_clear_new:N \l__wi_left_part_box + \hbox_set:Nn \l__wi_left_part_box + {$\bool_if:NT \l__wi_displaystyle_bool \displaystyle #1 {}$} + \bool_if:nT \c__wi_mathtools_loaded_bool {\MH_if_boolean:nT {show_only_refs} {\MT_showonlyrefs_false: \MH_set_boolean_T:n {show_only_refs} - \bool_set_true:N \l__ww_notag_bool}} - \bool_if:NT \c__ww_amsmath_loaded_bool \intertext@ + \clist_set:Nn \l__wi_tags_clist {all}}} + \bool_if:NT \c__wi_amsmath_loaded_bool \intertext@ \if_mode_math: - \__ww_error:n {{DispWithArrows}~used~in~math~mode} + \__wi_error:n {{DispWithArrows}~used~in~math~mode} \fi: - \bool_set_true:N \l__ww_in_DispWithArrows_bool + \bool_set_true:N \l__wi_in_DispWithArrows_bool % - \__ww_pre_environment:n {#2} + \__wi_pre_environment:n {#2} \nointerlineskip \hbox_to_wd:nn {0.6\linewidth} {} $$ \spread@equation - \vcoffin_set:Nnw \l__ww_halign_coffin \displaywidth - \bool_if:NTF \l__ww_fleqn_bool + \vcoffin_set:Nnw \l__wi_halign_coffin \displaywidth + \bool_if:NTF \l__wi_fleqn_bool {\tabskip = \c_zero_skip} {\tabskip = 0 pt plus 1000 pt minus 1000 pt} - \bool_if:NTF \c__ww_amsmath_loaded_bool - {\cs_set_eq:NN \__ww_old_label \ltx@label} - {\cs_set_eq:NN \__ww_old_label \label} - \cs_set:Npn \notag {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\notag}} - \cs_set:Npn \nonumber {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\nonumber}} - \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\tag}} - \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows} - {Command~not~allowed~in~{DispWithArrows}} - {\label}} + \bool_if:NTF \c__wi_amsmath_loaded_bool + {\cs_set_eq:NN \__wi_old_label \ltx@label} + {\cs_set_eq:NN \__wi_old_label \label} \halign to \displaywidth \bgroup - \int_gincr:N \g__ww_line_int - \cs_set_eq:cN \l__ww_CommandName_tl \__ww_Arrow_first_column: + \int_gincr:N \g__wi_line_int + \cs_set_eq:cN \l__wi_CommandName_tl \__wi_Arrow_first_column: + \bool_set_true:N \l__wi_in_first_column_bool \strut - \bool_if:NT \l__ww_fleqn_bool - {\skip_horizontal:n \l__ww_mathindent_dim} + \bool_if:NT \l__wi_fleqn_bool + {\skip_horizontal:n \l__wi_mathindent_dim} \hfil - \skip_horizontal:n {\box_wd:N \l__ww_left_part_box + \l__ww_delim_wd_dim} - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {##}$ + \skip_horizontal:n {\box_wd:N \l__wi_left_part_box + \l__wi_delim_wd_dim} + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {##}$ \tabskip = \c_zero_skip & - \cs_set:Npn \notag {\bool_set_true:N \l__ww_notag_bool} - \cs_set_eq:NN \nonumber \notag - \cs_set_eq:NN \tag \__ww_tag - \cs_set_eq:NN \label \__ww_label:n - $\bool_if:NT \l__ww_displaystyle_bool \displaystyle {{}##}$ + \clist_if_in:NVT \l__wi_tags_clist \g__wi_line_int + {\clist_set:Nn \l__wi_tags_clist {all}} + \cs_set:Npn \notag {\clist_clear:N \l__wi_tags_clist} + $\bool_if:NT \l__wi_displaystyle_bool \displaystyle {{}##}$ \tabskip = 0 pt plus 1000 pt minus 1000 pt - \int_gincr:N \g__ww_line_bis_int \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-l, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-l}} ] {} ; + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-l, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-l}} ] {} ; \hfil \tikz [remember~picture,overlay] - \node [__ww_node_style, - name = wa-\l__ww_prefix_str-\int_use:N\g__ww_line_int-r, - alias = {\tl_if_empty:NF \l__ww_name_tl - {\l__ww_name_tl-\int_use:N\g__ww_line_int-r}} ] {} ; - \bool_if:NT \l__ww_shownodenames_bool - {\hbox_overlap_right:n {\small wa-\l__ww_prefix_str - -\int_use:N\g__ww_line_int}} + \node [__wi_node_style, + name = wa-\l__wi_prefix_str-\int_use:N\g__wi_line_int-r, + alias = {\tl_if_empty:NF \l__wi_name_tl + {\l__wi_name_tl-\int_use:N\g__wi_line_int-r}} ] {} ; + \bool_if:NT \l__wi_shownodenames_bool + {\hbox_overlap_right:n {\small wa-\l__wi_prefix_str + -\int_use:N\g__wi_line_int}} & ## \tabskip = \c_zero_skip - && \__ww_error:n {Third~column~in~an~environment~{DispWithArrows}} + && \__wi_error:n {Third~column~in~an~environment~{DispWithArrows}} \if_false: ## \fi: \cr} - { \\ + {\clist_if_in:NnT {last} \l__wi_tags_clist + {\clist_set:Nn \l__wi_tags_clist {all}} + \\ \egroup \unskip\unpenalty\unskip\unpenalty \box_set_to_last:N \l_tmpa_box \nointerlineskip \box_use:N \l_tmpa_box - \dim_gzero_new:N \g__ww_alignment_dim - \dim_gset:Nn \g__ww_alignment_dim {\box_wd:N \l_tmpa_box} - \box_clear_new:N \l__ww_new_box - \hbox_set:Nn \l__ww_new_box {\hbox_unpack_clear:N \l_tmpa_box} - \dim_compare:nNnT {\box_wd:N \l__ww_new_box} < \g__ww_alignment_dim - {\dim_gset:Nn \g__ww_alignment_dim {\box_wd:N \l__ww_new_box}} + \dim_gzero_new:N \g__wi_alignment_dim + \dim_gset:Nn \g__wi_alignment_dim {\box_wd:N \l_tmpa_box} + \box_clear_new:N \l__wi_new_box + \hbox_set:Nn \l__wi_new_box {\hbox_unpack_clear:N \l_tmpa_box} + \dim_compare:nNnT {\box_wd:N \l__wi_new_box} < \g__wi_alignment_dim + {\dim_gset:Nn \g__wi_alignment_dim {\box_wd:N \l__wi_new_box}} \vcoffin_set_end: \hbox_to_wd:nn \displaywidth { - \bool_if:NTF \l__ww_fleqn_bool - {\skip_horizontal:n \l__ww_mathindent_dim} + \bool_if:NTF \l__wi_fleqn_bool + {\skip_horizontal:n \l__wi_mathindent_dim} {\hfil} - \hbox_to_wd:nn \g__ww_alignment_dim - { \box_use_drop:N \l__ww_left_part_box - \dim_set:Nn \l_tmpa_dim { \box_ht:N \l__ww_halign_coffin - + \box_dp:N \l__ww_halign_coffin} + \hbox_to_wd:nn \g__wi_alignment_dim + { \box_use_drop:N \l__wi_left_part_box + \dim_set:Nn \l_tmpa_dim { \box_ht:N \l__wi_halign_coffin + + \box_dp:N \l__wi_halign_coffin} $\left\{ \vcenter to \l_tmpa_dim {\vfil} \right.$} \hfil} \coffin_typeset:Nnnnn - \l__ww_halign_coffin {l} {vc} {-\displaywidth} \c_zero_dim + \l__wi_halign_coffin {l} {vc} {-\displaywidth} \c_zero_dim $$ - \__ww_post_environment: - \bool_if:nT \c__ww_mathtools_loaded_bool + \__wi_post_environment: + \bool_if:nT \c__wi_mathtools_loaded_bool {\MH_if_boolean:nT {show_only_refs} \MT_showonlyrefs_true:} \ignorespacesafterend } \NewDocumentCommand \WithArrowsNewStyle {mm} { \keys_if_exist:nnTF {WithArrows/General} {#1} - {\__ww_error:nn {Key~already~defined} {#1}} + {\__wi_error:nn {Key~already~defined} {#1}} {\keys_define:nn {WithArrows/General} - {#1 .code:n = {\int_compare:nNnTF \l__ww_level_int < 3 + {#1 .code:n = {\int_compare:nNnTF \l__wi_level_int < 3 {\keys_set:nn {WithArrows/General} {#2}} - {\__ww_error:n {Option~unknown}}}} + {\__wi_error:n {Option~unknown}}}} \group_begin: \WithArrowsOptions{#2} \group_end:} } -- cgit v1.2.3