diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/witharrows/README.md | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/witharrows/witharrows.pdf | bin | 375892 -> 389748 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/witharrows/witharrows.dtx | 1605 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 588 |
4 files changed, 1258 insertions, 941 deletions
diff --git a/Master/texmf-dist/doc/latex/witharrows/README.md b/Master/texmf-dist/doc/latex/witharrows/README.md index fdaf611cbf9..b706fd6ac2e 100644 --- a/Master/texmf-dist/doc/latex/witharrows/README.md +++ b/Master/texmf-dist/doc/latex/witharrows/README.md @@ -1,11 +1,13 @@ # Readme for the package witharrows +Author : F. Pantigny (`fpantigny@wanadoo.fr`). + +CTAN page : `https://ctan.org/pkg/witharrows` + ## License The LaTeX extension `witharrows` is distributed under the LPPL 1.3 license. ## Presentation -This extension has been written by F. Pantigny (`fpantigny@wanadoo.fr`). - The LaTeX package `witharrows` provides environments `{WithArrows}` and `{DispWithArrows}` similar to the environments `{aligned}` and `{align}` of `amsmath` but with the possibility to draw arrows on the right side of the alignment. These arrows are usually used to give explanations concerning the mathematical calculus presented. diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf Binary files differindex edaa0772c37..cdd7c11f9e0 100644 --- a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf +++ b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx index d8993abebd4..c9b463ca716 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.16} -\def\myfiledate{2019/03/11} +\def\myfileversion{1.17} +\def\myfiledate{2019/07/09} % % %<*batchfile> @@ -247,7 +247,7 @@ version 2005/12/01 or later. % % \smallskip % In fact, it's possible to change more drastically the shape or the arrows with -% the option |TikzCode| presented p.~\pageref{TikzCode}. +% the option |tikz-code| (presented p.~\pageref{tikz-code}. % % \interitem % It's possible to use the Tikz option ``|text width|'' to control the width of @@ -331,8 +331,8 @@ version 2005/12/01 or later. % environment |{WithArrows}|. \textbf{There must be no space before the opening % bracket (|[|) of the options of the environment.} The options apply to all the % arrows of the environment.\footnote{They also apply to the nested environments -% |{WithArrows}| (with the logical exceptions of |interline|, |CodeBefore| and -% |CodeAfter|).} +% |{WithArrows}| (with the logical exceptions of |interline|, |code-before| and +% |code-after|).} % % % \begin{Verbatim} % $\begin{WithArrows}[~emphase#tikz=blue@] @@ -432,13 +432,14 @@ version 2005/12/01 or later. % However, a previouly defined command |\Arrow| may still be useful in an % environment |{WithArrows}|. If we want to use it in such an environment, it's % possible to change the name of the command |\Arrow| of the package -% \pkg{witharrows}: there is an option |CommandName| for this purpose. The new -% name of the command must be given to the option \emph{without} the leading -% backslash. +% \pkg{witharrows}: there is an option |command-name|\footnote{For historical +% reasons, there is an alias for this option: |CommandName|.} for this purpose. +% The new name of the command must be given to the option \emph{without} the +% leading backslash. % % % \begin{Verbatim} % \NewDocumentCommand {\Arrow} {} {\longmapsto} -% $\begin{WithArrows}[~emphase#CommandName=Explanation@] +% $\begin{WithArrows}[~emphase#command-name=Explanation@] % f & = \bigl(x \Arrow (x+1)^2\bigr) % ~emphase#\Explanation{we work directly on fonctions}@\\ % & = \bigl(x \Arrow x^2+2x+1\bigr) @@ -447,7 +448,7 @@ version 2005/12/01 or later. % % % \begin{scope} % \NewDocumentCommand {\Arrow} {} {\longmapsto} -% $\begin{WithArrows}[CommandName=Explanation] +% $\begin{WithArrows}[command-name=Explanation] % f & = \bigl(x \Arrow (x+1)^2\bigr) % \Explanation{we work directly on fonctions}\\ % & = \bigl(x \Arrow x^2+2x+1\bigr) @@ -456,31 +457,87 @@ version 2005/12/01 or later. % % % \interitem -% The environment |{WithArrows}| gives also two options |CodeBefore| and -% |CodeAfter| for LaTeX code that will be executed at the beginning and at the -% end of the environment. These options are not designed to be hooks (they are -% available only at the environment level and they do not apply to the nested -% environments). +% The environment |{WithArrows}| gives also two options |code-before| and +% |code-after|\footnote{For historical reasons, there are aliases for these +% options: |CodeBefore| and |CodeAfter|.} for LaTeX code that will be executed +% at the beginning and at the end of the environment. These options are not +% designed to be hooks (they are available only at the environment level and +% they do not apply to the nested environments). % % % \begin{Verbatim} -% $\begin{WithArrows}[~emphase#CodeBefore = \color{blue}@] +% $\begin{WithArrows}[~emphase#code-before = \color{blue}@] % A & = (a+b)^2 \Arrow{we expand} \\ % & = a^2 + 2ab + b^2 % \end{WithArrows}$ % \end{Verbatim} % -% $\begin{WithArrows}[CodeBefore = \color{blue}] +% $\begin{WithArrows}[code-before = \color{blue}] % A & = (a+b)^2 \Arrow{we expand} \\ % & = a^2 + 2ab + b^2 % \end{WithArrows}$ % % \medskip -% Special commands are available in |CodeAfter|: a command |\WithArrowsNbLines| +% Special commands are available in |code-after|: a command |\WithArrowsNbLines| % which gives the number of lines (=rows) of the current environment (this is a % command and not a counter), a special form of the command |\Arrow| and the % command |\MultiArrow|: these commands are described in the section concerning % the nested environments, p.~\pageref{NestedEnv}. % +% \section{Numbers of columns} +% +% So far, we have used the environment |{WithArrows}| with two columns. However, +% it's possible to use the environment with an arbitrary number of columns with +% the option |format|. The value given to this option is like the preamble of an +% environment |{array}|, that is to say a sequence of letters |r|, |c| and |l|. +% The default value of the option |format| is, in fact, |rl|. +% +% \bigskip +% For exemple, if we want only one column left-aligned, we use the option |format=l|. +% \begin{Verbatim} +% $\begin{WithArrows}[~emphase#format = l@] +% f(x) \ge g(x) \Arrow{by squaring both sides} \\ +% f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \\ +% f(x)^2 - g(x)^2 \ge 0 +% \end{WithArrows}$ +% \end{Verbatim} +% +% $\begin{WithArrows}[format = l] +% f(x) \ge g(x) \Arrow{by squaring both sides} \\ +% f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \\ +% f(x)^2 - g(x)^2 \ge 0 +% \end{WithArrows}$ +% +% \interitem +% In the following example, we use five columns all centered (the environment +% |{DispWithArrows*}| is presented p.~\pageref{DispWithArrows}). +% +% \begin{Verbatim} +% \begin{DispWithArrows*}[~emphase#format = ccccc@, +% wrap-lines, +% tikz = {align = flush left}, +% interline=1mm] +% k & \;\le\; & t & \;\le\; & k+1 \\ +% \frac{1}{k+1} & \le & \frac{1}{t} & \le & \frac{1}{k} +% \Arrow{we can integrate the inequalities since $k \leq k+1$ } \\ +% \int\limits_k^{k+1} \frac{\text{d} t}{k+1} +% & \le & \int\limits_k^{k+1} \frac{\text{d} t}{t} +% & \le & \int\limits_k^{k+1} \frac{\text{d} t}{k} \\ +% \frac{1}{k+1} & \le & \ln(k+1)-\ln(k) & \le & \frac{1}{k} +% \end{DispWithArrows*} +% \end{Verbatim} +% \begin{DispWithArrows*}[format = ccccc, +% wrap-lines, +% tikz = {align = flush left}, +% interline=1mm] +% k & \;\le\; & t & \;\le\; & k+1 \\ +% \frac{1}{k+1} & \le & \frac{1}{t} & \le & \frac{1}{k} +% \Arrow{we can integrate the inequalities since $k \leq k+1$ } \\ +% \int\limits_k^{k+1} \frac{\text{d} t}{k+1} +% & \le & \int\limits_k^{k+1} \frac{\text{d} t}{t} +% & \le & \int\limits_k^{k+1} \frac{\text{d} t}{k} \\ +% \frac{1}{k+1} & \le & \ln(k+1)-\ln(k) & \le & \frac{1}{k} +% \end{DispWithArrows*} +% % % \section{Precise positioning of the arrows} % @@ -525,12 +582,12 @@ version 2005/12/01 or later. % $\begin{WithArrows}[displaystyle] % I % & = \int_{\frac{\pi}4}^0 \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)(-d u) -% \Arrow[lr]{This arrow uses the \texttt{lr} option.}\\ +% \Arrow[lr]{This arrow uses the |lr| option.}\\ % & = \int_0^{\frac{\pi}4} \ln\Bigl(1+\tan\left(\tfrac{\pi}4-u\right)\Bigr)d u \\ % & = \int_0^{\frac{\pi}4}\ln\left(1+\frac{1-\tan u}{1+\tan u}\right)\, d u \\ % & =\int_0^{\frac{\pi}4}\ln\left(\frac{1+\tan u+1-\tan u}{1+\tan u}\right) d u -% \Arrow[ll,jump=2,tikz={text width = 5cm}]{This arrow uses a \texttt{ll} option -% and a \texttt{jump} equal to $2$}\\ +% \Arrow[ll,jump=2,tikz={text width = 5cm}]{This arrow uses a |ll| option +% and a |jump| equal to $2$}\\ % & =\int_0^{\frac{\pi}4} \ln\left(\frac2{1+\tan u}\right)\, d u\\ % & =\int_0^{\frac{\pi}4}\bigl(\ln2-\ln(1+\tan u)\bigr)\, d u \\ % & =\frac{\pi}4\ln2-\int_0^{\frac{\pi}4}\ln(1+\tan u)\, d u \\ @@ -540,7 +597,7 @@ version 2005/12/01 or later. % % % \interitem -% There is also an option called \texttt{i} ($i$ for \emph{intermediate}). With +% There is also an option called |i| (\emph{i} for \emph{intermediate}). With % this option, the arrow is vertical and at the leftmost position. % % \begin{Verbatim} @@ -651,7 +708,8 @@ version 2005/12/01 or later. % % \interitem % -% \section{The options ``up'' and ``down'' for individual arrows} +% \section[The options 'up' and 'down' for individual arrows]% +% {The options ``up'' and ``down'' for individual arrows} % % \label{up-and-down} % At the local level, there are also two options for individuals arrows, called @@ -661,10 +719,10 @@ version 2005/12/01 or later. % \begin{Verbatim} % \(\begin{WithArrows} % A & = B -% \Arrow~emphase#[up]@{an arrow of type "up"} \\ +% \Arrow~emphase#[up]@{an arrow of type \texttt{up}} \\ % & = C + C + C + C + C + C + C + C \\ % & = C + C + C + C + C + C + C + C -% \Arrow~emphase#[down]@{an arrow of type "down"} \\ +% \Arrow~emphase#[down]@{an arrow of type \texttt{down}} \\ % & = E + E % \end{WithArrows}\) % \end{Verbatim} @@ -672,10 +730,10 @@ version 2005/12/01 or later. % \vspace{1cm} % \(\begin{WithArrows} % A & = B -% \Arrow[up]{an arrow of type "up"} \\ +% \Arrow[up]{an arrow of type \texttt{up}} \\ % & = C + C + C + C + C + C + C + C \\ % & = C + C + C + C + C + C + C + C -% \Arrow[down]{an arrow of type "down"} \\ +% \Arrow[down]{an arrow of type \texttt{down}} \\ % & = E + E % \end{WithArrows}\) % @@ -684,6 +742,7 @@ version 2005/12/01 or later. % The options |up| and |down| require the package \pkg{varwidth} and the Tikz % library \pkg{calc}. It they are not loaded, an error will be raised. % +% % \interitem % % \section{Comparison with the environment \{aligned\}} @@ -887,7 +946,7 @@ version 2005/12/01 or later. % % The environments |{WithArrows}| can be nested. In this case, the options given % to the encompassing environment applies also to the inner ones (with logical -% exceptions for |interline|, |CodeBefore| and |CodeAfter|). The command |Arrow| +% exceptions for |interline|, |code-before| and |code-after|). The command |Arrow| % can be used as usual in each environment |{WithArrows}|. % % \begin{Verbatim}[formatcom=\small\color{gray}] @@ -929,7 +988,7 @@ version 2005/12/01 or later. % environment. For example, one may want to draw the following arrow : % % \bigskip -% $\begin{WithArrows}[CodeAfter = \Arrow[v]{1-2}{2-2}{division by $2$} ] +% $\begin{WithArrows}[code-after = \Arrow[v]{1-2}{2-2}{division by $2$} ] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -947,12 +1006,12 @@ version 2005/12/01 or later. % % % \bigskip -% Such a construction is possible by using |\Arrow| in the |CodeAfter| option. -% Indeed, in |CodeAfter|, a special version of |\Arrow| is available (we will -% call it ``|\Arrow| in |CodeAfter|''). +% Such a construction is possible by using |\Arrow| in the |code-after| option. +% Indeed, in |code-after|, a special version of |\Arrow| is available (we will +% call it ``|\Arrow| in |code-after|''). % % \smallskip -% A command |\Arrow| in |CodeAfter| takes three arguments : +% A command |\Arrow| in |code-after| takes three arguments : % \begin{itemize} % \item a specification of the start row of the arrow ; % \item a specification of the end row of the arrow ; @@ -970,7 +1029,7 @@ version 2005/12/01 or later. % In the previous example, there are two environments |{WithArrows}| nested in % the main environment |{WithArrows}|. % -% $\begin{WithArrows}[TikzCode = {\path (#1) to node {#3} (#2) ; }] +% $\begin{WithArrows}[tikz-code = {\path (#1) to node {#3} (#2) ; }] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow \color{blue} @@ -990,16 +1049,16 @@ version 2005/12/01 or later. % The arrow we want to draw starts in the row~$2$ of the sub-environment % number~$1$ (and therefore, the 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| : +% We can draw the arrow with the following command |\Arrow| in |code-after| : % \begin{Verbatim} -% $\begin{WithArrows}[~emphase#CodeAfter = \Arrow{1-2}{2-2}{division by $2$}@ ] +% $\begin{WithArrows}[~emphase#code-after = \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}[code-after = \Arrow{1-2}{2-2}{division by $2$} ] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -1016,25 +1075,25 @@ version 2005/12/01 or later. % \end{WithArrows}$ % % \bigskip -% The options allowed for a command |\Arrow| in |CodeAfter| are : |ll|, |lr|, -% |rl|, |rr|, |v|, |xoffset|, |tikz| and |TikzCode|. Except |v|, which is -% specific to |\Arrow| in |CodeAfter|, all these options have their usual +% The options allowed for a command |\Arrow| in |code-after| are : |ll|, |lr|, +% |rl|, |rr|, |v|, |xoffset|, |tikz| and |tikz-code|. Except |v|, which is +% specific to |\Arrow| in |code-after|, all these options have their usual % meaning. % % With the option |v|, the arrow drawn is vertical to an abscissa computed with % the start row and the end row only : the intermediate lines are not taken into % account unlike with the option |i|. Currently, the option |i| is not available -% for the command~|\Arrow| in |CodeAfter|. However, it's always possible to +% for the command~|\Arrow| in |code-after|. 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}[code-after=\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}[code-after = \Arrow[v]{1-2}{2-2}{division by $2$} ] % \varphi(x,y)=0 % & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\ % & \Leftrightarrow @@ -1053,7 +1112,7 @@ version 2005/12/01 or later. % % \interitem % The package \pkg{witharrows} gives also another command available only in -% |CodeAfter|: the command |\MultiArrow|. This command draws a ``rak''. The list +% |code-after|: the command |\MultiArrow|. This command draws a ``rak''. The list % of the rows of the environment concerned by this rak are given in the first % argument of the command |\MultiArrow|. This list is given with the syntax of % the list in a |\foreach| command of \pkg{pgffor}. @@ -1061,7 +1120,7 @@ version 2005/12/01 or later. % % \begin{Verbatim} % $\begin{WithArrows}[tikz = rounded corners, -% CodeAfter = {~emphase#\MultiArrow{1,...,4}{text}@} ] +% code-after = {~emphase#\MultiArrow{1,...,4}{text}@} ] % A & = B \\ % & = C \\ % & = D \\ @@ -1072,7 +1131,7 @@ version 2005/12/01 or later. % % % $\begin{WithArrows}[tikz = rounded corners, -% CodeAfter = {\MultiArrow{1,...,4}{text}}] +% code-after = {\MultiArrow{1,...,4}{text}}] % A & = B \\ % & = C \\ % & = D \\ @@ -1147,16 +1206,15 @@ version 2005/12/01 or later. % \item the Tikz style |WithArrows/arrow| is the style used by \pkg{witharrows} % when drawing an arrow\footnote{More precisely, this style is given to the Tikz % option ``|every path|'' before drawing the arrow with the code of the option -% |TikzCode|. This style is modified (in TeX scopes) by the option |tikz| of +% |tikz-code|. This style is modified (in TeX scopes) by the option |tikz| of % \pkg{witharrows}.}; % % \item the Tikz style |WithArrows/arrow/tips| is the style for the tip of the % arrow (loaded by |WithArrows/arrow|). % \end{itemize} % -% For example, we can draw an arrow from -% \texttt{wa-\WithArrowsLastEnv-2-1-2-r.south} to -% \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command. +% For example, we can draw an arrow from \texttt{wa-\WithArrowsLastEnv-2-1-2-r.south} +% to \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command. % % \begin{Verbatim} % \begin{tikzpicture}[remember picture,overlay] @@ -1203,7 +1261,7 @@ version 2005/12/01 or later. % \end{tikzpicture} % % \medskip -% In this case, it would be easier to use a command |\Arrow| in |CodeAfter| but +% In this case, it would be easier to use a command |\Arrow| in |code-after| but % this is an example to explain how the Tikz nodes created by \pkg{witharrows} % can be used. % @@ -1453,7 +1511,7 @@ version 2005/12/01 or later. % \bigskip % The option |wrap-lines| doesn't apply to the environments |{WithArrows}| % nested in an environment |{DispWithArrows}| or |{DispWithArrows*}|. However, -% it applies to the instructions |\Arrow| and |\MultiArrow| of the |CodeAfter| +% it applies to the instructions |\Arrow| and |\MultiArrow| of the |code-after| % of the environments |{DispWithArrows}| or |{DispWithArrows*}|. % % \vspace{1cm} @@ -1504,19 +1562,19 @@ 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 +% \item The environment |{DispWithArrows}| cannot be inserted in an environment % |{gather}| of \pkg{amsmath}. % \item An environment |{DispWithArrows}| is always unbreakable (even with % |\allowdisplaybreaks| of \pkg{amsmath}). % \item The commands |\label|, |\tag|, |\notag| and |\nonumber| are allowed only -% in the second column. -% \item After an |\item| of a LaTeX list, no vertical space is added. +% in the last column. +% \item After an |\item| of a LaTeX list, no vertical space is added (this can +% be changed with the option |standard-behaviour-with-items|). % \item % \begin{bfseries} -% Last but not least, by default, the elements of a \texttt{\{DispWithArrows\}} -% are composed in \texttt{textstyle} and not in \texttt{displaystyle} (it's -% possible to change this point with the option \texttt{displaystyle}). +% Last but not least, by default, the elements of a |\{DispWithArrows\}| +% are composed in |textstyle| and not in |displaystyle| (it's possible to change +% this point with the option |displaystyle|). % \end{bfseries} % \end{itemize} % @@ -1535,20 +1593,21 @@ version 2005/12/01 or later. % % \section{Advanced features} % -% -% \subsection{The option TikzCode : how to change the shape of the arrows} % -% \label{TikzCode} +% \subsection{The option tikz-code : how to change the shape of the arrows} +% +% \label{tikz-code} % -% The option |TikzCode| allows the user to change the shape of the +% The option |tikz-code|\footnote{For historical reasons, the option |tikz-code| +% has an alias: |TikzCode|.} allows the user to change the shape of the % arrows.\footnote{If the option |wrap-lines| is used in an environment -% |{DispWithArrows}| or |{DispWithArrows*}|, the option |TikzCode| will have no +% |{DispWithArrows}| or |{DispWithArrows*}|, the option |tikz-code| will have no % effect for the arrows of this environment but only for the arrows in the % nested environments |{WithArrows}|.} % % \smallskip % For example, the options ``|up|'' and ``|down|'' described previously (cf. -% p.~\pageref{up-and-down}) are programmed internally with |TikzCode|. +% p.~\pageref{up-and-down}) are programmed internally with |tikz-code|. % % \smallskip % The value of this option must be a valid Tikz drawing instruction (with the @@ -1566,8 +1625,8 @@ version 2005/12/01 or later. % In the following example, we replace this default path by a path with three % segments (and the node overwriting the second segment). % \begin{Verbatim} -% \begin{WithArrows}[ygap=5pt,interline=4mm, -% ~emphase#TikzCode = {\draw[rounded corners]@ +% \begin{WithArrows}[format=c,ygap=5pt,interline=4mm, +% ~emphase#tikz-code = {\draw[rounded corners]@ % ~emphase# (~#1) -- ([xshift=5mm]~#1)@ % ~emphase# -- node[circle,@ % ~emphase# draw,@ @@ -1576,17 +1635,18 @@ version 2005/12/01 or later. % ~emphase# inner sep = 1pt] {\tiny ~#3}@ % ~emphase# ([xshift=5mm]~#2)@ % ~emphase# -- (~#2) ; }@] -% E & \Longleftrightarrow 3 (2x+4) = 6 \Arrow{$\div 3$} \\ -% & \Longleftrightarrow 2x+4 = 2 \Arrow{$-4$} \\ -% & \Longleftrightarrow 2x = -2 \Arrow{$\div 2$} \\ -% & \Longleftrightarrow x = -1 +% 3 (2x+4) = 6 \Arrow{$\div 3$} \\ +% 2x+4 = 2 \Arrow{$-4$} \\ +% 2x = -2 \Arrow{$\div 2$} \\ +% x = -1 % \end{WithArrows} % \end{Verbatim} % % -% \[\begin{WithArrows}[ygap=5pt, +% \[\begin{WithArrows}[format=c, +% ygap=5pt, % interline=4mm, -% TikzCode = {\draw[rounded corners] +% tikz-code = {\draw[rounded corners] % (#1) % -- % ([xshift=5mm]#1) @@ -1598,25 +1658,22 @@ version 2005/12/01 or later. % ([xshift=5mm]#2) % -- % (#2) ; }] -% E & \Longleftrightarrow 3 (2x+4) = 6 -% \Arrow{$\div 3$}\\ -% & \Longleftrightarrow 2x+4 = 2 -% \Arrow{$-4$}\\ -% & \Longleftrightarrow 2x = -2 -% \Arrow{$\div 2$} \\ -% & \Longleftrightarrow x = -1 +% 3 (2x+4) = 6 \Arrow{$\div 3$} \\ +% 2x+4 = 2 \Arrow{$-4$} \\ +% 2x = -2 \Arrow{$\div 2$} \\ +% x = -1 % \end{WithArrows}\] % % \bigskip % The environments |{DispWithArrows}| and its starred version % |{DispWithArrows*}| provide a command |\WithArrowsRightX| which can be used in -% a definition of |TikzCode|. This command gives the $x$-value of the right side +% a definition of |tikz-code|. This command gives the $x$-value of the right side % of the composition box (taking into account the eventual tags of the % equations). For an example of use, see p.~\pageref{example-WithArrowsRightX}. % % % \bigskip -% \subsection{The command WithArrowsNewStyle} +% \subsection{The command \textbackslash WithArrowsNewStyle} % % The extension \pkg{witharrows} provides a command |\WithArrowsNewStyle| to % define styles in a way similar to the ``styles'' of Tikz. @@ -1663,13 +1720,13 @@ version 2005/12/01 or later. % \draw (B) -- (C) ; % \draw[<-] (B) to ++(0,0.2) ; % \draw[<-] (C) to ++(0,-0.2) ; -% \path (C) node[right=1mm] {\texttt{ystart}} ; +% \path (C) node[right=1mm] {|ystart|} ; % \draw (wa-\WithArrowsLastEnv-2-r.north) to ++(3,0) coordinate (E) to ++(0.1,0); % \draw (wa-\WithArrowsLastEnv-2-r.south) to ++(3,0) coordinate (F) to ++(0.1,0); % \draw (E) -- (F) ; % \draw[<-] (E) to ++(0,0.2) ; % \draw[<-] (F) to ++(0,-0.2) ; -% \path (F) node[right=1mm] {\texttt{ygap}} ; +% \path (F) node[right=1mm] {|ygap|} ; % \end{tikzpicture} % % \interitem @@ -1810,27 +1867,7 @@ version 2005/12/01 or later. % % \section{Examples} % -% \subsection{With only one column} -% -% It's possible to use the environment |{WithArrows}| with making use of the -% left column only, or the right column only. -% % -% \begin{Verbatim} -% $\begin{WithArrows} -% & f(x) \ge g(x) \Arrow{by squaring both sides} \\ -% & f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \\ -% & f(x)^2 - g(x)^2 \ge 0 -% \end{WithArrows}$ -% \end{Verbatim} -% -% $\begin{WithArrows} -% & f(x) \ge g(x) \Arrow{by squaring both sides} \\ -% & f(x)^2 \ge g(x)^2 \Arrow{by moving to left side} \\ -% & f(x)^2 - g(x)^2 \ge 0 -% \end{WithArrows}$ -% -% \bigskip -% \subsection{MoveEqLeft} +% \subsection{\textbackslash MoveEqLeft} % % It's possible to use |\MoveEqLeft| of \pkg{mathtools} (if we don't want % ampersand on the first line): @@ -1868,24 +1905,23 @@ version 2005/12/01 or later. % % \begin{Verbatim} % \begin{WithArrows}% -% [interline = 4mm, +% [format = c, +% interline = 4mm, % tikz = {~emphase#every node/.style = {circle,@ % ~emphase# draw,@ % ~emphase# auto = false,@ % ~emphase# fill = gray!50,@ % ~emphase# inner sep = 1pt,@ % ~emphase# font = \tiny}@}] -% E & \Longleftrightarrow 3 (2x+4) = 6 -% \Arrow{$\div 3$}\\ -% & \Longleftrightarrow 2x+4 = 2 -% \Arrow{$-4$}\\ -% & \Longleftrightarrow 2x = -2 -% \Arrow{$\div 2$} \\ -% & \Longleftrightarrow 2x = -1 +% 3 (2x+4) = 6 \Arrow{$\div 3$} \\ +% 2x+4 = 2 \Arrow{$-4$} \\ +% 2x = -2 \Arrow{$\div 2$} \\ +% 2x = -1 % \end{WithArrows} % \end{Verbatim} % % \[\begin{WithArrows}[% +% format = c, % interline = 4mm, % tikz = {every node/.style = {circle, % draw, @@ -1893,34 +1929,31 @@ version 2005/12/01 or later. % fill = gray!50, % inner sep = 1pt, % font = \tiny}}] -% E & \Longleftrightarrow 3 (2x+4) = 6 -% \Arrow{$\div 3$}\\ -% & \Longleftrightarrow 2x+4 = 2 -% \Arrow{$-4$}\\ -% & \Longleftrightarrow 2x = -2 -% \Arrow{$\div 2$} \\ -% & \Longleftrightarrow 2x = -1 +% 3 (2x+4) = 6 \Arrow{$\div 3$} \\ +% 2x+4 = 2 \Arrow{$-4$} \\ +% 2x = -2 \Arrow{$\div 2$} \\ +% 2x = -1 % \end{WithArrows}\] % % % \bigskip -% \subsection{Examples with the option TikzCode} +% \subsection{Examples with the option tikz-code} % -% We recall that the option |TikzCode| is the Tikz code used by \pkg{witharrows} +% We recall that the option |tikz-code| is the Tikz code used by \pkg{witharrows} % to draw the arrows.\footnote{If an environment |{DispWithArrows}| or % |{DispWithArrows*}| is used with the option |wrap-lines|, the value of the -% option |TikzCode| is not used for this environment (but is used for the +% option |tikz-code| is not used for this environment (but is used for the % environments nested inside).} % % \smallskip -% The value by defaut of |TikzCode| is \verb|\draw (#1) to node {#3} (#2) ;| +% The value by defaut of |tikz-code| is \verb|\draw (#1) to node {#3} (#2) ;| % where the three markers |#1|, |#2| and |#3| represent the start row, the end % row and the label of the arrow. % % % \bigskip % \subsubsection{Example 1} -% In the following example, we define the value of |TikzCode| with two +% In the following example, we define the value of |tikz-code| with two % instructions |\path| : the first instruction draws the arrow itself and the % second puts the label in a Tikz node in the rectangle delimited by the arrow. % @@ -1929,9 +1962,9 @@ version 2005/12/01 or later. % [displaystyle, % ygap = 2mm, % ystart = 0mm, -% ~emphase#TikzCode = {\draw (~#1) -- ++(4.5cm,0) |- (~#2) ;@ -% ~emphase# \path (~#1) -- (~#2) @ -% ~emphase# node[text width = 4.2cm, right, midway] {~#3} ;}@] +% ~emphase#tikz-code = {\draw (~#1) -- ++(4.5cm,0) |- (~#2) ;@ +% ~emphase# \path (~#1) -- (~#2) @ +% ~emphase# node[text width = 4.2cm, right, midway] {~#3} ;}@] % S_n % & = \frac1n \sum_{k=0}^{n-1}\cos\bigl(\tfrac{\pi}2\cdot\tfrac kn\bigr) % ........... @@ -1943,9 +1976,9 @@ version 2005/12/01 or later. % displaystyle, % ygap = 2mm, % ystart = 0mm, -% TikzCode = {\draw (#1) -- ++(4.5cm,0) |- (#2) ; -% \path (#1) -- (#2) -% node[text width = 4.2cm, right, midway] {#3} ;}] +% tikz-code = {\draw (#1) -- ++(4.5cm,0) |- (#2) ; +% \path (#1) -- (#2) +% node[text width = 4.2cm, right, midway] {#3} ;}] % S_n % & = \frac1n \sum_{k=0}^{n-1}\cos\bigl(\tfrac{\pi}2\cdot\tfrac kn\bigr) % \Arrow{$\cos x = \Re(e^{ix})$}\\ @@ -1966,7 +1999,7 @@ version 2005/12/01 or later. % It's possible to modify the previous example to have the ``|text width|'' % automatically computed with the right 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 +% |{DispWithArrows*}|. In the definition of |tikz-code|, 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 lisibility, we % use a style. This example requires the Tikz library \pkg{calc}. @@ -1977,14 +2010,14 @@ version 2005/12/01 or later. % ygap = 2mm, % xoffset = 0pt, % ystart = 0mm, -% TikzCode = {\path let \p1 = (~#~#1) -% in (~#~#1) -% -- node [anchor = west, -% text width = {~emphase#\WithArrowsRightX@ - \x1 - 0.5 em}] -% {~#~#3} -% (~#~#2) ; -% \draw let \p1 = (~#~#1) -% in (~#~#1) -- ++(~emphase#\WithArrowsRightX@ - \x1,0) |- (~#~#2) ; }} +% tikz-code = {\path let \p1 = (~#~#1) +% in (~#~#1) +% -- node [anchor = west, +% text width = {~emphase#\WithArrowsRightX@ - \x1 - 0.5 em}] +% {~#~#3} +% (~#~#2) ; +% \draw let \p1 = (~#~#1) +% in (~#~#1) -- ++(~emphase#\WithArrowsRightX@ - \x1,0) |- (~#~#2) ; }} % \end{Verbatim} % % \begin{Verbatim} @@ -2000,13 +2033,13 @@ version 2005/12/01 or later. % ygap = 2mm, % xoffset = 0pt, % ystart = 0mm, -% TikzCode = {\path let \p1 = (##1) -% in (##1) -% -- node [anchor = west, -% text width = {\WithArrowsRightX - \x1 - 0.5 em}] {##3} -% (##2) ; -% \draw let \p1 = (##1) -% in (##1) -- ++(\WithArrowsRightX - \x1,0) |- (##2) ; }} +% tikz-code = {\path let \p1 = (##1) +% in (##1) +% -- node [anchor = west, +% text width = {\WithArrowsRightX - \x1 - 0.5 em}] {##3} +% (##2) ; +% \draw let \p1 = (##1) +% in (##1) -- ++(\WithArrowsRightX - \x1,0) |- (##2) ; }} % %\begin{DispWithArrows}[MyStyle] % S_n @@ -2027,26 +2060,26 @@ version 2005/12/01 or later. % \bigskip % \subsubsection{Example 3} % -% In the following example, we change the shape of the arrow depending on wether +% In the following example, we change the shape of the arrow depending on whether % the start row is longer than the end row or not. This example requires the % Tikz library \pkg{calc}. % % \begin{Verbatim} % \begin{WithArrows}[ll,interline=5mm,xoffset=5mm, -% ~emphase#TikzCode = {\draw[rounded corners,@ -% ~emphase# every node/.style = {circle,@ -% ~emphase# draw,@ -% ~emphase# auto = false,@ -% ~emphase# inner sep = 1pt,@ -% ~emphase# fill = gray!50,@ -% ~emphase# font = \tiny }]@ -% ~emphase# let \p1 = (~#1),@ -% ~emphase# \p2 = (~#2)@ -% ~emphase# in \ifdim \x1 > \x2@ -% ~emphase# (\p1) -- node {~#3} (\x1,\y2) -- (\p2)@ -% ~emphase# \else@ -% ~emphase# (\p1) -- (\x2,\y1) -- node {~#3} (\p2)@ -% ~emphase# \fi ;}@] +% ~emphase#tikz-code = {\draw[rounded corners,@ +% ~emphase# every node/.style = {circle,@ +% ~emphase# draw,@ +% ~emphase# auto = false,@ +% ~emphase# inner sep = 1pt,@ +% ~emphase# fill = gray!50,@ +% ~emphase# font = \tiny }]@ +% ~emphase# let \p1 = (~#1),@ +% ~emphase# \p2 = (~#2)@ +% ~emphase# in \ifdim \x1 > \x2@ +% ~emphase# (\p1) -- node {~#3} (\x1,\y2) -- (\p2)@ +% ~emphase# \else@ +% ~emphase# (\p1) -- (\x2,\y1) -- node {~#3} (\p2)@ +% ~emphase# \fi ;}@] % E & \Longleftrightarrow \frac{(x+4)}3 + \frac{5x+3}5 = 7 % \Arrow{$\times 15$}\\ % & \Longleftrightarrow 5(x+4) + 3(5x+3) = 105 \\ @@ -2061,20 +2094,20 @@ version 2005/12/01 or later. % % % \[\begin{WithArrows}[ll,interline=5mm,xoffset=5mm, -% TikzCode = {\draw[rounded corners, -% every node/.style = {circle, -% draw, -% auto = false, -% inner sep = 1pt, -% fill = gray!50, -% font = \tiny}] -% let \p1 = (#1), -% \p2 = (#2) -% in \ifdim \x1 > \x2 -% (\p1) -- node {#3} (\x1,\y2) -- (\p2) -% \else -% (\p1) -- (\x2,\y1) -- node {#3} (\p2) -% \fi ;}] +% tikz-code = {\draw[rounded corners, +% every node/.style = {circle, +% draw, +% auto = false, +% inner sep = 1pt, +% fill = gray!50, +% font = \tiny}] +% let \p1 = (#1), +% \p2 = (#2) +% in \ifdim \x1 > \x2 +% (\p1) -- node {#3} (\x1,\y2) -- (\p2) +% \else +% (\p1) -- (\x2,\y1) -- node {#3} (\p2) +% \fi ;}] % E & \Longleftrightarrow \frac{(x+4)}3 + \frac{5x+3}5 = 7 % \Arrow{$\times 15$}\\ % & \Longleftrightarrow 5(x+4) + 3(5x+3) = 105 \\ @@ -2092,7 +2125,7 @@ version 2005/12/01 or later. % % Assume we want to draw a loop of numbered arrows. In this purpose, it's % possible to write a dedicated command |\NumberedLoop| which will do the job -% when used in |CodeAfter|. In the following example, we write this command with +% when used in |code-after|. In the following example, we write this command with % |\NewDocumentCommand| of \pkg{xparse} and |\foreach| of \pkg{pgffor} (both % packages are loaded when \pkg{witharrows} is loaded). % @@ -2104,14 +2137,14 @@ version 2005/12/01 or later. % \Arrow[rr,xoffset=1cm,tikz=<-]{1}{\WithArrowsNbLines}{\WithArrowsNbLines}} % \end{Verbatim} % -% The command |\WithArrowsNbLines| is a command available in |CodeAfter| which +% The command |\WithArrowsNbLines| is a command available in |code-after| which % gives the total number of lines (=rows) of the current environment (it's a % command and not a counter). % % % \bigskip % \begin{Verbatim} -% $\begin{WithArrows}[~emphase#CodeAfter = \NumberedLoop@] +% $\begin{WithArrows}[~emphase#code-after = \NumberedLoop@] % a.\;& f \text{ est continuous on } E \\ % b.\;& f \text{ est continuous in } 0 \\ % c.\;& f \text{ is bounded on the unit sphere} \\ @@ -2129,7 +2162,7 @@ version 2005/12/01 or later. % \Arrow[rr,xoffset=1cm,tikz=<-]{1}{\WithArrowsNbLines}{\WithArrowsNbLines}} % % -% $\begin{WithArrows}[CodeAfter = \NumberedLoop] +% $\begin{WithArrows}[code-after = \NumberedLoop] % a.\;& f \text{ est continuous on } E \\ % b.\;& f \text{ est continuous in } 0 \\ % c.\;& f \text{ is bounded on the unit sphere} \\ @@ -2142,15 +2175,15 @@ version 2005/12/01 or later. % As usual, it's possible to change the characteristic of both arrows and nodes % with the option |tikz|. However, if we want to change the style to have, for % example, numbers in parenthesis, the best way is to change the value of -% |TikzCode|: +% |tikz-code|: % % \begin{Verbatim} -% TikzCode = {\draw (~#1) to node {\footnotesize (~#3)} (~#2) ;} +% tikz-code = {\draw (~#1) to node {\footnotesize (~#3)} (~#2) ;} % \end{Verbatim} % -% \WithArrowsOptions{TikzCode = {\draw (#1) to node {\footnotesize (#3)} (#2) ;}} +% \WithArrowsOptions{tikz-code = {\draw (#1) to node {\footnotesize (#3)} (#2) ;}} % -% $\begin{WithArrows}[CodeAfter = \NumberedLoop] +% $\begin{WithArrows}[code-after = \NumberedLoop] % a.\;& f \text{ est continuous on } E \\ % b.\;& f \text{ est continuous in } 0 \\ % c.\;& f \text{ is bounded on the unit sphere} \\ @@ -2320,7 +2353,7 @@ version 2005/12/01 or later. % \end{macrocode} % The flag |\g_@@_footnote_bool| is raised and so, we will only have to test % |\g_@@_footnote_bool| in order to know if we have to insert an environnement -% |{savenotes}| (the |\begin{savenotes}| is in |\@@_pre_environment:n| and +% |{savenotes}| (the |\begin{savenotes}| is in |\@@_pre_halign:n| and % |\end{savenotes}| at the end of the environments |{WithArrows}| and % |{DispWithArrows}|). % @@ -2353,7 +2386,11 @@ version 2005/12/01 or later. \cs_generate_variant:Nn \@@_error:nn { n x } % \end{macrocode} % -% +% \begin{macrocode} +\cs_generate_variant:Nn \tl_put_right:Nn { N v } +\cs_generate_variant:Nn \seq_set_split:Nnn { N x x } +% \end{macrocode} +% % \medskip % We create booleans in order to know if some packages are loaded. For example, % for the package \pkg{amsmath}, the boolean is called @@ -2379,7 +2416,7 @@ version 2005/12/01 or later. % % \bigskip % We define a command |\@@_strcmp:nn| to compare two token lists. It will be -% available wether the engine is pdfTeX, XeTeX or LuaTeX. +% available whether the engine is pdfTeX, XeTeX or LuaTeX. % \begin{macrocode} \sys_if_engine_luatex:TF { @@ -2412,11 +2449,6 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \bigskip -% The following variant will be used in the following command. -% \begin{macrocode} -\cs_generate_variant:Nn \seq_set_split:Nnn { N x x } -% \end{macrocode} % % \bigskip % The command |\@@_save:N| saves a \pkg{expl3} variable by creating a global @@ -2525,19 +2557,19 @@ version 2005/12/01 or later. \tikzset { WithArrows / arrow / .style = - { - align = left , + { + align = left , % \end{macrocode} % % We have put the option |align = left| because we want to give the user the % possibility of using |\\| in the labels. % \begin{macrocode} - auto = left , - font = \small \itshape , - WithArrows / arrow / tips , - bend~left = 45 , - -> - } + auto = left , + font = \small \itshape , + WithArrows / arrow / tips , + bend~left = 45 , + -> + } } % \end{macrocode} % @@ -2567,17 +2599,26 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% For the construction of the preambles of the environments |{WithArrows}| and +% |{DispWithArrows}|, we will have to insert the token |#| (catcode 6). We put it +% in a \emph{toks register} of TeX (with no equivalent in \pkg{expl3}). +% \begin{macrocode} +\newtoks \@@_parameter_token +\@@_parameter_token = { # } +% \end{macrocode} +% +% \bigskip % \subsection{Variables} % % The boolean |\l_@@_in_WithArrows_bool| will be raised in an environment -% |{WithArrows}| and the boolean |\l_@@_in_dispwitharrows_bool| in an -% environment |{DispWithArrows}| or |{DispWithArrows*}|. The boolean -% |\l_@@_in_CodeAfter_bool| will be raised during the execution of the -% |CodeAfter| (option |CodeAfter|). +% |{WithArrows}| and the boolean |\l_@@_in_dispwitharrows_bool| will be raised +% in an environment |{DispWithArrows}| or |{DispWithArrows*}|. The boolean +% |\l_@@_in_code_after_bool| will be raised during the execution of the +% |code-after| (option |code-after|). % \begin{macrocode} \bool_new:N \l_@@_in_WithArrows_bool \bool_new:N \l_@@_in_DispWithArrows_bool -\bool_new:N \l_@@_in_CodeAfter_bool +\bool_new:N \l_@@_in_code_after_bool % \end{macrocode} % % \bigskip @@ -2607,7 +2648,7 @@ version 2005/12/01 or later. % \bigskip % The integer |\l_@@_pos_arrow_int| indicates the position of the arrow with the % following code (the option |v| is accessible only for the arrows in -% |CodeAfter| where the options |i|, |group| et |groups| are not available). +% |code-after| where the options |i|, |group| et |groups| are not available). % % \begin{center} % \begin{tabular}{l} @@ -2618,7 +2659,7 @@ version 2005/12/01 or later. % |\l_@@_pos_arrow_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\ % \bottomrule % \end{tabular} \\ -% \footnotesize The option |v| can be used only in |\Arrow| in |CodeAfter| (see +% \footnotesize The option |v| can be used only in |\Arrow| in |code-after| (see % below). % \end{tabular} % \end{center} @@ -2631,10 +2672,11 @@ version 2005/12/01 or later. % % \bigskip % In the |\halign| of an environment |{WithArrows}| or |{DispWithArrows}|, we -% will have to use two counters: +% will have to use four 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_int| to count the lines of the |\halign| ; +% \item |\g_@@_col_int| to count the column of the |\halign|. % \end{itemize} % % These counters will be incremented in a cell of the |\halign| and, therefore, @@ -2647,6 +2689,8 @@ 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_@@_col_int_seq +\int_new:N \g_@@_col_int % \end{macrocode} % % @@ -2659,18 +2703,37 @@ version 2005/12/01 or later. \clist_new:N \l_@@_tags_clist \clist_set:Nn \l_@@_tags_clist { all } % \end{macrocode} -% % % \bigskip +% During the execution of an environment |{DispWithArrows}|, if a row must be +% tagged, the (local) value of |\l_@@_tags_clist| will be put (by convention) to +% |all|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_test_if_to_tag: + { + \clist_if_in:NVT \l_@@_tags_clist \g_@@_line_int + { \clist_set:Nn \l_@@_tags_clist { all } } + } +% \end{macrocode} +% +% +% \bigskip +% If the user has given a value for the option |command-name| (at the global or +% at the \emph{environment} level), a command with this name is defined locally +% in the environment with meaning |\@@_Arrow|. The default value of the option +% |command-name| is ``|Arrow|'' and thus, by default, the name of the command +% will be |\Arrow|. % \begin{macrocode} -\str_set:Nn \l_@@_CommandName_str { Arrow } +\str_new:N \l_@@_command_name_str +\str_set:Nn \l_@@_command_name_str { Arrow } % \end{macrocode} % % \bigskip % The string |\l_@@_string_Arrow_for_msg_str| is only a string that will be -% displayed in some error messages. For example, if |CommandName| is defined to +% displayed in some error messages. For example, if |command-name| is defined to % be |Explanation|, this string will contain ``|\Arrow alias \Explanation|''. % \begin{macrocode} +\str_new:N \l_@@_string_Arrow_for_msg_str \str_set:Nx \l_@@_string_Arrow_for_msg_str { \token_to_str:N \Arrow } % \end{macrocode} % @@ -2696,6 +2759,31 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% \begin{macrocode} +\bool_new:N \l_@@_in_first_columns_bool +\bool_new:N \l_@@_tag_star_bool +\bool_new:N \l_@@_tag_next_line_bool +\bool_new:N \l_@@_qedhere_bool +\bool_new:N \l_@@_new_group_bool +\bool_new:N \l_@@_initial_r_bool +\bool_new:N \l_@@_final_r_bool +\tl_new:N \l_@@_initial_tl +\tl_new:N \l_@@_final_tl +\int_new:N \l_@@_nb_of_columns_int +\bool_new:N \l_@@_last_col_bool +% \end{macrocode} +% +% \bigskip +% The string |\l_@@_format_str| will contain the \emph{format} of the array +% which is a succession of letters |r|, |c| and |l| specifying the type of the +% columns of the |\halign| (except the column for the labels of the equations +% in the environment |{DispWithArrows}|). +% \begin{macrocode} +\str_new:N \l_@@_format_str +% \end{macrocode} +% +% +% \bigskip % \subsection{The definition of the options} % % There are four levels where options can be set: @@ -2708,17 +2796,18 @@ version 2005/12/01 or later. % the current TeX group.}; % \item with |\begin{WithArrows}[...]|: this level will be called % \emph{environment} level; -% \item with |\Arrow[...]| (included in |CodeAfter|): this level will be called +% \item with |\Arrow[...]| (included in |code-after|): this level will be called % \emph{local} level. % \end{itemize} % % % \bigskip % When we scan a list of options, we want to be able to raise an error if two -% options of position of the arrows are present. That's why we keep -% the first option of position in a variable called |\l_@@_previous_key_str|. -% The following function |\@@_eval_if_allowed:n| will execute its argument only -% if a first key of position has not been set (and raise an error elsewhere). +% options of position (|ll|, |rl|, |i|, etc.) of the arrows are present. That's +% why we keep the first option of position in a variable called +% |\l_@@_previous_key_str|. The following function |\@@_eval_if_allowed:n| will +% execute its argument only if a first key of position has not been set (and +% raise an error elsewhere). % % \begin{macrocode} \cs_new_protected:Npn \@@_eval_if_allowed:n #1 @@ -2751,16 +2840,17 @@ version 2005/12/01 or later. ystart .value_required:n = true , ystart .initial:n = 0.4 ex , more-columns .code:n = - \@@_msg_redirect_name:nn { Third~column~in~WithArrows } { none } , + \@@_msg_redirect_name:nn { Too~much~columns~in~WithArrows } { none } , more-columns .value_forbidden:n = true, - CommandName .code:n = - \str_set:Nn \l_@@_CommandName_str { #1 } + command-name .code:n = + \str_set:Nn \l_@@_command_name_str { #1 } \str_set:Nx \l_@@_string_Arrow_for_msg_str { \c_backslash_str Arrow~alias~\c_backslash_str #1 } , - CommandName .value_required:n = true , - TikzCode .tl_set:N = \l_@@_tikz_code_tl, - TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , - TikzCode .value_required:n = true , + command-name .value_required:n = true , + tikz-code .tl_set:N = \l_@@_tikz_code_tl, + tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , + tikz-code .value_required:n = true , + TikzCode .meta:n = { tikz-code = #1 } , displaystyle .bool_set:N = \l_@@_displaystyle_bool , displaystyle .default:n = true , show-nodes .code:n = @@ -2826,7 +2916,7 @@ version 2005/12/01 or later. % With the option |no-arrows|, the arrows won't be drawn. However, the ``first % pass'' of the arrows is done and some errors may be detected. The % nullification of |\@@_draw_arrows:nn| is for the standard arrows and the -% nullification of |\@@_draw_arrow:nnn| is for ``Arrow in CodeAfter''. +% nullification of |\@@_draw_arrow:nnn| is for ``Arrow in code-after''. % \begin{macrocode} no-arrows .code:n = \cs_set_eq:NN \@@_draw_arrows:nn \use_none:nn @@ -2908,12 +2998,37 @@ version 2005/12/01 or later. { \seq_gput_left:Nn \g_@@_names_seq { #1 } } \str_set:Nn \l_@@_name_str { #1 } , name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l_@@_code_before_tl { #1 } , - CodeBefore .value_required:n = true, - CodeAfter .code:n = \tl_put_right:Nn \l_@@_code_after_tl { #1 } , - CodeAfter .value_required:n = true + code-before .code:n = \tl_put_right:Nn \l_@@_code_before_tl { #1 } , + code-before .value_required:n = true, + CodeBefore .meta:n = { code-before = #1 } , + code-after .code:n = \tl_put_right:Nn \l_@@_code_after_tl { #1 } , + code-after .value_required:n = true , + CodeAfter .meta:n = { code-after = #1 } , + format .code:n = \@@_set_option_format:n { #1 }, + format .value_required:n = true , } % \end{macrocode} +% +% \medskip +% An option |format| should contain only the letters |r|, |c| and |l|. That's +% why we write a function to validate and set the value given to |format|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_set_option_format:n #1 + { + \bool_set_true:N \l_tmpa_bool + \str_map_inline:nn { #1 } + { + \str_if_in:nnF {rcl} { ##1 } + { + \bool_set_false:N \l_tmpa_bool + \@@_error:n { Invalid~option~format } + \str_map_break: + } + } + \bool_if:NT \l_tmpa_bool { \tl_set:Nn \l_@@_format_str { #1 } } + } +% \end{macrocode} +% % % \bigskip % Now, we begin the construction of the major sets of keys which are named @@ -2944,29 +3059,30 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \medskip -% \begin{macrocode} -\keys_define:nn { WithArrows / WithArrows } - { - unknown .code:n = - \@@_sort_seq:N \l_@@_options_WithArrows_seq - \@@_error:n { Unknown~option~WithArrows } - } -% \end{macrocode} % % \bigskip % A sequence of the options available in |{WithArrows}|. This sequence will be % used in the error messages and can be modified dynamically. % \begin{macrocode} +\seq_new:N \l_@@_options_WithArrows_seq \seq_set_from_clist:Nn \l_@@_options_WithArrows_seq { - adjust, b, c, CodeAfter, CodeBefore, CommandName, displaystyle, end-adjust, - group, groups, i, interline, jot, ll, lr, more-columns, name, no-arrows, rl, - rr, show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, - ygap, ystart + adjust, b, c, code-after, code-before, command-name, displaystyle, end-adjust, + format, group, groups, i, interline, jot, ll, lr, more-columns, name, + no-arrows, rl, rr, show-node-names, show-nodes, start-adjust, t, tikz, + tikz-code, xoffset, ygap, ystart } % \end{macrocode} % +% \medskip +% \begin{macrocode} +\keys_define:nn { WithArrows / WithArrows } + { + unknown .code:n = + \@@_sort_seq:N \l_@@_options_WithArrows_seq + \@@_error:n { Unknown~option~WithArrows } + } +% \end{macrocode} % % \bigskip % \begin{macrocode} @@ -2982,13 +3098,14 @@ version 2005/12/01 or later. % A sequence of the options available in |{DispWithArrows}|. This sequence will % be used in the error messages and can be modified dynamically. % \begin{macrocode} +\seq_new:N \l_@@_options_DispWithArrows_seq \seq_set_from_clist:Nn \l_@@_options_DispWithArrows_seq { - allow-multiple-labels, CodeAfter, CodeBefore, CommandName, TikzCode, adjust, - displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, name, no-arrows, nonumber, notag, rl, rr, show-node-names, - show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, - ystart + allow-multiple-labels, code-after, code-before, command-name, tikz-code, adjust, + displaystyle, end-adjust, fleqn, group, format, groups, i, interline, jot, + ll, lr, mathindent, name, no-arrows, nonumber, notag, rl, rr, + show-node-names, show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, + xoffset, ygap, ystart } % \end{macrocode} % @@ -3010,10 +3127,11 @@ version 2005/12/01 or later. % A sequence of the options available in |\WithArrowsOptions|. This sequence % will be used in the error messages and can be modified dynamically. % \begin{macrocode} +\seq_new:N \l_@@_options_WithArrowsOptions_seq \seq_set_from_clist:Nn \l_@@_options_WithArrowsOptions_seq { - allow-duplicate-names, allow-multiple-labels, b, c, CommandName, - more-columns, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, + allow-duplicate-names, allow-multiple-labels, b, c, command-name, + more-columns, tikz-code, adjust, displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, mathindent, no-arrows, nonumber, notag, rl, rr, show-node-names, show-nodes, standard-behaviour-with-items, start-adjust, t, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart @@ -3022,7 +3140,7 @@ version 2005/12/01 or later. % % \bigskip % The command |\@@_set_independent:| is a command without argument that will be -% used to specifiy that the arrow will be ``independent'' (of the potential +% used to specify that the arrow will be ``independent'' (of the potential % groups of the option |group| or |groups|). This information will be stored in % the field ``status'' of the arrow. Another value of the field ``status'' is % ``new-group''. @@ -3079,8 +3197,8 @@ version 2005/12/01 or later. % listed in this keys set. An unknown key will be detected at the point of the % command |\Arrow| and not at the end of the environment. % \begin{macrocode} - TikzCode .code:n = \prg_do_nothing: , - TikzCode .value_required:n = true , + tikz-code .code:n = \prg_do_nothing: , + tikz-code .value_required:n = true , tikz .code:n = \prg_do_nothing: , tikz .value_required:n = true , % \end{macrocode} @@ -3110,9 +3228,10 @@ version 2005/12/01 or later. % A sequence of the options available in |\Arrow|. This sequence will be used in % the error messages and can be modified dynamically. % \begin{macrocode} +\seq_new:N \l_@@_options_Arrow_seq \seq_set_from_clist:Nn \l_@@_options_Arrow_seq { - adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, TikzCode, + adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, tikz-code, xoffset } % \end{macrocode} @@ -3138,8 +3257,8 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn {WithArrows / Arrow / SecondPass } { - TikzCode .tl_set:N = \l_@@_tikz_code_tl , - TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , + tikz-code .tl_set:N = \l_@@_tikz_code_tl , + tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , tikz .initial:n = \c_empty_tl , rr .code:n = \@@_fix_pos_arrow:n 3 , @@ -3170,7 +3289,7 @@ version 2005/12/01 or later. % |\WithArrowsOptions| is the command of the \pkg{witharrows} package to fix % options at the document level. It's possible to fix in |\WithArrowsOptions| % some options specific to |{WithArrows}| (in contrast with |{DispWithArrows}|) -% or specific to |{DispWithArrows}| (in construct with |{WithArrows}|). That's +% or specific to |{DispWithArrows}| (in contrast with |{WithArrows}|). That's % why we have constructed a set of keys specific to |\WithArrowsOptions|. % \begin{macrocode} \NewDocumentCommand \WithArrowsOptions { m } @@ -3182,12 +3301,12 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection{The command Arrow} +% \subsection{The command \textbackslash Arrow} % % In fact, the internal command is not named |\Arrow| but |\@@_Arrow|. Usually, % at the beginning of an environment |{WithArrows}|, |\Arrow| is set to be % equivalent to |\@@_Arrow|. However, the user can change the name with the -% option |CommandName| and the user command for |\@@_Arrow| will be different. +% option |command-name| and the user command for |\@@_Arrow| will be different. % This mechanism can be useful when the user has already a command named % |\Arrow| he still wants to use in the environments |{WithArrows}| or % |{DispWithArrows}|. @@ -3279,23 +3398,30 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip +% The command |\Arrow| (or the corresponding command with a name given by the +% user with the option |command-name|) will be available only in the last column of +% the environments |{WithArrows}| and |{DispWithArrows}|. In the other columns, +% the command will be linked to the following command |\@@_Arrow_first_columns:| +% which will raise an error. % \begin{macrocode} -\cs_new_protected:Npn \@@_Arrow_first_column: - { \@@_error:n { Arrow~in~first~column } \@@_Arrow } +\cs_new_protected:Npn \@@_Arrow_first_columns: + { \@@_error:n { Arrow~not~in~last~column } \@@_Arrow } % \end{macrocode} % % % \bigskip -% \subsection{The environment \{WithArrows\}} +% \subsection{The environments \{WithArrows\} and \{DispWithArrows\}} +% +% \subsubsection{Code before the \textbackslash halign} % -% The command |\@@_pre_environement:| is a code common to the environments +% The command |\@@_pre_halign:n| is a code common to the environments % |{WithArrows}| and |{DispWithArrows}|. The argument is the list of options % given to the environment. % \begin{macrocode} -\cs_new_protected:Npn \@@_pre_environment:n #1 +\cs_new_protected:Npn \@@_pre_halign:n #1 % \end{macrocode} % -% First the initialisation of |\l_@@_type_env_str| which is the name of the +% First, the initialisation of |\l_@@_type_env_str| which is the name of the % encompassing environment. In fact, this token list is used only in the error % messages. % \begin{macrocode} @@ -3348,14 +3474,16 @@ version 2005/12/01 or later. % \end{macrocode} % % -% The initialisation of the counters |\g_@@_arrow_int| and |\g_@@_line_int|. -% However, we have to save their previous values with the two stacks created for -% this end. +% The initialisation of the counters |\g_@@_arrow_int|, |\g_@@_line_int| and +% |\g_@@_col_int|. However, we have to save their previous values with the +% 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_@@_col_int_seq \g_@@_col_int + \int_gzero:N \g_@@_col_int % \end{macrocode} % % \bigskip @@ -3393,18 +3521,32 @@ version 2005/12/01 or later. \int_zero_new:N \l_@@_arrow_int \int_zero_new:N \l_@@_pos_of_arrow_int \int_zero_new:N \l_@@_jump_int +% \end{macrocode} +% +% \medskip +% The counter |\l_@@_jump_int| corresponds to the option |jump|. Now, we set the +% default value for this option. +% \begin{macrocode} \int_set:Nn \l_@@_jump_int \c_one_int % \end{macrocode} % +% \medskip +% The string |\l_@@_format_str| corresponds to the option |format|. Now, we set +% the default value for this option. +% \begin{macrocode} + \str_set:Nn \l_@@_format_str { rl } +% \end{macrocode} +% % \bigskip -% The boolean |\l_@@_in_first_column_bool| will be used to know wether we are in -% the first column of the environment |{WithArrows}| or |{DispWithArrows}|. +% The boolean |\l_@@_last_col_bool| will be used only during the construction of +% the preamble (in |\@@_construct_halign:|). % \begin{macrocode} - \bool_set_false:N \l_@@_in_first_column_bool + \bool_set_true:N \l_@@_last_col_bool % \end{macrocode} % +% % \bigskip -% In (the second column of) |{DispWithArrows}|, it's possible to put several +% In (the last 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} @@ -3425,10 +3567,10 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The value corresponding to the key |CodeBefore| is put to nil before the +% The value corresponding to the key |code-before| is put to nil before the % treatment of the options of the environment, because, of course, we don't want % the code executed at the beginning of all the nested -% environments~|{WithArrows}|. Idem for |CodeAfter|. +% environments~|{WithArrows}|. Idem for |code-after|. % \begin{macrocode} \tl_clear_new:N \l_@@_code_before_tl \tl_clear_new:N \l_@@_code_after_tl @@ -3445,32 +3587,63 @@ version 2005/12/01 or later. { \keys_set:nn { WithArrows / DispWithArrows } { #1 } } % \end{macrocode} % +% \medskip +% Now we link the command |\Arrow| (or the corresponding command with a name +% given by the user with the option |command-name|: that's why the following line +% must be after the loading of the options) to the command +% |\@@_Arrow_first_columns:| which will raise an error. +% \begin{macrocode} + \cs_set_eq:cN \l_@@_command_name_str \@@_Arrow_first_columns: +% \end{macrocode} +% It's only in the last column of the environment that it will be linked to the +% command |\@@_Arrow:|. +% +% \medskip +% The counter |\l_@@_nb_of_columns_int| is the number of columns in the +% |\halign| (excepted the column for the labels of equations in +% |{DispWithArrows}| and excepted evenutals other columns in |{WithArrows}| if +% the user uses the option |more-columns|). +% \begin{macrocode} + \int_set:Nn \l_@@_nb_of_columns_int { \str_count:N \l_@@_format_str } +% \end{macrocode} +% +% \medskip +% We convert the format in a sequence because we use it as a stack in the +% construction of the preamble. +% \begin{macrocode} + \seq_clear_new:N \l_@@_format_seq + \seq_set_split:NnV \l_@@_format_seq { } \l_@@_format_str +% \end{macrocode} +% % \bigskip % If the option |footnote| or the option |footnotehyper| is used, then we -% extract the footnotes with a environment |{savenotes}| (of the package +% 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 } } % \end{macrocode} % % \bigskip -% We execute the code |\l_@@_code_before_tl| of the option |CodeBefore| of the -% environment after the eventual |\savenotes| and, symetrically, we will execute -% the |\l_@@_code_after_tl| before the eventual |\endsavenotes| (we have a good -% reason for the last point: we want to extract the footnotes of the arrows -% executed in the |CodeAfter|). +% We execute the code |\l_@@_code_before_tl| of the option |code-before| of the +% environment after the eventual |\begin{savenotes}| and, symetrically, we will +% execute the |\l_@@_code_after_tl| before the eventual |\end{savenotes}| (we +% have a good reason for the last point: we want to extract the footnotes of the +% arrows executed in the |code-after|). % \begin{macrocode} \l_@@_code_before_tl % \end{macrocode} % % \bigskip -% If the user has given a value for the option |CommandName| (at the global or -% at the \emph{environment} level), a command with this name is defined locally -% in the environment with meaning |\@@_Arrow|. The default value of the option -% |CommandName| is ``|Arrow|'' and thus, by default, the name of the command -% will be |\Arrow|. +% The command |\spread@equation| is the command used by \pkg{amsmath} in the +% beginning of an alignment to fix the interline. When used, it becomes no-op. +% However, it's possible to use \pkg{witharrows} without \pkg{amsmath} since we +% have redefined |\spread@equation| (if it is not defined yet). +% \begin{macrocode} + \spread@equation +% \end{macrocode} +% +% % \begin{macrocode} - \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow \cs_set_eq:NN \notag \@@_notag: \cs_set_eq:NN \nonumber \@@_notag: \cs_set_eq:NN \tag \@@_tag @@ -3479,74 +3652,141 @@ version 2005/12/01 or later. \cs_set_eq:NN \tagnextline \@@_tagnextline: } % \end{macrocode} -% This is the end of |\@@_pre_environment:n|. -% +% This is the end of |\@@_pre_halign:n|. % % \bigskip -% Now, we begin the environment |{WithArrows}|. +% \subsubsection{The construction of the preamble of the \textbackslash halign} +% +% The control sequence |\@@_construct_halign:| will ``start'' the |\halign| and +% the preamble. In fact, it constructs all the preamble excepted the end of +% the last column (more precisely: except the part concerning the construction +% of the left node and the right node). +% +% The same function |\@@_construct_halign:| will be used both for |{WithArrows}| +% and |{DispWithArrows}|. +% +% Several important points must be noted concerning that construction of the +% preamble. +% \begin{itemize} +% \item The construction of the preamble is done by reading backwards the +% format |\l_@@_format_str| and adding the corresponding tokens in the input +% stream of TeX. That means that the part of the preamble concerning the last +% cell will be constructed first. +% \item The function |\@@_construct_halign:| is recursive in order to treat +% succesively all the letters of the preamble. +% \item Each part of the preamble is created with a |\use:x| function. This +% expansion of the preamble gives the ability of controlling which parts of the +% code will be expanded during the construction of the preamble (other parts +% will be expanded and executed only during the execution of the |\halign|). +% \end{itemize} +% % \begin{macrocode} -\NewDocumentEnvironment { WithArrows } { ! O { } } - { - \bool_set_true:N \l_@@_in_WithArrows_bool - \bool_set_false:N \l_@@_in_DispWithArrows_bool - \@@_pre_environment:n { #1 } - \if_mode_math: \else: - \@@_error:n { WithArrows~outside~math~mode } - \fi: +\cs_new_protected:Npn \@@_construct_halign: + { + \seq_pop_right:NNTF \l_@@_format_seq \l_@@_type_col_str + { % \end{macrocode} -% \bigskip -% The environment begins with a |\vtop|, a |\vcenter| or a -% |\vbox|\footnote{Notice that the use of |\vtop| seems color-safe here...} -% depending of the value of |\l_@@_pos_env_int| (fixed by the options |t|, |c| -% or |b|). The environment |{WithArrows}| must be used in math mode\footnote{An -% error is raised if the environment is used outside math mode.} and therefore, -% we can use |\vcenter|. +% Here is the |\use:x| which is fundamental: it will really construct the part +% of the preamble corresponding to a column by expanding only some parts of the +% following code. % \begin{macrocode} - \int_case:nn \l_@@_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox } - \bgroup + \use:x + { % \end{macrocode} +% Before the recursive call of |\@@_construct_halign:|, +% we lower the flag |\l_@@_last_col_bool| in order that all the recursive calls +% will know that they are not in the last column. But, during the construction +% of the first column, it is \emph{not} lowered because |\bool_set_false:N|, +% which is protected, won't be expanded by the |\use:x|. % -% \bigskip -% The command |\spread@equation| is the command used by \pkg{amsmath} in the -% beginning of an alignment to fix the interline. When used, it becomes no-op. -% However, it's possible to use \pkg{witharrows} without \pkg{amsmath} since we -% have redefined |\spread@equation| (if it is not defined yet). +% We begin the construction of a generic column. % \begin{macrocode} - \spread@equation + \bool_set_false:N \l_@@_last_col_bool + \@@_construct_halign: + \bool_if:NT \l_@@_last_col_bool + { % \end{macrocode} -% -% \bigskip -% We begin the |\halign| and the preamble. +% We redefine the command |\Arrow| (or the name given to the corresponding +% command by the option |command-name|) in each cell of the last column. +% The braces around |\l_@@_command_name_str| are mandatory because +% |\l_@@_command_name_str| will be expanded by the |\use:x| and the command +% |\cs_set_eq:cN| must still be efficient during the execution of the |\halign|. % \begin{macrocode} - \ialign \bgroup + \cs_set_eq:cN { \l_@@_command_name_str } \@@_Arrow + \bool_if:NT \l_@@_in_DispWithArrows_bool + { % \end{macrocode} -% -% \bigskip -% We increment the counter |\g_@@_line_int| which will be used in the names of -% the Tikz nodes created in the array. This incrementation must be global -% (|gincr|) because we are in the cell of a |\halign|. It's recalled that we -% manage a stack for this counter. -% \begin{macrocode} - \int_gincr:N \g_@@_line_int - \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow_first_column: - \bool_set_true:N \l_@@_in_first_column_bool - \strut \hfil - $ - \bool_if:NT \l_@@_displaystyle_bool \displaystyle - { ## } - $ - & +% The command |\@@_test_if_to_tag:| (which is protected and, thus, will not be +% expanded during the construction of the preamble) will test, at each row, +% whether the current row must be tagged (and the tag will be put in the very +% last column). +% \begin{macrocode} + \@@_test_if_to_tag: % \end{macrocode} -% -% \bigskip +% The command |\@@_set_qedhere:| will do a redefinition of |\qedhere| in each +% cell of the last column. % \begin{macrocode} - $ - \bool_if:NT \l_@@_displaystyle_bool \displaystyle - { { } ## } - $ + \bool_if:NT \c_@@_amsthm_loaded_bool \@@_set_qedhere: + } + } + \str_if_eq:VnT \l_@@_type_col_str { c } \hfil + \str_if_eq:VnT \l_@@_type_col_str { r } \hfill + \int_gincr:N \g_@@_col_int + $ % $ + { + { } + \bool_if:NT \l_@@_displaystyle_bool \displaystyle + #### + } + $ % $ + \bool_if:NTF \l_@@_last_col_bool + { \@@_construct_nodes: } + { +% \end{macrocode} +% The following glue (|\hfil|) will be added only if we are not in the last cell +% because, in the last cell, a glue is added beetween the nodes (in +% |\@@_construct_nodes:|). +% \begin{macrocode} + \str_if_eq:VnT \l_@@_type_col_str { l } \hfil + \str_if_eq:VnT \l_@@_type_col_str { c } \hfil + \bool_if:NT \l_@@_in_DispWithArrows_bool { \tabskip = \c_zero_skip } + & + } + } + } % \end{macrocode} +% Now the tokens that will be inserted after the analyze of all the tokens of +% the format: here is the token |\halign|. +% \begin{macrocode} + { + \bool_if:NTF \l_@@_in_WithArrows_bool + { + \ialign + \bgroup + } + { + \halign to + \bool_if:NTF \l_@@_inlabel_bool \linewidth \displaywidth + \bgroup + \bool_if:NT \l_@@_fleqn_bool + { \skip_horizontal:N \l_@@_mathindent_dim } + } + \int_gincr:N \g_@@_line_int + \int_gzero:N \g_@@_col_int + \strut + } + } +% \end{macrocode} +% % % \bigskip +% The command |\@@_construct_nodes:| is only for the lisibility of the code +% because, in fact, it is used only once. It construct the ``left node'' and the +% ``right node'' at the end of each row of the arrow. +% \begin{macrocode} +\cs_new_protected:Npn \@@_construct_nodes: + { +% \end{macrocode} % We create the ``left node'' of the line (when using macros in Tikz node names, % the macros have to be fully expandable: here, |\int_use:N| is fully % expandable). @@ -3588,17 +3828,59 @@ version 2005/12/01 or later. \bool_if:NT \l_@@_show_node_names_bool { \hbox_overlap_right:n - { \small wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int } + { \small wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int - r } } + } % \end{macrocode} +% +% +% +% \bigskip +% \subsubsection{The environment \{WithArrows\}} +% +% % +% \begin{macrocode} +\NewDocumentEnvironment { WithArrows } { ! O { } } + { + \bool_set_true:N \l_@@_in_WithArrows_bool + \bool_set_false:N \l_@@_in_DispWithArrows_bool + \@@_pre_halign:n { #1 } + \if_mode_math: \else: + \@@_error:n { WithArrows~outside~math~mode } + \fi: +% \end{macrocode} +% +% \bigskip +% The environment begins with a |\vtop|, a |\vcenter| or a +% |\vbox|\footnote{Notice that the use of |\vtop| seems color-safe here...} +% depending of the value of |\l_@@_pos_env_int| (fixed by the options |t|, |c| +% or |b|). The environment |{WithArrows}| must be used in math mode\footnote{An +% error is raised if the 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 } + \bgroup +% \end{macrocode} +% % \bigskip -% Usually, the |\halign| of an environment |{WithArrows}| will have exactly two -% columns. Nevertheless, if the user wants to use more columns (without arrows) +% We begin the |\halign| and the preamble. +% \begin{macrocode} + \@@_construct_halign: +% \end{macrocode} +% +% +% \medskip +% In fact, the construction of the preamble is not finished. We add a little more. +% +% \medskip +% An environmemnt |{WithArrows}| should have a number of columns equal to the +% length of its format (by default, 2 since the default format is |rl|). +% Nevertheless, if the user wants to use more columns (without arrows) % it's possible with the option |more-columns|. % \begin{macrocode} && - \@@_error:n { Third~column~in~WithArrows } + \@@_error:n { Too~much~columns~in~WithArrows } $ \bool_if:NT \l_@@_displaystyle_bool \displaystyle { ## } @@ -3607,6 +3889,7 @@ version 2005/12/01 or later. } % \end{macrocode} % +% % \bigskip % We begin the second part of the environment |{WithArrows}|. We have two % |\egroup|\,: one for the |\halign| and one for the |\vtop| (or |\vcenter| or @@ -3616,7 +3899,7 @@ version 2005/12/01 or later. \\ \egroup \egroup - \@@_post_environment: + \@@_post_halign: % \end{macrocode} % % \bigskip @@ -3631,10 +3914,12 @@ version 2005/12/01 or later. % % % \bigskip -% The command |\@@_post_environment:| is a code common to the second part of the +% \subsubsection{After the construction of the \textbackslash halign} +% +% The command |\@@_post_halign:| is a code common to the second part of the % environment |{WithArrows}| and the environment |{DispWithArrows}|. % \begin{macrocode} -\cs_new_protected:Npn \@@_post_environment: +\cs_new_protected:Npn \@@_post_halign: % \end{macrocode} % % \bigskip @@ -3652,7 +3937,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% We will execute the code specified in the option |CodeAfter|, after some +% We will execute the code specified in the option |code-after|, after some % settings. % \begin{macrocode} \group_begin: @@ -3663,16 +3948,16 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set:Npn \WithArrowsNbLines { \int_use:N \g_@@_line_int } % \end{macrocode} -% The command |\MultiArrow| is available in |CodeAfter|, and we have a special -% version of |\Arrow|, called ``|\Arrow| in |CodeAfter|'' in the +% The command |\MultiArrow| is available in |code-after|, and we have a special +% version of |\Arrow|, called ``|\Arrow| in |code-after|'' in the % documentation.\footnote{As for now, |\MultiArrow| has no option, and that's % why its internal name is a name of \pkg{expl3} with the signature |:nn| -% whereas |\Arrow| in |CodeAfter| provides options and has the name of a +% whereas |\Arrow| in |code-after| provides options and has the name of a % function defined with |\NewDocumentCommand|.} % \begin{macrocode} \cs_set_eq:NN \MultiArrow \@@_MultiArrow:nn - \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow_code_after - \bool_set_true:N \l_@@_in_CodeAfter_bool + \cs_set_eq:cN \l_@@_command_name_str \@@_Arrow_code_after + \bool_set_true:N \l_@@_in_code_after_bool \l_@@_code_after_tl \group_end: % \end{macrocode} @@ -3696,19 +3981,23 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% 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. +% Finally, we restore the previous values of the counters |\g_@@_arrow_int|, +% |\g_@@_line_int| and |\g_@@_col_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_@@_col_int_seq \l_tmpa_tl + \int_gset:Nn \g_@@_col_int \l_tmpa_tl } % \end{macrocode} -% That's the end of the command |\@@_post_environment:|. +% That's the end of the command |\@@_post_halign:|. % % \bigskip +% \subsubsection{The command of end of row} +% % We give now the definition of |\@@_cr:| which is the definition of |\\| in an % environment |{WithArrows}|. The two \pkg{expl3} commands % |\group_align_safe_begin:| and |\group_align_safe_end:| are specifically @@ -3723,7 +4012,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_cr: { \scan_stop: - \bool_if:NT \l_@@_in_first_column_bool { & { } } + \prg_replicate:nn { \l_@@_nb_of_columns_int - \g_@@_col_int } { & { } } \group_align_safe_begin: \peek_meaning_remove:NTF * \@@_cr_i: \@@_cr_i: } @@ -3853,7 +4142,7 @@ version 2005/12/01 or later. % \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 +% However, of course, the position of the |v|-node is not the same whether the % option |leqno| is used or not. That's here that we use the flag % |\c_@@_leqno_bool|. % \begin{macrocode} @@ -3889,180 +4178,38 @@ version 2005/12/01 or later. % 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} -% -% Some commands are allowed only in the second column of the environment -% |{DispWithArrows}|. We write a command |\@@_if_in_second_col_of_disp:Nn| to -% execute this command only if we are in the second column. If we are in the -% first column, an error is raised. The first argument of -% |\@@_if_in_second_col_of_disp:Nn| is the name of the command used in the error -% message and the second is the code to execute. -% \begin{macrocode} -\cs_new_protected:Npn \@@_if_in_second_col_of_disp:Nn #1 #2 - { - \bool_if:NTF \l_@@_in_WithArrows_bool - { \@@_error:nn { Not~allowed~in~WithArrows } { #1 } } - { - \bool_if:NTF \l_@@_in_first_column_bool - { \@@_error:nn { Not~allowed~in~DispWithArrows } { #1 } } - { #2 } - } - } -% \end{macrocode} -% -% \bigskip -% The command |\@@_notag:| will be linked to |\notag| and |\nonumber| in the -% environments |{WithArrows}| and |{DispWithArrows}|. -% \begin{macrocode} -\cs_new_protected:Npn \@@_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 { s m } - { - \@@_if_in_second_col_of_disp:Nn \tag - { - \tl_if_empty:NF \l_@@_tag_tl - { \@@_error:nn { Multiple~tags } { #2 } } - \clist_set:Nn \l_@@_tags_clist { all } - \bool_if:nT \c_@@_mathtools_loaded_bool - { - \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 deactivating 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:Npn \@@_label:n #1 - { - \@@_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:Npn \@@_tagnextline: - { - \@@_if_in_second_col_of_disp:Nn \tagnextline - { \bool_set_true:N \l_@@_tag_next_line_bool } - } -% \end{macrocode} +% \subsubsection{The environment \{DispWithArrows\}} % +% For the environment |{DispWithArrows}|, the general form of the construction +% is of the type: % -% \bigskip -% The environments |{DispWithArrows}| and |{DispWithArrows*}| are compliant with -% the command |\qedhere| of \pkg{amsthm}. However, this compatibility requires a -% special version of |\qedhere|. +% |\[\vtop{\halign to \displaywidth {...}}\]| % -% 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} -\cs_new_protected:Npn \@@_qedhere: { \bool_set_true:N \l_@@_qedhere_bool } -% \end{macrocode} +% The purpose of the |\vtop| is to have an environment unbreakable. % -% 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 an adaptation of the code of |\qedhere| in -% \pkg{amsthm}. -% \begin{macrocode} -\cs_new_protected:Npn \@@_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\}} -% -% -% For the environment |{DispWithArrows}|, the construction is a construction of -% the type: +% However, if we are juste after an item of a LaTeX list, the construction is +% slightly different: % -% |\[\vcenter{\halign to \displaywidth {...}}\]| +% |\[\vtop{\halign to \linewidth {...}}\]| % -% The purpose of the |\vcenter| is to have an environment unbreakable. % % \bigskip +% The boolean |\l_@@_inlabel_bool| will be raised if we are just after a |\item| +% of a list of LaTeX. % \begin{macrocode} \bool_new:N \l_@@_inlabel_bool +% \end{macrocode} +% +% +% \begin{macrocode} \NewDocumentEnvironment { DispWithArrows } { ! O { } } { % \end{macrocode} % If \pkg{mathtools} has been loaded with the option |showonlyrefs|, we disable % the code of \pkg{mathtools} for the option |showonlyrefs| with the command % |\MT_showonlyrefs_false:| (it will be reactivated at the end of the -% environment). +% environment). % \begin{macrocode} \bool_if:nT \c_@@_mathtools_loaded_bool { @@ -4091,7 +4238,7 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \c_@@_amsmath_loaded_bool \intertext@ \bool_set_true:N \l_@@_in_DispWithArrows_bool - \@@_pre_environment:n { #1 } + \@@_pre_halign:n { #1 } % \end{macrocode} % % Since the version 1.16 of \pkg{witharrows}, no space is added between an @@ -4133,8 +4280,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The construction is not exactly the same wether we are just after an |\item| -% of a LaTeX list or not. We know if we are after un |\item| thanks to the +% The construction is not exactly the same whether we are just after an |\item| +% of a LaTeX list or not. We know if we are after an |\item| thanks to the % boolean |\l_@@_inlabel_bool|. % \begin{macrocode} \bool_if:NTF \l_@@_inlabel_bool @@ -4152,86 +4299,38 @@ version 2005/12/01 or later. $$ } % \end{macrocode} -% We use a |\vcenter| in order to prevent page breaks in the environment. +% We use a |\vtop| in order to prevent page breaks in the environment. % \begin{macrocode} - \bool_if:NTF \l_@@_inlabel_bool \vtop \vcenter \bgroup - \spread@equation + \vtop \bgroup \bool_if:NTF \l_@@_fleqn_bool { \tabskip = \c_zero_skip } { \tabskip = 0 pt plus 1000 pt minus 1000 pt } - \halign to \bool_if:NTF \l_@@_inlabel_bool \linewidth \displaywidth - \bgroup - \int_gincr:N \g_@@_line_int - \cs_set_eq:cN \l_@@_CommandName_str \@@_Arrow_first_column: - \bool_set_true:N \l_@@_in_first_column_bool - \strut - \bool_if:NT \l_@@_fleqn_bool { \skip_horizontal:n \l_@@_mathindent_dim } - \hfil - $ - \bool_if:NT \l_@@_displaystyle_bool \displaystyle - { ## } - $ - \tabskip = \c_zero_skip - & - \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 - { { } ## } - $ + \@@_construct_halign: \tabskip = 0 pt plus 1000 pt minus 1000 pt - \tikz [ remember~picture , overlay ] - \node - [ - node~contents = { } , - @@_node_style , - name = wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int - l , - alias = - { - \str_if_empty:NF \l_@@_name_str - { \l_@@_name_str - \int_use:N \g_@@_line_int - l } - } - ] - ; - \hfil - \tikz [ remember~picture , overlay ] - \node - [ - node~contents = { } , - @@_node_style , - name = wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int - r , - alias = - { - \str_if_empty:NF \l_@@_name_str - { \l_@@_name_str - \int_use:N \g_@@_line_int - r } - } - ] - ; - \bool_if:NT \l_@@_show_node_names_bool - { - \hbox_overlap_right:n - { \small wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int } - } & % \end{macrocode} % -% We put now the contents of the third column in math mode because because we -% don't want an error if the user uses a third column with contents in math -% mode: the error will be in the next cell. +% If the user try to use more columns than the lenght of the format, we have to +% raise an error. However, the error won't be in the next column which is the +% columns for the labels of the equations. The error will be after... and it +% must be after. That means that we must not have an error in the next column +% simply because we are not in math mode. That's why this column, even if it is +% for the labels, is in math mode. % \begin{macrocode} $ ## $ \tabskip = \c_zero_skip && - \@@_error:n { Third~column~in~DispWithArrows } + \@@_error:n { Too~much~columns~in~DispWithArrows } \bool_if:nT \c_false_bool { ## } \cr } % \end{macrocode} +% +% \bigskip % We begin the second part of the environment |{DispWithArrows}|. % \begin{macrocode} { @@ -4243,45 +4342,42 @@ version 2005/12/01 or later. % \begin{macrocode} \egroup % \end{macrocode} -% The following |\egroup| is for the |\vcenter| (aimed to prevent page breaks). +% The following |\egroup| is for the |\vtop|. % \begin{macrocode} \egroup % \end{macrocode} % -% If we are in an environment |{DispWithArrows}| or |{DispWithArrows*}|, we -% compute the dimension |\g_@@_right_x_dim|. As a first approximation, +% +% We compute the dimension |\g_@@_right_x_dim|. As a first approximation, % |\g_@@_right_x_dim| is the $x$-value of the right side of the current % composition box. In fact, we must take into account the potential labels of % the equations. That's why we compute |\g_@@_right_x_dim| with the |v|-nodes of % each row specifically built in this goal. |\g_@@_right_x_dim| is the minimal % value of the $x$-value of these nodes. % \begin{macrocode} - \bool_if:NT \l_@@_in_DispWithArrows_bool - { - \dim_gzero_new:N \g_@@_right_x_dim - \dim_gset_eq:NN \g_@@_right_x_dim \c_max_dim - \begin { tikzpicture } [ @@_standard ] - \int_step_variable:nNn \g_@@_line_int \l_tmpa_int + \dim_gzero_new:N \g_@@_right_x_dim + \dim_gset_eq:NN \g_@@_right_x_dim \c_max_dim + \begin { tikzpicture } [ @@_standard ] + \int_step_variable:nNn \g_@@_line_int \l_tmpa_int + { + \cs_if_free:cTF + { pgf@sh@ns@wa - \l_@@_prefix_str - \l_tmpa_int - v } + { \@@_error:n { Inexistent~v-node } } { - \cs_if_free:cTF - { pgf@sh@ns@wa - \l_@@_prefix_str - \l_tmpa_int - v } - { \@@_error:n { Inexistent~v-node } } - { - \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) - \dim_set:Nn \l_tmpa_dim \pgf@x - \dim_compare:nNnT \l_tmpa_dim < \g_@@_right_x_dim - { \dim_gset:Nn \g_@@_right_x_dim \l_tmpa_dim } - } - } - \end { tikzpicture } - } + \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) + \dim_set:Nn \l_tmpa_dim \pgf@x + \dim_compare:nNnT \l_tmpa_dim < \g_@@_right_x_dim + { \dim_gset:Nn \g_@@_right_x_dim \l_tmpa_dim } + } + } + \end { tikzpicture } % \end{macrocode} % % \bigskip -% The code in |\@@_post_environment:| is common to |{WithArrows}| and +% The code in |\@@_post_halign:| is common to |{WithArrows}| and % |{DispWithArrows}|. % \begin{macrocode} - \@@_post_environment: + \@@_post_halign: % \end{macrocode} % If \pkg{mathtools} has been loaded with the option |showonlyrefs|, we % reactivate the code of \pkg{mathtools} for the option |showonlyrefs| with the @@ -4291,7 +4387,8 @@ version 2005/12/01 or later. \bool_if:nT \c_@@_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } \MT_showonlyrefs_true: } \bool_if:NTF \l_@@_inlabel_bool - { $ % $ + { + $ % $ \skip_vertical:N \belowdisplayskip } { $$ } @@ -4320,6 +4417,161 @@ version 2005/12/01 or later. \endDispWithArrows % \end{macrocode} % +% +% \bigskip +% \subsection{The commands \textbackslash tag, \textbackslash notag, +% \textbackslash label, \textbackslash tagnextline and \textbackslash qedhere for +% \{DispWithArrows\}} +% +% Some commands are allowed only in the last column of the environment +% |{DispWithArrows}|. We write a command |\@@_if_in_last_col_of_disp:Nn| to +% execute this command only if we are in the last column. If we are in +% another column, an error is raised. The first argument of +% |\@@_if_in_last_col_of_disp:Nn| is the name of the command used in the error +% message and the second is the code to execute. +% \begin{macrocode} +\cs_new_protected:Npn \@@_if_in_last_col_of_disp:Nn #1 #2 + { + \bool_if:NTF \l_@@_in_WithArrows_bool + { \@@_error:nn { Not~allowed~in~WithArrows } { #1 } } + { + \int_compare:nNnTF \g_@@_col_int < \l_@@_nb_of_columns_int + { \@@_error:nn { Not~allowed~in~DispWithArrows } { #1 } } + { #2 } + } + } +% \end{macrocode} +% +% \bigskip +% The command |\@@_notag:| will be linked to |\notag| and |\nonumber| in the +% environments |{WithArrows}| and |{DispWithArrows}|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_notag: + { \@@_if_in_last_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 { s m } + { + \@@_if_in_last_col_of_disp:Nn \tag + { + \tl_if_empty:NF \l_@@_tag_tl + { \@@_error:nn { Multiple~tags } { #2 } } + \clist_set:Nn \l_@@_tags_clist { all } + \bool_if:nT \c_@@_mathtools_loaded_bool + { + \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 deactivating 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:Npn \@@_label:n #1 + { + \@@_if_in_last_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 |{DispWithArrows}|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_tagnextline: + { + \@@_if_in_last_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 last column of the environment |{DispWithArrows}| (only if +% the package \pkg{amsthm} has been loaded). |\@@_qedhere:| raises the boolean +% |\l_@@_qedhere_bool|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_qedhere: { \bool_set_true:N \l_@@_qedhere_bool } +\cs_new_protected:Npn \@@_set_qedhere: { \cs_set_eq:NN \qedhere \@@_qedhere: } +% \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 an adaptation of the code of |\qedhere| in +% \pkg{amsthm}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_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} +% +% +% % % \subsection{We draw the arrows} % @@ -4374,7 +4626,7 @@ version 2005/12/01 or later. % |\l_@@_last_line_of_group_int| will be the last line involved in the group % (impossible to guess in advance). % -% |\l_@@_last_arrows_seq| will the list of all the arrows of the group +% |\l_@@_last_arrows_seq| will be the list of all the arrows of the group % ending at the last line of the group (impossible to guess in advance). % \begin{macrocode} \int_zero_new:N \l_@@_first_arrow_of_group_int @@ -4426,7 +4678,7 @@ version 2005/12/01 or later. % \bigskip % We recall that, after the construction of the |\halign|, |\g_@@_line_int| is % the total number of lines of the environment. Therefore, the conditionnal -% |\l_@@_final_int > \g_@@_line_int| tests wether an arrow arrives after the +% |\l_@@_final_int > \g_@@_line_int| tests whether an arrow arrives after the % last line of the environment. In this case, we raise an error (except in the % second step of treatment for the option |group|). The arrow will be completely % ignored, even for the computation of |\l_@@_x_dim|. @@ -4693,7 +4945,7 @@ version 2005/12/01 or later. % |\l_@@_pos_arrow_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\ % \bottomrule % \end{tabular} \\ -% \footnotesize The option |v| can be used only in |\Arrow| in |CodeAfter| (see +% \footnotesize The option |v| can be used only in |\Arrow| in |code-after| (see % below). % \end{tabular} % \end{center} @@ -4805,7 +5057,7 @@ version 2005/12/01 or later. % Eventually, we can draw the arrow with the code in |\l_@@_tikz_code_tl|. We % recall that the value by default for this token list is :\enskip % ``\verb|\draw (#1) to node {#3} (#2) ;|''. This value can be modified with the -% option |TikzCode|. We use the variant |\@@_draw_arrow:nno| of the macro +% option |tikz-code|. We use the variant |\@@_draw_arrow:nno| of the macro % |\@@_draw_arrow:nnn| because of 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 @@ -4860,7 +5112,7 @@ version 2005/12/01 or later. % % \medskip % If the option |wrap-lines| is used, we have to use a special version of -% |\l_@@_tikz_code_tl| (which corresponds to the option |TikzCode|). +% |\l_@@_tikz_code_tl| (which corresponds to the option |tikz-code|). % \begin{macrocode} \bool_if:nT { \l_@@_wrap_lines_bool && \l_@@_in_DispWithArrows_bool } { \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_wrap_lines_tl } @@ -4877,7 +5129,7 @@ version 2005/12/01 or later. % % \bigskip % If the option |wrap-lines| is used, we have to use a special version of -% |\l_@@_tikz_code_tl| (which corresponds to the option |TikzCode|). +% |\l_@@_tikz_code_tl| (which corresponds to the option |tikz-code|). % \begin{macrocode} \tl_const:Nn \c_@@_tikz_code_wrap_lines_tl { @@ -4961,16 +5213,16 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection{The command Arrow in CodeAfter} +% \subsection{The command \textbackslash Arrow in code-after} % -% The option |CodeAfter| is an option of the environment |{WithArrows}| (this -% option is only available at the environment level). In the option |CodeAfter|, +% The option |code-after| is an option of the environment |{WithArrows}| (this +% option is only available at the environment level). In the option |code-after|, % one can use the command |Arrow| but it's a special version of the command % |Arrow|. For this special version (internally called |\@@_Arrow_code_after|), -% we define a special set of keys called |WithArrows/Arrow/CodeAfter|. +% we define a special set of keys called |WithArrows/Arrow/code-after|. % % \begin{macrocode} -\keys_define:nn { WithArrows / Arrow / CodeAfter } +\keys_define:nn { WithArrows / Arrow / code-after } { tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , @@ -4985,22 +5237,23 @@ version 2005/12/01 or later. lr .code:n = \@@_fix_pos_option:n 3 , v .value_forbidden:n = true , v .code:n = \@@_fix_pos_option:n 4 , - TikzCode .tl_set:N = \l_@@_tikz_code_tl , - TikzCode .value_required:n = true , + tikz-code .tl_set:N = \l_@@_tikz_code_tl , + tikz-code .value_required:n = true , xoffset .dim_set:N = \l_@@_xoffset_dim , xoffset .value_required:n = true , unknown .code:n = - \@@_sort_seq:N \l_@@_options_Arrow_CodeAfter_seq - \@@_error:n { Unknown~option~Arrow~in~CodeAfter } + \@@_sort_seq:N \l_@@_options_Arrow_code_after_seq + \@@_error:n { Unknown~option~Arrow~in~code-after } } % \end{macrocode} % % \bigskip -% A sequence of the options available in |\Arrow| in |\CodeAfter|. This sequence +% A sequence of the options available in |\Arrow| in |\code-after|. This sequence % will be used in the error messages and can be modified dynamically. % \begin{macrocode} -\seq_set_from_clist:Nn \l_@@_options_Arrow_CodeAfter_seq - { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } +\seq_new:N \l_@@_options_Arrow_code_after_seq +\seq_set_from_clist:Nn \l_@@_options_Arrow_code_after_seq + { ll, lr, rl, rr, tikz, tikz-code, v, x, offset } % \end{macrocode} % % \bigskip @@ -5010,7 +5263,7 @@ version 2005/12/01 or later. \int_set:Nn \l_@@_pos_arrow_int 1 \str_clear_new:N \l_@@_previous_key_str \group_begin: - \keys_set:nn { WithArrows / Arrow / CodeAfter } + \keys_set:nn { WithArrows / Arrow / code-after } { #1, #5, tikz = { xshift = \l_@@_xoffset_dim } } \bool_set_false:N \l_@@_initial_r_bool \bool_set_false:N \l_@@_final_r_bool @@ -5029,7 +5282,7 @@ version 2005/12/01 or later. \tl_if_eq:nnTF { #2 } { #3 } { \@@_error:nn { Both~lines~are~equal } { #2 } } % \end{macrocode} -% We test wether the two Tikz nodes |(#2-l)| and |(#3-l)| really exist. If not, +% We test whether the two Tikz nodes |(#2-l)| and |(#3-l)| really exist. If not, % the arrow won't be drawn. % \begin{macrocode} { @@ -5076,15 +5329,15 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection{MultiArrow} +% \subsection{The command \textbackslash MultiArrow in code-after} % The command |\@@_MultiArrow:nn| will be linked to |\MultiArrow| when the -% |CodeAfter| is executed. +% |code-after| is executed. % % \begin{macrocode} \cs_new_protected:Npn \@@_MultiArrow:nn #1 #2 { % \end{macrocode} -% The user of the command |\MultiArrow| (in |CodeAfter|) will be able to specify +% The user of the command |\MultiArrow| (in |code-after|) will be able to specify % the list of lines with the same syntax as the loop |\foreach| of \pkg{pgffor}. % That's why we construct a ``clist'' of \pkg{expl3} from the specification of % list given by the user. The construction of the ``clist'' must be global in @@ -5152,7 +5405,7 @@ version 2005/12/01 or later. \bool_if:nT { \l_@@_wrap_lines_bool && \l_@@_in_DispWithArrows_bool } { \dim_set:Nn \l_tmpb_dim - { \g_@@_right_x_dim - \pgf@x - 0.3333 em } + { \g_@@_right_x_dim - \pgf@x - 0.3333 em } \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } } @@ -5187,8 +5440,18 @@ version 2005/12/01 or later. % \begin{macrocode} \str_const:Nn \c_@@_option_ignored_str { If~you~go~on,~this~option~will~be~ignored. } +\str_const:Nn \c_@@_command_ignored_str + { If~you~go~on,~this~command~will~be~ignored. } % \end{macrocode} -% +% +% \begin{macrocode} +\@@_msg_new:nn { Invalid~option~format } + { + The~option~'format'~should~contain~only~letters~r,~c~and~l.\\ + \c_@@_option_ignored_str + } +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { Value~for~a~key } { @@ -5255,37 +5518,38 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nnn { Unknown~option~Arrow~in~CodeAfter } +\@@_msg_new:nnn { Unknown~option~Arrow~in~code-after } { The~option~'\l_keys_key_tl'~is~unknown~in~ \token_to_str:N \Arrow\ - in~\token_to_str:N \CodeAfter. \\ + in~\token_to_str:N \code-after. \\ \c_@@_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l_@@_options_Arrow_CodeAfter_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l_@@_options_Arrow_code_after_seq {~and~} {,~} {~and~}. } % \end{macrocode} % % % \begin{macrocode} -\@@_msg_new:nn { Third~column~in~WithArrows } +\@@_msg_new:nn { Too~much~columns~in~WithArrows } { - By~default,~an~environment~\{\l_@@_type_env_str\}~can~only~have~ - two~columns.~Maybe~you~have~forgotten~a~ - \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ - two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ - level~or~for~an~environment. \\ + Your~environment~\{\l_@@_type_env_str\}~has~\int_use:N + \l_@@_nb_of_columns_int\ columns~and~you~try~to~use~one~more.~ + Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str.~ + If~you~really~want~to~use~more~columns~(after~the~arrows)~you~should~use~ + the~option~'more-columns'~at~a~global~level~or~for~an~environment. \\ However,~you~can~go~one~for~this~time. } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Third~column~in~DispWithArrows } +\@@_msg_new:nn { Too~much~columns~in~DispWithArrows } { - An~environment~\{\l_@@_type_env_str\}~can~only~have~two~columns.~ + Your~environment~\{\l_@@_type_env_str\}~has~\int_use:N + \l_@@_nb_of_columns_int\ columns~and~you~try~to~use~one~more.~ Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str\ at~the~end~of~row~\int_use:N \g_@@_line_int. \\ If~you~go~on,~you~may~have~other~errors. @@ -5362,21 +5626,20 @@ version 2005/12/01 or later. { You~try~to~use~the~option~'\l_keys_key_tl'~but~ this~option~is~incompatible~or~redundant~with~the~option~ '\l_@@_previous_key_str'~set~in~the~same~command~ - \bool_if:NT \l_@@_in_CodeAfter_bool + \bool_if:NT \l_@@_in_code_after_bool { \l_@@_string_Arrow_for_msg_str\ - in~the~CodeAfter~of~your~environment~\{\l_@@_type_env_str\} + in~the~code-after~of~your~environment~\{\l_@@_type_env_str\} }. \\ \c_@@_option_ignored_str } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Arrow~in~first~column } +\@@_msg_new:nn { Arrow~not~in~last~column } { - You~should~not~use~the~command~\l_@@_string_Arrow_for_msg_str\ - in~the~first~column~of~your~environment~\{\l_@@_type_env_str\}~ - but~only~in~the~second~column. \\ + You~should~use~the~command~\l_@@_string_Arrow_for_msg_str\ + only~in~the~last~column~of~your~environment~\{\l_@@_type_env_str\}.\\ However~you~can~go~on~for~this~time. } % \end{macrocode} @@ -5386,17 +5649,17 @@ version 2005/12/01 or later. { The~specification~of~line~'#1'~you~use~in~the~command~ \l_@@_string_Arrow_for_msg_str\ - in~the~'CodeAfter'~of~\{\l_@@_type_env_str\}~doesn't~exist. \\ - If~you~go~on,~this~command~will~be~ignored. + in~the~'code-after'~of~\{\l_@@_type_env_str\}~doesn't~exist. \\ + \c_@@_option_ignored_str } % \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { Both~lines~are~equal } { - In~the~'CodeAfter'~of~\{\l_@@_type_env_str\}~you~try~to~ + In~the~'code-after'~of~\{\l_@@_type_env_str\}~you~try~to~ draw~an~arrow~going~to~it~self~from~the~line~'#1'.~This~is~not~possible. \\ - If~you~go~on,~this~command~will~be~ignored. + \c_@@_option_ignored_str } % \end{macrocode} % @@ -5413,7 +5676,7 @@ version 2005/12/01 or later. { The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\ is~too~small:~you~need~at~least~two~lines. \\ - If~you~go~on,~this~command~will~be~ignored. + \c_@@_option_ignored_str } % \end{macrocode} % @@ -5431,9 +5694,8 @@ version 2005/12/01 or later. \@@_msg_new:nn { Not~allowed~in~DispWithArrows } { The~command~\token_to_str:N #1 - is~not~allowed~in~the~first~column~of~\{\l_@@_type_env_str\}~but~ - only~in~the~second~column. \\ - If~you~go~on,~this~command~will~be~ignored. + is~allowed~only~in~the~last~columnm~of~\{\l_@@_type_env_str\}. \\ + \c_@@_option_ignored_str } % \end{macrocode} % @@ -5441,8 +5703,8 @@ version 2005/12/01 or later. \@@_msg_new:nn { Not~allowed~in~WithArrows } { The~command~\token_to_str:N #1 is~not~allowed~in~\{\l_@@_type_env_str\}~ - (it's~allowed~in~the~second~column~of~\{DispWithArrows\}). \\ - If~you~go~on,~this~command~will~be~ignored. + (it's~allowed~in~the~last~column~of~\{DispWithArrows\}). \\ + \c_@@_option_ignored_str } % \end{macrocode} % @@ -5505,7 +5767,7 @@ version 2005/12/01 or later. % % % -% \subsection{The command WithArrowsNewStyle} +% \subsection{The command \textbackslash WithArrowsNewStyle} % % A new key defined with |\WithArrowsNewStyle| will not be available at the % local level. @@ -5563,7 +5825,7 @@ version 2005/12/01 or later. % user will have an error only if he uses the option |up| or the option |down|. % % \medskip -% The token list |\c_@@_tikz_code_up_tl| is the value of |TikzCode| which will +% The token list |\c_@@_tikz_code_up_tl| is the value of |tikz-code| which will % be used for an option |up|. % \begin{macrocode} \tl_const:Nn \c_@@_tikz_code_up_tl @@ -5628,7 +5890,7 @@ version 2005/12/01 or later. % \end{macrocode} % We have to set |\l_@@_wrap_lines_bool| to |false| because, otherwise, if the % option |wrap_lines| is used at a higher level (global or environment), we will -% have a special affectation to |TikzCode| that will overwrite our affectation. +% have a special affectation to |tikz-code| that will overwrite our affectation. % \begin{macrocode} \bool_set_false:N \l_@@_wrap_lines_bool \tl_set_eq:NN \l_@@_tikz_code_tl @@ -5678,7 +5940,7 @@ version 2005/12/01 or later. { You~can't~use~the~option~'\l_keys_key_tl'~because~you~don't~have~loaded~the~ Tikz~library~'calc'.You~should~add~'\token_to_str:N\usetikzlibrary{calc}' - ~in~your~preamble. \\ + ~in~the~preamble~of~your~document. \\ \c_@@_option_ignored_str } % \end{macrocode} @@ -5719,7 +5981,6 @@ version 2005/12/01 or later. % % New option |groups| (with a \emph{s}) % -% Better error messages % % \subsection*{Changes between versions 1.2 and 1.3} % @@ -5734,15 +5995,15 @@ version 2005/12/01 or later. % \subsection*{Changes between versions 1.4 and 1.5} % % The Tikz code used to draw the arrows can be changed with the option -% |TikzCode|. +% |tikz-code|. % -% Two new options |CodeBefore| and |CodeAfter| have been added at the +% Two new options |code-before| and |code-after| have been added at the % environment level. % -% A special version of |\Arrow| is available in |CodeAfter| in order to draw +% A special version of |\Arrow| is available in |code-after| in order to draw % arrows in nested environments. % -% A command |\MultiArrow| is available in |CodeAfter| to draw arrows of other +% A command |\MultiArrow| is available in |code-after| to draw arrows of other % shapes. % % \subsection*{Changes between versions 1.5 and 1.6} @@ -5752,10 +6013,7 @@ version 2005/12/01 or later. % % A new option |name| is available for the environments |{WithArrows}|. % -% In the version 1.6.1, correction of a bug that leads to incompatibility with -% |\usetikzlibrary{babel}|. -% -% \subsection*{Changes between 1.6.1 and 1.7} +% \subsection*{Changes between 1.6 and 1.7} % % New environments |{DispWithArrows}| and |{DispWithArrows*}|. % @@ -5817,7 +6075,7 @@ version 2005/12/01 or later. % \WithArrowsOptions{adjust = 0pt} % \end{Verbatim} % -% \subsection*{Changes between 1.13 et 1.14} +% \subsection*{Changes between 1.13 and 1.14} % % New options |up| and |down| for the arrows. % @@ -5838,10 +6096,10 @@ version 2005/12/01 or later. % 1.12 but this was a mistake since this error is used with the option |xoffset| % at the local level. The error is put back. % -% \subsection*{Changes between 1.14 et 1.15} +% \subsection*{Changes between 1.14 and 1.15} % % Option |new-group| to start a new group of arrows (only available when the -% environment is composed with the option the option |groups|). +% environment is composed with the option |groups|). % % Tikz externalization is now deactivated in the environments of the % extension \pkg{witharrows}.\footnote{Before this version, there was an error @@ -5849,7 +6107,7 @@ version 2005/12/01 or later. % possible to externalize the Tikz elements constructed by \pkg{witharrows} % because they use the options |overlay| and |remember picture|.} % -% \subsection*{Changes between 1.15 et 1.16} +% \subsection*{Changes between 1.15 and 1.16} % % Option |no-arrows| % @@ -5861,6 +6119,11 @@ version 2005/12/01 or later. % it's possible to deactivate this control with the option % |allow-duplicate-names|. % +% +% \subsection*{Changes between 1.16 and 1.17} +% +% Option |format| +% % \endinput % Local Variables: % TeX-fold-mode: nil diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index 291cd84469e..795d67b973b 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.16} -\def\myfiledate{2019/03/11} +\def\myfileversion{1.17} +\def\myfiledate{2019/07/09} \RequirePackage{tikz} \usetikzlibrary{arrows.meta,bending} \RequirePackage{expl3}[2019/02/15] @@ -99,6 +99,8 @@ \cs_new_protected:Npn \__wa_error:n { \msg_error:nn { witharrows } } \cs_new_protected:Npn \__wa_error:nn { \msg_error:nnn { witharrows } } \cs_generate_variant:Nn \__wa_error:nn { n x } +\cs_generate_variant:Nn \tl_put_right:Nn { N v } +\cs_generate_variant:Nn \seq_set_split:Nnn { N x x } \AtBeginDocument { \clist_map_inline:nn @@ -137,7 +139,6 @@ \sort_return_same: } } -\cs_generate_variant:Nn \seq_set_split:Nnn { N x x } \cs_new_protected:Npn \__wa_save:N #1 { \seq_set_split:Nxx \l_tmpa_seq @@ -191,14 +192,14 @@ \tikzset { WithArrows / arrow / .style = - { - align = left , - auto = left , - font = \small \itshape , - WithArrows / arrow / tips , - bend~left = 45 , - -> - } + { + align = left , + auto = left , + font = \small \itshape , + WithArrows / arrow / tips , + bend~left = 45 , + -> + } } \AtBeginDocument { @@ -211,9 +212,11 @@ } } } +\newtoks \__wa_parameter_token +\__wa_parameter_token = { # } \bool_new:N \l__wa_in_WithArrows_bool \bool_new:N \l__wa_in_DispWithArrows_bool -\bool_new:N \l__wa_in_CodeAfter_bool +\bool_new:N \l__wa_in_code_after_bool \seq_new:N \g__wa_position_in_the_tree_seq \seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 \int_new:N \g__wa_last_env_int @@ -224,12 +227,33 @@ \int_new:N \g__wa_arrow_int \seq_new:N \g__wa_line_int_seq \int_new:N \g__wa_line_int +\seq_new:N \g__wa_col_int_seq +\int_new:N \g__wa_col_int \clist_new:N \l__wa_tags_clist \clist_set:Nn \l__wa_tags_clist { all } -\str_set:Nn \l__wa_CommandName_str { Arrow } +\cs_new_protected:Npn \__wa_test_if_to_tag: + { + \clist_if_in:NVT \l__wa_tags_clist \g__wa_line_int + { \clist_set:Nn \l__wa_tags_clist { all } } + } +\str_new:N \l__wa_command_name_str +\str_set:Nn \l__wa_command_name_str { Arrow } +\str_new:N \l__wa_string_Arrow_for_msg_str \str_set:Nx \l__wa_string_Arrow_for_msg_str { \token_to_str:N \Arrow } \seq_new:N \g__wa_names_seq \bool_new:N \l__wa_sbwi_bool +\bool_new:N \l__wa_in_first_columns_bool +\bool_new:N \l__wa_tag_star_bool +\bool_new:N \l__wa_tag_next_line_bool +\bool_new:N \l__wa_qedhere_bool +\bool_new:N \l__wa_new_group_bool +\bool_new:N \l__wa_initial_r_bool +\bool_new:N \l__wa_final_r_bool +\tl_new:N \l__wa_initial_tl +\tl_new:N \l__wa_final_tl +\int_new:N \l__wa_nb_of_columns_int +\bool_new:N \l__wa_last_col_bool +\str_new:N \l__wa_format_str \cs_new_protected:Npn \__wa_eval_if_allowed:n #1 { \str_if_empty:NTF \l__wa_previous_key_str @@ -250,16 +274,17 @@ ystart .value_required:n = true , ystart .initial:n = 0.4 ex , more-columns .code:n = - \__wa_msg_redirect_name:nn { Third~column~in~WithArrows } { none } , + \__wa_msg_redirect_name:nn { Too~much~columns~in~WithArrows } { none } , more-columns .value_forbidden:n = true, - CommandName .code:n = - \str_set:Nn \l__wa_CommandName_str { #1 } + command-name .code:n = + \str_set:Nn \l__wa_command_name_str { #1 } \str_set:Nx \l__wa_string_Arrow_for_msg_str { \c_backslash_str Arrow~alias~\c_backslash_str #1 } , - CommandName .value_required:n = true , - TikzCode .tl_set:N = \l__wa_tikz_code_tl, - TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , - TikzCode .value_required:n = true , + command-name .value_required:n = true , + tikz-code .tl_set:N = \l__wa_tikz_code_tl, + tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , + tikz-code .value_required:n = true , + TikzCode .meta:n = { tikz-code = #1 } , displaystyle .bool_set:N = \l__wa_displaystyle_bool , displaystyle .default:n = true , show-nodes .code:n = @@ -370,10 +395,28 @@ { \seq_gput_left:Nn \g__wa_names_seq { #1 } } \str_set:Nn \l__wa_name_str { #1 } , name .value_required:n = true , - CodeBefore .code:n = \tl_put_right:Nn \l__wa_code_before_tl { #1 } , - CodeBefore .value_required:n = true, - CodeAfter .code:n = \tl_put_right:Nn \l__wa_code_after_tl { #1 } , - CodeAfter .value_required:n = true + code-before .code:n = \tl_put_right:Nn \l__wa_code_before_tl { #1 } , + code-before .value_required:n = true, + CodeBefore .meta:n = { code-before = #1 } , + code-after .code:n = \tl_put_right:Nn \l__wa_code_after_tl { #1 } , + code-after .value_required:n = true , + CodeAfter .meta:n = { code-after = #1 } , + format .code:n = \__wa_set_option_format:n { #1 }, + format .value_required:n = true , + } +\cs_new_protected:Npn \__wa_set_option_format:n #1 + { + \bool_set_true:N \l_tmpa_bool + \str_map_inline:nn { #1 } + { + \str_if_in:nnF {rcl} { ##1 } + { + \bool_set_false:N \l_tmpa_bool + \__wa_error:n { Invalid~option~format } + \str_map_break: + } + } + \bool_if:NT \l_tmpa_bool { \tl_set:Nn \l__wa_format_str { #1 } } } \keys_define:nn { WithArrows } { @@ -396,32 +439,34 @@ WithArrows / DispWithArrowsSpecific } } +\seq_new:N \l__wa_options_WithArrows_seq +\seq_set_from_clist:Nn \l__wa_options_WithArrows_seq + { + adjust, b, c, code-after, code-before, command-name, displaystyle, end-adjust, + format, group, groups, i, interline, jot, ll, lr, more-columns, name, + no-arrows, rl, rr, show-node-names, show-nodes, start-adjust, t, tikz, + tikz-code, xoffset, ygap, ystart + } \keys_define:nn { WithArrows / WithArrows } { unknown .code:n = \__wa_sort_seq:N \l__wa_options_WithArrows_seq \__wa_error:n { Unknown~option~WithArrows } } -\seq_set_from_clist:Nn \l__wa_options_WithArrows_seq - { - adjust, b, c, CodeAfter, CodeBefore, CommandName, displaystyle, end-adjust, - group, groups, i, interline, jot, ll, lr, more-columns, name, no-arrows, rl, - rr, show-node-names, show-nodes, start-adjust, t, tikz, TikzCode, xoffset, - ygap, ystart - } \keys_define:nn { WithArrows / DispWithArrows } { unknown .code:n = \__wa_sort_seq:N \l__wa_options_DispWithArrows_seq \__wa_error:n { Unknown~option~DispWithArrows } } +\seq_new:N \l__wa_options_DispWithArrows_seq \seq_set_from_clist:Nn \l__wa_options_DispWithArrows_seq { - allow-multiple-labels, CodeAfter, CodeBefore, CommandName, TikzCode, adjust, - displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, name, no-arrows, nonumber, notag, rl, rr, show-node-names, - show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, xoffset, ygap, - ystart + allow-multiple-labels, code-after, code-before, command-name, tikz-code, adjust, + displaystyle, end-adjust, fleqn, group, format, groups, i, interline, jot, + ll, lr, mathindent, name, no-arrows, nonumber, notag, rl, rr, + show-node-names, show-nodes, start-adjust, tagged-lines, tikz, wrap-lines, + xoffset, ygap, ystart } \keys_define:nn { WithArrows / WithArrowsOptions } { @@ -432,10 +477,11 @@ \__wa_sort_seq:N \l__wa_options_WithArrowsOptions_seq \__wa_error:n { Unknown~option~WithArrowsOptions } } +\seq_new:N \l__wa_options_WithArrowsOptions_seq \seq_set_from_clist:Nn \l__wa_options_WithArrowsOptions_seq { - allow-duplicate-names, allow-multiple-labels, b, c, CommandName, - more-columns, TikzCode, adjust, displaystyle, end-adjust, fleqn, group, + allow-duplicate-names, allow-multiple-labels, b, c, command-name, + more-columns, tikz-code, adjust, displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, mathindent, no-arrows, nonumber, notag, rl, rr, show-node-names, show-nodes, standard-behaviour-with-items, start-adjust, t, tagged-lines, tikz, wrap-lines, xoffset, ygap, ystart @@ -473,8 +519,8 @@ \int_compare:nTF { \l__wa_pos_arrow_int = 6 } { \str_set:Nn \l__wa_status_arrow_str { new-group } } { \__wa_error:n { new-group~without~groups } } , - TikzCode .code:n = \prg_do_nothing: , - TikzCode .value_required:n = true , + tikz-code .code:n = \prg_do_nothing: , + tikz-code .value_required:n = true , tikz .code:n = \prg_do_nothing: , tikz .value_required:n = true , xoffset .code:n = @@ -491,9 +537,10 @@ \__wa_sort_seq:N \l__wa_options_Arrow_seq \__wa_error:n { Unknown~option~in~Arrow } } +\seq_new:N \l__wa_options_Arrow_seq \seq_set_from_clist:Nn \l__wa_options_Arrow_seq { - adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, TikzCode, + adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, tikz-code, xoffset } \cs_new_protected:Npn \__wa_fix_pos_arrow:n #1 @@ -506,8 +553,8 @@ } \keys_define:nn {WithArrows / Arrow / SecondPass } { - TikzCode .tl_set:N = \l__wa_tikz_code_tl , - TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , + tikz-code .tl_set:N = \l__wa_tikz_code_tl , + tikz-code .initial:n = \draw~(#1)~to~node{#3}~(#2)~; , tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , tikz .initial:n = \c_empty_tl , rr .code:n = \__wa_fix_pos_arrow:n 3 , @@ -547,9 +594,9 @@ { g__wa_arrow _ \l__wa_prefix_str _ \int_use:N \g__wa_arrow_int _ prop } \l_tmpa_prop } -\cs_new_protected:Npn \__wa_Arrow_first_column: - { \__wa_error:n { Arrow~in~first~column } \__wa_Arrow } -\cs_new_protected:Npn \__wa_pre_environment:n #1 +\cs_new_protected:Npn \__wa_Arrow_first_columns: + { \__wa_error:n { Arrow~not~in~last~column } \__wa_Arrow } +\cs_new_protected:Npn \__wa_pre_halign:n #1 { \str_clear_new:N \l__wa_type_env_str \str_set:NV \l__wa_type_env_str \@currenvir @@ -563,6 +610,8 @@ \int_gzero:N \g__wa_arrow_int \seq_gput_right:NV \g__wa_line_int_seq \g__wa_line_int \int_gzero:N \g__wa_line_int + \seq_gput_right:NV \g__wa_col_int_seq \g__wa_col_int + \int_gzero:N \g__wa_col_int \seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1 \seq_set_eq:NN \l_tmpa_seq \g__wa_position_in_the_tree_seq \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl @@ -576,7 +625,8 @@ \int_zero_new:N \l__wa_pos_of_arrow_int \int_zero_new:N \l__wa_jump_int \int_set:Nn \l__wa_jump_int \c_one_int - \bool_set_false:N \l__wa_in_first_column_bool + \str_set:Nn \l__wa_format_str { rl } + \bool_set_true:N \l__wa_last_col_bool \seq_clear_new:N \l__wa_labels_seq \bool_set_false:N \l__wa_tag_next_line_bool \skip_zero:N \l__wa_interline_skip @@ -587,9 +637,13 @@ { \keys_set:nn { WithArrows / WithArrows } { #1 } } \bool_if:NT \l__wa_in_DispWithArrows_bool { \keys_set:nn { WithArrows / DispWithArrows } { #1 } } + \cs_set_eq:cN \l__wa_command_name_str \__wa_Arrow_first_columns: + \int_set:Nn \l__wa_nb_of_columns_int { \str_count:N \l__wa_format_str } + \seq_clear_new:N \l__wa_format_seq + \seq_set_split:NnV \l__wa_format_seq { } \l__wa_format_str \bool_if:NT \g__wa_footnote_bool { \begin { savenotes } } \l__wa_code_before_tl - \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow + \spread@equation \cs_set_eq:NN \notag \__wa_notag: \cs_set_eq:NN \nonumber \__wa_notag: \cs_set_eq:NN \tag \__wa_tag @@ -597,31 +651,63 @@ \cs_set_eq:NN \label \__wa_label:n \cs_set_eq:NN \tagnextline \__wa_tagnextline: } -\NewDocumentEnvironment { WithArrows } { ! O { } } +\cs_new_protected:Npn \__wa_construct_halign: + { + \seq_pop_right:NNTF \l__wa_format_seq \l__wa_type_col_str + { + \use:x + { + \bool_set_false:N \l__wa_last_col_bool + \__wa_construct_halign: + \bool_if:NT \l__wa_last_col_bool + { + \cs_set_eq:cN { \l__wa_command_name_str } \__wa_Arrow + \bool_if:NT \l__wa_in_DispWithArrows_bool + { + \__wa_test_if_to_tag: + \bool_if:NT \c__wa_amsthm_loaded_bool \__wa_set_qedhere: + } + } + \str_if_eq:VnT \l__wa_type_col_str { c } \hfil + \str_if_eq:VnT \l__wa_type_col_str { r } \hfill + \int_gincr:N \g__wa_col_int + $ % $ + { + { } + \bool_if:NT \l__wa_displaystyle_bool \displaystyle + #### + } + $ % $ + \bool_if:NTF \l__wa_last_col_bool + { \__wa_construct_nodes: } + { + \str_if_eq:VnT \l__wa_type_col_str { l } \hfil + \str_if_eq:VnT \l__wa_type_col_str { c } \hfil + \bool_if:NT \l__wa_in_DispWithArrows_bool { \tabskip = \c_zero_skip } + & + } + } + } + { + \bool_if:NTF \l__wa_in_WithArrows_bool + { + \ialign + \bgroup + } + { + \halign to + \bool_if:NTF \l__wa_inlabel_bool \linewidth \displaywidth + \bgroup + \bool_if:NT \l__wa_fleqn_bool + { \skip_horizontal:N \l__wa_mathindent_dim } + } + \int_gincr:N \g__wa_line_int + \int_gzero:N \g__wa_col_int + \strut + } + } +\cs_new_protected:Npn \__wa_construct_nodes: { - \bool_set_true:N \l__wa_in_WithArrows_bool - \bool_set_false:N \l__wa_in_DispWithArrows_bool - \__wa_pre_environment:n { #1 } - \if_mode_math: \else: - \__wa_error:n { WithArrows~outside~math~mode } - \fi: - \int_case:nn \l__wa_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox } - \bgroup - \spread@equation - \ialign \bgroup - \int_gincr:N \g__wa_line_int - \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_first_column: - \bool_set_true:N \l__wa_in_first_column_bool - \strut \hfil - $ - \bool_if:NT \l__wa_displaystyle_bool \displaystyle - { ## } - $ - & - $ - \bool_if:NT \l__wa_displaystyle_bool \displaystyle - { { } ## } - $ \tikz [ remember~picture , overlay ] \node [ @@ -652,10 +738,22 @@ \bool_if:NT \l__wa_show_node_names_bool { \hbox_overlap_right:n - { \small wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int } + { \small wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - r } } + } +\NewDocumentEnvironment { WithArrows } { ! O { } } + { + \bool_set_true:N \l__wa_in_WithArrows_bool + \bool_set_false:N \l__wa_in_DispWithArrows_bool + \__wa_pre_halign:n { #1 } + \if_mode_math: \else: + \__wa_error:n { WithArrows~outside~math~mode } + \fi: + \int_case:nn \l__wa_pos_env_int { 0 \vtop 1 \vcenter 2 \vbox } + \bgroup + \__wa_construct_halign: && - \__wa_error:n { Third~column~in~WithArrows } + \__wa_error:n { Too~much~columns~in~WithArrows } $ \bool_if:NT \l__wa_displaystyle_bool \displaystyle { ## } @@ -666,10 +764,10 @@ \\ \egroup \egroup - \__wa_post_environment: + \__wa_post_halign: \bool_if:NT \g__wa_footnote_bool { \end { savenotes } } } -\cs_new_protected:Npn \__wa_post_environment: +\cs_new_protected:Npn \__wa_post_halign: { \cs_set:Npn \WithArrowsRightX { \g__wa_right_x_dim } \int_compare:nNnT \g__wa_arrow_int > 0 \__wa_scan_arrows: @@ -677,8 +775,8 @@ \tikzset { every~picture / .style = __wa_standard } \cs_set:Npn \WithArrowsNbLines { \int_use:N \g__wa_line_int } \cs_set_eq:NN \MultiArrow \__wa_MultiArrow:nn - \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_code_after - \bool_set_true:N \l__wa_in_CodeAfter_bool + \cs_set_eq:cN \l__wa_command_name_str \__wa_Arrow_code_after + \bool_set_true:N \l__wa_in_code_after_bool \l__wa_code_after_tl \group_end: \seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl @@ -691,11 +789,13 @@ \int_gset:Nn \g__wa_arrow_int \l_tmpa_tl \seq_gpop_right:NN \g__wa_line_int_seq \l_tmpa_tl \int_gset:Nn \g__wa_line_int \l_tmpa_tl + \seq_gpop_right:NN \g__wa_col_int_seq \l_tmpa_tl + \int_gset:Nn \g__wa_col_int \l_tmpa_tl } \cs_new_protected:Npn \__wa_cr: { \scan_stop: - \bool_if:NT \l__wa_in_first_column_bool { & { } } + \prg_replicate:nn { \l__wa_nb_of_columns_int - \g__wa_col_int } { & { } } \group_align_safe_begin: \peek_meaning_remove:NTF * \__wa_cr_i: \__wa_cr_i: } @@ -779,81 +879,6 @@ } \cr \noalign { \skip_vertical:n { #1 + \l__wa_interline_skip } \scan_stop: } } -\cs_new_protected:Npn \__wa_if_in_second_col_of_disp:Nn #1 #2 - { - \bool_if:NTF \l__wa_in_WithArrows_bool - { \__wa_error:nn { Not~allowed~in~WithArrows } { #1 } } - { - \bool_if:NTF \l__wa_in_first_column_bool - { \__wa_error:nn { Not~allowed~in~DispWithArrows } { #1 } } - { #2 } - } - } -\cs_new_protected:Npn \__wa_notag: - { \__wa_if_in_second_col_of_disp:Nn \notag { \clist_clear:N \l__wa_tags_clist } } -\NewDocumentCommand \__wa_tag { s m } - { - \__wa_if_in_second_col_of_disp:Nn \tag - { - \tl_if_empty:NF \l__wa_tag_tl - { \__wa_error:nn { Multiple~tags } { #2 } } - \clist_set:Nn \l__wa_tags_clist { all } - \bool_if:nT \c__wa_mathtools_loaded_bool - { - \MH_if_boolean:nT { show_only_refs } - { - \MH_if_boolean:nF { show_manual_tags } - { \clist_clear:N \l__wa_tags_clist } - } - } - \tl_set:Nn \l__wa_tag_tl { #2 } - \bool_set:Nn \l__wa_tag_star_bool { #1 } - \bool_if:nT { #1 && ! \bool_if_p:N \c__wa_amsmath_loaded_bool } - { \__wa_error:n { tag*~without~amsmath } } - } - } -\cs_new_protected:Npn \__wa_label:n #1 - { - \__wa_if_in_second_col_of_disp:Nn \label - { - \seq_if_empty:NF \l__wa_labels_seq - { - \bool_if:NTF \c__wa_cleveref_loaded_bool - { \__wa_error:n { Multiple~labels~with~cleveref } } - { \__wa_error:n { Multiple~labels } } - } - \seq_put_right:Nn \l__wa_labels_seq { #1 } - \bool_if:nT \c__wa_mathtools_loaded_bool - { - \MH_if_boolean:nT { show_only_refs } - { - \cs_if_exist:cTF { MT_r_#1 } - { \clist_set:Nn \l__wa_tags_clist { all } } - { \clist_clear:N \l__wa_tags_clist } - } - } - \bool_if:nT \c__wa_autonum_loaded_bool - { - \cs_if_exist:cTF { autonum@#1Referenced } - { \clist_set:Nn \l__wa_tags_clist { all } } - { \clist_clear:N \l__wa_tags_clist } - } - } - } -\cs_new_protected:Npn \__wa_tagnextline: - { - \__wa_if_in_second_col_of_disp:Nn \tagnextline - { \bool_set_true:N \l__wa_tag_next_line_bool } - } -\cs_new_protected:Npn \__wa_qedhere: { \bool_set_true:N \l__wa_qedhere_bool } -\cs_new_protected:Npn \__wa_qedhere_i: - { - \group_begin: - \cs_set_eq:NN \qed \qedsymbol - \cs_set_eq:NN \qed@elt \setQED@elt - \QED@stack \relax \relax - \group_end: - } \bool_new:N \l__wa_inlabel_bool \NewDocumentEnvironment { DispWithArrows } { ! O { } } { @@ -868,7 +893,7 @@ \bool_if:NT \c__wa_typedref_loaded_bool { \str_set:Nn \sr@name { equation } } \bool_if:NT \c__wa_amsmath_loaded_bool \intertext@ \bool_set_true:N \l__wa_in_DispWithArrows_bool - \__wa_pre_environment:n { #1 } + \__wa_pre_halign:n { #1 } \bool_if:NF \l__wa_sbwi_bool { \if@inlabel @@ -890,71 +915,17 @@ \fi: $$ } - \bool_if:NTF \l__wa_inlabel_bool \vtop \vcenter \bgroup - \spread@equation + \vtop \bgroup \bool_if:NTF \l__wa_fleqn_bool { \tabskip = \c_zero_skip } { \tabskip = 0 pt plus 1000 pt minus 1000 pt } - \halign to \bool_if:NTF \l__wa_inlabel_bool \linewidth \displaywidth - \bgroup - \int_gincr:N \g__wa_line_int - \cs_set_eq:cN \l__wa_CommandName_str \__wa_Arrow_first_column: - \bool_set_true:N \l__wa_in_first_column_bool - \strut - \bool_if:NT \l__wa_fleqn_bool { \skip_horizontal:n \l__wa_mathindent_dim } - \hfil - $ - \bool_if:NT \l__wa_displaystyle_bool \displaystyle - { ## } - $ - \tabskip = \c_zero_skip - & - \clist_if_in:NVT \l__wa_tags_clist \g__wa_line_int - { \clist_set:Nn \l__wa_tags_clist { all } } - \bool_if:NT \c__wa_amsthm_loaded_bool - { \cs_set_eq:NN \qedhere \__wa_qedhere: } - $ - \bool_if:NT \l__wa_displaystyle_bool \displaystyle - { { } ## } - $ + \__wa_construct_halign: \tabskip = 0 pt plus 1000 pt minus 1000 pt - \tikz [ remember~picture , overlay ] - \node - [ - node~contents = { } , - __wa_node_style , - name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - l , - alias = - { - \str_if_empty:NF \l__wa_name_str - { \l__wa_name_str - \int_use:N \g__wa_line_int - l } - } - ] - ; - \hfil - \tikz [ remember~picture , overlay ] - \node - [ - node~contents = { } , - __wa_node_style , - name = wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int - r , - alias = - { - \str_if_empty:NF \l__wa_name_str - { \l__wa_name_str - \int_use:N \g__wa_line_int - r } - } - ] - ; - \bool_if:NT \l__wa_show_node_names_bool - { - \hbox_overlap_right:n - { \small wa - \l__wa_prefix_str - \int_use:N \g__wa_line_int } - } & $ ## $ \tabskip = \c_zero_skip && - \__wa_error:n { Third~column~in~DispWithArrows } + \__wa_error:n { Too~much~columns~in~DispWithArrows } \bool_if:nT \c_false_bool { ## } \cr } @@ -964,30 +935,28 @@ \\ \egroup \egroup - \bool_if:NT \l__wa_in_DispWithArrows_bool - { - \dim_gzero_new:N \g__wa_right_x_dim - \dim_gset_eq:NN \g__wa_right_x_dim \c_max_dim - \begin { tikzpicture } [ __wa_standard ] - \int_step_variable:nNn \g__wa_line_int \l_tmpa_int + \dim_gzero_new:N \g__wa_right_x_dim + \dim_gset_eq:NN \g__wa_right_x_dim \c_max_dim + \begin { tikzpicture } [ __wa_standard ] + \int_step_variable:nNn \g__wa_line_int \l_tmpa_int + { + \cs_if_free:cTF + { pgf@sh@ns@wa - \l__wa_prefix_str - \l_tmpa_int - v } + { \__wa_error:n { Inexistent~v-node } } { - \cs_if_free:cTF - { pgf@sh@ns@wa - \l__wa_prefix_str - \l_tmpa_int - v } - { \__wa_error:n { Inexistent~v-node } } - { - \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) - \dim_set:Nn \l_tmpa_dim \pgf@x - \dim_compare:nNnT \l_tmpa_dim < \g__wa_right_x_dim - { \dim_gset:Nn \g__wa_right_x_dim \l_tmpa_dim } - } + \tikz@parse@node\pgfutil@firstofone ( \l_tmpa_int - v ) + \dim_set:Nn \l_tmpa_dim \pgf@x + \dim_compare:nNnT \l_tmpa_dim < \g__wa_right_x_dim + { \dim_gset:Nn \g__wa_right_x_dim \l_tmpa_dim } } - \end { tikzpicture } - } - \__wa_post_environment: + } + \end { tikzpicture } + \__wa_post_halign: \bool_if:nT \c__wa_mathtools_loaded_bool { \MH_if_boolean:nT { show_only_refs } \MT_showonlyrefs_true: } \bool_if:NTF \l__wa_inlabel_bool - { $ % $ + { + $ % $ \skip_vertical:N \belowdisplayskip } { $$ } @@ -1000,6 +969,82 @@ \DispWithArrows } \endDispWithArrows +\cs_new_protected:Npn \__wa_if_in_last_col_of_disp:Nn #1 #2 + { + \bool_if:NTF \l__wa_in_WithArrows_bool + { \__wa_error:nn { Not~allowed~in~WithArrows } { #1 } } + { + \int_compare:nNnTF \g__wa_col_int < \l__wa_nb_of_columns_int + { \__wa_error:nn { Not~allowed~in~DispWithArrows } { #1 } } + { #2 } + } + } +\cs_new_protected:Npn \__wa_notag: + { \__wa_if_in_last_col_of_disp:Nn \notag { \clist_clear:N \l__wa_tags_clist } } +\NewDocumentCommand \__wa_tag { s m } + { + \__wa_if_in_last_col_of_disp:Nn \tag + { + \tl_if_empty:NF \l__wa_tag_tl + { \__wa_error:nn { Multiple~tags } { #2 } } + \clist_set:Nn \l__wa_tags_clist { all } + \bool_if:nT \c__wa_mathtools_loaded_bool + { + \MH_if_boolean:nT { show_only_refs } + { + \MH_if_boolean:nF { show_manual_tags } + { \clist_clear:N \l__wa_tags_clist } + } + } + \tl_set:Nn \l__wa_tag_tl { #2 } + \bool_set:Nn \l__wa_tag_star_bool { #1 } + \bool_if:nT { #1 && ! \bool_if_p:N \c__wa_amsmath_loaded_bool } + { \__wa_error:n { tag*~without~amsmath } } + } + } +\cs_new_protected:Npn \__wa_label:n #1 + { + \__wa_if_in_last_col_of_disp:Nn \label + { + \seq_if_empty:NF \l__wa_labels_seq + { + \bool_if:NTF \c__wa_cleveref_loaded_bool + { \__wa_error:n { Multiple~labels~with~cleveref } } + { \__wa_error:n { Multiple~labels } } + } + \seq_put_right:Nn \l__wa_labels_seq { #1 } + \bool_if:nT \c__wa_mathtools_loaded_bool + { + \MH_if_boolean:nT { show_only_refs } + { + \cs_if_exist:cTF { MT_r_#1 } + { \clist_set:Nn \l__wa_tags_clist { all } } + { \clist_clear:N \l__wa_tags_clist } + } + } + \bool_if:nT \c__wa_autonum_loaded_bool + { + \cs_if_exist:cTF { autonum@#1Referenced } + { \clist_set:Nn \l__wa_tags_clist { all } } + { \clist_clear:N \l__wa_tags_clist } + } + } + } +\cs_new_protected:Npn \__wa_tagnextline: + { + \__wa_if_in_last_col_of_disp:Nn \tagnextline + { \bool_set_true:N \l__wa_tag_next_line_bool } + } +\cs_new_protected:Npn \__wa_qedhere: { \bool_set_true:N \l__wa_qedhere_bool } +\cs_new_protected:Npn \__wa_set_qedhere: { \cs_set_eq:NN \qedhere \__wa_qedhere: } +\cs_new_protected:Npn \__wa_qedhere_i: + { + \group_begin: + \cs_set_eq:NN \qed \qedsymbol + \cs_set_eq:NN \qed@elt \setQED@elt + \QED@stack \relax \relax + \group_end: + } \cs_new_protected:Npn \__wa_scan_arrows: { \group_begin: @@ -1265,7 +1310,7 @@ } } \cs_new:Npn \WithArrowsLastEnv { \int_use:N \g__wa_last_env_int } -\keys_define:nn { WithArrows / Arrow / CodeAfter } +\keys_define:nn { WithArrows / Arrow / code-after } { tikz .code:n = \tikzset { WithArrows / arrow / .append~style = { #1 } } , @@ -1280,22 +1325,23 @@ lr .code:n = \__wa_fix_pos_option:n 3 , v .value_forbidden:n = true , v .code:n = \__wa_fix_pos_option:n 4 , - TikzCode .tl_set:N = \l__wa_tikz_code_tl , - TikzCode .value_required:n = true , + tikz-code .tl_set:N = \l__wa_tikz_code_tl , + tikz-code .value_required:n = true , xoffset .dim_set:N = \l__wa_xoffset_dim , xoffset .value_required:n = true , unknown .code:n = - \__wa_sort_seq:N \l__wa_options_Arrow_CodeAfter_seq - \__wa_error:n { Unknown~option~Arrow~in~CodeAfter } + \__wa_sort_seq:N \l__wa_options_Arrow_code_after_seq + \__wa_error:n { Unknown~option~Arrow~in~code-after } } -\seq_set_from_clist:Nn \l__wa_options_Arrow_CodeAfter_seq - { ll, lr, rl, rr, tikz, TikzCode, v, x, offset } +\seq_new:N \l__wa_options_Arrow_code_after_seq +\seq_set_from_clist:Nn \l__wa_options_Arrow_code_after_seq + { ll, lr, rl, rr, tikz, tikz-code, v, x, offset } \NewDocumentCommand \__wa_Arrow_code_after { O { } m m m ! O { } } { \int_set:Nn \l__wa_pos_arrow_int 1 \str_clear_new:N \l__wa_previous_key_str \group_begin: - \keys_set:nn { WithArrows / Arrow / CodeAfter } + \keys_set:nn { WithArrows / Arrow / code-after } { #1, #5, tikz = { xshift = \l__wa_xoffset_dim } } \bool_set_false:N \l__wa_initial_r_bool \bool_set_false:N \l__wa_final_r_bool @@ -1388,7 +1434,7 @@ \bool_if:nT { \l__wa_wrap_lines_bool && \l__wa_in_DispWithArrows_bool } { \dim_set:Nn \l_tmpb_dim - { \g__wa_right_x_dim - \pgf@x - 0.3333 em } + { \g__wa_right_x_dim - \pgf@x - 0.3333 em } \dim_compare:nNnT \l_tmpb_dim < \l_tmpa_dim { \dim_set_eq:NN \l_tmpa_dim \l_tmpb_dim } } @@ -1413,6 +1459,13 @@ } \str_const:Nn \c__wa_option_ignored_str { If~you~go~on,~this~option~will~be~ignored. } +\str_const:Nn \c__wa_command_ignored_str + { If~you~go~on,~this~command~will~be~ignored. } +\__wa_msg_new:nn { Invalid~option~format } + { + The~option~'format'~should~contain~only~letters~r,~c~and~l.\\ + \c__wa_option_ignored_str + } \__wa_msg_new:nn { Value~for~a~key } { The~key~'\l_keys_key_tl'~should~be~used~without~value. \\ @@ -1462,30 +1515,31 @@ The~available~keys~are~(in~alphabetic~order):~ \seq_use:Nnnn \l__wa_options_WithArrowsOptions_seq {~and~} {,~} {~and~}. } -\__wa_msg_new:nnn { Unknown~option~Arrow~in~CodeAfter } +\__wa_msg_new:nnn { Unknown~option~Arrow~in~code-after } { The~option~'\l_keys_key_tl'~is~unknown~in~ \token_to_str:N \Arrow\ - in~\token_to_str:N \CodeAfter. \\ + in~\token_to_str:N \code-after. \\ \c__wa_option_ignored_str \\ For~a~list~of~the~available~keys,~type~H~<return>. } { The~available~keys~are~(in~alphabetic~order):~ - \seq_use:Nnnn \l__wa_options_Arrow_CodeAfter_seq {~and~} {,~} {~and~}. + \seq_use:Nnnn \l__wa_options_Arrow_code_after_seq {~and~} {,~} {~and~}. } -\__wa_msg_new:nn { Third~column~in~WithArrows } +\__wa_msg_new:nn { Too~much~columns~in~WithArrows } { - By~default,~an~environment~\{\l__wa_type_env_str\}~can~only~have~ - two~columns.~Maybe~you~have~forgotten~a~ - \c_backslash_str\c_backslash_str.~If~you~really~want~more~than~ - two~columns,~you~should~use~the~option~'more-columns'~at~a~global~ - level~or~for~an~environment. \\ + Your~environment~\{\l__wa_type_env_str\}~has~\int_use:N + \l__wa_nb_of_columns_int\ columns~and~you~try~to~use~one~more.~ + Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str.~ + If~you~really~want~to~use~more~columns~(after~the~arrows)~you~should~use~ + the~option~'more-columns'~at~a~global~level~or~for~an~environment. \\ However,~you~can~go~one~for~this~time. } -\__wa_msg_new:nn { Third~column~in~DispWithArrows } +\__wa_msg_new:nn { Too~much~columns~in~DispWithArrows } { - An~environment~\{\l__wa_type_env_str\}~can~only~have~two~columns.~ + Your~environment~\{\l__wa_type_env_str\}~has~\int_use:N + \l__wa_nb_of_columns_int\ columns~and~you~try~to~use~one~more.~ Maybe~you~have~forgotten~a~\c_backslash_str\c_backslash_str\ at~the~end~of~row~\int_use:N \g__wa_line_int. \\ If~you~go~on,~you~may~have~other~errors. @@ -1539,32 +1593,31 @@ { You~try~to~use~the~option~'\l_keys_key_tl'~but~ this~option~is~incompatible~or~redundant~with~the~option~ '\l__wa_previous_key_str'~set~in~the~same~command~ - \bool_if:NT \l__wa_in_CodeAfter_bool + \bool_if:NT \l__wa_in_code_after_bool { \l__wa_string_Arrow_for_msg_str\ - in~the~CodeAfter~of~your~environment~\{\l__wa_type_env_str\} + in~the~code-after~of~your~environment~\{\l__wa_type_env_str\} }. \\ \c__wa_option_ignored_str } -\__wa_msg_new:nn { Arrow~in~first~column } +\__wa_msg_new:nn { Arrow~not~in~last~column } { - You~should~not~use~the~command~\l__wa_string_Arrow_for_msg_str\ - in~the~first~column~of~your~environment~\{\l__wa_type_env_str\}~ - but~only~in~the~second~column. \\ + You~should~use~the~command~\l__wa_string_Arrow_for_msg_str\ + only~in~the~last~column~of~your~environment~\{\l__wa_type_env_str\}.\\ However~you~can~go~on~for~this~time. } \__wa_msg_new:nn { Wrong~line~in~Arrow } { The~specification~of~line~'#1'~you~use~in~the~command~ \l__wa_string_Arrow_for_msg_str\ - in~the~'CodeAfter'~of~\{\l__wa_type_env_str\}~doesn't~exist. \\ - If~you~go~on,~this~command~will~be~ignored. + in~the~'code-after'~of~\{\l__wa_type_env_str\}~doesn't~exist. \\ + \c__wa_option_ignored_str } \__wa_msg_new:nn { Both~lines~are~equal } { - In~the~'CodeAfter'~of~\{\l__wa_type_env_str\}~you~try~to~ + In~the~'code-after'~of~\{\l__wa_type_env_str\}~you~try~to~ draw~an~arrow~going~to~it~self~from~the~line~'#1'.~This~is~not~possible. \\ - If~you~go~on,~this~command~will~be~ignored. + \c__wa_option_ignored_str } \__wa_msg_new:nn { Wrong~line~specification~in~MultiArrow } { @@ -1575,7 +1628,7 @@ { The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\ is~too~small:~you~need~at~least~two~lines. \\ - If~you~go~on,~this~command~will~be~ignored. + \c__wa_option_ignored_str } \__wa_msg_new:nn { tag*~without~amsmath } { @@ -1587,15 +1640,14 @@ \__wa_msg_new:nn { Not~allowed~in~DispWithArrows } { The~command~\token_to_str:N #1 - is~not~allowed~in~the~first~column~of~\{\l__wa_type_env_str\}~but~ - only~in~the~second~column. \\ - If~you~go~on,~this~command~will~be~ignored. + is~allowed~only~in~the~last~columnm~of~\{\l__wa_type_env_str\}. \\ + \c__wa_option_ignored_str } \__wa_msg_new:nn { Not~allowed~in~WithArrows } { The~command~\token_to_str:N #1 is~not~allowed~in~\{\l__wa_type_env_str\}~ - (it's~allowed~in~the~second~column~of~\{DispWithArrows\}). \\ - If~you~go~on,~this~command~will~be~ignored. + (it's~allowed~in~the~last~column~of~\{DispWithArrows\}). \\ + \c__wa_option_ignored_str } \__wa_msg_new:nn { Multiple~tags } { @@ -1752,7 +1804,7 @@ { You~can't~use~the~option~'\l_keys_key_tl'~because~you~don't~have~loaded~the~ Tikz~library~'calc'.You~should~add~'\token_to_str:N\usetikzlibrary{calc}' - ~in~your~preamble. \\ + ~in~the~preamble~of~your~document. \\ \c__wa_option_ignored_str } \__wa_msg_new:nnn { Duplicate~name } |