summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/witharrows/witharrows.pdfbin231745 -> 264660 bytes
-rw-r--r--Master/texmf-dist/source/latex/witharrows/witharrows.dtx1595
-rw-r--r--Master/texmf-dist/tex/latex/witharrows/witharrows.sty386
3 files changed, 1391 insertions, 590 deletions
diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
index 7530c6bc469..b09a847b2eb 100644
--- a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
+++ b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx
index daefc27bc6e..cdd73303cb8 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.4}
-\def\myfiledate{2018/01/20}
+\def\myfileversion{1.5}
+\def\myfiledate{2018/02/12}
%
%
%<*batchfile>
@@ -46,16 +46,15 @@ version 2005/12/01 or later.
%
%<@@=wa>
%<*driver>
-\documentclass{l3doc} % load fancyvrb, amsmath, array, color, etc.
+\documentclass[dvipsnames]{l3doc} % load fancyvrb, amsmath, array, color, etc.
\usepackage{xltxtra}
\usepackage{lmodern}
\usepackage{geometry}
-\usepackage[dvipsnames]{xcolor} % color is already loaded with l3doc (?)
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
\usepackage[footnotehyper]{witharrows}
\usepackage{mathtools}
\usepackage{amsfonts}
-\usepackage{stmaryrd}
+\usepackage[only,llbracket,rrbracket]{stmaryrd}
\NewDocumentEnvironment {scope} {} {} {}
\def\interitem{\vskip 7mm plus 2 mm minus 3mm}
\def\emphase#1{{\color{RoyalPurple}#1}}
@@ -68,6 +67,7 @@ version 2005/12/01 or later.
\end{document}
%</driver>
% \fi
+% \VerbatimFootnotes
% \title{The package \pkg{witharrows}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{witharrows},
% at the date of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}}
%
@@ -103,9 +103,11 @@ version 2005/12/01 or later.
% \end{WithArrows}$
%
%
+%
+%
% \medskip
% The arrow has been drawn with the command |\Arrow| on the line from which it starts. The command |\Arrow| must be used
-% in the second column (the best way is to put it at the end of the second cell of the line as in the previous exemple).
+% in the second column (the best way is to put it at the end of the second cell of the line as in the previous example).
%
%
% \section{Options for the shape of the arrows}
@@ -113,7 +115,7 @@ version 2005/12/01 or later.
% The commande |\Arrow| has several options. These options can be put between square brackets, before, or after the
% mandatory argument.
%
-% The option |jump| gives the number\footnote{It's not possible to give a non-positive value to \texttt{jump}. See
+% The option |jump| gives the number\footnote{It's not possible to give a non-positive value to |jump|. See
% below (p.~\pageref{Backwards}) the way to draw an arrow which goes backwards.} of lines the arrow must jump (the
% default value is, of course,~$1$).
%
@@ -174,17 +176,17 @@ version 2005/12/01 or later.
% \interitem
% The arrows are drawn with Tikz. That's why the command |\Arrow| has an option |tikz| which can be used to give to
% the arrow (in fact, the command |\path| of Tikz) the options proposed by Tikz for such an arrow. The following
-% example gives an blue thick arrow.
+% example gives an thick arrow.
% %
% \begin{Verbatim}
% $\begin{WithArrows}
-% A & = (a+1)^2 \Arrow[~emphase#tikz={blue,thick}@]{we expand} \\
+% A & = (a+1)^2 \Arrow[~emphase#tikz=thick@]{we expand} \\
% & = a^2 + 2a + 1
% \end{WithArrows}$
% \end{Verbatim}
%
% $\begin{WithArrows}
-% A & = (a+1)^2 \Arrow[tikz={blue,thick}]{we expand} \\
+% A & = (a+1)^2 \Arrow[tikz=thick]{we expand} \\
% & = a^2 + 2a + 1
% \end{WithArrows}$
%
@@ -235,6 +237,10 @@ version 2005/12/01 or later.
% & = a^2 + 2a + 1
% \end{WithArrows}$
%
+% \smallskip
+% In fact, it's possible to change more drastically the shape or the arrows with the option |TikzCode| presented
+% p.~\pageref{TikzCode}.
+%
% \interitem
% One of the most useful options is ``|text width|'' to control the width of the text associated to the arrow.
% %
@@ -299,7 +305,7 @@ version 2005/12/01 or later.
% \interitem
% Almost all the options can be given directly to the environment |{WithArrows}| (between square brackets). In this
% case, they apply to all the arrows of the environment.\footnote{They also apply to the nested environments
-% \texttt{\{WithArrows\}} with the notable exception of \texttt{interline}.}
+% |{WithArrows}| (with the logical exceptions of |interline|, |CodeBefore| and |CodeAfter|).}
% %
% \begin{Verbatim}
% $\begin{WithArrows}[~emphase#tikz=blue@]
@@ -356,13 +362,50 @@ version 2005/12/01 or later.
% & = \frac73
% \end{WithArrows}$
%
+% \interitem
+% The version 1.3 of \pkg{witharrows} give two options for a fine tuning of the arrows:
+%
+% \begin{itemize}
+% \item the option |ystart| set the vertical distance between the base line of the text and the start of the arrow
+% (default value: 0.4 ex);
+% \item the option |ygap| set the vertical distance between two consecutive arrows (default value: 0.4~ex).
+% \end{itemize}
+%
+%
+% \bigskip
+% $\begin{WithArrows}[interline=1mm]
+% (\cos x + \sin x)^2 & = \cos^2 x +2 \cos x \sin x + \sin^2 x\Arrow{}\tikz[remember picture] \coordinate (A) ; \\
+% & = \cos^2x + \sin^2x + 2\sin x\cos x \Arrow{} \\
+% & = 1 + \sin(2x)
+% \end{WithArrows}$
+%
+% \begin{tikzpicture}[remember picture,overlay,blue]
+% \draw (wa-\WithArrowsLastEnv-1-r.south) to ++(1,0) coordinate (B) to ++(0.1,0) ;;
+% \draw (A) to ++(1,0) coordinate (C) to ++(0.1,0) ;;
+% \draw (B) -- (C) ;
+% \draw[<-] (B) to ++(0,0.2) ;
+% \draw[<-] (C) to ++(0,-0.2) ;
+% \path (C) node[right=1mm] {\texttt{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}} ;
+% \end{tikzpicture}
+%
+%
+% \bigskip
+% \emph{Remark}: It's also possible to use the options ``|shorten <|'' and ``|shorten >|'' of Tikz (via the option
+% |tikz| of \pkg{witharrows}).
+%
%
% \interitem
% Almost all the options can also be set at the document level with the command |\WithArrowsOptions|. In this case,
% the scope of the declarations is the current TeX group (these declarations are ``semi-global''). For example, if
% we want all the environments |{WithArrows}| composed in |\displaystyle| with blue arrows, we can write
% |\WithArrowsOptions{displaystyle,tikz=blue}|.\footnote{Since version 1.4 of \pkg{witharrows}, it's no longer possible
-% to give these options directly when loading the package, \emph{i.e.} with the command \texttt{\string\usepackage} in the preamble.}
+% to give these options directly when loading the package, \emph{i.e.} with the command |\usepackage| in the preamble.}
%
% \begin{Verbatim}
% ~emphase#\WithArrowsOptions{displaystyle,tikz=blue}@
@@ -393,7 +436,7 @@ version 2005/12/01 or later.
% the option \emph{without} the leading backslash.
% %
% \begin{Verbatim}
-% \newcommand{\Arrow}{\longmapsto}
+% \NewDocumentCommand {\Arrow} {} {\longmapsto}
% $\begin{WithArrows}[~emphase#CommandName=Explanation@]
% f & = \bigl(x \Arrow (x+1)^2\bigr)
% ~emphase#\Explanation{we work directly on fonctions}@\\
@@ -402,7 +445,7 @@ version 2005/12/01 or later.
% \end{Verbatim}
% %
% \begin{scope}
-% \newcommand{\Arrow}{\longmapsto}
+% \NewDocumentCommand {\Arrow} {} {\longmapsto}
% $\begin{WithArrows}[CommandName=Explanation]
% f & = \bigl(x \Arrow (x+1)^2\bigr)
% \Explanation{we work directly on fonctions}\\
@@ -412,27 +455,33 @@ version 2005/12/01 or later.
%
%
% \interitem
-% It's possible to use directly the nodes created by |{WithArrows}| with explicit Tikz instructions (in order, for
-% example, to draw something that can't be drawn with the command |\Arrow|). That's why a style for the tips of the
-% arrows has be created: |TipsOfWithArrows|. By using this style, we will have homogeneous tips for the arrows of
-% the document.
-%
-% Therefore, if we want to modify the tips of the arrows of |{WithArrows}|, we have to modify the style
-% |TipsOfWithArrows|.
+% 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. Theses options are not designed to be hooks (they
+% are avalaible only at the environment level and they are not applied to the nested environments).
% %
% \begin{Verbatim}
-% \tikzset{TipsOfWithArrows/.style= { > = {Latex[scale=1.2,bend]}} }
+% $\begin{WithArrows}[~emphase#CodeBefore = \color{blue}@]
+% A & = (a+b)^2 \Arrow{we expand} \\
+% & = a^2 + 2ab + b^2
+% \end{WithArrows}$
% \end{Verbatim}
%
-% The names of the Tikz nodes created by \pkg{witharrows} in the whole document are explained
-% p.~\pageref{NamesOfTheNodes}.
+% $\begin{WithArrows}[CodeBefore = \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 |\NbLines| which gives the number of lines 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{Precise positioning of the arrows}
%
%
% The environment |{WithArrows}| defines, during the composition of the array, two series of nodes materialized in
-% red in the following example.\footnote{The option \texttt{shownodes} can be used to materialize the nodes. The
+% red in the following example.\footnote{The option |shownodes| can be used to materialize the nodes. The
% nodes are in fact Tikz nodes of shape ``rectangle'', but with zero width. An arrow between two nodes starts at
% the \emph{south} anchor of the first node and arrives at the \emph{north} anchor of the second node.}
%
@@ -582,8 +631,8 @@ version 2005/12/01 or later.
% In the environments of \pkg{amsmath} (or \pkg{mathtools}), the spacing between lines is fixed by a parameter
% called |\jot| (it's a dimension and not a skip). That's also the case for the environment |{WithArrows}|. An
% option |jot| has been given to the environment |{WithArrows}| in order to change the value of this parameter
-% |\jot| for an given environment.\footnote{It's also possible to change \texttt{\string\jot} with the environment
-% \texttt{\{spreadlines\}} of \pkg{mathtools}.}
+% |\jot| for an given environment.\footnote{It's also possible to change |\jot| with the environment |{spreadlines}|
+% of \pkg{mathtools}.}
% %
% \begin{Verbatim}
% $\begin{WithArrows}[displaystyle,~emphase#jot=2ex@]
@@ -666,7 +715,7 @@ version 2005/12/01 or later.
% default with the command |\WithArrowsOptions{c}| at the beginning of the document.
% %
% \begin{Verbatim}
-% ~emphase#Et donc\enskip@
+% So\enskip
% $\begin{WithArrows}
% A & = (a+1)^2 \Arrow{we expand} \\
% & = a^2 + 2a + 1
@@ -726,8 +775,8 @@ version 2005/12/01 or later.
%
% \medskip
% The following is composed with |{WithArrows}[c,displaystyle]|. The results are stricly identical.\footnote{In
-% versions of \texttt{amsmath} older than the 5~nov.~2016, an thin space was added on the left of an environment
-% \texttt{\{aligned\}}. The new versions do not add this space and neither do \texttt{\{WithArrows\}}.}\par\nobreak
+% versions of \pkg{amsmath} older than the 5~nov.~2016, an thin space was added on the left of an environment
+% |{aligned}|. The new versions do not add this space and neither do |{WithArrows}|.}\par\nobreak
%
% \smallskip
% $\left\{
@@ -739,85 +788,155 @@ version 2005/12/01 or later.
% \right.$
%
%
-% \section{Examples}
+% \section{Arrows in nested environments}
%
-% \subsection{With only one column}
+% \label{NestedEnv}
%
-% 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}$
+% 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| can be used as usual in each environment |{WithArrows}|.
+%
+% \begin{Verbatim}[formatcom=\small\color{gray}]
+% $~emphase#\begin{WithArrows}@
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \Arrow{the numbers are real}\\
+% & \Leftrightarrow
+% \left\{~emphase#\begin{WithArrows}@[c]
+% x+2y & = 0 \\
+% 2x+4y & = 0
+% ~emphase#\end{WithArrows}@\right. \\
+% & \Leftrightarrow
+% \left\{~emphase#\begin{WithArrows}@[c]
+% x+2y & = 0 \Arrow[tikz=-]{the same equation}\\
+% x+2y & = 0
+% ~emphase#\end{WithArrows}@\right. \\
+% & \Leftrightarrow x+2y=0
+% ~emphase#\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
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \Arrow{the numbers are real}\\
+% & \Leftrightarrow
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \\
+% 2x+4y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \Arrow[tikz=-]{the same equation}\\
+% x+2y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow x+2y=0
% \end{WithArrows}$
%
+% \bigskip
+% However, one may want to draw an arrow between lines that are not in the same environment. For example, one may want
+% to draw the following arrow :
%
-% \subsection{MoveEqLeft}
-%
-% It's possible to use |\MoveEqLeft| of \pkg{mathtools} (if we don't want ampersand on the first line):
-% %
-% \begin{Verbatim}[formatcom=\small\color{gray}]
-% $\begin{WithArrows}[interline=0.5ex]
-% ~emphase#\MoveEqLeft@ \arccos(x) = \arcsin \frac45 + \arcsin \frac5{13}
-% \Arrow{because both are in $[-\frac{\pi}2,\frac{\pi}2]$} \\
-% & \Leftrightarrow x = \sin\left(\arcsin\frac45 + \arcsin\frac5{13}\right) \\
-% & \Leftrightarrow x = \frac45\cos\arcsin\frac5{13} + \frac5{13} \cos\arcsin\frac45
-% \Arrow{$\forall x \in [-1,1], \cos(\arcsin x) = \sqrt{1-x^2}$} \\
-% & \Leftrightarrow x = \frac45\sqrt{1-\bigl(\frac5{13}\bigr)^2}
-% + \frac5{13}\sqrt{1-\bigl(\frac45\bigr)^2} \\
+% \bigskip
+% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{Division by $2$}}]
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
+% & \Leftrightarrow
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \\
+% 2x+4y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \\
+% x+2y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow x+2y=0
% \end{WithArrows}$
-% \end{Verbatim}
%
%
-% \medskip
-% $\begin{WithArrows}[interline=0.5ex]
-% \MoveEqLeft \arccos(x) = \arcsin \frac45 + \arcsin \frac5{13}
-% \Arrow{because both are in $[-\frac{\pi}2,\frac{\pi}2]$} \\
-% & \Leftrightarrow x = \sin\left(\arcsin\frac45 + \arcsin\frac5{13}\right) \\
-% & \Leftrightarrow x = \frac45\cos\arcsin\frac5{13} + \frac5{13} \cos\arcsin\frac45
-% \Arrow{$\forall x \in [-1,1], \cos(\arcsin x) = \sqrt{1-x^2}$} \\
-% & \Leftrightarrow x = \frac45\sqrt{1-\bigl(\frac5{13}\bigr)^2}
-% + \frac5{13}\sqrt{1-\bigl(\frac45\bigr)^2} \\
-% \end{WithArrows}$
+% \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|'').
%
+% \smallskip
+% A command |\Arrow| in |CodeAfter| takes three arguments :
+% \begin{itemize}
+% \item a specification of the start line of the arrow ;
+% \item a specification of the end line of the arrow ;
+% \item the label of the arrow.
+% \end{itemize}
+% As usual, it's also possible to give options within square brackets before or after the three arguments. However,
+% these options are limited (see below).
+%
+% \bigskip
+% The specification of the line is constructed with the position of the concerned environment in the nesting tree,
+% followed (after an hyphen) by the number of the line.
%
+% \bigskip
+% In the previous example, there are two environments |{WithArrows}| nested in the main environment |{WithArrows}|.
%
-% \subsection{Nested environments}
+% $\begin{WithArrows}[TikzCode = {\path (#1) to node {#3} (#2) ; }]
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
+% & \Leftrightarrow \color{blue}
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \Arrow{environment number 1}\\
+% 2x+4y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow \color{red}
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \Arrow{environment number 2}\\
+% x+2y & = 0
+% \end{WithArrows}\right. \\
+% & \Leftrightarrow x+2y=0
+% \end{WithArrows}$
%
+% \bigskip
+% The arrow we want to draw starts in the line~$2$ of the sub-environment number~$1$ (and therefore, the
+% specification is |1-2|) and ends in the line~$2$ of the sub-environment number~$2$ (and therefore, the
+% specification is |2-2|). We can draw the arrow with the following command |\Arrow| in |CodeAfter| :
+% \begin{Verbatim}
+% $\begin{WithArrows}[~emphase#CodeAfter = {\Arrow{1-2}{2-2}{Division by $2$}}@]
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
+% .........
+% \end{WithArrows}$
+% \end{Verbatim}
%
-% The environments |{WithArrows}| can be nested. In this case, the options given to the encompassing environment
-% applies also to the inner ones (with the notable exception of |interline|).
-% %
-% \begin{Verbatim}[formatcom=\small\color{gray}]
-% $~emphase#\begin{WithArrows}@[tikz=blue]
+% $\begin{WithArrows}[CodeAfter = {\Arrow{1-2}{2-2}{Division by $2$}}]
% \varphi(x,y)=0
-% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \Arrow{the numbers are real}\\
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
% & \Leftrightarrow
-% \left\{~emphase#\begin{WithArrows}@[c]
+% \left\{\begin{WithArrows}[c]
% x+2y & = 0 \\
% 2x+4y & = 0
-% ~emphase#\end{WithArrows}@\right. \\
+% \end{WithArrows}\right. \\
% & \Leftrightarrow
-% \left\{~emphase#\begin{WithArrows}@[c]
-% x+2y & = 0 \Arrow[tikz=-]{the same équation}\\
+% \left\{\begin{WithArrows}[c]
+% x+2y & = 0 \\
% x+2y & = 0
-% ~emphase#\end{WithArrows}@\right. \\
+% \end{WithArrows}\right. \\
% & \Leftrightarrow x+2y=0
-% ~emphase#\end{WithArrows}@$
+% \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
+% meaning.
+%
+% With the option |v|, the arrow drawn is vertical to an abscissa computed with the start line and the end line
+% 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 translate an arrow with
+% |xoffset| (or |xshift| of Tikz).
+% \begin{Verbatim}
+% $\begin{WithArrows}[CodeAfter = {\Arrow~emphase#[v]@{1-2}{2-2}{Division by $2$}}]
+% \varphi(x,y)=0
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
+% .........
+% \end{WithArrows}$
% \end{Verbatim}
%
-% $\begin{WithArrows}[tikz=blue]
+% $\begin{WithArrows}[CodeAfter = {\Arrow[v]{1-2}{2-2}{Division by $2$}}]
% \varphi(x,y)=0
-% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \Arrow{the numbers are real}\\
+% & \Leftrightarrow (x+2y)^2+(2x+4y)^2 = 0 \\
% & \Leftrightarrow
% \left\{\begin{WithArrows}[c]
% x+2y & = 0 \\
@@ -825,84 +944,222 @@ version 2005/12/01 or later.
% \end{WithArrows}\right. \\
% & \Leftrightarrow
% \left\{\begin{WithArrows}[c]
-% x+2y & = 0 \Arrow[tikz=-]{the same equation}\\
+% x+2y & = 0 \\
% x+2y & = 0
% \end{WithArrows}\right. \\
% & \Leftrightarrow x+2y=0
% \end{WithArrows}$
%
+%
+% \interitem
+% The package \pkg{witharrows} gives also another command available only in |CodeAfter| : the command
+% |\MultiArrow|. This commands draws a ``rak''. The list of the lines 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{pgfkeys}.
%
%
-% \subsection{A loop flow}
-%
-% Here is an example with a loop flow.\par\nobreak
-% %
-% \begin{Verbatim}[formatcom=\small\color{gray}]
-% $\begin{WithArrows}[tikz={font={\tiny}}]
-% a.\;& f \text{ est continuous on } E
-% \Arrow{(1)}\Arrow[tikz=<-,jump=4,xoffset=1cm]{(5)}\\
-% b.\;& f \text{ est continuous in } 0
-% \Arrow{(2)}\\
-% c.\;& f \text{ is bounded on the unit sphere}
-% \Arrow{(3)}\\
-% d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\|
-% \Arrow{(4)}\\
-% e.\;& f \text{ is lipschitzian}
+% \begin{Verbatim}
+% $\begin{WithArrows}[tikz = rounded corners,
+% CodeAfter = {~emphase#\MultiArrow{1,...,4}{text}@}]
+% A & = B \\
+% & = C \\
+% & = D \\
+% & = E \\
+% & = F
% \end{WithArrows}$
% \end{Verbatim}
-%
-% $\begin{WithArrows}[tikz={font={\tiny}}]
-% a.\;& f \text{ est continuous on } E
-% \Arrow{(1)}\Arrow[tikz=<-,jump=4,xoffset=1cm]{(5)}\\
-% b.\;& f \text{ est continuous in } 0
-% \Arrow{(2)}\\
-% c.\;& f \text{ is bounded on the unit sphere}
-% \Arrow{(3)}\\
-% d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\|
-% \Arrow{(4)}\\
-% e.\;& f \text{ is lipschitzian}
+%
+%
+% $\begin{WithArrows}[tikz = rounded corners,
+% CodeAfter = {\MultiArrow{1,...,4}{text}}]
+% A & = B \\
+% & = C \\
+% & = D \\
+% & = E \\
+% & = F
% \end{WithArrows}$
%
+% \medskip
+% As of now, there is no option available for the command |\MultiArrow| (maybe in a future release).
+%
+%
+% \bigskip
+% \section{Arrows from outside environments WithArrows}
+%
+% If someone wants to draw arrows from outside the environments |{WithArrows}|, he can use the Tikz nodes created
+% in the environments.
+%
+% The Tikz name of a node created by \pkg{witharrows} is prefixed by |wa-|. Then, we have a list of numbers which
+% give the position in the nesting tree and the number of the line in the environment. At the end, we have the
+% suffixe |l| for a ``left node'' and |r| for a ``right node''.
+%
+% \smallskip
+% For illustrative purposes, we give an example of nested environments |{WithArrows}|, and, for each ``right
+% node'', the name of that node.\footnote{There is an option |shownodenames| to show the names of these nodes.}
+%
+% \medskip
+% \[\begin{WithArrows}[shownodes,shownodenames]
+% A & \vartriangleleft B+B+B+B+B+B+B+B+B+B+B+B+B \\
+% & \vartriangleleft \left\{
+% \begin{WithArrows}[c]
+% C & \vartriangleleft D \\
+% E & \vartriangleleft F
+% \end{WithArrows}
+% \right. \\
+% & \vartriangleleft
+% \left\{
+% \begin{WithArrows}[c]
+% G & \vartriangleleft H+H+H+H+H+H+H \\
+% I & \vartriangleleft
+% \left\{
+% \begin{WithArrows}
+% J &\vartriangleleft K \\
+% L &\vartriangleleft M
+% \end{WithArrows}
+% \right.
+% \end{WithArrows}
+% \right. \\
+% & \vartriangleleft
+% \left\{
+% \begin{WithArrows}[c]
+% N & \vartriangleleft O \\
+% P & \vartriangleleft Q
+% \end{WithArrows}
+% \right.
+% \end{WithArrows}\]
+%
+% \medskip
+% The package \pkg{witharrows} provides some tools to use directly these nodes :
+% \begin{itemize}
+% \item the command |\WithArrowsLastEnv| gives the number of the last environment of level~$0$ ;
%
-% \subsection{Automatic numerotation}
+% \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 \pkg{witharrows}.} ;
%
-% The option |font| of Tikz contains in fact a list of tokens which will be placed at the beginning of the text.
-% These tokens can be true commands for a change of font (like |\bfseries| or |\sffamily|) but can also be, in
-% fact, any TeX command.
+% \item the Tikz style |WithArrows/arrow/tips| is the style for the style of the arrow (loaded by |WithArrows/arrow|).
+% \end{itemize}
%
-% In the following example, the argument of |font| is the token list |\tiny\counter| where |\counter| is a command
-% which increments a counter previously defined and displays its new value. Thus, the arrows are automatically
-% numbered.
-% %
-% \begin{Verbatim}[formatcom=\small\color{gray}]
-% \newcounter{MyCounter}
-% \newcommand{\counter}{\stepcounter{MyCounter}\theMyCounter.}
-% $\begin{WithArrows}[tikz={~emphase#font={\tiny\counter}@}]
-% A(x)
-% & = B(x) \Arrow{} \\
-% & = C(x) \Arrow{} \\
-% & = C(x) \Arrow{} \\
-% & = E(x) \Arrow{} \\
-% & = F(x) \Arrow{} \\
-% & = G(x)
-% \end{WithArrows}$
+% 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]
+% \draw [WithArrows/arrow]
+% ($(wa-\WithArrowsLastEnv-2-1-2-r.south)+(3mm,0)$)
+% to ($(wa-\WithArrowsLastEnv-3-2-r.north)+(3mm,0)$) ;
+% \end{tikzpicture}
% \end{Verbatim}
%
-% \begin{scope}
-% \newcounter{MyCounter}
-% \newcommand{\counter}{\stepcounter{MyCounter}\theMyCounter.}
-% $\begin{WithArrows}[tikz={font={\tiny\counter}}]
-% A(x)
-% & = B(x) \Arrow{} \\
-% & = C(x) \Arrow{} \\
-% & = C(x) \Arrow{} \\
-% & = E(x) \Arrow{} \\
-% & = F(x) \Arrow{} \\
-% & = G(x)
-% \end{WithArrows}$
-% \end{scope}
+% \[\begin{WithArrows}
+% A & \vartriangleleft B+B+B+B+B+B+B+B+B+B+B+B+B \\
+% & \vartriangleleft \left\{
+% \begin{WithArrows}[c]
+% C & \vartriangleleft D \\
+% E & \vartriangleleft F
+% \end{WithArrows}
+% \right. \\
+% & \vartriangleleft
+% \left\{
+% \begin{WithArrows}[c]
+% G & \vartriangleleft H+H+H+H+H+H+H \\
+% I & \vartriangleleft
+% \left\{
+% \begin{WithArrows}
+% J &\vartriangleleft K \\
+% L &\vartriangleleft M
+% \end{WithArrows}
+% \right.
+% \end{WithArrows}
+% \right. \\
+% & \vartriangleleft
+% \left\{
+% \begin{WithArrows}[c]
+% N & \vartriangleleft O \\
+% P & \vartriangleleft Q
+% \end{WithArrows}
+% \right.
+% \end{WithArrows}\]
%
-% \section{Footnotes in the environment WithArrows}
+% \begin{tikzpicture}[remember picture,overlay]
+% \draw [WithArrows/arrow]
+% ($(wa-\WithArrowsLastEnv-2-1-2-r.south)+(3mm,0)$)
+% to ($(wa-\WithArrowsLastEnv-3-2-r.north)+(3mm,0)$) ;
+% \end{tikzpicture}
+%
+% \medskip
+% In this case, it would be easier to use a command |\Arrow| in |CodeAfter| but this is an example to explain how
+% the Tikz nodes created by \pkg{witharrows} can be used.
+%
+%
+%
+% \section{Advanced features}
+%
+%
+% \subsection{The option TikzCode : how to change the shape of the arrows}
+%
+% \label{TikzCode}
+%
+% The option |TikzCode| allows the user to change the shape of the arrow.
+%
+% \smallskip
+% The value of this option must be an valid Tikz drawing instruction (with the final semi-colon) with three markers
+% |#1|, |#2| and |#3| for the start point, the end point and the label of the arrow.
+%
+% \bigskip
+% By default, the value is the following :
+%
+% \smallskip
+% \qquad \verb|\draw (#1) to node {#3} (#2) ;|
+%
+%
+% \bigskip
+% 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]@
+% ~emphase# (~#1) -- ($(~#1) + (5mm,0)$)@
+% ~emphase# -- node[circle,@
+% ~emphase# draw,@
+% ~emphase# auto = false,@
+% ~emphase# fill = gray!50,@
+% ~emphase# inner sep = 1pt] {\tiny ~#3}@
+% ~emphase# ($(~#2) + (5mm,0)$)@
+% ~emphase# -- (~#2) ; }@]
+% E & \Longleftrightarrow 3 (2x+4) = 6 \Arrow{$\div 3$} \\
+% & \Longleftrightarrow 2x+4 = 2 \Arrow{$-4$} \\
+% & \Longleftrightarrow 2x = -2 \Arrow{$\div 2$} \\
+% & \Longleftrightarrow 2x = -1
+% \end{WithArrows}
+% \end{Verbatim}
+%
+%
+% \[\begin{WithArrows}[ygap=5pt,
+% interline=4mm,
+% TikzCode = {\draw[rounded corners]
+% (#1)
+% --
+% ($(#1) + (5mm,0)$)
+% -- node[circle,
+% draw,
+% auto=false,
+% fill=gray!50,
+% inner sep = 1pt] {\tiny #3}
+% ($(#2) + (5mm,0)$)
+% --
+% (#2) ; }]
+% E & \Longleftrightarrow 3 (2x+4) = 6
+% \Arrow{$\div 3$}\\
+% & \Longleftrightarrow 2x+4 = 2
+% \Arrow{$-4$}\\
+% & \Longleftrightarrow 2x = -2
+% \Arrow{$\div 2$} \\
+% & \Longleftrightarrow 2x = -1
+% \end{WithArrows}\]
+%
+% \bigskip
+% \subsection{Footnotes in the environment WithArrows}
%
% If you want to put footnotes in an environment |{WithArrows}|, you can use a pair
% |\footnotemark|--|\footnotetext|.
@@ -935,106 +1192,283 @@ version 2005/12/01 or later.
% \Arrow{We expand\,\footnote{A footnote.}} \\
% & = a^2+b^2+2ab
% \end{WithArrows}$
-%
-%\section{Fine tuning}
%
-% The version 1.3 of \pkg{witharrows} give two new options for a fine tuning of the arrows:
-%
-% \begin{itemize}
-% \item the option |ystart| set the vertical distance between the base line of the text and the start of the arrow
-% (default value: 0.4 ex).
-% \item the option |ygap| set the vertical distance between two consecutive arrows (default value: 0.4~ex).
-% \end{itemize}
%
-% These options can be set at the document level or at the environment level.
+% \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
-% $\begin{WithArrows}[interline=1mm]
-% (\cos x + \sin x)^2 & = \cos^2 x +2 \cos x \sin x + \sin^2 x\Arrow{}\tikz[remember picture] \coordinate (A) ; \\
-% & = \cos^2x + \sin^2x + 2\sin x\cos x \Arrow{} \\
-% & = 1 + \sin(2x)
+% \subsection{MoveEqLeft}
+%
+% It's possible to use |\MoveEqLeft| of \pkg{mathtools} (if we don't want ampersand on the first line):
+% %
+% \begin{Verbatim}[formatcom=\small\color{gray}]
+% $\begin{WithArrows}[interline=0.5ex]
+% ~emphase#\MoveEqLeft@ \arccos(x) = \arcsin \frac45 + \arcsin \frac5{13}
+% \Arrow{because both are in $[-\frac{\pi}2,\frac{\pi}2]$} \\
+% & \Leftrightarrow x = \sin\left(\arcsin\frac45 + \arcsin\frac5{13}\right) \\
+% & \Leftrightarrow x = \frac45\cos\arcsin\frac5{13} + \frac5{13} \cos\arcsin\frac45
+% \Arrow{$\forall x \in [-1,1], \cos(\arcsin x) = \sqrt{1-x^2}$} \\
+% & \Leftrightarrow x = \frac45\sqrt{1-\bigl(\frac5{13}\bigr)^2}
+% + \frac5{13}\sqrt{1-\bigl(\frac45\bigr)^2} \\
% \end{WithArrows}$
+% \end{Verbatim}
%
-% \begin{tikzpicture}[remember picture,overlay,blue]
-% \draw (wa-\WithArrowsLastEnv-1-r.south) to ++(1,0) coordinate (B) to ++(0.1,0) ;;
-% \draw (A) to ++(1,0) coordinate (C) to ++(0.1,0) ;;
-% \draw (B) -- (C) ;
-% \draw[<-] (B) to ++(0,0.2) ;
-% \draw[<-] (C) to ++(0,-0.2) ;
-% \path (C) node[right=1mm] {\texttt{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}} ;
-% \end{tikzpicture}
+%
+% \medskip
+% $\begin{WithArrows}[interline=0.5ex]
+% \MoveEqLeft \arccos(x) = \arcsin \frac45 + \arcsin \frac5{13}
+% \Arrow{because both are in $[-\frac{\pi}2,\frac{\pi}2]$} \\
+% & \Leftrightarrow x = \sin\left(\arcsin\frac45 + \arcsin\frac5{13}\right) \\
+% & \Leftrightarrow x = \frac45\cos\arcsin\frac5{13} + \frac5{13} \cos\arcsin\frac45
+% \Arrow{$\forall x \in [-1,1], \cos(\arcsin x) = \sqrt{1-x^2}$} \\
+% & \Leftrightarrow x = \frac45\sqrt{1-\bigl(\frac5{13}\bigr)^2}
+% + \frac5{13}\sqrt{1-\bigl(\frac45\bigr)^2} \\
+% \end{WithArrows}$
%
%
% \bigskip
-% \emph{Remark}: It's also possible to use the options ``|shorten <|'' and ``|shorten >|'' of Tikz (via the option
-% |tikz| of \pkg{witharrows}).
+% \subsection{Modifying the shape of the nodes}
%
-% \section{An technical remark about the names of the nodes}
+% It's possible to change the shape of the labels, which are Tikz nodes, by modifying the key ``|every node|'' of
+% Tikz.
%
-% \label{NamesOfTheNodes}
-%
-% Environments |{WithArrows}| can be nested, and, therefore, we have a ``nesting tree'' for the environments
-% |{WithArrows}| of the whole document. This nesting tree is used to give a unique name to each node in the
-% document.
+% \begin{Verbatim}
+% \begin{WithArrows}[%
+% 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
+% \end{WithArrows}
+% \end{Verbatim}
+%
+% \[\begin{WithArrows}[%
+% interline = 4mm,
+% tikz = {every node/.style = {circle,
+% draw,
+% auto = false,
+% 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
+% \end{WithArrows}\]
+%
+%
+% \bigskip
+% \subsection{Examples with the option TikzCode}
+%
+% We recall that the option |TikzCode| is the Tikz code used by \pkg{witharrows} to draw the arrows.
%
-% \smallskip
-% The Tikz name of a node created by \pkg{witharrows} is prefixed by |wa-|. Then, we have a list of numbers which
-% give the position in the nesting tree and the number of the line in the environment. At the end, we have the
-% suffixe |l| for a ``left node'' and |r| for a ``right node''.
-%
% \smallskip
-% For illustrative purposes, we give an example of nested environments |{WithArrows}|, and, for each ``right
-% node'', the name of that node.\footnote{There is an option \texttt{shownodenames} to show the names of these nodes.}
+% The value by defaut of |TikzCode| is \verb|\draw (#1) to node {#3} (#2) ;| where the three markers |#1|, |#2| and
+% |#3| represent the start line, the end line and the label of the arrow.
+%
+%
+% \bigskip
+% \subsubsection{Example 1}
+% In the following example, we define the value of |TikzCode| with two instructions |\path| : the first instruction
+% draw the arrow itself and the second puts the label in a Tikz node in the rectangle delimited by the arrow.
+%
+% \begin{Verbatim}
+% $\begin{WithArrows}[
+% displaystyle,
+% ygap = 2mm,
+% ystart = 0mm,
+% ~emphase#TikzCode = {\path[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)
+% ...........
+% \end{Verbatim}
+%
+%
+% \bigskip
+% $\begin{WithArrows}[
+% displaystyle,
+% ygap = 2mm,
+% ystart = 0mm,
+% TikzCode = {\path[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})$}\\
+% & = \frac1n\sum_{k=0}^{n-1} \Re\left(e^{i\frac{k\pi}{2n}}\right)
+% \Arrow{$\Re(z+z')=\Re(z)+\Re(z')$}\\
+% & = \frac1n \Re\left(\sum_{k=0}^{n-1} e^{i\frac{k\pi}{2n}}\right)
+% \Arrow{$\exp$ is a morphism for $\times$ et $+$} \\
+% & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right)
+% \Arrow{sum of terms of a geometric progression of ratio $e^{i\frac{2\pi}n}$}\\
+% & = \frac1n \Re \left( \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}{1-e^{i\frac{\pi}{2n}}}\right)\\
+% & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right)
+% \end{WithArrows}$
+%
+% \bigskip
+% \subsubsection{Example 2}
%
-% \medskip
-% \[\begin{WithArrows}[shownodes,shownodenames]
-% A & \vartriangleleft B+B+B+B+B+B+B+B+B+B+B+B+B \\
-% & \vartriangleleft \left\{
-% \begin{WithArrows}[c]
-% C & \vartriangleleft D \\
-% E & \vartriangleleft F
-% \end{WithArrows}
-% \right. \\
-% & \vartriangleleft
-% \left\{
-% \begin{WithArrows}[c]
-% G & \vartriangleleft H+H+H+H+H+H+H \\
-% I & \vartriangleleft
-% \left\{
-% \begin{WithArrows}
-% J &\vartriangleleft K \\
-% L &\vartriangleleft M
-% \end{WithArrows}
-% \right.
-% \end{WithArrows}
-% \right. \\
-% & \vartriangleleft
-% \left\{
-% \begin{WithArrows}[c]
-% N & \vartriangleleft O \\
-% P & \vartriangleleft Q
+% In the following example, we change the shape of the arrow depending on wether the start line is longer than the
+% end line or not.
+%
+% \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 ;}@]
+% E & \Longleftrightarrow \frac{(x+4)}3 + \frac{5x+3}5 = 7
+% \Arrow{$\times 15$}\\
+% & \Longleftrightarrow 5(x+4) + 3(5x+3) = 105 \\
+% & \Longleftrightarrow 5x+20 + 15x+9 = 105 \\
+% & \Longleftrightarrow 20x+29 = 105
+% \Arrow{$-29$}\\
+% & \Longleftrightarrow 20x = 76
+% \Arrow{$\div 20$}\\
+% & \Longleftrightarrow x = \frac{38}{10}
% \end{WithArrows}
-% \right.
+% \end{Verbatim}
+%
+%
+% \[\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 ;}]
+% E & \Longleftrightarrow \frac{(x+4)}3 + \frac{5x+3}5 = 7
+% \Arrow{$\times 15$}\\
+% & \Longleftrightarrow 5(x+4) + 3(5x+3) = 105 \\
+% & \Longleftrightarrow 5x+20 + 15x+9 = 105 \\
+% & \Longleftrightarrow 20x+29 = 105
+% \Arrow{$-29$}\\
+% & \Longleftrightarrow 20x = 76
+% \Arrow{$\div 20$}\\
+% & \Longleftrightarrow x = \frac{38}{10}
% \end{WithArrows}\]
%
+%
+%
+% \subsection{Automatic numbered loop}
+%
+% 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 |\NewDocumentCommand| of \pkg{xparse} and |\foreach| of \pkg{pgffor} (both packages are loaded when
+% \pkg{witharrows} is loaded).
+%
+% \begin{Verbatim}
+% \NewDocumentCommand \NumberedLoop {}
+% {\foreach \j in {2,...,\NbLines}
+% { \pgfmathtruncatemacro{\i}{\j-1}
+% \Arrow[rr]{\i}{\j}{\i} }
+% \Arrow[rr,xoffset=1cm,tikz=<-]{1}{\NbLines}{\NbLines}}
+% \end{Verbatim}
+%
+% The command |\NbLines| is a command available in |CodeAfter| which gives the total number of lines of the current
+% environment (it's a command and not a counter).
+%
+%
+% \bigskip
+% \begin{Verbatim}
+% $\begin{WithArrows}[~emphase#CodeAfter = {\NumberedLoop}@]
+% a.\;& f \text{ est continuous on } E \\
+% b.\;& f \text{ est continuous in } 0 \\
+% c.\;& f \text{ is bounded on the unit sphere} \\
+% d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\| \\
+% e.\;& f \text{ is lipschitzian}
+% \end{WithArrows}$
+% \end{Verbatim}
+%
+% \bigskip
+% \begin{scope}
+% \NewDocumentCommand \NumberedLoop {}
+% {\foreach \j in {2,...,\NbLines}
+% { \pgfmathtruncatemacro{\i}{\j-1}
+% \Arrow[rr]{\i}{\j}{\i} }
+% \Arrow[rr,xoffset=1cm,tikz=<-]{1}{\NbLines}{\NbLines}}
+%
+%
+% $\begin{WithArrows}[CodeAfter = {\NumberedLoop}]
+% a.\;& f \text{ est continuous on } E \\
+% b.\;& f \text{ est continuous in } 0 \\
+% c.\;& f \text{ is bounded on the unit sphere} \\
+% d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\| \\
+% e.\;& f \text{ is lipschitzian}
+% \end{WithArrows}$
+%
+%
% \bigskip
-% The command |\WithArrowsLastEnv| gives the number of the last environment of level~$0$. For example, we can draw
-% an arrow from the node \texttt{wa-\WithArrowsLastEnv-1} to the node \texttt{wa-\WithArrowsLastEnv-2-1} with the
-% following Tikz command.\footnote{The command \texttt{\string\WithArrowsLastEnv} is \emph{fully expandable} and
-% thus, can be used directly in the name of a Tikz node.}
+% 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 and to have, for example, numbers in parenthesis, the best way is to change the value
+% of |TikzCode|:
%
% \begin{Verbatim}
-% \begin{tikzpicture}[remember picture,overlay,->,TipsOfWithArrows]
-% \draw (wa-\WithArrowsLastEnv-1-r) to (wa-\WithArrowsLastEnv-2-1-r) ;
-% \end{tikzpicture}
+% TikzCode = {\draw (~#1) to node {\footnotesize (~#3)} (~#2) ;}}
% \end{Verbatim}
%
+% \WithArrowsOptions{TikzCode = {\draw (#1) to node {\footnotesize (#3)} (#2) ;}}
+%
+% $\begin{WithArrows}[CodeAfter = {\NumberedLoop}]
+% a.\;& f \text{ est continuous on } E \\
+% b.\;& f \text{ est continuous in } 0 \\
+% c.\;& f \text{ is bounded on the unit sphere} \\
+% d.\;& \exists K > 0\quad \forall x \in E\quad \|f(x)\| \le K \|x\| \\
+% e.\;& f \text{ is lipschitzian}
+% \end{WithArrows}$
+%
+% \end{scope}
%
% \section{Implementation}
%
@@ -1063,12 +1497,13 @@ version 2005/12/01 or later.
%
% \bigskip
% The package \pkg{xparse} will be used to define the environment |{WithArrows}| and the document-level commands
-% (|\Arrow|, |\WithArrowsOptions| and |\WithArrowsLastEnv|).
+% |\Arrow| and |\WithArrowsOptions|.
% \begin{macrocode}
\RequirePackage{xparse}
% \end{macrocode}
%
-% \subsection{The packages footnote and footnotehyper }
+% \bigskip
+% \subsection{The packages footnote and footnotehyper}
%
% A few options can be given to the package \pkg{witharrows} when it is loaded (with |\usepackage|,
% |\RequirePackage| or |\PassOptionsToPackage|). Currently (version \myfileversion), there are two such options:
@@ -1138,16 +1573,11 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{macrocode}
-\cs_new_protected:Nn \@@_test_beamer:n
- {\@ifclassloaded {beamer}
+\bool_if:NT \g_@@_footnote_bool
+ {\@ifclassloaded {beamer}
{\msg_fatal:nn {witharrows}
{Option~incompatible~with~Beamer}}
- {} }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\bool_if:NT \g_@@_footnote_bool
- {\@@_test_beamer:n {footnote}
+ {}
\@ifpackageloaded{footnotehyper}
{\msg_fatal:nn {witharrows}
{footnote~with~footnotehyper~package}}
@@ -1157,7 +1587,10 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\bool_if:NT \g_@@_footnotehyper_bool
- {\@@_test_beamer:n {footnotehyper}
+ {\@ifclassloaded {beamer}
+ {\msg_fatal:nn {witharrows}
+ {Option~incompatible~with~Beamer}}
+ {}
\@ifpackageloaded{footnote}
{\msg_fatal:nn {witharrows}
{footnotehyper~with~footnote~package}}
@@ -1165,33 +1598,53 @@ version 2005/12/01 or later.
\usepackage{footnotehyper}
\bool_gset_true:N \g_@@_footnote_bool}
% \end{macrocode}
-% The flag |\g_@@_footnote_bool| has been set to |true| and so, we will only have to test
-% |\g_@@_footnote_bool| in order to known if we have to insert an environnement |{savenotes}| (see the definition
-% of environnement |{WithArrows}|).
+% The flag |\g_@@_footnote_bool| is raised and so, we will only have to test |\g_@@_footnote_bool| in order to
+% known if we have to insert an environnement |{savenotes}| (see the definition of environnement |{WithArrows}|).
%
+% \bigskip
% \subsection{Some technical definitions}
%
% We define a Tikz style |@@_node_style| for the nodes that will be created in the |\halign|. The nodes are Tikz
% nodes of shape ``rectangle'' but with zero width. An arrow between two nodes starts from the \emph{south} anchor
% of the first node and arrives at the \emph{north} anchor of the second node.
% \begin{macrocode}
-\tikzset{@@_node_style/.style={
+\tikzset{@@_node_style/.style= {
above = \l_@@_ystart_dim,
inner~sep = 0 pt,
minimum~width = 0pt,
minimum~height = \l_@@_ygap_dim,
red,
- \bool_if:NT \l_@@_shownodes_bool {draw}}}
+ \bool_if:NT \l_@@_shownodes_bool {draw} }}
% \end{macrocode}
% The color of the nodes is red, but in fact, the nodes will be drawn only when the option |shownodes| is used
% (this option is useful for debugging).
%
+%
+% \bigskip
+% The style |@@_standard| is load in standard in the |{tikzpicture}| we need. The names of the nodes are prefixed by
+% |wa| (by security) but also by a prefix which is the position-in-the-tree of the nested environments.
+% \begin{macrocode}
+\tikzset{@@_standard/.style= { remember~picture,
+ overlay,
+ name~prefix = wa-\l_@@_prefix_str- }}
+% \end{macrocode}
+%
% \bigskip
% We also define a style for the tips of arrow. The final user of the extension \pkg{witharrows} will use this
% style if he wants to draw an arrow directly with a Tikz command in his document (probably using the Tikz nodes
% created by |{WithArrows}| in the |\halign|).
% \begin{macrocode}
-\tikzset{TipsOfWithArrows/.style= { > = {Straight~Barb[scale=1.2,bend]}} }
+\tikzset{WithArrows/arrow/tips/.style = { > = {Straight~Barb[scale=1.2,bend]} }}
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\tikzset{WithArrows/arrow/.style = { align = left,
+ auto = left,
+ font = {\small\itshape},
+ WithArrows/arrow/tips,
+ bend~left = 45,
+ -> }}
% \end{macrocode}
%
% \bigskip
@@ -1211,6 +1664,7 @@ version 2005/12/01 or later.
% with nested environments.
%
%
+% \bigskip
% \subsection{Variables}
%
% The following sequence is the position of the last environment |{WithArrows}| in the tree of the nested
@@ -1247,15 +1701,22 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The integer |\l_@@_pos_arrows_int| indicates the position of the arrows with the following code:
+% \begin{macrocode}
+\dim_new:N \l_@@_xoffset_dim
+\dim_set:Nn \l_@@_xoffset_dim {3mm}
+% \end{macrocode}
+%
+% \bigskip
+% The integer |\l_@@_pos_arrows_int| indicates the position of the arrows 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).
%
% \begin{center}
% \setlength{\extrarowheight}{2pt}
-% \begin{tabular}{|l|c|c|c|c|c|c|c|}
+% \begin{tabular}{|l|c|c|c|c|c|c|c|c|}
% \hline
-% option & |rr| & |ll| & |rl| & |lr| & |i| & |group| & |groups| \\
+% option & |rr| & |ll| & |rl| & |lr| & |v| & |i| & |group| & |groups| \\
% \hline
-% |\l_@@_pos_arrows_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ \\
+% |\l_@@_pos_arrows_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
% \hline
% \end{tabular}
% \end{center}
@@ -1274,59 +1735,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The gap between two consecutive arrows.
-% \begin{macrocode}
-\dim_new:N \l_@@_ygap_dim
-\dim_set:Nn \l_@@_ygap_dim {0.4 ex}
-% \end{macrocode}
-%
-% \bigskip
-% The vertical position of the starting point of an arrow.
-% \begin{macrocode}
-\dim_new:N \l_@@_ystart_dim
-\dim_set:Nn \l_@@_ystart_dim {0.4 ex}
-% \end{macrocode}
-%
-%
-% \bigskip
-% The following dimension is the value of the translation of the whole arrow to the right (of course, it's a
-% dimension and not a skip).
-% \begin{macrocode}
-\dim_new:N \l_@@_xoffset_dim
-\dim_set:Nn \l_@@_xoffset_dim {3mm}
-% \end{macrocode}
-%
-% \bigskip
-% If the following flag is raised, the nodes will be drawn in red (useful for debugging).
-% \begin{macrocode}
-\bool_new:N \l_@@_shownodes_bool
-% \end{macrocode}
-%
-% \bigskip
-% If the following flag is raised, the name of the ``right nodes'' will be shown in the document (useful for
-% debugging).
-% \begin{macrocode}
-\bool_new:N \l_@@_shownodenames_bool
-% \end{macrocode}
-%
-% \bigskip
-% If the following flag is raised, the elements of the |\halign| will be composed with |\displaystyle|:
-% \begin{macrocode}
-\bool_new:N \l_@@_displaystyle_bool
-% \end{macrocode}
-%
-% \bigskip
-% The following token list variable will contains the Tikz options used to draw the arrows.
-% \begin{macrocode}
-\tl_clear_new:N \l_@@_options_tikz_tl
-% \end{macrocode}
%
% At each possible level for the options (\emph{global}, \emph{environment} or \emph{local}: see below), the new
% values will be appended on the right of this token list.
%
% \bigskip
% The dimension |\g_@@_x_dim| will be used to compute the $x$-value for some vertical arrows when one of the
-% options |i|, |group| and |groups| (values 4, 5 and 6 of |\l_@@_pos_arrows_int|) is used.
+% options |i|, |group| and |groups| (values 5, 6 and 7 of |\l_@@_pos_arrows_int|) is used.
% \begin{macrocode}
\dim_new:N \g_@@_x_dim
% \end{macrocode}
@@ -1354,13 +1769,15 @@ version 2005/12/01 or later.
\int_new:N \g_@@_line_bis_int
% \end{macrocode}
%
+% \bigskip
% \subsection{The definition of the options}
+%
% There are four levels where options can be set:
% \begin{itemize}
% \item in the options of the |\usepackage|: this level will be called \emph{package} level (number~$0$);
% \item with |\WithArrowsOptions{...}|: this level will be called \emph{global} level (number~$1$);
% \item with |\begin{WithArrows}[...]|: this level will be called \emph{environment} level (number~$2$);
-% \item with |\Arrow[...]|: this level will be called \emph{local} level (number~$3$).
+% \item with |\Arrow[...]| (included in |CodeAfter|): this level will be called \emph{local} level (number~$3$).
% \end{itemize}
%
% \bigskip
@@ -1380,11 +1797,11 @@ version 2005/12/01 or later.
% stored in the variable |\l_@@_pos_env_int|.
% \begin{macrocode}
\keys_define:nn {WithArrows/GlobalOrEnv}
- { t .code:n = {\int_set:Nn \l_@@_pos_env_int 0},
+ { t .code:n = \int_set:Nn \l_@@_pos_env_int 0,
t .value_forbidden:n = true,
- c .code:n = {\int_set:Nn \l_@@_pos_env_int 1},
+ c .code:n = \int_set:Nn \l_@@_pos_env_int 1,
c .value_forbidden:n = true,
- b .code:n = {\int_set:Nn \l_@@_pos_env_int 2},
+ b .code:n = \int_set:Nn \l_@@_pos_env_int 2,
b .value_forbidden:n = true,
% \end{macrocode}
%
@@ -1393,13 +1810,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
ygap .dim_set:N = \l_@@_ygap_dim,
ygap .value_required:n = true,
+ ygap .initial:n = 0.4 ex,
% \end{macrocode}
%
% \bigskip
-% The vertical position of the starting point of an arrow.
+% The vertical position of the start point of an arrow.
% \begin{macrocode}
ystart .dim_set:N = \l_@@_ystart_dim,
ystart .value_required:n = true,
+ ystart .initial:n = 0.4 ex,
% \end{macrocode}
%
% \bigskip
@@ -1414,20 +1833,29 @@ version 2005/12/01 or later.
% If the user wants to give a new name to the |\Arrow| command (and the name |\Arrow| remains free).
% \begin{macrocode}
CommandName .tl_set:N = \l_@@_CommandName_tl,
- CommandName .initial:n = {Arrow},
+ CommandName .initial:n = Arrow ,
CommandName .value_required:n = true,
% \end{macrocode}
%
% \bigskip
+% \begin{macrocode}
+ TikzCode .tl_set:N = \l_@@_tikz_code_tl,
+ TikzCode .initial:n = \draw~(#1)~to~node{#3}~(#2)~; ,
+ TikzCode .value_required:n = true,
+% \end{macrocode}
+%
+% \bigskip
% With the option |displaystyle|, the environments will be composed in |\displaystyle|.
% \begin{macrocode}
displaystyle .bool_set:N = \l_@@_displaystyle_bool,
+ displaystyle .initial:n = false,
% \end{macrocode}
%
% \bigskip
% With the option |shownodes|, the nodes will be drawn in red (useful only for debugging).
% \begin{macrocode}
shownodes .bool_set:N = \l_@@_shownodes_bool,
+ shownodes .initial:n = false,
% \end{macrocode}
%
% \bigskip
@@ -1435,6 +1863,7 @@ version 2005/12/01 or later.
% for debugging).
% \begin{macrocode}
shownodenames .bool_set:N = \l_@@_shownodenames_bool,
+ shownodenames .initial:n = false,
% \end{macrocode}
%
% \bigskip
@@ -1444,36 +1873,56 @@ version 2005/12/01 or later.
group .code:n = {\int_compare:nNnT \l_@@_previous_pos_arrows_int > {-1}
{\msg_error:nn {witharrows}
{Two~options~are~incompatible}}
- \int_set:Nn \l_@@_previous_pos_arrows_int 5
- \int_set:Nn \l_@@_pos_arrows_int 5},
+ \int_set:Nn \l_@@_previous_pos_arrows_int 6
+ \int_set:Nn \l_@@_pos_arrows_int 6} ,
group .value_forbidden:n = true,
% \end{macrocode}
%
% \bigskip
% With the option |groups| (with a \emph{s}), the arrows of the environment are divided in groups by an argument of
% connexity, and, in each group, the arrows are vertical with the same abscissa and at a leftmost position. When
-% the option |group| or |groups| is used, it's not possible to an other option of position like |ll|, |lr|, etc.
+% the option |group| or |groups| is used, it's not possible to another option of position like |ll|, |lr|, etc.
% for a individual key.
% \begin{macrocode}
groups .code:n = {\int_compare:nNnT \l_@@_previous_pos_arrows_int > {-1}
{\msg_error:nn {witharrows}
{Two~options~are~incompatible}}
- \int_set:Nn \l_@@_previous_pos_arrows_int 6
- \int_set:Nn \l_@@_pos_arrows_int 6},
- groups .value_forbidden:n = true}
+ \int_set:Nn \l_@@_previous_pos_arrows_int 7
+ \int_set:Nn \l_@@_pos_arrows_int 7} ,
+ groups .value_forbidden:n = true,
+% \end{macrocode}
+%
+% \bigskip
+% The option |CodeBefore| gives a code that is executed at the beginning of the environment |{WithArrows}| (after
+% the eventual |\begin{savenotes}|).
+% \begin{macrocode}
+ CodeBefore .code:n = {\int_compare:nNnTF \l_@@_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_put_right:Nn \l_@@_code_before_tl {#1}}} ,
% \end{macrocode}
%
+% \bigskip
+% The option |CodeAfter| gives a code that is executed at the end of the environment |{WithArrows}| (after the
+% eventual |\end{savenotes}|).
+% \begin{macrocode}
+ CodeAfter .code:n = {\int_compare:nNnTF \l_@@_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_put_right:Nn \l_@@_code_after_tl {#1}}} ,
+ unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
+ }
+% \end{macrocode}
%
%
% \bigskip
-% Then we define the main module called |WithArrows| which will be loaded at all the levels.
+% Then we define the main module called |WithArrows/General| which will be loaded at all the levels.
%
% \medskip
% The option |tikz| gives Tikz parameters that will be given to the arrow when it is drawn (more precisely, the
% parameters will be given to the command |\path| of Tikz).
% \begin{macrocode}
-\keys_define:nn {WithArrows}
- {tikz .code:n = {\tl_put_right:Nn \l_@@_options_tikz_tl {,#1}},
+\keys_define:nn {WithArrows/General}
+ {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}},
+ tikz .initial:n = {},
tikz .value_required:n = true,
% \end{macrocode}
%
@@ -1482,27 +1931,30 @@ version 2005/12/01 or later.
% |lr| and |i| and that's why a dedicated fonction |\@@_analyze_option_position:n| has been written (see below).
% \begin{macrocode}
rr .value_forbidden:n = true,
- rr .code:n = {\@@_analyze_option_position:n 0},
+ rr .code:n = \@@_analyze_option_position:n 0 ,
ll .value_forbidden:n = true,
- ll .code:n = {\@@_analyze_option_position:n 1},
+ ll .code:n = \@@_analyze_option_position:n 1 ,
rl .value_forbidden:n = true,
- rl .code:n = {\@@_analyze_option_position:n 2},
+ rl .code:n = \@@_analyze_option_position:n 2 ,
lr .value_forbidden:n = true,
- lr .code:n = {\@@_analyze_option_position:n 3},
+ lr .code:n = \@@_analyze_option_position:n 3 ,
i .value_forbidden:n = true,
- i .code:n = {\@@_analyze_option_position:n 4},
+ i .code:n = \@@_analyze_option_position:n 5 ,
% \end{macrocode}
%
% \bigskip
% The option |xoffset| change the $x$-offset of the arrows (towards the right). It's a dimension and not a skip.
% It's not possible to change the value of this parameter for a individual arrow if the option |group| or the
-% option |groups| is used.
+% option |groups| is used. When we will treat an individual arrow, we will give it the option
+% |tikz={xshift=\l_@@_xoffset_dim}| (we can't to it at the global or the environment level because the Tikz options
+% |xshift| are cumulative.
+%
% \begin{macrocode}
xoffset .code:n = {\bool_if:nTF {\int_compare_p:nNn \l_@@_level_int = 3 &&
- \int_compare_p:nNn \l_@@_pos_arrows_int > 4}
+ \int_compare_p:nNn \l_@@_pos_arrows_int > 5}
{\msg_error:nn {witharrows}
{Option~incompatible~with~"group(s)"}}
- {\dim_set:Nn \l_@@_xoffset_dim {#1}}},
+ {\dim_set:Nn \l_@@_xoffset_dim {#1}}} ,
xoffset .value_required:n = true,
% \end{macrocode}
%
@@ -1513,7 +1965,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
jot .code:n = {\int_compare:nNnTF \l_@@_level_int = 2
{\dim_set:Nn \jot {#1}}
- {\msg_error:nn {witharrows} {Option~will~be~ignored} }},
+ {\msg_error:nn {witharrows}
+ {Option~will~be~ignored}}} ,
jot .value_required:n = true,
% \end{macrocode}
%
@@ -1524,15 +1977,16 @@ version 2005/12/01 or later.
% \begin{macrocode}
interline .code:n = {\int_compare:nNnTF \l_@@_level_int = 2
{\skip_set:Nn \l_@@_interline_skip {#1}}
- {\msg_error:nn {witharrows} {Option~will~be~ignored}}},
+ {\msg_error:nn {witharrows}
+ {Option~will~be~ignored}}} ,
interline .value_required:n = true,
% \end{macrocode}
%
% \bigskip
% Eventually, a key |jump| (see below) and a key for unknown keys.
% \begin{macrocode}
- jump .code:n = {\msg_error:nn {witharrows} {Option~will~be~ignored}},
- unknown .code:n = {\msg_error:nn {witharrows} {Option~unknown}}
+ jump .code:n = \msg_error:nn {witharrows} {Option~will~be~ignored} ,
+ unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
}
% \end{macrocode}
%
@@ -1546,7 +2000,7 @@ version 2005/12/01 or later.
{jump .code:n = {\int_set:Nn \l_@@_jump_int {#1}
\int_compare:nNnF \l_@@_jump_int > 0
{\msg_error:nn {witharrows}
- {The~option~"jump"~must~be~non~negative}}},
+ {The~option~"jump"~must~be~non~negative}}} ,
jump .value_required:n = true}
% \end{macrocode}
%
@@ -1567,7 +2021,7 @@ version 2005/12/01 or later.
% a global level by |\WithArrowsOptions|).
% \begin{macrocode}
\bool_if:nTF { \int_compare_p:nNn \l_@@_level_int = 3 &&
- \int_compare_p:nNn \l_@@_pos_arrows_int > 4}
+ \int_compare_p:nNn \l_@@_pos_arrows_int > 5}
{\msg_error:nn {witharrows}
{Option~incompatible~with~"group(s)"}}
{\int_set:Nn \l_@@_pos_arrows_int {#1}}}
@@ -1579,11 +2033,12 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentCommand \WithArrowsOptions {m}
{\int_set:Nn \l_@@_previous_pos_arrows_int {-1}
- \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl
+ \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl
\keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl}
% \end{macrocode}
%
%
+% \bigskip
% \subsection{The command Arrow}
%
% In fact, the internal command is not named |\Arrow| but |\@@_Arrow|. Usually, at the beginning of an environment
@@ -1646,9 +2101,9 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\prop_gclear_new:c
- {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\g_@@_arrow_int _prop}
+ {g_@@_arrow_\l_@@_prefix_str _\int_use:N\g_@@_arrow_int _prop}
\prop_gset_eq:cN
- {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\g_@@_arrow_int _prop}
+ {g_@@_arrow_\l_@@_prefix_str _\int_use:N\g_@@_arrow_int _prop}
\l_tmpa_prop
}
% \end{macrocode}
@@ -1666,7 +2121,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
-% \subsection{The environnement \{WithArrows\}}
+% \bigskip
+% \subsection{The environment \{WithArrows\}}
%
%
% The environment |{WithArrows}| starts with the initialisation of the three counters |\g_@@_arrow_int|,
@@ -1696,24 +2152,19 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_set_eq:NN \l_tmpa_seq \g_@@_position_in_the_tree_seq
\seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl
- \tl_clear_new:N \l_@@_prefix_tl
- \tl_set:Nx \l_@@_prefix_tl {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}}
+ \str_clear_new:N \l_@@_prefix_str
+ \str_set:Nx \l_@@_prefix_str {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}}
% \end{macrocode}
%
% \bigskip
% The environment |{WithArrows}| must be used in math mode.
% \begin{macrocode}
\reverse_if:N \if_mode_math:
- \msg_error:nn {witharrows} {{WithArrows}~used~outside~math~mode}
- \fi
+ \msg_error:nn {witharrows}
+ {{WithArrows}~used~outside~math~mode}
+ \fi:
% \end{macrocode}
%
-% \bigskip
-% If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment
-% |{savenotes}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}).
-% \begin{macrocode}
- \bool_if:NT \g_@@_footnote_bool {\begin{savenotes}}
-% \end{macrocode}
%
% \bigskip
% We define the command |\\| to be the command |\@@_cr:| (defined below).
@@ -1732,22 +2183,47 @@ version 2005/12/01 or later.
%
% \bigskip
% The value corresponding to the key |interline| is put to zero before the treatment of the options of the
-% environment.\footnote{It's recalled that, by design, the option \texttt{interline} of a environment doesn't apply
+% environment.\footnote{It's recalled that, by design, the option |interline| of an environment doesn't apply
% in the nested environments.}
% \begin{macrocode}
\skip_zero:N \l_@@_interline_skip
% \end{macrocode}
%
% \bigskip
+% The value corresponding to the key |CodeBefore| 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|.
+% \begin{macrocode}
+ \tl_clear_new:N \l_@@_code_before_tl
+ \tl_clear_new:N \l_@@_code_after_tl
+% \end{macrocode}
+% \bigskip
% We process the options given to the |{WithArrows}| environment. The level of options is set to 1.
% \begin{macrocode}
\int_set:Nn \l_@@_previous_pos_arrows_int {-1}
\int_set:Nn \l_@@_level_int 2
- \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl
+ \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl
\keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl
% \end{macrocode}
%
% \bigskip
+% If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment
+% |{savenotes}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}).
+% \begin{macrocode}
+ \bool_if:NT \g_@@_footnote_bool {\begin{savenotes}}
+% \end{macrocode}
+%
+% \bigskip
+% We execute the code |\l_@@_code_before_tl| of the option |CodeBefore| of the environment after the eventual
+% |\begin{savenotes}| and, symetricaly, 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 |CodeAfter|).
+% \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|.
@@ -1757,7 +2233,7 @@ version 2005/12/01 or later.
%
% \bigskip
% The environment begins with a |\vtop|, a |\vcenter| or a |\vbox|\footnote{Notice that the use of
-% \texttt{\string\vtop} seems color-safe here...} depending of the value of |\l_@@_pos_env_int| (fixed by the options
+% |\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}
@@ -1807,9 +2283,7 @@ version 2005/12/01 or later.
% We create the ``left node'' of the line (when using macros in Tikz node names, the macros have to be fully
% expandable: here, |\tl_use:N| and |\int_use:N| are fully expandable).
% \begin{macrocode}
- \tikz[remember~picture,overlay]
- \node[@@_node_style]
- (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-l) {} ;
+ \tikz [@@_standard] \node [@@_node_style] (\int_use:N\g_@@_line_int-l) {} ;
\hfil
% \end{macrocode}
%
@@ -1817,11 +2291,9 @@ version 2005/12/01 or later.
% Now, after the |\hfil|, we create the ``right node'' and, if the option |shownodenames| is raised, the name of
% the node is written in the document (useful for debugging).
% \begin{macrocode}
- \tikz[remember~picture,overlay]
- \node[@@_node_style]
- (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-r) {} ;
+ \tikz [@@_standard] \node [@@_node_style] (\int_use:N\g_@@_line_int-r) {} ;
\bool_if:NT \l_@@_shownodenames_bool
- {\hbox_overlap_right:n {\small wa-\tl_use:N\l_@@_prefix_tl
+ {\hbox_overlap_right:n {\small wa-\l_@@_prefix_str
-\int_use:N\g_@@_line_int}}
% \end{macrocode}
%
@@ -1857,18 +2329,39 @@ version 2005/12/01 or later.
% It there is really arrows in the environment, we draw the arrows:
% \begin{itemize}
% \item if neither option |group| or |groups| is used, we can draw directly ;
-% \item if option |group| or option |groups| is used (|\l_@@_pos_arrows_int| > 4), we have to draw the
+% \item if option |group| or option |groups| is used (|\l_@@_pos_arrows_int| > 5), we have to draw the
% arrows group by group ; the macro |\@@_draw_arrows:| does the work.
% \end{itemize}
%
% \begin{macrocode}
- \int_compare:nNnT \g_@@_arrow_int > 0
- {\int_compare:nNnTF \l_@@_pos_arrows_int > 4
+ \int_compare:nNnT \g_@@_arrow_int > 0
+ {\int_compare:nNnTF \l_@@_pos_arrows_int > 5
\@@_draw_arrows:
{\@@_draw_arrows:nn 1 \g_@@_arrow_int}}
% \end{macrocode}
%
% \bigskip
+% We will execute the code specified in the option |CodeAfter|, after some settings.
+% \begin{macrocode}
+ \group_begin:
+ \tikzset{every~picture/.style = @@_standard}
+% \end{macrocode}
+% The command |\NbLines| is not used by \pkg{witharrows}. It's only a convenience given to the user.
+% \begin{macrocode}
+ \cs_set:Npn \NbLines {\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 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 function defined with |\NewDocumentCommand|.}
+% \begin{macrocode}
+ \cs_set_eq:NN \MultiArrow \@@_MultiArrow:nn
+ \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_code_after
+ \l_@@_code_after_tl
+ \group_end:
+% \end{macrocode}
+%
+% \bigskip
% If the option |footnote| or the option |footnotehyper| is used, then we extract the footnotes with an environment
% |{footnote}| (of the package \pkg{footnote} or the package \pkg{footnotehyper}).
% \begin{macrocode}
@@ -1880,11 +2373,12 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_gpop_right:NN \g_@@_position_in_the_tree_seq \l_tmpa_tl
\seq_gpop_right:NN \g_@@_position_in_the_tree_seq \l_tmpa_tl
- \seq_gput_right:Nx \g_@@_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl + 1}}
+ \seq_gput_right:Nx \g_@@_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl+1}}
% \end{macrocode}
%
% \bigskip
-% We update the value of the counter |\g_@@_last_env_int|. This counter is used only by the user function |\WithArrowsLastEnv|.
+% We update the value of the counter |\g_@@_last_env_int|. This counter is used only by the user function
+% |\WithArrowsLastEnv|.
% \begin{macrocode}
\int_compare:nNnT {\seq_count:N \g_@@_position_in_the_tree_seq} = 1
{\int_gincr:N \g_@@_last_env_int}
@@ -1932,6 +2426,7 @@ version 2005/12/01 or later.
% According of the documentation of \pkg{expl3}, the previous addition in ``|#1 + \l_@@_interline_skip|'' is really
% an addition of skips (=glues).
%
+% \bigskip
% \subsection{We draw the arrows}
%
% \bigskip
@@ -1972,10 +2467,10 @@ version 2005/12/01 or later.
% values in |\l_@@_initial_int| and |\l_@@_final_int|. However, we have to do a conversion because the components
% of a property list are token lists.
% \begin{macrocode}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop}
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop}
{initial} \l_tmpa_tl
\int_set:Nn \l_@@_initial_int {\l_tmpa_tl}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop}
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop}
{final} \l_tmpa_tl
\int_set:Nn \l_@@_final_int {\l_tmpa_tl}
% \end{macrocode}
@@ -1984,9 +2479,10 @@ version 2005/12/01 or later.
% We test if the previous arrow was in fact the last arrow of a group. In this case, we have to draw all the arrows
% of that group (with the $x$-value computed in |\g_@@_x_dim|).
% \begin{macrocode}
- \bool_if:nT { \int_compare_p:nNn \l_@@_pos_arrows_int = 6
+ \bool_if:nT { \int_compare_p:nNn \l_@@_pos_arrows_int = 7
&& \int_compare_p:nNn \l_@@_arrow_int > 1
- && \int_compare_p:nNn \l_@@_initial_int > \l_@@_last_line_of_group_int}
+ && \int_compare_p:nNn
+ \l_@@_initial_int > \l_@@_last_line_of_group_int}
{\@@_draw_arrows:nn \l_@@_first_arrow_of_group_int {\l_@@_arrow_int - 1}
\bool_set_true:N \l_@@_new_group_bool}
% \end{macrocode}
@@ -2004,9 +2500,9 @@ version 2005/12/01 or later.
\int_set:Nn \l_@@_first_arrow_of_group_int \l_@@_arrow_int
\int_set:Nn \l_@@_first_line_of_group_int \l_@@_initial_int
\int_set:Nn \l_@@_last_line_of_group_int \l_@@_final_int
- \tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int-l)
- in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ;
+ \tikz [@@_standard]
+ \path let \p1=(\int_use:N\l_@@_initial_int-l)
+ in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ;
}
% \end{macrocode}
%
@@ -2021,7 +2517,7 @@ version 2005/12/01 or later.
% We actualise the current $x$-value (in |\g_@@_x_dim|) even if we are at the beginning of a group. Indeed, the
% previous initialisation of |\g_@@_x_dim| only considers the initial line of the arrows and now we consider all
% the lines between the initial and the final line. This is done with |\@@_actualise_x_value:nn|. We have written a
-% command for this because it is also used with the option |i| (|\l_@@_pos_arrows_int| = 4).
+% command for this because it is also used with the option |i| (|\l_@@_pos_arrows_int| = 5).
% \begin{macrocode}
\@@_actualise_x_value:nn \l_@@_initial_int \l_@@_final_int
% \end{macrocode}
@@ -2045,7 +2541,7 @@ version 2005/12/01 or later.
% The following code is necessary because we will have to expand an argument exactly 3 times.
% \begin{macrocode}
\cs_generate_variant:Nn \keys_set:nn {no}
-\cs_new_protected:Nn \keys_set_WithArrows: {\keys_set:no {WithArrows}}
+\cs_new_protected:Nn \@@_keys_set: {\keys_set:no {WithArrows/General}}
% \end{macrocode}
%
%
@@ -2077,10 +2573,10 @@ version 2005/12/01 or later.
% of a property list are token lists.
%
% \begin{macrocode}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop}
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop}
{initial} \l_tmpa_tl
\int_set:Nn \l_@@_initial_int {\l_tmpa_tl}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop}
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop}
{final} \l_tmpa_tl
\int_set:Nn \l_@@_final_int {\l_tmpa_tl}
% \end{macrocode}
@@ -2088,14 +2584,22 @@ version 2005/12/01 or later.
% \bigskip
% If the arrow ends after the last line of the environment, we raise an error.
% \begin{macrocode}
- \int_compare:nNnT \l_@@_final_int > \g_@@_line_int
- {\msg_fatal:nn {witharrows} {Too~few~lines~for~an~arrow}}
+ \int_compare:nNnTF \l_@@_final_int > \g_@@_line_int
+ {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
+ {\@@_draw_arrows_i:}
+ \int_incr:N \l_@@_arrow_int
+ }
+ \group_end:
+ }
% \end{macrocode}
%
% \bigskip
-% We prepare the process of the options of the current arrow.
+% The macro |\@@_draw_arrows_i:| is only for the lisibility of the code. This macro will draw the current arrow
+% if the arrow is not impossible (that is to say if the Tikz node exists). The first |\group_begin:| is for the
+% options of the arrow.
% \begin{macrocode}
- \group_begin:
+\cs_new:Nn \@@_draw_arrows_i:
+ {\group_begin:
\int_set:Nn \l_@@_previous_pos_arrows_int {-1}
\int_set:Nn \l_@@_level_int 3
% \end{macrocode}
@@ -2105,9 +2609,10 @@ version 2005/12/01 or later.
% three times. An x-expansion is not possible because there can be tokens like |\bfseries| in the option |font| of
% the option |tikz|. This expansion is a bit tricky.
% \begin{macrocode}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str
_\int_use:N\l_@@_arrow_int _prop} {options} \l_tmpa_tl
- \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl}
+ \exp_args:NNo \exp_args:No
+ \@@_keys_set: {\l_tmpa_tl,tikz={xshift = \l_@@_xoffset_dim}}
% \end{macrocode}
%
%
@@ -2124,12 +2629,27 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% In case of option |i| (|\l_@@_pos_arrows_int| = 4), we have to compute the $x$-value of the arrow (which is
+% \begin{center}
+% \begin{tabular}{l}
+% \setlength{\extrarowheight}{2pt}
+% \begin{tabular}{|l|c|c|c|c|c|c|c|c|}
+% \hline
+% option & |rr| & |ll| & |rl| & |lr| & |v| & |i| & |group| & |groups| \\
+% \hline
+% |\l_@@_pos_arrows_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
+% \hline
+% \end{tabular} \\
+% \quad \small The option |v| can be used only in |\Arrow| in |CodeAfter| (see below).
+% \end{tabular}
+% \end{center}
+%
+% \bigskip
+% In case of option |i| (|\l_@@_pos_arrows_int| = 5), we have to compute the $x$-value of the arrow (which is
% vertical). The computed $x$-value is stored in |\g_@@_x_dim| (the same variable used when the option |group| or
% the option |groups| is used). This variable is global for technical reasons: we have to do assignments in a Tikz
% node.
% \begin{macrocode}
- \int_compare:nNnT \l_@@_pos_arrows_int = 4
+ \int_compare:nNnT \l_@@_pos_arrows_int = 5
{
% \end{macrocode}
%
@@ -2137,96 +2657,106 @@ version 2005/12/01 or later.
% First, we calculate the initial value for |\g_@@_x_dim|. We use a Tikz command, but, in fact, nothing is drawn.
% We use this Tikz command only to read the abscissa of a Tikz node.
% \begin{macrocode}
- \tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int-l)
+ \tikz [@@_standard]
+ \path let \p1 = (\int_use:N\l_@@_initial_int-l)
in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ;
% \end{macrocode}
% A global assignment is necessary because of Tikz.
%
-% Then, we will loop to determine the maximal length of all the lines between the lines |\l_@@_initial_int| and
+% Then, we will loop to determine the maximal length of the lines between the lines |\l_@@_initial_int| and
% |\l_@@_final_int|... but we have written a command dedicated to this work because it will also be used in
% |\@@_draw_arrows:|.
% \begin{macrocode}
\@@_actualise_x_value:nn \l_@@_initial_int \l_@@_final_int
- }
+ }
% \end{macrocode}
%
% \bigskip
% |\l_@@_initial_tl| contains the name of the Tikz node from which the arrow starts (in normal cases...
-% because with the option |i|, |group| and |groups|, the point will perhaps have an other $x$-value --- but always the
-% same |y|-value). Idem for |\l_@@_final_tl|.
+% because with the option |i|, |group| and |groups|, the point will perhaps have another $x$-value --- but always the
+% same $y$-value). Idem for |\l_@@_final_tl|.
% \begin{macrocode}
\tl_set:Nx \l_@@_initial_tl
- {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int-
- \bool_if:NTF\l_@@_initial_r_bool rl .south}
+ {\int_use:N\l_@@_initial_int-\bool_if:NTF\l_@@_initial_r_bool rl .south}
\tl_set:Nx \l_@@_final_tl
- {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_final_int-
- \bool_if:NTF\l_@@_final_r_bool rl .north}
+ {\int_use:N\l_@@_final_int-\bool_if:NTF\l_@@_final_r_bool rl .north}
% \end{macrocode}
-% We use ``|. north|'' because we want a small gap between two consecutive arrows (and the Tikz nodes created have
-% the shape of small vertical segments: use option |shownodes| to visualize the nodes).
+% We use ``|.south|'' and ``|.north|'' because we want a small gap between two consecutive arrows (and the Tikz
+% nodes created have the shape of small vertical segments: use option |shownodes| to visualize the nodes).
%
% \bigskip
-% We can now draw the arrow in a |{tikzpicture}|:
+% The label of the arrow will is stored in |\l_tmpa_tl|.
% \begin{macrocode}
- \begin{tikzpicture}[remember~picture,
- overlay,
- align=left,
- auto=left,
- font = {\small\itshape},
- TipsOfWithArrows,
- ->,
- looseness=1,
- bend~left=45]
+ \prop_get:cnN {g_@@_arrow_\l_@@_prefix_str _\int_use:N\l_@@_arrow_int _prop}
+ {label}
+ \l_tmpa_tl
% \end{macrocode}
%
-% Of course, the arrow is drawn with the command |\draw| of Tikz. The syntax for this command is:
-%
-% \qquad |\draw| $(x_1,y_1)$ |to node| (\textsl{name}) |{|\textsl{contents}|}| $(x_2,y_2)$
+% \bigskip
+% We have to compute the coordinates of the extremities of the arrow. We use the library |calc| to define two
+% points |\p1| and |\p2| and we retrieve the coordinates in |\g_tmpa_tl| and |\g_tmpb_tl|. This extraction of the
+% coordinates is necessary because we must give coordinates and not nodes (even anchored) to |\@@_draw_arrow:nnn|
+% to have the |xshift| correct.
+% \begin{macrocode}
+ \int_compare:nNnTF \l_@@_pos_arrows_int < 5
+ {\tikz [@@_standard]
+ \path let \p1 = (\l_@@_initial_tl),
+ \p2 = (\l_@@_final_tl)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1}
+ \tl_gset:Nx \g_tmpb_tl {\p2}} ; }
+% \end{macrocode}
%
-% The surprising aspect of this syntax is the position of \textsl{contents} which is the label of the arrow.
-%
-% |\p1| and |\p2| are the two ends of the arrow (in fact, if the option |i| or the option |group| is used, it's not
-% exactly the two ends of the arrow because, in this case, the abscissa used is the value previously calculated in
-% |g_@@_x_dim|).
-%
-% The ability to define |\p1| and |\p2| is given by the library |calc| of Tikz. When |\p1| and |\p2| are defined,
-% the $x$-value and $y$-value of these two points can be read in |\x1|, |\x2|, |\y1| and |\y2|. This is the way to
-% have the coordinates of a node defined in Tikz.
-% \begin{macrocode}
- \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop}
- {label} \l_tmpa_tl
- \draw \exp_after:wN [\l_@@_options_tikz_tl]
- let \p1 = (\tl_use:N \l_@@_initial_tl),
- \p2 = (\tl_use:N \l_@@_final_tl) in
- (\int_compare:nNnTF \l_@@_pos_arrows_int > 3
- {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y1}
- {\x1 + \dim_use:N \l_@@_xoffset_dim, \y1} )
-% \end{macrocode}
-% There are two ways to give the content of the node: the classical way, with curly braces, and the option ``node
-% contents''. However, both are not strictly equivalent: when |\usetikzlibrary{babel}| is used, the tokens of the
-% contents are rescanned in the first way but not in the second. We don't want the tokens to be rescanned (because
-% this would lead to an error due of the characters |_| and |:| of the \pkg{expl3} syntax) and that's why we use
-% the second method. \footnote{cf.:
-% |tex.stackexchange.com/questions/298177/how-to-get-around-a-problem-with-usetikzlibrarybabel|}
-% \begin{macrocode}
- to node [node~contents = {\tl_use:N \l_tmpa_tl}] {}
- (\int_compare:nNnTF \l_@@_pos_arrows_int > 3
- {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y2}
- {\x2 + \dim_use:N \l_@@_xoffset_dim, \y2} ) ;
- \end{tikzpicture}
+% If we use option |i| or |group| or |groups|, we use the abscissa specially computed in |\g_@@_x_dim|.
+% \begin{macrocode}
+ {\tikz [@@_standard]
+ \path let \p1 = (\l_@@_initial_tl),
+ \p2 = (\l_@@_final_tl)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g_@@_x_dim , \y1}
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g_@@_x_dim , \y2}} ; }
+% \end{macrocode}
+%
+% \bigskip
+% 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|.
+% \begin{macrocode}
+ \@@_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl}
% \end{macrocode}
%
% \smallskip
% We close the TeX group opened for the options given to |\Arrow[...]| (local level of the options).
% \begin{macrocode}
- \group_end:
- \int_incr:N \l_@@_arrow_int
- }
- \group_end:
- }
+ \group_end: }
% \end{macrocode}
%
+%
+%
+%
+%
+%
+%
+% \bigskip
+% The function |@@_tmpa:nnn| will draw the arrow. It's merely an environment |{tikzpicture}|. However, the Tikz
+% instruction in this environment must be inserted from |\l_@@_tikz_code_tl| with the markers |#1|, |#2| and |#3|.
+% That's why we create a function |\@@_def_function_tmpa:n| which will create the function |\@@_tmpa:nnn|.
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_def_function_tmpa:n
+ {\cs_set:Nn \@@_tmpa:nnn
+ {\begin{tikzpicture}[@@_standard,every~path/.style = {WithArrows/arrow}]
+ #1
+ \end{tikzpicture}}}
+% \end{macrocode}
+%
+% \medskip
+% When we draw the arrow (with |\@@_draw_arrow:nnn|), we create first the function |\@@_tmpa:nnn| and, then, we use
+% the function |\@@_tmpa:nnn| :
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_draw_arrow:nnn
+ {\exp_args:No \@@_def_function_tmpa:n \l_@@_tikz_code_tl
+ \@@_tmpa:nnn {#1} {#2} {#3} }
+% \end{macrocode}
+%
+%
% \bigskip
% The command |\@@_actualise_x_value:nn| will analyze the lines between |#1| and |#2| in order to modify
% |\g_@@_x_dim| in consequence. More precisely, |\g_@@_x_dim| is increased if a line longer than the current value
@@ -2234,25 +2764,10 @@ version 2005/12/01 or later.
% |groups|) and in |\@@_draw_arrows:nn| (for option |i|).
% \begin{macrocode}
\cs_new_protected:Nn \@@_actualise_x_value:nn
- {\group_begin:
- \int_set:Nn \l_@@_initial_int {#1}
- \int_set:Nn \l_@@_final_int {#2}
- \int_compare:nNnT \l_@@_final_int > \g_@@_line_int
- {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
-% \end{macrocode}
-%
-% We begin a loop with |\l_tmpa_int| as index. In this loop, we use a Tikz command, but, in fact, nothing is drawn.
-% We use this Tikz command only to read the abscissa of a Tikz node.
-% \begin{macrocode}
- \int_set:Nn \l_tmpa_int \l_@@_initial_int
- \int_until_do:nNnn \l_tmpa_int > \l_@@_final_int
- {\tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_tmpa_int-l)
- in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\dim_max:nn \g_@@_x_dim {\x1}}} ;
- \int_incr:N \l_tmpa_int
- }
- \group_end:
- }
+ {\int_step_inline:nnnn {#1} \c_one {#2}
+ {\tikz [@@_standard]
+ \path let \p1 = (##1-l)
+ in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\dim_max:nn \g_@@_x_dim {\x1}}}; }}
% \end{macrocode}
%
%
@@ -2261,10 +2776,149 @@ version 2005/12/01 or later.
% final user. It gives the number of the last environment |{WithArrows}| at level~$0$ (to the sens of the nested
% environments). This macro is fully expandable and, thus, can be used directly in the name of a Tikz node.
% \begin{macrocode}
-\NewDocumentCommand \WithArrowsLastEnv {}
- {\int_use:N \g_@@_last_env_int}
+\cs_new:Npn \WithArrowsLastEnv {\int_use:N \g_@@_last_env_int}
+% \end{macrocode}
+%
+% \bigskip
+% \subsection{The command Arrow in CodeAfter}
+%
+% The option |CodeAfter| is an option of the environment |{WithArrows}| (this option is only available at the
+% environment level). In the option |CodeAfter|, 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/CodeAfter|.
+%
+% \begin{macrocode}
+\keys_define:nn {WithArrows/CodeAfter}
+ {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}} ,
+ tikz .value_required:n = true,
+ rr .value_forbidden:n = true,
+ rr .code:n = \@@_analyze_option_position:n 0 ,
+ ll .value_forbidden:n = true,
+ ll .code:n = \@@_analyze_option_position:n 1 ,
+ rl .value_forbidden:n = true,
+ rl .code:n = \@@_analyze_option_position:n 2 ,
+ lr .value_forbidden:n = true,
+ lr .code:n = \@@_analyze_option_position:n 3 ,
+ v .value_forbidden:n = true,
+ v .code:n = \@@_analyze_option_position:n 4 ,
+ TikzCode .tl_set:N = \l_@@_tikz_code_tl,
+ TikzCode .value_required:n = true,
+ xoffset .dim_set:N = \l_@@_xoffset_dim,
+ xoffset .value_required:n = true}
% \end{macrocode}
+%
%
+% \bigskip
+% \begin{macrocode}
+\NewDocumentCommand \@@_Arrow_code_after {O{} mmm O{}}
+ {\int_set:Nn \l_@@_pos_arrows_int 1
+ \int_set:Nn \l_@@_previous_pos_arrows_int {-1}
+ \group_begin:
+% \end{macrocode}
+% Even if |\Arrow| in |CodeAfter| has its own set of options (|WithArrows/CodeAfter|), we set the level of the
+% options to~$3$ (as with the classical command |\Arrow|) because of the error messages.
+% \begin{macrocode}
+ \int_set:Nn \l_@@_level_int 3
+ \keys_set:nn {WithArrows/CodeAfter}
+ {#1,#5,tikz={xshift = \l_@@_xoffset_dim}}
+ \bool_set_false:N \l_@@_initial_r_bool
+ \bool_set_false:N \l_@@_final_r_bool
+ \int_case:nn \l_@@_pos_arrows_int
+ {0 {\bool_set_true:N \l_@@_initial_r_bool
+ \bool_set_true:N \l_@@_final_r_bool}
+ 2 {\bool_set_true:N \l_@@_initial_r_bool}
+ 3 {\bool_set_true:N \l_@@_final_r_bool}}
+% \end{macrocode}
+% We test wether the two Tikz nodes |(#2-l)| and |(#3-l)| really exist. If not, the arrow won't be drawn.
+% \begin{macrocode}
+ \cs_if_free:cTF {pgf@sh@ns@wa-\l_@@_prefix_str-#2-l}
+ {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#2}}
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l_@@_prefix_str-#3-l}
+ {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#3}}
+ {\int_compare:nNnTF \l_@@_pos_arrows_int = 4
+ {\tikz [@@_standard]
+ \path let \p1 = (#2-l.south),
+ \p2 = (#3-l.north),
+ \p3 = (\dim_max:nn {\x1} {\x2} , \y1),
+ \p4 = (\dim_max:nn {\x1} {\x2} , \y2)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p3}
+ \tl_gset:Nx \g_tmpb_tl {\p4}} ; }
+ {\tikz [@@_standard]
+ \path let \p1 = (#2-\bool_if:NTF\l_@@_initial_r_bool rl .south),
+ \p2 = (#3-\bool_if:NTF\l_@@_final_r_bool rl .north)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1}
+ \tl_gset:Nx \g_tmpb_tl {\p2}} ; }
+ \@@_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }}
+ \group_end:
+ }
+% \end{macrocode}
+%
+%
+% \bigskip
+% \subsection{MultiArrow}
+% The command |\@@_MultiArrow:nn| will be linked to |\MultiArrow| when the |CodeAfter| is executed.
+%
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_MultiArrow:nn
+ {
+% \end{macrocode}
+% The user of the command |\MultiArrow| (in |CodeAfter|) 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 order to exit the
+% |\foreach| and that's why we construct the list in |\g_tmpa_clist|.
+% \begin{macrocode}
+ \foreach \x in {#1} {\cs_if_free:cTF {pgf@sh@ns@wa-\l_@@_prefix_str-\x-l}
+ {\msg_error:nnx {witharrows}
+ {Wrong~line~specification~in~MultiArrow} {\x}}
+ {\clist_gput_right:Nx \g_tmpa_clist {\x}}}
+% \end{macrocode}
+% We sort the list |\g_tmpa_clist| because we want to extract the minimum and the maximum.
+% \begin{macrocode}
+ \int_compare:nNnTF {\clist_count:N \g_tmpa_clist} < 2
+ {\msg_error:nn {witharrows} {Too~small~specification~for~MultiArrow}}
+ {\clist_sort:Nn \g_tmpa_clist
+ {\int_compare:nNnTF {##1} > {##2}
+ {\sort_return_swapped:}
+ {\sort_return_same:}}
+% \end{macrocode}
+% We extract the minimum in |\l_tmpa_tl| (it must be a integer but we store it in a token list of \pkg{expl3}).
+% \begin{macrocode}
+ \clist_pop:NN \g_tmpa_clist \l_tmpa_tl
+% \end{macrocode}
+%
+% We extract the maximum in |\l_tmpb_tl|. The remaining list (in |\g_tmpa_clist| will be sorted in decreasing order
+% but never mind...).
+% \begin{macrocode}
+ \clist_reverse:N \g_tmpa_clist
+ \clist_pop:NN \g_tmpa_clist \l_tmpb_tl
+% \end{macrocode}
+%
+% We draw the teeth of the rak (except the first one and the last one) with the auxiliary function
+% |\@@_MultiArrow_i:n|. This auxiliary fonction is necessary to expand the specification of the list in the
+% |\foreach| loop. The first and the last teeth of the rak can't be drawn the same way as the others (think, for
+% example, to the case of the option ``rounded corners'' is used).
+% \begin{macrocode}
+ \exp_args:Nx \@@_MultiArrow_i:n {\g_tmpa_clist}
+% \end{macrocode}
+%
+% Now, we draw the rest of the structure.
+% \begin{macrocode}
+ \begin{tikzpicture}[@@_standard,every~path/.style={WithArrows/arrow}]
+ \draw [<->] ($(\l_tmpa_tl-r.south)+(\l_@@_xoffset_dim,0)$)
+ -- ++(5mm,0)
+ -- node {#2} ($(\l_tmpb_tl-r.south)+(\l_@@_xoffset_dim+5mm,0)$)
+ -- ($(\l_tmpb_tl-r.south)+(\l_@@_xoffset_dim,0)$) ;
+ \end{tikzpicture} } }
+
+\cs_new_protected:Nn \@@_MultiArrow_i:n
+ {\begin{tikzpicture}[@@_standard,every~path/.style={WithArrows/arrow}]
+ \foreach \k in {#1}
+ {\draw[<-] ($(\k-r.south)+(\l_@@_xoffset_dim,0)$) -- ++(5mm,0) ;} ;
+ \end{tikzpicture}}
+% \end{macrocode}
+%
+%
+% \bigskip
% \subsection{The error messages of the package}
% \begin{macrocode}
\msg_new:nnn {witharrows}
@@ -2288,7 +2942,8 @@ version 2005/12/01 or later.
\msg_new:nnn {witharrows}
{Too~few~lines~for~an~arrow}
{An~arrow~specified~in~line~\int_use:N \l_@@_initial_int\ can't~be~drawn~
- because~it~arrives~after~the~last~line~of~the~environment.}
+ because~it~arrives~after~the~last~line~of~the~environment.~If~you~go~on,~
+ this~arrow~will~be~ignored.}
% \end{macrocode}
%
% \begin{macrocode}
@@ -2310,7 +2965,8 @@ version 2005/12/01 or later.
3 {lr}
4 {i}
5 {group}
- 6 {groups}}"~
+ 6 {groups}
+ 7 {v}}"~
previously~set~in~the~same~
\int_case:nn\l_@@_level_int
{1 {command~\token_to_str:N\WithArrowsOptions}
@@ -2323,8 +2979,9 @@ version 2005/12/01 or later.
\msg_new:nnnn {witharrows}
{All~lines~must~have~an~ampersand}
{All~lines~of~an~environment~\{WithArrows\}~must~have~an~second~column~
- (because~the~nodes~are~created~in~the~second~column).~You~can~go~on~but~maybe~
- you~will~have~an~pgf~error~for~an~undefined~shape.}
+ (because~the~nodes~are~created~in~the~second~column).~
+ You~can~go~on~but~maybe~you~will~have~an~pgf~error~for~
+ an~undefined~shape.}
{The~ampersand~can~be~implicit~
(e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).}
% \end{macrocode}
@@ -2352,8 +3009,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\msg_new:nnn {witharrows}
{Option~unknown}
- {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~meaningless~in~the~context.~
- If~you~go~on,~it~will~be~ignored.}
+ {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~
+ meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.}
% \end{macrocode}
%
% \begin{macrocode}
@@ -2371,9 +3028,30 @@ version 2005/12/01 or later.
However~you~can~go~on~for~this~time.}
% \end{macrocode}
%
+% \begin{macrocode}
+\msg_new:nnn {witharrows}
+ {Wrong~line~specification~in~Arrow}
+ {The~specification~of~line~"#1"~you~use~in~\token_to_str:N\Arrow\
+ ~doesn't~exist.\\
+ If~you~go~on,~the~arrow~will~be~ignored.}
+% \end{macrocode}
%
+% \begin{macrocode}
+\msg_new:nnn {witharrows}
+ {Wrong~line~specification~in~MultiArrow}
+ {The~specification~of~line~"#1"~doesn't~exist.\\
+ If~you~go~on,~it~will~be~ignored~for~\token_to_str:N \MultiArrow.}
+% \end{macrocode}
%
%
+% \begin{macrocode}
+\msg_new:nnn {witharrows}
+ {Too~small~specification~for~MultiArrow}
+ {The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\
+ is~too~small:~we~need~at~least~two~lines.~If~you~go~on,~the~
+ command~\token_to_str:N\MultiArrow\ ~will~be~ignored.}
+% \end{macrocode}
+%
% \section{History}
%
% \subsection{Changes between versions 1.0 and 1.1}
@@ -2408,8 +3086,15 @@ version 2005/12/01 or later.
% The package \pkg{footnote} is no longer loaded by default. Instead, two options |footnote| and |footnotehyper| have
% been added. In particular, \pkg{witharrows} becomes compatible with \cls{beamer}.
%
+% \subsection{Changes between versions 1.4 and 1.5}
+%
+% The Tikz code used to draw the arrows can be changed with the option |TikzCode|.
%
+% Two new options |CodeBefore| and |CodeAfter| have been added at the environment level.
%
+% A special version of |\Arrow| is available in |CodeAfter| in order to draw arrows in nested environments.
+%
+% A command |\MultiArrow| is available in |CodeAfter| to draw arrows of other shapes.
% \endinput
%
% Local Variables:
diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty
index 513e618da95..296989cac2a 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.4}
-\def\myfiledate{2018/01/20}
+\def\myfileversion{1.5}
+\def\myfiledate{2018/02/12}
\RequirePackage{tikz}
\usetikzlibrary{calc,arrows.meta,bending}
\RequirePackage{l3keys2e}
@@ -54,34 +54,44 @@
If~you~want,~you~can~use~the~option~"footnote"~and~the~footnotes~
within~the~environments~{WithArrows}~will~be~extracted~with~the~tools~
of~the~package~footnote.}
-\cs_new_protected:Nn \__wa_test_beamer:n
- {\@ifclassloaded {beamer}
+\bool_if:NT \g__wa_footnote_bool
+ {\@ifclassloaded {beamer}
{\msg_fatal:nn {witharrows}
{Option~incompatible~with~Beamer}}
- {} }
-\bool_if:NT \g__wa_footnote_bool
- {\__wa_test_beamer:n {footnote}
+ {}
\@ifpackageloaded{footnotehyper}
{\msg_fatal:nn {witharrows}
{footnote~with~footnotehyper~package}}
{}
\usepackage{footnote}}
\bool_if:NT \g__wa_footnotehyper_bool
- {\__wa_test_beamer:n {footnotehyper}
+ {\@ifclassloaded {beamer}
+ {\msg_fatal:nn {witharrows}
+ {Option~incompatible~with~Beamer}}
+ {}
\@ifpackageloaded{footnote}
{\msg_fatal:nn {witharrows}
{footnotehyper~with~footnote~package}}
{}
\usepackage{footnotehyper}
\bool_gset_true:N \g__wa_footnote_bool}
-\tikzset{__wa_node_style/.style={
+\tikzset{__wa_node_style/.style= {
above = \l__wa_ystart_dim,
inner~sep = 0 pt,
minimum~width = 0pt,
minimum~height = \l__wa_ygap_dim,
red,
- \bool_if:NT \l__wa_shownodes_bool {draw}}}
-\tikzset{TipsOfWithArrows/.style= { > = {Straight~Barb[scale=1.2,bend]}} }
+ \bool_if:NT \l__wa_shownodes_bool {draw} }}
+\tikzset{__wa_standard/.style= { remember~picture,
+ overlay,
+ name~prefix = wa-\l__wa_prefix_str- }}
+\tikzset{WithArrows/arrow/tips/.style = { > = {Straight~Barb[scale=1.2,bend]} }}
+\tikzset{WithArrows/arrow/.style = { align = left,
+ auto = left,
+ font = {\small\itshape},
+ WithArrows/arrow/tips,
+ bend~left = 45,
+ -> }}
\cs_if_free:NT \spread@equation
{\cs_set:Npn \spread@equation{\openup\jot
\cs_set:Npn \spread@equation {}}}
@@ -92,18 +102,10 @@
\skip_new:N \l__wa_interline_skip
\bool_new:N \l__wa_MoreColumns_bool
\int_new:N \l__wa_pos_env_int
-\int_new:N \l__wa_pos_arrows_int
-\int_new:N \l__wa_previous_pos_arrows_int
-\dim_new:N \l__wa_ygap_dim
-\dim_set:Nn \l__wa_ygap_dim {0.4 ex}
-\dim_new:N \l__wa_ystart_dim
-\dim_set:Nn \l__wa_ystart_dim {0.4 ex}
\dim_new:N \l__wa_xoffset_dim
\dim_set:Nn \l__wa_xoffset_dim {3mm}
-\bool_new:N \l__wa_shownodes_bool
-\bool_new:N \l__wa_shownodenames_bool
-\bool_new:N \l__wa_displaystyle_bool
-\tl_clear_new:N \l__wa_options_tikz_tl
+\int_new:N \l__wa_pos_arrows_int
+\int_new:N \l__wa_previous_pos_arrows_int
\dim_new:N \g__wa_x_dim
\seq_new:N \g__wa_arrow_int_seq
\int_new:N \g__wa_arrow_int
@@ -113,71 +115,90 @@
\int_new:N \g__wa_line_bis_int
\int_set:Nn \l__wa_level_int 1
\keys_define:nn {WithArrows/GlobalOrEnv}
- { t .code:n = {\int_set:Nn \l__wa_pos_env_int 0},
+ { t .code:n = \int_set:Nn \l__wa_pos_env_int 0,
t .value_forbidden:n = true,
- c .code:n = {\int_set:Nn \l__wa_pos_env_int 1},
+ c .code:n = \int_set:Nn \l__wa_pos_env_int 1,
c .value_forbidden:n = true,
- b .code:n = {\int_set:Nn \l__wa_pos_env_int 2},
+ b .code:n = \int_set:Nn \l__wa_pos_env_int 2,
b .value_forbidden:n = true,
ygap .dim_set:N = \l__wa_ygap_dim,
ygap .value_required:n = true,
+ ygap .initial:n = 0.4 ex,
ystart .dim_set:N = \l__wa_ystart_dim,
ystart .value_required:n = true,
+ ystart .initial:n = 0.4 ex,
MoreColumns .bool_set:N = \l__wa_MoreColumns_bool,
MoreColumns .value_forbidden:n = true,
CommandName .tl_set:N = \l__wa_CommandName_tl,
- CommandName .initial:n = {Arrow},
+ CommandName .initial:n = Arrow ,
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,
displaystyle .bool_set:N = \l__wa_displaystyle_bool,
+ displaystyle .initial:n = false,
shownodes .bool_set:N = \l__wa_shownodes_bool,
+ shownodes .initial:n = false,
shownodenames .bool_set:N = \l__wa_shownodenames_bool,
+ shownodenames .initial:n = false,
group .code:n = {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1}
{\msg_error:nn {witharrows}
{Two~options~are~incompatible}}
- \int_set:Nn \l__wa_previous_pos_arrows_int 5
- \int_set:Nn \l__wa_pos_arrows_int 5},
+ \int_set:Nn \l__wa_previous_pos_arrows_int 6
+ \int_set:Nn \l__wa_pos_arrows_int 6} ,
group .value_forbidden:n = true,
groups .code:n = {\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1}
{\msg_error:nn {witharrows}
{Two~options~are~incompatible}}
- \int_set:Nn \l__wa_previous_pos_arrows_int 6
- \int_set:Nn \l__wa_pos_arrows_int 6},
- groups .value_forbidden:n = true}
-\keys_define:nn {WithArrows}
- {tikz .code:n = {\tl_put_right:Nn \l__wa_options_tikz_tl {,#1}},
+ \int_set:Nn \l__wa_previous_pos_arrows_int 7
+ \int_set:Nn \l__wa_pos_arrows_int 7} ,
+ groups .value_forbidden:n = true,
+ CodeBefore .code:n = {\int_compare:nNnTF \l__wa_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_put_right:Nn \l__wa_code_before_tl {#1}}} ,
+ CodeAfter .code:n = {\int_compare:nNnTF \l__wa_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_put_right:Nn \l__wa_code_after_tl {#1}}} ,
+ unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
+ }
+\keys_define:nn {WithArrows/General}
+ {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}},
+ tikz .initial:n = {},
tikz .value_required:n = true,
rr .value_forbidden:n = true,
- rr .code:n = {\__wa_analyze_option_position:n 0},
+ rr .code:n = \__wa_analyze_option_position:n 0 ,
ll .value_forbidden:n = true,
- ll .code:n = {\__wa_analyze_option_position:n 1},
+ ll .code:n = \__wa_analyze_option_position:n 1 ,
rl .value_forbidden:n = true,
- rl .code:n = {\__wa_analyze_option_position:n 2},
+ rl .code:n = \__wa_analyze_option_position:n 2 ,
lr .value_forbidden:n = true,
- lr .code:n = {\__wa_analyze_option_position:n 3},
+ lr .code:n = \__wa_analyze_option_position:n 3 ,
i .value_forbidden:n = true,
- i .code:n = {\__wa_analyze_option_position:n 4},
+ i .code:n = \__wa_analyze_option_position:n 5 ,
xoffset .code:n = {\bool_if:nTF {\int_compare_p:nNn \l__wa_level_int = 3 &&
- \int_compare_p:nNn \l__wa_pos_arrows_int > 4}
+ \int_compare_p:nNn \l__wa_pos_arrows_int > 5}
{\msg_error:nn {witharrows}
{Option~incompatible~with~"group(s)"}}
- {\dim_set:Nn \l__wa_xoffset_dim {#1}}},
+ {\dim_set:Nn \l__wa_xoffset_dim {#1}}} ,
xoffset .value_required:n = true,
jot .code:n = {\int_compare:nNnTF \l__wa_level_int = 2
{\dim_set:Nn \jot {#1}}
- {\msg_error:nn {witharrows} {Option~will~be~ignored} }},
+ {\msg_error:nn {witharrows}
+ {Option~will~be~ignored}}} ,
jot .value_required:n = true,
interline .code:n = {\int_compare:nNnTF \l__wa_level_int = 2
{\skip_set:Nn \l__wa_interline_skip {#1}}
- {\msg_error:nn {witharrows} {Option~will~be~ignored}}},
+ {\msg_error:nn {witharrows}
+ {Option~will~be~ignored}}} ,
interline .value_required:n = true,
- jump .code:n = {\msg_error:nn {witharrows} {Option~will~be~ignored}},
- unknown .code:n = {\msg_error:nn {witharrows} {Option~unknown}}
+ jump .code:n = \msg_error:nn {witharrows} {Option~will~be~ignored} ,
+ unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
}
\keys_define:nn {WithArrows/jump}
{jump .code:n = {\int_set:Nn \l__wa_jump_int {#1}
\int_compare:nNnF \l__wa_jump_int > 0
{\msg_error:nn {witharrows}
- {The~option~"jump"~must~be~non~negative}}},
+ {The~option~"jump"~must~be~non~negative}}} ,
jump .value_required:n = true}
\cs_new_protected:Nn \__wa_analyze_option_position:n
{\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1}
@@ -185,13 +206,13 @@
{Two~options~are~incompatible}}
\int_set:Nn \l__wa_previous_pos_arrows_int {#1}
\bool_if:nTF { \int_compare_p:nNn \l__wa_level_int = 3 &&
- \int_compare_p:nNn \l__wa_pos_arrows_int > 4}
+ \int_compare_p:nNn \l__wa_pos_arrows_int > 5}
{\msg_error:nn {witharrows}
{Option~incompatible~with~"group(s)"}}
{\int_set:Nn \l__wa_pos_arrows_int {#1}}}
\NewDocumentCommand \WithArrowsOptions {m}
{\int_set:Nn \l__wa_previous_pos_arrows_int {-1}
- \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl
+ \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl
\keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl}
\NewDocumentCommand \__wa_Arrow {O{} m O{}}
{
@@ -205,9 +226,9 @@
\prop_put:NnV \l_tmpa_prop {options} \l_tmpa_tl
\prop_put:Nnn \l_tmpa_prop {label} {#2}
\prop_gclear_new:c
- {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\g__wa_arrow_int _prop}
+ {g__wa_arrow_\l__wa_prefix_str _\int_use:N\g__wa_arrow_int _prop}
\prop_gset_eq:cN
- {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\g__wa_arrow_int _prop}
+ {g__wa_arrow_\l__wa_prefix_str _\int_use:N\g__wa_arrow_int _prop}
\l_tmpa_prop
}
\cs_new_protected:Nn \__wa_Arrow_first_column:
@@ -224,22 +245,26 @@
\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
- \tl_clear_new:N \l__wa_prefix_tl
- \tl_set:Nx \l__wa_prefix_tl {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}}
+ \str_clear_new:N \l__wa_prefix_str
+ \str_set:Nx \l__wa_prefix_str {\seq_use:Nnnn \l_tmpa_seq {-} {-} {-}}
\reverse_if:N \if_mode_math:
- \msg_error:nn {witharrows} {{WithArrows}~used~outside~math~mode}
- \fi
- \bool_if:NT \g__wa_footnote_bool {\begin{savenotes}}
+ \msg_error:nn {witharrows}
+ {{WithArrows}~used~outside~math~mode}
+ \fi:
\cs_set_eq:NN \\ \__wa_cr:
\mathsurround = \c_zero_dim
\int_zero_new:N \l__wa_initial_int
\int_zero_new:N \l__wa_final_int
\int_zero_new:N \l__wa_arrow_int
\skip_zero:N \l__wa_interline_skip
+ \tl_clear_new:N \l__wa_code_before_tl
+ \tl_clear_new:N \l__wa_code_after_tl
\int_set:Nn \l__wa_previous_pos_arrows_int {-1}
\int_set:Nn \l__wa_level_int 2
- \keys_set_known:nnN {WithArrows} {#1} \l_tmpa_tl
+ \keys_set_known:nnN {WithArrows/General} {#1} \l_tmpa_tl
\keys_set:nV {WithArrows/GlobalOrEnv} \l_tmpa_tl
+ \bool_if:NT \g__wa_footnote_bool {\begin{savenotes}}
+ \l__wa_code_before_tl
\cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow
\int_case:nn \l__wa_pos_env_int
{0 {\vtop}
@@ -255,15 +280,11 @@
&
\int_gincr:N \g__wa_line_bis_int
$\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$
- \tikz[remember~picture,overlay]
- \node[__wa_node_style]
- (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-l) {} ;
+ \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-l) {} ;
\hfil
- \tikz[remember~picture,overlay]
- \node[__wa_node_style]
- (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-r) {} ;
+ \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-r) {} ;
\bool_if:NT \l__wa_shownodenames_bool
- {\hbox_overlap_right:n {\small wa-\tl_use:N\l__wa_prefix_tl
+ {\hbox_overlap_right:n {\small wa-\l__wa_prefix_str
-\int_use:N\g__wa_line_int}}
&& \bool_if:NF \l__wa_MoreColumns_bool
{\msg_error:nn {witharrows} {Third~column~in~a~{WithArrows}~environment}}
@@ -275,14 +296,21 @@
\egroup
\int_compare:nNnT \g__wa_line_bis_int < \g__wa_line_int
{\msg_error:nn {witharrows} {All~lines~must~have~an~ampersand}}
- \int_compare:nNnT \g__wa_arrow_int > 0
- {\int_compare:nNnTF \l__wa_pos_arrows_int > 4
+ \int_compare:nNnT \g__wa_arrow_int > 0
+ {\int_compare:nNnTF \l__wa_pos_arrows_int > 5
\__wa_draw_arrows:
{\__wa_draw_arrows:nn 1 \g__wa_arrow_int}}
+ \group_begin:
+ \tikzset{every~picture/.style = __wa_standard}
+ \cs_set:Npn \NbLines {\int_use:N \g__wa_line_int}
+ \cs_set_eq:NN \MultiArrow \__wa_MultiArrow:nn
+ \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow_code_after
+ \l__wa_code_after_tl
+ \group_end:
\bool_if:NT \g__wa_footnote_bool {\end{savenotes}}
\seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl
\seq_gpop_right:NN \g__wa_position_in_the_tree_seq \l_tmpa_tl
- \seq_gput_right:Nx \g__wa_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl + 1}}
+ \seq_gput_right:Nx \g__wa_position_in_the_tree_seq {\int_eval:n {\l_tmpa_tl+1}}
\int_compare:nNnT {\seq_count:N \g__wa_position_in_the_tree_seq} = 1
{\int_gincr:N \g__wa_last_env_int}
\seq_gpop_right:NN \g__wa_arrow_int_seq {\l_tmpa_tl}
@@ -311,15 +339,16 @@
\int_set:Nn \l__wa_arrow_int 1
\int_until_do:nNnn \l__wa_arrow_int > \g__wa_arrow_int
{
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop}
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop}
{initial} \l_tmpa_tl
\int_set:Nn \l__wa_initial_int {\l_tmpa_tl}
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop}
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop}
{final} \l_tmpa_tl
\int_set:Nn \l__wa_final_int {\l_tmpa_tl}
- \bool_if:nT { \int_compare_p:nNn \l__wa_pos_arrows_int = 6
+ \bool_if:nT { \int_compare_p:nNn \l__wa_pos_arrows_int = 7
&& \int_compare_p:nNn \l__wa_arrow_int > 1
- && \int_compare_p:nNn \l__wa_initial_int > \l__wa_last_line_of_group_int}
+ && \int_compare_p:nNn
+ \l__wa_initial_int > \l__wa_last_line_of_group_int}
{\__wa_draw_arrows:nn \l__wa_first_arrow_of_group_int {\l__wa_arrow_int - 1}
\bool_set_true:N \l__wa_new_group_bool}
\bool_if:nTF \l__wa_new_group_bool
@@ -327,9 +356,9 @@
\int_set:Nn \l__wa_first_arrow_of_group_int \l__wa_arrow_int
\int_set:Nn \l__wa_first_line_of_group_int \l__wa_initial_int
\int_set:Nn \l__wa_last_line_of_group_int \l__wa_final_int
- \tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l)
- in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ;
+ \tikz [__wa_standard]
+ \path let \p1=(\int_use:N\l__wa_initial_int-l)
+ in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ;
}
{\int_set:Nn \l__wa_last_line_of_group_int
{\int_max:nn \l__wa_last_line_of_group_int \l__wa_final_int}}
@@ -340,7 +369,7 @@
\group_end:
}
\cs_generate_variant:Nn \keys_set:nn {no}
-\cs_new_protected:Nn \keys_set_WithArrows: {\keys_set:no {WithArrows}}
+\cs_new_protected:Nn \__wa_keys_set: {\keys_set:no {WithArrows/General}}
\cs_new_protected:Nn \__wa_draw_arrows:nn
{\group_begin:
\int_zero_new:N \l__wa_first_arrow_int
@@ -350,20 +379,27 @@
\int_set:Nn \l__wa_arrow_int \l__wa_first_arrow_int
\int_until_do:nNnn \l__wa_arrow_int > \l__wa_last_arrow_int
{
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop}
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop}
{initial} \l_tmpa_tl
\int_set:Nn \l__wa_initial_int {\l_tmpa_tl}
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop}
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop}
{final} \l_tmpa_tl
\int_set:Nn \l__wa_final_int {\l_tmpa_tl}
- \int_compare:nNnT \l__wa_final_int > \g__wa_line_int
- {\msg_fatal:nn {witharrows} {Too~few~lines~for~an~arrow}}
- \group_begin:
+ \int_compare:nNnTF \l__wa_final_int > \g__wa_line_int
+ {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
+ {\__wa_draw_arrows_i:}
+ \int_incr:N \l__wa_arrow_int
+ }
+ \group_end:
+ }
+\cs_new:Nn \__wa_draw_arrows_i:
+ {\group_begin:
\int_set:Nn \l__wa_previous_pos_arrows_int {-1}
\int_set:Nn \l__wa_level_int 3
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str
_\int_use:N\l__wa_arrow_int _prop} {options} \l_tmpa_tl
- \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl}
+ \exp_args:NNo \exp_args:No
+ \__wa_keys_set: {\l_tmpa_tl,tikz={xshift = \l__wa_xoffset_dim}}
\bool_set_false:N \l__wa_initial_r_bool
\bool_set_false:N \l__wa_final_r_bool
\int_case:nn \l__wa_pos_arrows_int
@@ -371,63 +407,126 @@
\bool_set_true:N \l__wa_final_r_bool}
2 {\bool_set_true:N \l__wa_initial_r_bool}
3 {\bool_set_true:N \l__wa_final_r_bool}}
- \int_compare:nNnT \l__wa_pos_arrows_int = 4
+ \int_compare:nNnT \l__wa_pos_arrows_int = 5
{
- \tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l)
+ \tikz [__wa_standard]
+ \path let \p1 = (\int_use:N\l__wa_initial_int-l)
in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ;
\__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int
- }
+ }
\tl_set:Nx \l__wa_initial_tl
- {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-
- \bool_if:NTF\l__wa_initial_r_bool rl .south}
+ {\int_use:N\l__wa_initial_int-\bool_if:NTF\l__wa_initial_r_bool rl .south}
\tl_set:Nx \l__wa_final_tl
- {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_final_int-
- \bool_if:NTF\l__wa_final_r_bool rl .north}
- \begin{tikzpicture}[remember~picture,
- overlay,
- align=left,
- auto=left,
- font = {\small\itshape},
- TipsOfWithArrows,
- ->,
- looseness=1,
- bend~left=45]
- \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop}
- {label} \l_tmpa_tl
- \draw \exp_after:wN [\l__wa_options_tikz_tl]
- let \p1 = (\tl_use:N \l__wa_initial_tl),
- \p2 = (\tl_use:N \l__wa_final_tl) in
- (\int_compare:nNnTF \l__wa_pos_arrows_int > 3
- {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y1}
- {\x1 + \dim_use:N \l__wa_xoffset_dim, \y1} )
- to node [node~contents = {\tl_use:N \l_tmpa_tl}] {}
- (\int_compare:nNnTF \l__wa_pos_arrows_int > 3
- {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y2}
- {\x2 + \dim_use:N \l__wa_xoffset_dim, \y2} ) ;
- \end{tikzpicture}
+ {\int_use:N\l__wa_final_int-\bool_if:NTF\l__wa_final_r_bool rl .north}
+ \prop_get:cnN {g__wa_arrow_\l__wa_prefix_str _\int_use:N\l__wa_arrow_int _prop}
+ {label}
+ \l_tmpa_tl
+ \int_compare:nNnTF \l__wa_pos_arrows_int < 5
+ {\tikz [__wa_standard]
+ \path let \p1 = (\l__wa_initial_tl),
+ \p2 = (\l__wa_final_tl)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1}
+ \tl_gset:Nx \g_tmpb_tl {\p2}} ; }
+ {\tikz [__wa_standard]
+ \path let \p1 = (\l__wa_initial_tl),
+ \p2 = (\l__wa_final_tl)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g__wa_x_dim , \y1}
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g__wa_x_dim , \y2}} ; }
+ \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl}
+ \group_end: }
+\cs_new_protected:Nn \__wa_def_function_tmpa:n
+ {\cs_set:Nn \__wa_tmpa:nnn
+ {\begin{tikzpicture}[__wa_standard,every~path/.style = {WithArrows/arrow}]
+ #1
+ \end{tikzpicture}}}
+\cs_new_protected:Nn \__wa_draw_arrow:nnn
+ {\exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl
+ \__wa_tmpa:nnn {#1} {#2} {#3} }
+\cs_new_protected:Nn \__wa_actualise_x_value:nn
+ {\int_step_inline:nnnn {#1} \c_one {#2}
+ {\tikz [__wa_standard]
+ \path let \p1 = (##1-l)
+ in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim {\x1}}}; }}
+\cs_new:Npn \WithArrowsLastEnv {\int_use:N \g__wa_last_env_int}
+\keys_define:nn {WithArrows/CodeAfter}
+ {tikz .code:n = \tikzset {WithArrows/arrow/.append~style = {#1}} ,
+ tikz .value_required:n = true,
+ rr .value_forbidden:n = true,
+ rr .code:n = \__wa_analyze_option_position:n 0 ,
+ ll .value_forbidden:n = true,
+ ll .code:n = \__wa_analyze_option_position:n 1 ,
+ rl .value_forbidden:n = true,
+ rl .code:n = \__wa_analyze_option_position:n 2 ,
+ lr .value_forbidden:n = true,
+ lr .code:n = \__wa_analyze_option_position:n 3 ,
+ v .value_forbidden:n = true,
+ v .code:n = \__wa_analyze_option_position:n 4 ,
+ TikzCode .tl_set:N = \l__wa_tikz_code_tl,
+ TikzCode .value_required:n = true,
+ xoffset .dim_set:N = \l__wa_xoffset_dim,
+ xoffset .value_required:n = true}
+\NewDocumentCommand \__wa_Arrow_code_after {O{} mmm O{}}
+ {\int_set:Nn \l__wa_pos_arrows_int 1
+ \int_set:Nn \l__wa_previous_pos_arrows_int {-1}
+ \group_begin:
+ \int_set:Nn \l__wa_level_int 3
+ \keys_set:nn {WithArrows/CodeAfter}
+ {#1,#5,tikz={xshift = \l__wa_xoffset_dim}}
+ \bool_set_false:N \l__wa_initial_r_bool
+ \bool_set_false:N \l__wa_final_r_bool
+ \int_case:nn \l__wa_pos_arrows_int
+ {0 {\bool_set_true:N \l__wa_initial_r_bool
+ \bool_set_true:N \l__wa_final_r_bool}
+ 2 {\bool_set_true:N \l__wa_initial_r_bool}
+ 3 {\bool_set_true:N \l__wa_final_r_bool}}
+ \cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-#2-l}
+ {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#2}}
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-#3-l}
+ {\msg_error:nnn {witharrows} {Wrong~line~specification~in~Arrow} {#3}}
+ {\int_compare:nNnTF \l__wa_pos_arrows_int = 4
+ {\tikz [__wa_standard]
+ \path let \p1 = (#2-l.south),
+ \p2 = (#3-l.north),
+ \p3 = (\dim_max:nn {\x1} {\x2} , \y1),
+ \p4 = (\dim_max:nn {\x1} {\x2} , \y2)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p3}
+ \tl_gset:Nx \g_tmpb_tl {\p4}} ; }
+ {\tikz [__wa_standard]
+ \path let \p1 = (#2-\bool_if:NTF\l__wa_initial_r_bool rl .south),
+ \p2 = (#3-\bool_if:NTF\l__wa_final_r_bool rl .north)
+ in \pgfextra { \tl_gset:Nx \g_tmpa_tl {\p1}
+ \tl_gset:Nx \g_tmpb_tl {\p2}} ; }
+ \__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }}
\group_end:
- \int_incr:N \l__wa_arrow_int
}
- \group_end:
- }
-\cs_new_protected:Nn \__wa_actualise_x_value:nn
- {\group_begin:
- \int_set:Nn \l__wa_initial_int {#1}
- \int_set:Nn \l__wa_final_int {#2}
- \int_compare:nNnT \l__wa_final_int > \g__wa_line_int
- {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
- \int_set:Nn \l_tmpa_int \l__wa_initial_int
- \int_until_do:nNnn \l_tmpa_int > \l__wa_final_int
- {\tikz[remember~picture]
- \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l_tmpa_int-l)
- in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim {\x1}}} ;
- \int_incr:N \l_tmpa_int
- }
- \group_end:
- }
-\NewDocumentCommand \WithArrowsLastEnv {}
- {\int_use:N \g__wa_last_env_int}
+\cs_new_protected:Nn \__wa_MultiArrow:nn
+ {
+ \foreach \x in {#1} {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\x-l}
+ {\msg_error:nnx {witharrows}
+ {Wrong~line~specification~in~MultiArrow} {\x}}
+ {\clist_gput_right:Nx \g_tmpa_clist {\x}}}
+ \int_compare:nNnTF {\clist_count:N \g_tmpa_clist} < 2
+ {\msg_error:nn {witharrows} {Too~small~specification~for~MultiArrow}}
+ {\clist_sort:Nn \g_tmpa_clist
+ {\int_compare:nNnTF {##1} > {##2}
+ {\sort_return_swapped:}
+ {\sort_return_same:}}
+ \clist_pop:NN \g_tmpa_clist \l_tmpa_tl
+ \clist_reverse:N \g_tmpa_clist
+ \clist_pop:NN \g_tmpa_clist \l_tmpb_tl
+ \exp_args:Nx \__wa_MultiArrow_i:n {\g_tmpa_clist}
+ \begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}]
+ \draw [<->] ($(\l_tmpa_tl-r.south)+(\l__wa_xoffset_dim,0)$)
+ -- ++(5mm,0)
+ -- node {#2} ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim+5mm,0)$)
+ -- ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim,0)$) ;
+ \end{tikzpicture} } }
+
+\cs_new_protected:Nn \__wa_MultiArrow_i:n
+ {\begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}]
+ \foreach \k in {#1}
+ {\draw[<-] ($(\k-r.south)+(\l__wa_xoffset_dim,0)$) -- ++(5mm,0) ;} ;
+ \end{tikzpicture}}
\msg_new:nnn {witharrows}
{Third~column~in~a~{WithArrows}~environment}
{By~default,~a~\{WithArrows\}~environment~can~only~have~two~columns.~
@@ -443,7 +542,8 @@
\msg_new:nnn {witharrows}
{Too~few~lines~for~an~arrow}
{An~arrow~specified~in~line~\int_use:N \l__wa_initial_int\ can't~be~drawn~
- because~it~arrives~after~the~last~line~of~the~environment.}
+ because~it~arrives~after~the~last~line~of~the~environment.~If~you~go~on,~
+ this~arrow~will~be~ignored.}
\msg_new:nnn {witharrows}
{{WithArrows}~used~outside~math~mode}
{The~environment~\{WithArrows\}~should~be~used~only~in~math~mode.~
@@ -459,7 +559,8 @@
3 {lr}
4 {i}
5 {group}
- 6 {groups}}"~
+ 6 {groups}
+ 7 {v}}"~
previously~set~in~the~same~
\int_case:nn\l__wa_level_int
{1 {command~\token_to_str:N\WithArrowsOptions}
@@ -469,8 +570,9 @@
\msg_new:nnnn {witharrows}
{All~lines~must~have~an~ampersand}
{All~lines~of~an~environment~\{WithArrows\}~must~have~an~second~column~
- (because~the~nodes~are~created~in~the~second~column).~You~can~go~on~but~maybe~
- you~will~have~an~pgf~error~for~an~undefined~shape.}
+ (because~the~nodes~are~created~in~the~second~column).~
+ You~can~go~on~but~maybe~you~will~have~an~pgf~error~for~
+ an~undefined~shape.}
{The~ampersand~can~be~implicit~
(e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).}
\msg_new:nnn {witharrows}
@@ -488,8 +590,8 @@
If~you~go~on,~it~will~be~ignored.}
\msg_new:nnn {witharrows}
{Option~unknown}
- {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~meaningless~in~the~context.~
- If~you~go~on,~it~will~be~ignored.}
+ {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~
+ meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.}
\msg_new:nnn {witharrows}
{Arrow~in~first~column}
{You~should~not~use~the~command~\token_to_str:N\Arrow\
@@ -502,6 +604,20 @@
~a~new~functionality~with~\token_to_str:N\Arrow\ in~the~
first~column).\\
However~you~can~go~on~for~this~time.}
+\msg_new:nnn {witharrows}
+ {Wrong~line~specification~in~Arrow}
+ {The~specification~of~line~"#1"~you~use~in~\token_to_str:N\Arrow\
+ ~doesn't~exist.\\
+ If~you~go~on,~the~arrow~will~be~ignored.}
+\msg_new:nnn {witharrows}
+ {Wrong~line~specification~in~MultiArrow}
+ {The~specification~of~line~"#1"~doesn't~exist.\\
+ If~you~go~on,~it~will~be~ignored~for~\token_to_str:N \MultiArrow.}
+\msg_new:nnn {witharrows}
+ {Too~small~specification~for~MultiArrow}
+ {The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\
+ is~too~small:~we~need~at~least~two~lines.~If~you~go~on,~the~
+ command~\token_to_str:N\MultiArrow\ ~will~be~ignored.}
\endinput
%%
%% End of file `witharrows.sty'.