summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/witharrows/witharrows.pdfbin264660 -> 269155 bytes
-rw-r--r--Master/texmf-dist/source/latex/witharrows/witharrows.dtx459
-rw-r--r--Master/texmf-dist/tex/latex/witharrows/witharrows.sty223
3 files changed, 431 insertions, 251 deletions
diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
index b09a847b2eb..a2c3c692dec 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 cdd73303cb8..191ac8058a5 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.5}
-\def\myfiledate{2018/02/12}
+\def\myfileversion{1.6}
+\def\myfiledate{2018/05/10}
%
%
%<*batchfile>
@@ -46,18 +46,19 @@ version 2005/12/01 or later.
%
%<@@=wa>
%<*driver>
-\documentclass[dvipsnames]{l3doc} % load fancyvrb, amsmath, array, color, etc.
+\documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz, loaded by witharrows)
\usepackage{xltxtra}
-\usepackage{lmodern}
\usepackage{geometry}
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
\usepackage[footnotehyper]{witharrows}
+\usetikzlibrary{calc}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage[only,llbracket,rrbracket]{stmaryrd}
+\usepackage{booktabs}
\NewDocumentEnvironment {scope} {} {} {}
\def\interitem{\vskip 7mm plus 2 mm minus 3mm}
-\def\emphase#1{{\color{RoyalPurple}#1}}
+\def\emphase{\bgroup\color{RoyalPurple}\let\next=}
\fvset{commandchars=\~\#\@,formatcom={\color{gray}}}
\DeclareMathOperator{\re}{Re}
\parindent 0pt
@@ -74,7 +75,7 @@ version 2005/12/01 or later.
% \maketitle
%
% \begin{abstract}
-% The LaTeX package \pkg{witharrows} gives an environment |{WithArrows}| which is similar to environment
+% The LaTeX package \pkg{witharrows} provides an environment |{WithArrows}| which is similar to environment
% |{aligned}| of \pkg{amsmath} (and \pkg{mathtools}) but gives the possibility to draw arrows on the right side of
% the alignment. These arrows are usually used to give explanations concerning the mathematical calculus presented.
% \end{abstract}
@@ -83,11 +84,11 @@ version 2005/12/01 or later.
% \vskip1cm
% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by the classical workflow
% |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two compilations may be necessary. This package requires the
-% packages \pkg{expl3}, \pkg{xparse} and \pkg{tikz}. The following Tikz libraries are also required: \pkg{calc},
-% \pkg{arrows.meta} and \pkg{bending}.
+% packages \pkg{expl3}, \pkg{xparse} and \pkg{tikz}. The following Tikz libraries \pkg{arrows.meta} and
+% \pkg{bending} are also required.
%
% \bigskip
-% This package gives an environment |{WithArrows}| to construct alignments of equations with arrows for the
+% This package provides an environment |{WithArrows}| to construct alignments of equations with arrows for the
% explanations on the right side:
% %
% \begin{Verbatim}
@@ -99,24 +100,22 @@ version 2005/12/01 or later.
%
% $\begin{WithArrows}
% A & = (a+1)^2 \Arrow{we expand} \\
-% & = a^2 + 2a + 1
+% & = a^2 + 2a + 1
% \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 example).
-%
+% The arrow has been drawn with the command |\Arrow| on the row 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 row as in the previous example).
%
% \section{Options for the shape of the arrows}
%
-% The commande |\Arrow| has several options. These options can be put between square brackets, before, or after the
+% The command |\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 |jump|. See
-% below (p.~\pageref{Backwards}) the way to draw an arrow which goes backwards.} of lines the arrow must jump (the
+% below (p.~\pageref{Backwards}) the way to draw an arrow which goes backwards.} of rows the arrow must jump (the
% default value is, of course,~$1$).
%
%
@@ -138,7 +137,7 @@ version 2005/12/01 or later.
%
%
% \interitem
-% It's possible to put several arrows which start from the same line.
+% It's possible to put several arrows which start from the same row.
% %
% \begin{Verbatim}
% $\begin{WithArrows}
@@ -471,10 +470,11 @@ version 2005/12/01 or later.
% & = 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}.
+% \medskip
+% Special commands are available in |CodeAfter| : a command |\NbLines| which gives the number of lines (=rows) of
+% the current environment (this is a command and not a counter), a special form of the command |\Arrow| and the
+% command |\MultiArrow| : these commands are described in the section concerning the nested environments,
+% p.~\pageref{NestedEnv}.
%
%
% \section{Precise positioning of the arrows}
@@ -579,7 +579,7 @@ version 2005/12/01 or later.
% \bigskip
% The environment |{WithArrows}| gives also a |groups| option (with a \emph{s} in the name). With this option, the
% arrows are divided into several ``groups''. Each group is a set of connected\footnote{More precisely: for each
-% arrow $a$, we note $i(a)$ the number of its initial line and $f(a)$ the number of its final line ; for two arrows
+% arrow $a$, we note $i(a)$ the number of its initial row and $f(a)$ the number of its final line ; for two arrows
% $a$ and $b$, we say that $a \sim b$ when
% $\llbracket i(a),f(a)\rrbracket \cap \llbracket i(b),f(b)\rrbracket \neq \varnothing$ ; the groups are the
% equivalence classes of the transitive closure of $\sim$.} arrows. All the arrows of a given group are grouped on
@@ -609,7 +609,7 @@ version 2005/12/01 or later.
% possible to use the package \pkg{witharrows} without the package \pkg{amsmath}.}
%
% \interitem
-% As in the environments of \pkg{amsmath}, it's possible to change the spacing between two given lines with the
+% As in the environments of \pkg{amsmath}, it's possible to change the spacing between two given rows with the
% option of the command |\\| of end of line (it's also possible to use |\\*| but is has exactly the same effect as
% |\\| since an environment |{WithArrows}| is always unbreakable).
% %
@@ -628,7 +628,7 @@ version 2005/12/01 or later.
%
%
% \interitem
-% In the environments of \pkg{amsmath} (or \pkg{mathtools}), the spacing between lines is fixed by a parameter
+% In the environments of \pkg{amsmath} (or \pkg{mathtools}), the spacing between rows 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 |\jot| with the environment |{spreadlines}|
@@ -831,7 +831,7 @@ version 2005/12/01 or later.
% \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
+% However, one may want to draw an arrow between rows that are not in the same environment. For example, one may want
% to draw the following arrow :
%
% \bigskip
@@ -859,16 +859,16 @@ version 2005/12/01 or later.
% \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 a specification of the start row of the arrow ;
+% \item a specification of the end row 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.
+% The specification of the row is constructed with the position of the concerned environment in the nesting tree,
+% followed (after an hyphen) by the number of the row.
%
% \bigskip
% In the previous example, there are two environments |{WithArrows}| nested in the main environment |{WithArrows}|.
@@ -890,8 +890,8 @@ version 2005/12/01 or later.
% \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
+% The arrow we want to draw starts in the row~$2$ of the sub-environment number~$1$ (and therefore, the
+% specification is |1-2|) and ends in the row~$2$ of the sub-environment number~$2$ (and therefore, the
% specification is |2-2|). We can draw the arrow with the following command |\Arrow| in |CodeAfter| :
% \begin{Verbatim}
% $\begin{WithArrows}[~emphase#CodeAfter = {\Arrow{1-2}{2-2}{Division by $2$}}@]
@@ -922,7 +922,7 @@ version 2005/12/01 or later.
% 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
+% With the option |v|, the arrow drawn is vertical to an abscissa computed with the start row and the end row
% only : the intermediate lines are not taken into account unlike with the option |i|. Currently, the option |i| is
% not available for the command~|\Arrow| in |CodeAfter|. However, it's always possible to translate an arrow with
% |xoffset| (or |xshift| of Tikz).
@@ -953,7 +953,7 @@ version 2005/12/01 or later.
%
% \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
+% |\MultiArrow|. This command draws a ``rak''. The list of the rows of the environment concerned by this rak are
% given in the first argument of the command |\MultiArrow|. This list is given with the syntax of the list in a
% |\foreach| command of \pkg{pgfkeys}.
%
@@ -984,14 +984,14 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% \section{Arrows from outside environments WithArrows}
+% \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''.
+% give the position in the nesting tree and the row number 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
@@ -1029,10 +1029,13 @@ version 2005/12/01 or later.
% \end{WithArrows}\]
%
% \medskip
-% The package \pkg{witharrows} provides some tools to use directly these nodes :
+% The package \pkg{witharrows} provides some tools facilitating the use of these nodes :
% \begin{itemize}
% \item the command |\WithArrowsLastEnv| gives the number of the last environment of level~$0$ ;
%
+% \item a name can be given to a given environment with the option |name| and, in this case, the nodes created in
+% the environment will have aliases constructed with this name ;
+%
% \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}.} ;
@@ -1041,7 +1044,7 @@ version 2005/12/01 or later.
% \end{itemize}
%
% For example, we can draw an arrow from \texttt{wa-\WithArrowsLastEnv-2-1-2-r.south} to
-% \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command.
+% \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command (requires the Tikz library |calc|).
%
% \begin{Verbatim}
% \begin{tikzpicture}[remember picture,overlay]
@@ -1091,8 +1094,50 @@ version 2005/12/01 or later.
% 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.
%
+% \bigskip
+% In the following example, we create two environments |{WithArrows}| named ``|first|'' and ``|second|'' and we
+% draw a line between a node of the first and a node of the second.
+%
+% \begin{Verbatim}
+% $\begin{WithArrows}[~emphase#name=first@]
+% A & = B \\
+% & = C \\
+% \end{WithArrows}$
+%
+% \bigskip
+% $\begin{WithArrows}[~emphase#name=second@]
+% A' & = B' \\
+% & = C' \\
+% \end{WithArrows}$
+%
+% \begin{tikzpicture}[remember picture,overlay]
+% \draw [WithArrows/arrow]
+% ($(~emphase#first@-1-r.south)+(3mm,0)$)
+% to ($(~emphase#second@-1-r.north)+(3mm,0)$) ;
+% \end{tikzpicture}
+% \end{Verbatim}
+%
+%
+% \begin{center}
+% $\begin{WithArrows}[name=first]
+% A & = B \\
+% & = C \\
+% \end{WithArrows}$
+%
+% \bigskip
+% $\begin{WithArrows}[name=second]
+% A' & = B' \\
+% & = C' \\
+% \end{WithArrows}$
+% \end{center}
%
+% \begin{tikzpicture}[remember picture,overlay]
+% \draw [WithArrows/arrow]
+% ($(first-1-r.south)+(3mm,0)$)
+% to ($(second-1-r.north)+(3mm,0)$) ;
+% \end{tikzpicture}
%
+%
% \section{Advanced features}
%
%
@@ -1130,7 +1175,7 @@ version 2005/12/01 or later.
% E & \Longleftrightarrow 3 (2x+4) = 6 \Arrow{$\div 3$} \\
% & \Longleftrightarrow 2x+4 = 2 \Arrow{$-4$} \\
% & \Longleftrightarrow 2x = -2 \Arrow{$\div 2$} \\
-% & \Longleftrightarrow 2x = -1
+% & \Longleftrightarrow x = -1
% \end{WithArrows}
% \end{Verbatim}
%
@@ -1295,13 +1340,13 @@ version 2005/12/01 or later.
%
% \smallskip
% 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.
+% |#3| represent the start raw, the end raw 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.
+% draws the arrow itself and the second puts the label in a Tikz node in the rectangle delimited by the arrow.
%
% \begin{Verbatim}
% $\begin{WithArrows}[
@@ -1341,8 +1386,8 @@ version 2005/12/01 or later.
% \bigskip
% \subsubsection{Example 2}
%
-% 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.
+% In the following example, we change the shape of the arrow depending on wether the start raw is longer than the
+% end row or not. This example requires the Tikz library \pkg{calc}.
%
% \begin{Verbatim}
% \begin{WithArrows}[ll,interline=5mm,xoffset=5mm,
@@ -1416,8 +1461,8 @@ version 2005/12/01 or later.
% \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).
+% The command |\NbLines| is a command available in |CodeAfter| which gives the total number of lines (=rows) of the
+% current environment (it's a command and not a counter).
%
%
% \bigskip
@@ -1451,7 +1496,7 @@ version 2005/12/01 or later.
%
% \bigskip
% 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
+% we want to change the style to have, for example, numbers in parenthesis, the best way is to change the value
% of |TikzCode|:
%
% \begin{Verbatim}
@@ -1465,7 +1510,7 @@ version 2005/12/01 or later.
% 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}
+% e.\;& f \text{ is lipschitzian} \\
% \end{WithArrows}$
%
% \end{scope}
@@ -1481,7 +1526,7 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\RequirePackage{tikz}
-\usetikzlibrary{calc,arrows.meta,bending}
+\usetikzlibrary{arrows.meta,bending}
% \end{macrocode}
%
% \bigskip
@@ -1657,8 +1702,9 @@ version 2005/12/01 or later.
% not been loaded yet).
% \begin{macrocode}
\cs_if_free:NT \spread@equation
- {\cs_set:Npn \spread@equation{\openup\jot
- \cs_set:Npn \spread@equation {}}}
+ {\cs_set_protected:Npn \spread@equation
+ {\openup\jot
+ \cs_set_protected:Npn \spread@equation {}}}
% \end{macrocode}
% Don't put |\cs_set_eq:NN \spread@equation \prog_do_nothing:| in the last line because this would raise errors
% with nested environments.
@@ -1682,19 +1728,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-
-% The following skip (=glue) is the vertical space inserted between two lines of the |\halign|.
+% The following skip (=glue) is the vertical space inserted between two lines (=rows) of the |\halign|.
% \begin{macrocode}
\skip_new:N \l_@@_interline_skip
% \end{macrocode}
%
% \bigskip
-% If the following flag is raised, then the user can use more than two columns.
-% \begin{macrocode}
-\bool_new:N \l_@@_MoreColumns_bool
-% \end{macrocode}
-%
-% \bigskip
% The following integer indicates the position of the box that will be created: 0 (=|t|=|\vtop|), 1~(=|c|=|\vcenter|) or 2 (=|b|=|\vbox|).
% \begin{macrocode}
\int_new:N \l_@@_pos_env_int
@@ -1711,13 +1750,15 @@ version 2005/12/01 or later.
% 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|c|}
-% \hline
+% \begin{tabular}{l}
+% \begin{tabular}{@{}l*8c@{}}
+% \toprule
% option & |rr| & |ll| & |rl| & |lr| & |v| & |i| & |group| & |groups| \\
-% \hline
+% \midrule
% |\l_@@_pos_arrows_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
-% \hline
+% \bottomrule
+% \end{tabular} \\
+% \footnotesize The option |v| can be used only in |\Arrow| in |CodeAfter| (see below).
% \end{tabular}
% \end{center}
%
@@ -1770,11 +1811,17 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The token list |\l_@@_name_tl| will contain the name of the environment (given with the option |name|). This name
+% will be used to create aliases for the names of the nodes.
+% \begin{macrocode}
+\tl_new:N \l_@@_name_tl
+% \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 |\usepackage[...]{witharrows}|: this level will be called \emph{package} level (number~$0$);
% \item with |\WithArrowsOptions{...}|: this level will be called \emph{global} level (number~$1$);
% \item with |\begin{WithArrows}[...]|: this level will be called \emph{environment} level (number~$2$);
% \item with |\Arrow[...]| (included in |CodeAfter|): this level will be called \emph{local} level (number~$3$).
@@ -1782,7 +1829,7 @@ version 2005/12/01 or later.
%
% \bigskip
% The level is specified in the variable |\l_@@_level_int| and the code attached to the options can use this
-% information to alter their actions.
+% information to alter its actions.
%
% \medskip
% \begin{macrocode}
@@ -1790,10 +1837,10 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% We go on with a submodule which will be loaded only at the global or the environment level.
+% We start with a submodule which will be loaded only at the global or the environment level.
%
% \medskip
-% The options |t|, |c| and |b| indicate if we will create a |\vtop|, a |\vcenter| of a |\vbox|. This information is
+% The options |t|, |c| and |b| indicate if we will create a |\vtop|, a |\vcenter| or a |\vbox|. This information is
% stored in the variable |\l_@@_pos_env_int|.
% \begin{macrocode}
\keys_define:nn {WithArrows/GlobalOrEnv}
@@ -1825,10 +1872,25 @@ version 2005/12/01 or later.
% Usually, the number of columns in a |{WithArrows}| environment is limited to 2. Nevertheless, it's possible to
% have more columns with the option |MoreColumns|.
% \begin{macrocode}
- MoreColumns .bool_set:N = \l_@@_MoreColumns_bool,
+ MoreColumns .code:n = { \msg_redirect_name:nnn
+ {witharrows}
+ {Third~column~in~an~environment}
+ {none} },
MoreColumns .value_forbidden:n = true,
% \end{macrocode}
%
+%
+% \bigskip
+% By default, an error message is raised if there is a line without ampersand (|&|). However, it's possible to
+% suppress this error with the option |AllowLineWithoutAmpersand|.
+% \begin{macrocode}
+ AllowLineWithoutAmpersand .code:n = { \msg_redirect_name:nnn
+ {witharrows}
+ {All~lines~must~have~an~ampersand}
+ {none} },
+ AllowLineWithoutAmpersand .value_forbidden:n = true,
+% \end{macrocode}
+%
% \bigskip
% If the user wants to give a new name to the |\Arrow| command (and the name |\Arrow| remains free).
% \begin{macrocode}
@@ -1899,15 +1961,28 @@ version 2005/12/01 or later.
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}}} ,
+ CodeBefore .value_required:n = true,
% \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
+ 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}}} ,
+ CodeAfter .value_required:n = true,
+% \end{macrocode}
+%
+% \bigskip
+% The option |name| is a name given to the environment. If this option is used, the nodes created in the
+% environment will have aliases constructed with this name (and it will be easier to use these nodes from outside
+% the environment).
+% \begin{macrocode}
+ name .code:n = {\int_compare:nNnTF \l_@@_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_set:Nn \l_@@_name_tl {#1}}} ,
+ name .value_required:n = true,
unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
}
% \end{macrocode}
@@ -1997,10 +2072,10 @@ version 2005/12/01 or later.
% useful for the options |group| and |groups|).
% \begin{macrocode}
\keys_define:nn {WithArrows/jump}
- {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}}} ,
+ {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}}} ,
jump .value_required:n = true}
% \end{macrocode}
%
@@ -2170,7 +2245,7 @@ version 2005/12/01 or later.
% We define the command |\\| to be the command |\@@_cr:| (defined below).
% \begin{macrocode}
\cs_set_eq:NN \\ \@@_cr:
- \mathsurround = \c_zero_dim
+ \dim_zero:N \mathsurround
% \end{macrocode}
%
% \bigskip
@@ -2283,7 +2358,18 @@ 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 [@@_standard] \node [@@_node_style] (\int_use:N\g_@@_line_int-l) {} ;
+ \tl_if_empty:NTF \l_@@_name_tl
+ {\tikz [remember~picture,overlay]
+ \node [@@_node_style,
+ name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l] {} ;}
+% \end{macrocode}
+% If the environment |{WithArrows}| has a name (given with the option |name|), the node has also an alias
+% constructed with this name.
+% \begin{macrocode}
+ {\tikz [remember~picture,overlay]
+ \node [@@_node_style,
+ name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l,
+ alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-l] {} ;}
\hfil
% \end{macrocode}
%
@@ -2291,7 +2377,14 @@ 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 [@@_standard] \node [@@_node_style] (\int_use:N\g_@@_line_int-r) {} ;
+ \tl_if_empty:NTF \l_@@_name_tl
+ {\tikz [remember~picture,overlay]
+ \node [@@_node_style,
+ name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r] {} ;}
+ {\tikz [remember~picture,overlay]
+ \node [@@_node_style,
+ name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r,
+ alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-r] {} ;}
\bool_if:NT \l_@@_shownodenames_bool
{\hbox_overlap_right:n {\small wa-\l_@@_prefix_str
-\int_use:N\g_@@_line_int}}
@@ -2301,8 +2394,7 @@ version 2005/12/01 or later.
% Usually, the |\halign| of an environment |{WithArrows}| will have exactly two columns. Nevertheless, if the user
% wants to use more columns (without arrows) it's possible with the option |MoreColumns|.
% \begin{macrocode}
- && \bool_if:NF \l_@@_MoreColumns_bool
- {\msg_error:nn {witharrows} {Third~column~in~a~{WithArrows}~environment}}
+ && \msg_error:nn {witharrows} {Third~column~in~an~environment}
$\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$
\cr
}
@@ -2488,7 +2580,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The flag |\l_@@_new_group_bool| indicates if we have to begin a new group of arrows. In fact, We have to begin a
+% The flag |\l_@@_new_group_bool| indicates if we have to begin a new group of arrows. In fact, we have to begin a
% new group in two circonstancies: if we are at the first arrow of the environment (that's why the flag is raised
% before the beginning of the loop) an if we have just finished a group (that's why the flag is raised in the
% previous conditionnal). At the beginning of a group, we have to initialize four variables:
@@ -2500,10 +2592,11 @@ 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 [@@_standard]
- \path let \p1=(\int_use:N\l_@@_initial_int-l)
- in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ;
- }
+ \begin{tikzpicture} [@@_standard]
+ \tikz@parse@node\pgfutil@firstofone (\int_use:N\l_@@_initial_int-l)
+ \dim_gset:Nn \g_@@_x_dim \pgf@x
+ \end{tikzpicture}
+ }
% \end{macrocode}
%
% \bigskip
@@ -2513,13 +2606,13 @@ version 2005/12/01 or later.
{\int_max:nn \l_@@_last_line_of_group_int \l_@@_final_int}}
% \end{macrocode}
%
-% \bigskip
-% We actualise the current $x$-value (in |\g_@@_x_dim|) even if we are at the beginning of a group. Indeed, the
+% \bigskip
+% We update the current $x$-value (in |\g_@@_x_dim|) even if we are at the beginning of a group. Indeed, the
% previous initialisation of |\g_@@_x_dim| only considers the initial line of the arrows and now we consider all
-% the lines between the initial and the final line. This is done with |\@@_actualise_x_value:nn|. We have written a
+% the lines between the initial and the final line. This is done with |\@@_update_x_value:nn|. We have written a
% command for this because it is also used with the option |i| (|\l_@@_pos_arrows_int| = 5).
% \begin{macrocode}
- \@@_actualise_x_value:nn \l_@@_initial_int \l_@@_final_int
+ \@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int
% \end{macrocode}
%
% \bigskip
@@ -2559,7 +2652,7 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% We begin a loop over the arrows of the environment. The variable |\l_@@_arrow_int| (local in the environment
+% We begin a loop over the arrows we have to draw. The variable |\l_@@_arrow_int| (local in the environment
% |{WithArrows}|) will be used as index for the loop.
% \begin{macrocode}
\int_set:Nn \l_@@_arrow_int \l_@@_first_arrow_int
@@ -2582,11 +2675,19 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% If the arrow ends after the last line of the environment, we raise an error.
+% If the arrow ends after the last line of the environment, we raise an error (we recall that, after the
+% construction of the |\halign|, |\g_@@_line_int| is the total number of lines of the environment). If the initial
+% node or the final node doesn't exist, we also raise an error.\footnote{This case occurs if the considered line
+% has no ampersand. In fact, we raise an error if there is such a line in the |\halign|, but, nonetheless, we consider
+% the case where the user goes on and we try to avoid other errors.}
% \begin{macrocode}
\int_compare:nNnTF \l_@@_final_int > \g_@@_line_int
- {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
- {\@@_draw_arrows_i:}
+ {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l_@@_prefix_str-\int_use:N\l_@@_initial_int-l}
+ { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} }
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l_@@_prefix_str-\int_use:N\l_@@_final_int-l}
+ { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} }
+ {\@@_draw_arrows_i:}}}
\int_incr:N \l_@@_arrow_int
}
\group_end:
@@ -2631,15 +2732,14 @@ version 2005/12/01 or later.
% \bigskip
% \begin{center}
% \begin{tabular}{l}
-% \setlength{\extrarowheight}{2pt}
-% \begin{tabular}{|l|c|c|c|c|c|c|c|c|}
-% \hline
+% \begin{tabular}{@{}l*8c@{}}
+% \toprule
% option & |rr| & |ll| & |rl| & |lr| & |v| & |i| & |group| & |groups| \\
-% \hline
+% \midrule
% |\l_@@_pos_arrows_int| & $0$ & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ \\
-% \hline
+% \bottomrule
% \end{tabular} \\
-% \quad \small The option |v| can be used only in |\Arrow| in |CodeAfter| (see below).
+% \footnotesize The option |v| can be used only in |\Arrow| in |CodeAfter| (see below).
% \end{tabular}
% \end{center}
%
@@ -2657,9 +2757,10 @@ 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 [@@_standard]
- \path let \p1 = (\int_use:N\l_@@_initial_int-l)
- in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ;
+ \begin{tikzpicture} [@@_standard]
+ \tikz@parse@node\pgfutil@firstofone (\int_use:N\l_@@_initial_int-l)
+ \dim_gset:Nn \g_@@_x_dim \pgf@x
+ \end{tikzpicture}
% \end{macrocode}
% A global assignment is necessary because of Tikz.
%
@@ -2667,7 +2768,7 @@ version 2005/12/01 or later.
% |\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
+ \@@_update_x_value:nn \l_@@_initial_int \l_@@_final_int
}
% \end{macrocode}
%
@@ -2693,26 +2794,28 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \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.
+% We have to compute the coordinates of the extremities of the arrow. 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}} ; }
+ {\begin{tikzpicture} [@@_standard]
+ \tikz@scan@one@point\pgfutil@firstofone(\l_@@_initial_tl)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone(\l_@@_final_tl)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y}
+ \end{tikzpicture}
+}
% \end{macrocode}
%
% 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}} ; }
+ {\begin{tikzpicture} [@@_standard]
+ \tikz@scan@one@point\pgfutil@firstofone (\l_@@_initial_tl)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g_@@_x_dim , \dim_use:N \pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone (\l_@@_final_tl)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g_@@_x_dim , \dim_use:N \pgf@y}
+ \end{tikzpicture}}
% \end{macrocode}
%
% \bigskip
@@ -2758,16 +2861,20 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% The command |\@@_actualise_x_value:nn| will analyze the lines between |#1| and |#2| in order to modify
+% The command |\@@_update_x_value:nn| will analyze the lines\footnote{If a line has no ampersand, this line is
+% ignored. In fact, we raise an error if there is a line without ampersand but, nonetheless, we consider the case
+% where the user goes on and we try to avoid other errors.} between |#1| and |#2| in order to modify
% |\g_@@_x_dim| in consequence. More precisely, |\g_@@_x_dim| is increased if a line longer than the current value
-% of |\g_@@_x_dim| is found. |\@@_actualise_x_value:nn| is used in |\@@_draw_arrows:| (for options |group| and
+% of |\g_@@_x_dim| is found. |\@@_update_x_value:nn| is used in |\@@_draw_arrows:| (for options |group| and
% |groups|) and in |\@@_draw_arrows:nn| (for option |i|).
% \begin{macrocode}
-\cs_new_protected:Nn \@@_actualise_x_value:nn
+\cs_new_protected:Nn \@@_update_x_value:nn
{\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}}}; }}
+ {\cs_if_exist:cT {pgf@sh@ns@wa-\l_@@_prefix_str-##1-l}
+ {\begin{tikzpicture} [@@_standard]
+ \tikz@scan@one@point\pgfutil@firstofone (##1-l)
+ \dim_gset:Nn \g_@@_x_dim {\dim_max:nn \g_@@_x_dim \pgf@x}
+ \end{tikzpicture} } } }
% \end{macrocode}
%
%
@@ -2832,22 +2939,27 @@ version 2005/12/01 or later.
% 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}}
+ {\msg_error:nnx {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}}
+ {\msg_error:nnx {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}} ; }
+ {\begin{tikzpicture} [@@_standard]
+ \tikz@scan@one@point\pgfutil@firstofone(#2-l.south)
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \tikz@scan@one@point\pgfutil@firstofone(#3-l.north)
+ \dim_set:Nn \l_tmpa_dim {\dim_max:nn \l_tmpa_dim \pgf@x}
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \l_tmpb_dim}
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \pgf@y}
+ \end{tikzpicture} }
+ {\begin{tikzpicture} [@@_standard]
+ \tikz@scan@one@point\pgfutil@firstofone
+ (#2-\bool_if:NTF\l_@@_initial_r_bool rl .south)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone
+ (#3-\bool_if:NTF\l_@@_final_r_bool rl .north)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y}
+ \end{tikzpicture}}
\@@_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }}
\group_end:
}
@@ -2869,7 +2981,8 @@ version 2005/12/01 or later.
% \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}}
+ {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.
@@ -2922,8 +3035,8 @@ version 2005/12/01 or later.
% \subsection{The error messages of the package}
% \begin{macrocode}
\msg_new:nnn {witharrows}
- {Third~column~in~a~{WithArrows}~environment}
- {By~default,~a~\{WithArrows\}~environment~can~only~have~two~columns.~
+ {Third~column~in~an~environment}
+ {By~default,~an~environment~\{WithArrows\}~can~only~have~two~columns.~
Maybe~you~have~forgotten~a~\str_use:N \c_backslash_str
\str_use:N \c_backslash_str.~If~you~really~want~more~than~two~columns,~
you~should~use~the~option~"MoreColumns"~at~a~global~level~or~for~
@@ -2942,8 +3055,9 @@ 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.~If~you~go~on,~
- this~arrow~will~be~ignored.}
+ because~it~arrives~after~the~last~line~of~the~environment~(remind~that~
+ the~command~\token_to_str:N\Arrow\ must~be~in~the~*start*~line~
+ of~the~arrow).~If~you~go~on,~this~arrow~will~be~ignored.}
% \end{macrocode}
%
% \begin{macrocode}
@@ -2954,35 +3068,36 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\msg_new:nnn {witharrows}
- {Two~options~are~incompatible}
- {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~
- this~option~is~incompatible~or~redundant~with~the~option~"
- \int_case:nn\l_@@_previous_pos_arrows_int
- {0 {rr}
- 1 {ll}
- 2 {rl}
- 3 {lr}
- 4 {i}
- 5 {group}
- 6 {groups}
- 7 {v}}"~
- previously~set~in~the~same~
- \int_case:nn\l_@@_level_int
- {1 {command~\token_to_str:N\WithArrowsOptions}
- 2 {declaration~of~options~of~the~environment~\{WithArrows\}}
- 3 {command~\token_to_str:N\Arrow}}.~
- If~you~go~on,~I~will~overwrite~the~first~option.}
+\msg_new:nnn {witharrows}
+ {Two~options~are~incompatible}
+ {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~
+ this~option~is~incompatible~or~redundant~with~the~option~"
+ \int_case:nn\l_@@_previous_pos_arrows_int
+ {0 {rr}
+ 1 {ll}
+ 2 {rl}
+ 3 {lr}
+ 4 {v}
+ 5 {i}
+ 6 {group}
+ 7 {groups}}"~
+ previously~set~in~the~same~
+ \int_case:nn\l_@@_level_int
+ {1 {command~\token_to_str:N\WithArrowsOptions}
+ 2 {declaration~of~options~of~the~environment~\{WithArrows\}}
+ 3 {command~\token_to_str:N\Arrow}}.~
+ If~you~go~on,~I~will~overwrite~the~first~option.}
% \end{macrocode}
%
% \begin{macrocode}
\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.}
- {The~ampersand~can~be~implicit~
+ {All~lines~of~an~environment~\{WithArrows\}~should~have~an~second~column~
+ (because~the~nodes~are~created~in~the~second~column).~However,~you~can~go~but~you~will~
+ have~an~error~if~one~of~your~arrows~needs~an~PGF~node~absent~by~lack~of~ampersand.~
+ If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~
+ AllowLineWithoutAmpersand.}
+ {Morevoer, the~ampersand~can~be~implicit~
(e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).}
% \end{macrocode}
%
@@ -3051,6 +3166,14 @@ version 2005/12/01 or later.
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}
+%
+% \begin{macrocode}
+\msg_new:nnn {witharrows}
+ {A~PGF~node~doesn't~exist}
+ {A~PGF~node~necessary~to~draw~an~arrow~doesn't~exist~
+ because~you~didn't~put~an~ampersand~in~the~corresponding~line.~
+ If~you~go~on,~the~arrow~will~be~ignored.}
+% \end{macrocode}
%
% \section{History}
%
@@ -3068,7 +3191,7 @@ version 2005/12/01 or later.
%
% \subsection{Changes between versions 1.1 and 1.2}
%
-% The package \pkg{witharrows} can now be loaded without having loaded previously \pkg{tikz} and the Tikz libraries |calc|,
+% The package \pkg{witharrows} can now be loaded without having loaded previously \pkg{tikz} and the libraries
% |arrow.meta| and |bending|.
%
% New option |groups| (with a \emph{s})
@@ -3095,6 +3218,12 @@ version 2005/12/01 or later.
% 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.
+%
+% \subsection{Changes between versions 1.5 and 1.6}
+%
+% The code has been improved to be faster and the Tikz library |calc| is no longer required.
+%
+% A new option |name| is available for the environments |{WithArrows}|.
% \endinput
%
% Local Variables:
diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty
index 296989cac2a..66b60045581 100644
--- a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty
+++ b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty
@@ -18,10 +18,10 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{1.5}
-\def\myfiledate{2018/02/12}
+\def\myfileversion{1.6}
+\def\myfiledate{2018/05/10}
\RequirePackage{tikz}
-\usetikzlibrary{calc,arrows.meta,bending}
+\usetikzlibrary{arrows.meta,bending}
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{witharrows}
@@ -93,14 +93,13 @@
bend~left = 45,
-> }}
\cs_if_free:NT \spread@equation
- {\cs_set:Npn \spread@equation{\openup\jot
- \cs_set:Npn \spread@equation {}}}
+ {\cs_set_protected:Npn \spread@equation
+ {\openup\jot
+ \cs_set_protected:Npn \spread@equation {}}}
\seq_new:N \g__wa_position_in_the_tree_seq
\seq_gput_right:Nn \g__wa_position_in_the_tree_seq 1
\int_new:N \g__wa_last_env_int
-
\skip_new:N \l__wa_interline_skip
-\bool_new:N \l__wa_MoreColumns_bool
\int_new:N \l__wa_pos_env_int
\dim_new:N \l__wa_xoffset_dim
\dim_set:Nn \l__wa_xoffset_dim {3mm}
@@ -113,6 +112,7 @@
\int_new:N \g__wa_line_int
\seq_new:N \g__wa_line_bis_int_seq
\int_new:N \g__wa_line_bis_int
+\tl_new:N \l__wa_name_tl
\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,
@@ -127,8 +127,16 @@
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 .code:n = { \msg_redirect_name:nnn
+ {witharrows}
+ {Third~column~in~an~environment}
+ {none} },
MoreColumns .value_forbidden:n = true,
+ AllowLineWithoutAmpersand .code:n = { \msg_redirect_name:nnn
+ {witharrows}
+ {All~lines~must~have~an~ampersand}
+ {none} },
+ AllowLineWithoutAmpersand .value_forbidden:n = true,
CommandName .tl_set:N = \l__wa_CommandName_tl,
CommandName .initial:n = Arrow ,
CommandName .value_required:n = true,
@@ -156,9 +164,15 @@
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
+ CodeBefore .value_required:n = true,
+ 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}}} ,
+ CodeAfter .value_required:n = true,
+ name .code:n = {\int_compare:nNnTF \l__wa_level_int = 1
+ {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+ {\tl_set:Nn \l__wa_name_tl {#1}}} ,
+ name .value_required:n = true,
unknown .code:n = \msg_error:nn {witharrows} {Option~unknown}
}
\keys_define:nn {WithArrows/General}
@@ -195,10 +209,10 @@
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}}} ,
+ {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}}} ,
jump .value_required:n = true}
\cs_new_protected:Nn \__wa_analyze_option_position:n
{\int_compare:nNnT \l__wa_previous_pos_arrows_int > {-1}
@@ -252,7 +266,7 @@
{{WithArrows}~used~outside~math~mode}
\fi:
\cs_set_eq:NN \\ \__wa_cr:
- \mathsurround = \c_zero_dim
+ \dim_zero:N \mathsurround
\int_zero_new:N \l__wa_initial_int
\int_zero_new:N \l__wa_final_int
\int_zero_new:N \l__wa_arrow_int
@@ -280,14 +294,27 @@
&
\int_gincr:N \g__wa_line_bis_int
$\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$
- \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-l) {} ;
+ \tl_if_empty:NTF \l__wa_name_tl
+ {\tikz [remember~picture,overlay]
+ \node [__wa_node_style,
+ name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l] {} ;}
+ {\tikz [remember~picture,overlay]
+ \node [__wa_node_style,
+ name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l,
+ alias = \l__wa_name_tl-\int_use:N\g__wa_line_int-l] {} ;}
\hfil
- \tikz [__wa_standard] \node [__wa_node_style] (\int_use:N\g__wa_line_int-r) {} ;
+ \tl_if_empty:NTF \l__wa_name_tl
+ {\tikz [remember~picture,overlay]
+ \node [__wa_node_style,
+ name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r] {} ;}
+ {\tikz [remember~picture,overlay]
+ \node [__wa_node_style,
+ name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r,
+ alias = \l__wa_name_tl-\int_use:N\g__wa_line_int-r] {} ;}
\bool_if:NT \l__wa_shownodenames_bool
{\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}}
+ && \msg_error:nn {witharrows} {Third~column~in~an~environment}
$\bool_if:NT \l__wa_displaystyle_bool \displaystyle {##}$
\cr
}
@@ -356,13 +383,14 @@
\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 [__wa_standard]
- \path let \p1=(\int_use:N\l__wa_initial_int-l)
- in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ;
- }
+ \begin{tikzpicture} [__wa_standard]
+ \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__wa_initial_int-l)
+ \dim_gset:Nn \g__wa_x_dim \pgf@x
+ \end{tikzpicture}
+ }
{\int_set:Nn \l__wa_last_line_of_group_int
{\int_max:nn \l__wa_last_line_of_group_int \l__wa_final_int}}
- \__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int
+ \__wa_update_x_value:nn \l__wa_initial_int \l__wa_final_int
\int_incr:N \l__wa_arrow_int
}
\__wa_draw_arrows:nn \l__wa_first_arrow_of_group_int \g__wa_arrow_int
@@ -386,8 +414,12 @@
{final} \l_tmpa_tl
\int_set:Nn \l__wa_final_int {\l_tmpa_tl}
\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:}
+ {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}}
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\int_use:N\l__wa_initial_int-l}
+ { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} }
+ {\cs_if_free:cTF {pgf@sh@ns@wa-\l__wa_prefix_str-\int_use:N\l__wa_final_int-l}
+ { \msg_error:nn {witharrows} {A~PGF~node~doesn't~exist} }
+ {\__wa_draw_arrows_i:}}}
\int_incr:N \l__wa_arrow_int
}
\group_end:
@@ -409,10 +441,11 @@
3 {\bool_set_true:N \l__wa_final_r_bool}}
\int_compare:nNnT \l__wa_pos_arrows_int = 5
{
- \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
+ \begin{tikzpicture} [__wa_standard]
+ \tikz@parse@node\pgfutil@firstofone (\int_use:N\l__wa_initial_int-l)
+ \dim_gset:Nn \g__wa_x_dim \pgf@x
+ \end{tikzpicture}
+ \__wa_update_x_value:nn \l__wa_initial_int \l__wa_final_int
}
\tl_set:Nx \l__wa_initial_tl
{\int_use:N\l__wa_initial_int-\bool_if:NTF\l__wa_initial_r_bool rl .south}
@@ -422,16 +455,19 @@
{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}} ; }
+ {\begin{tikzpicture} [__wa_standard]
+ \tikz@scan@one@point\pgfutil@firstofone(\l__wa_initial_tl)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone(\l__wa_final_tl)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N\pgf@x,\dim_use:N\pgf@y}
+ \end{tikzpicture}
+}
+ {\begin{tikzpicture} [__wa_standard]
+ \tikz@scan@one@point\pgfutil@firstofone (\l__wa_initial_tl)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \g__wa_x_dim , \dim_use:N \pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone (\l__wa_final_tl)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \g__wa_x_dim , \dim_use:N \pgf@y}
+ \end{tikzpicture}}
\__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {\l_tmpa_tl}
\group_end: }
\cs_new_protected:Nn \__wa_def_function_tmpa:n
@@ -442,11 +478,13 @@
\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
+\cs_new_protected:Nn \__wa_update_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_if_exist:cT {pgf@sh@ns@wa-\l__wa_prefix_str-##1-l}
+ {\begin{tikzpicture} [__wa_standard]
+ \tikz@scan@one@point\pgfutil@firstofone (##1-l)
+ \dim_gset:Nn \g__wa_x_dim {\dim_max:nn \g__wa_x_dim \pgf@x}
+ \end{tikzpicture} } } }
\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}} ,
@@ -480,22 +518,27 @@
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}}
+ {\msg_error:nnx {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}}
+ {\msg_error:nnx {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}} ; }
+ {\begin{tikzpicture} [__wa_standard]
+ \tikz@scan@one@point\pgfutil@firstofone(#2-l.south)
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \tikz@scan@one@point\pgfutil@firstofone(#3-l.north)
+ \dim_set:Nn \l_tmpa_dim {\dim_max:nn \l_tmpa_dim \pgf@x}
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \l_tmpb_dim}
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \l_tmpa_dim , \dim_use:N \pgf@y}
+ \end{tikzpicture} }
+ {\begin{tikzpicture} [__wa_standard]
+ \tikz@scan@one@point\pgfutil@firstofone
+ (#2-\bool_if:NTF\l__wa_initial_r_bool rl .south)
+ \tl_gset:Nx \g_tmpa_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y}
+ \tikz@scan@one@point\pgfutil@firstofone
+ (#3-\bool_if:NTF\l__wa_final_r_bool rl .north)
+ \tl_gset:Nx \g_tmpb_tl {\dim_use:N \pgf@x , \dim_use:N \pgf@y}
+ \end{tikzpicture}}
\__wa_draw_arrow:nnn {\g_tmpa_tl} {\g_tmpb_tl} {#4} }}
\group_end:
}
@@ -503,7 +546,8 @@
{
\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}}
+ {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}}
@@ -528,8 +572,8 @@
{\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.~
+ {Third~column~in~an~environment}
+ {By~default,~an~environment~\{WithArrows\}~can~only~have~two~columns.~
Maybe~you~have~forgotten~a~\str_use:N \c_backslash_str
\str_use:N \c_backslash_str.~If~you~really~want~more~than~two~columns,~
you~should~use~the~option~"MoreColumns"~at~a~global~level~or~for~
@@ -542,38 +586,40 @@
\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.~If~you~go~on,~
- this~arrow~will~be~ignored.}
+ because~it~arrives~after~the~last~line~of~the~environment~(remind~that~
+ the~command~\token_to_str:N\Arrow\ must~be~in~the~*start*~line~
+ of~the~arrow).~If~you~go~on,~this~arrow~will~be~ignored.}
\msg_new:nnn {witharrows}
{{WithArrows}~used~outside~math~mode}
{The~environment~\{WithArrows\}~should~be~used~only~in~math~mode.~
Nevertheless,~you~can~go~on.}
-\msg_new:nnn {witharrows}
- {Two~options~are~incompatible}
- {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~
- this~option~is~incompatible~or~redundant~with~the~option~"
- \int_case:nn\l__wa_previous_pos_arrows_int
- {0 {rr}
- 1 {ll}
- 2 {rl}
- 3 {lr}
- 4 {i}
- 5 {group}
- 6 {groups}
- 7 {v}}"~
- previously~set~in~the~same~
- \int_case:nn\l__wa_level_int
- {1 {command~\token_to_str:N\WithArrowsOptions}
- 2 {declaration~of~options~of~the~environment~\{WithArrows\}}
- 3 {command~\token_to_str:N\Arrow}}.~
- If~you~go~on,~I~will~overwrite~the~first~option.}
+\msg_new:nnn {witharrows}
+ {Two~options~are~incompatible}
+ {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~but~
+ this~option~is~incompatible~or~redundant~with~the~option~"
+ \int_case:nn\l__wa_previous_pos_arrows_int
+ {0 {rr}
+ 1 {ll}
+ 2 {rl}
+ 3 {lr}
+ 4 {v}
+ 5 {i}
+ 6 {group}
+ 7 {groups}}"~
+ previously~set~in~the~same~
+ \int_case:nn\l__wa_level_int
+ {1 {command~\token_to_str:N\WithArrowsOptions}
+ 2 {declaration~of~options~of~the~environment~\{WithArrows\}}
+ 3 {command~\token_to_str:N\Arrow}}.~
+ If~you~go~on,~I~will~overwrite~the~first~option.}
\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.}
- {The~ampersand~can~be~implicit~
+ {All~lines~of~an~environment~\{WithArrows\}~should~have~an~second~column~
+ (because~the~nodes~are~created~in~the~second~column).~However,~you~can~go~but~you~will~
+ have~an~error~if~one~of~your~arrows~needs~an~PGF~node~absent~by~lack~of~ampersand.~
+ If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~
+ AllowLineWithoutAmpersand.}
+ {Morevoer, the~ampersand~can~be~implicit~
(e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).}
\msg_new:nnn {witharrows}
{Option~incompatible~with~"group(s)"}
@@ -618,6 +664,11 @@
{The~specification~of~lines~you~gave~to~\token_to_str:N \MultiArrow\
is~too~small:~we~need~at~least~two~lines.~If~you~go~on,~the~
command~\token_to_str:N\MultiArrow\ ~will~be~ignored.}
+\msg_new:nnn {witharrows}
+ {A~PGF~node~doesn't~exist}
+ {A~PGF~node~necessary~to~draw~an~arrow~doesn't~exist~
+ because~you~didn't~put~an~ampersand~in~the~corresponding~line.~
+ If~you~go~on,~the~arrow~will~be~ignored.}
\endinput
%%
%% End of file `witharrows.sty'.