summaryrefslogtreecommitdiff
path: root/macros/generic/witharrows/witharrows.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/witharrows/witharrows.dtx')
-rw-r--r--macros/generic/witharrows/witharrows.dtx609
1 files changed, 496 insertions, 113 deletions
diff --git a/macros/generic/witharrows/witharrows.dtx b/macros/generic/witharrows/witharrows.dtx
index fc8cd3ae2a..9a4b5067ef 100644
--- a/macros/generic/witharrows/witharrows.dtx
+++ b/macros/generic/witharrows/witharrows.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{2.4}
-\def\myfiledate{2020/03/31}
+\def\myfileversion{2.5}
+\def\myfiledate{2020/06/22}
%
%
%<*batchfile>
@@ -96,13 +96,12 @@ version 2005/12/01 or later.
% \end{abstract}
%
%
-% \vspace{1cm}
-% In this document, we describe the LaTeX extension
+% \vspace{1cm} In this document, we describe the LaTeX extension
% \pkg{witharrows} (however, \pkg{witharrows} can also be used with plain-TeX:
% see p.~\pageref{plain-TeX}). This package can be used with |xelatex|,
% |lualatex|, |pdflatex| but also by the classical workflow
% |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). This package loads the packages
-% \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{tikz} and the Tikz libraries
+% \pkg{l3keys2e}, \pkg{xparse}, \pkg{varwidth}, \pkg{tikz} and the Tikz libraries
% \pkg{arrows.meta} and \pkg{bending}. The arrows are drawn with Tikz and that's
% why several compilations may be necessary.
%
@@ -113,7 +112,7 @@ version 2005/12/01 or later.
% \begin{Verbatim}
% $\begin{WithArrows}
% A & = (a+1)^2 ~emphase#\Arrow{we expand}@ \\
-% & = a^2 + 2a + 1 % don't put \\ here
+% & = a^2 + 2a + 1 % <------- don't put \\ here
% \end{WithArrows}$
% \end{Verbatim}
%
@@ -500,6 +499,7 @@ version 2005/12/01 or later.
% command |\MultiArrow|: these commands are described in the section concerning
% the nested environments, p.~\pageref{NestedEnv}.
%
+% \interitem
% \section{Numbers of columns}
%
% So far, we have used the environment |{WithArrows}| with two columns. However,
@@ -556,6 +556,7 @@ version 2005/12/01 or later.
% \end{DispWithArrows*}
%
%
+% \interitem
% \section{Precise positioning of the arrows}
%
%
@@ -638,6 +639,7 @@ version 2005/12/01 or later.
% The environment |{WithArrows}| gives also a |group| option. With this option,
% \emph{all} the arrows of the environment are grouped on a same vertical line
% and at a leftmost position.
+% \label{group}
% %
% \begin{Verbatim}[formatcom=\small\color{gray}]
% $\begin{WithArrows}[~emphase#displaystyle,group@]
@@ -724,6 +726,88 @@ version 2005/12/01 or later.
% & = \frac1{\cos^nx}\cdot\frac{\sin(n+1)x}{\sin x}
% \end{WithArrows}$
%
+%
+% \interitem
+% \section[The option 'o' for individual arrows]%
+% {The option ``o'' for individual arrows}
+%
+% \label{option-o}
+%
+% Let's consider, in a given environment, two arrows called $a$ and $b$.
+% We will note $i_a$ and $i_b$ the numbers of the initial lines of $a$ et $b$
+% dans $f_a$ and $f_b$ the numbers of the final lines. Of course, we have $i_a
+% \le f_a$ and $i_b \le f_b$
+%
+% \smallskip
+% We will say that the arrow~$a$ \emph{covers} the arrow~$b$ when $i_a \le i_b
+% \le f_b \le f_a$. We will also say that the arrow $a$ is \emph{over} the arrow~$b$.
+%
+% \bigskip
+% \parbox{8cm}{In the exemple on the right, the red arrow covers the blue one.}\hspace{3cm}
+% $\begin{WithArrows}[c]
+% A & = B \Arrow[tikz=red,jump=3]{}\\
+% & = C \Arrow[tikz=blue]{}\\
+% & = D \\
+% & = E
+% \end{WithArrows}$
+%
+% \medskip
+% On the local level, there exists a key |o|. This key is available only when
+% the option |group| or the option |groups| is in force (cf.~p.~\pageref{group}).
+%
+% An arrow of type |o| is drawn with an horizontal shift (such as those set by
+% |xoffset|) automatically computed by taking into account the arrows covered by
+% our arrow.\footnote{Among the covered arrows, the independent ones (that is to
+% say with an explicit key |rr|, |ll|, |lr|, |rl|, |i|, |up| or |down|) are not
+% taken into account in the computation of the value of |xoffset|.}
+%
+% \bigskip
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% $\begin{WithArrows}[groups]
+% A & = B \Arrow{one}\Arrow[~emphase#o@,jump=3]{direct} \\
+% & = C + C \Arrow{two} \\
+% & = D + D + D \Arrow{three} \\
+% & = E + E \\
+% & = F + F
+% \end{WithArrows}$
+% \end{BVerbatim}
+% $\begin{WithArrows}[c,groups]
+% A & = B \Arrow{one}\Arrow[o,jump=3]{direct} \\
+% & = C + C \Arrow{two} \\
+% & = D + D + D \Arrow{three} \\
+% & = E + E \\
+% & = F + F
+% \end{WithArrows}$
+%
+%
+% \interitem
+% Arrows of type |o| may themselves be covered by other arrows of type~|o|.\par\nobreak
+%
+% \bigskip
+% \begin{BVerbatim}
+% $\begin{WithArrows}[groups]
+% A & = B \Arrow{one}\Arrow[~emphase#o@,jump=2]{two}\Arrow[~emphase#o@,jump=3]{three}\\
+% & = C \\
+% & = D \\
+% & = E + E + E + E + E + E + E
+% \end{WithArrows}$
+% \end{BVerbatim}
+%
+%
+% \bigskip
+% $\begin{WithArrows}[c,groups]
+% A & = B \Arrow{one}\Arrow[o,jump=2]{two}\Arrow[o,jump=3]{three}\\
+% & = C \\
+% & = D \\
+% & = E + E + E + E + E + E + E
+% \end{WithArrows}$
+%
+% \bigskip
+% The horizontal space between an arrow of type |o| and the arrows immediately
+% covered is fixed by the dimension \verb|xoffset-for-o-arrows| which can be set
+% which the command |\WithArrowsOptions| (initial value: 2~mm).
+%
+%
% \interitem
%
% \section[The options 'up' and 'down' for individual arrows]%
@@ -757,9 +841,8 @@ version 2005/12/01 or later.
%
%
% \vspace{1cm}
-% The options |up| and |down| require the package \pkg{varwidth} and the Tikz
-% library \pkg{calc}. It they are not previously loaded by the user, an error
-% will be raised.
+% The options |up| and |down| require the Tikz library \pkg{calc}. It it has not
+% been previously loaded by the user, an error will be raised.
%
% \vspace{1cm}
% In fact, the options |up| and |down| may be used with a value which is a list
@@ -1019,6 +1102,7 @@ version 2005/12/01 or later.
% \right.$
%
%
+% \interitem
% \section{Arrows in nested environments}
%
% \label{NestedEnv}
@@ -1102,7 +1186,7 @@ version 2005/12/01 or later.
% \bigskip
% 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.
+% that row.
%
% \bigskip
% In the previous example, there are two environments |{WithArrows}| nested in
@@ -1223,7 +1307,7 @@ version 2005/12/01 or later.
% in a future release).
%
%
-% \bigskip
+% \interitem
% \section{Arrows from outside environments \{WithArrows\}}
%
% If someone wants to draw arrows from outside the environments |{WithArrows}|,
@@ -1388,6 +1472,7 @@ version 2005/12/01 or later.
% to ([xshift=3mm]second-1-r.north) ;
% \end{tikzpicture}
%
+% \interitem
% \section{The environment \{DispWithArrows\}}
% \label{DispWithArrows}
%
@@ -1534,7 +1619,7 @@ version 2005/12/01 or later.
% \medskip
% In the following example, the key |{subequations}| is fixed by the command
% |\WithArrowsOptions|. Each environment |{DispWithArrows}| will be subnumerated
-% (in the scope of the |\WithArrowsOptions|)
+% (in the scope of |\WithArrowsOptions|)
% \begin{Verbatim}
% ~emphase#\WithArrowsOptions{subequations}@
% First environment.
@@ -1782,7 +1867,7 @@ version 2005/12/01 or later.
% ``|replace-left-brace-by = [\enskip|'' will compose with a bracket and add also a
% |\enskip| after this bracket.
%
-% \bigskip
+% \interitem
% \section{Advanced features}
%
% \subsection{Utilisation with plain-TeX}
@@ -1813,6 +1898,7 @@ version 2005/12/01 or later.
% deal with the number of the equations are not available (since they rely upon
% the system of tags of LaTeX).
%
+% \bigskip
% \subsection{The option tikz-code : how to change the shape of the arrows}
%
% \label{tikz-code}
@@ -2153,6 +2239,7 @@ version 2005/12/01 or later.
%
%
%
+% \interitem
% \section{Examples}
%
% \subsection{\textbackslash MoveEqLeft}
@@ -2189,6 +2276,49 @@ version 2005/12/01 or later.
%
%
% \bigskip
+% \subsection{A command \textbackslash DoubleArrow}
+%
+% By using the key |o| (cf. p. \pageref{option-o}) available at the local level,
+% it's easy to write a command |\DoubleArrow| for two arrows going in opposite
+% directions.
+%
+% \bigskip
+% \begin{Verbatim}
+% \NewDocumentCommand \DoubleArrow { O {} m m }
+% {
+% \Arrow[tikz=->,~#1]{~#2}%
+% \Arrow[o,tikz=<-,~#1]{~#3}
+% }
+% \end{Verbatim}
+%
+%
+% \NewDocumentCommand \DoubleArrow { O {} m m }
+% {
+% \Arrow[tikz=->,#1]{#2}%
+% \Arrow[o,tikz=<-,#1]{#3}
+% }
+%
+%
+% \bigskip
+% Example of utilisation:
+%
+% \begin{Verbatim}
+% $\begin{WithArrows}[groups]
+% A & = (a+b)^2 \DoubleArrow[tikz={font=\bfseries}]{expansion}{factorization} \\
+% & = a^2 + 2ab+b^2
+% \end{WithArrows}$
+% \end{Verbatim}
+%
+% \bigskip
+% $\begin{WithArrows}[groups]
+% A & = (a+b)^2 \DoubleArrow[tikz={font=\bfseries}]{expansion}{factorization} \\
+% & = a^2 + 2ab+b^2
+% \end{WithArrows}$
+%
+%
+%
+%
+% \bigskip
% \subsection{Modifying the shape of the nodes}
%
% It's possible to change the shape of the labels, which are Tikz nodes, by
@@ -2506,7 +2636,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
%<*LaTeX>
\RequirePackage{tikz}
-\RequirePackage{expl3}[2020/02/08]
%</LaTeX>
%<*plain-TeX>
\input tikz.tex
@@ -2546,11 +2675,9 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The package \pkg{xparse} will be used to define the environments
-% |{WithArrows}|, |{DispWithArrows}|, |{DispWithArrows*}| and the commands
-% |\Arrow|, |\WithArrowsOptions| and |\WithArrowsNewStyle|.
% \begin{macrocode}
\RequirePackage { xparse } [ 2019-01-01 ]
+\RequirePackage { varwidth }
%</LaTeX>
% \end{macrocode}
%
@@ -2739,7 +2866,7 @@ version 2005/12/01 or later.
\clist_map_inline:nn
{
amsmath, amsthm, autonum, cleveref, hyperref, mathtools, showlabels,
- typedref, unicode-math, varwidth
+ typedref, unicode-math
}
{
\bool_new:c { c_@@_#1_loaded_bool }
@@ -3194,7 +3321,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The parameter |\l_@@_up_and_down_radius_dim| corresponds to the option
+% The parameter |\l_@@_up_and_down_radius_dim| corresponds to option
% |radius_for_up_and_down|.
% \begin{macrocode}
\dim_new:N \l_@@_up_and_down_radius_dim
@@ -3202,6 +3329,23 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The sequence |\l_@@_o_arrows_seq| will be used to store the numbers of the
+% arrows which are of type |o| (for \emph{over}) (they are drawn \emph{after}
+% the other arrows).
+% \begin{macrocode}
+\seq_new:N \l_@@_o_arrows_seq
+% \end{macrocode}
+%
+% \bigskip
+% The dimension |\l_@@_xoffset_for_o_arrows_dim| is the xoffset added when
+% drawing an arrow of type |o| (for \emph{over}).
+%
+% \begin{macrocode}
+\dim_new:N \l_@@_xoffset_for_o_arrows_dim
+\dim_set:Nn \l_@@_xoffset_for_o_arrows_dim { 2 mm }
+% \end{macrocode}
+%
+% \bigskip
% \subsection{The definition of the options}
%
% There are four levels where options can be set:
@@ -3591,6 +3735,8 @@ version 2005/12/01 or later.
allow-duplicate-names .code:n =
\@@_msg_redirect_name:nn { Duplicate~name } { none } ,
allow-duplicate-names .value_forbidden:n = true ,
+ xoffset-for-o-arrows .dim_set:N = \l_@@_xoffset_for_o_arrows_dim ,
+ xoffset-for-o-arrows .value_required:n = true ,
unknown .code:n =
\@@_sort_seq:N \l_@@_options_WithArrowsOptions_seq
\@@_error:n { Unknown~option~WithArrowsOptions }
@@ -3609,7 +3755,7 @@ version 2005/12/01 or later.
displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr,
mathindent, max-length-of-arrow, no-arrows, up-and-down, rl, rr,
show-node-names, show-nodes, start-adjust, t, tikz, wrap-lines, xoffset,
- ygap, ystart,
+ xoffset-for-o-arrows, ygap, ystart,
%<*LaTeX>
allow-multiple-labels, nonumber, notag, standard-behaviour-with-items,
tagged-lines
@@ -3652,7 +3798,7 @@ version 2005/12/01 or later.
% The options of an individual arrow are parsed twice. The first pass is when
% the command |\Arrow| is read. The second pass is when the arrows are drawn
% (after the end of the environment |{WithArrows}| or |{DispWithArrows}|). Now,
-% we present the keys set for the first pass. The main goal is to extract
+% we present the set of keys for the first pass. The main goal is to extract
% informations which will be necessary during the scan of the arrows. For
% instance, we have to know if some arrows are ``independent'' or use the
% option ``new-group''.
@@ -3674,11 +3820,22 @@ version 2005/12/01 or later.
rl .default:n = NoValue ,
lr .default:n = NoValue ,
i .default:n = NoValue ,
- new-group .value_forbidden:n = true,
+ new-group .value_forbidden:n = true ,
new-group .code:n =
\int_compare:nTF { \l_@@_pos_arrow_int = 6 }
{ \str_set:Nn \l_@@_status_arrow_str { new-group } }
{ \@@_error:n { new-group~without~groups } } ,
+ o .code:n =
+ \str_if_empty:NTF \l_@@_previous_key_str
+ {
+ \int_compare:nNnTF \l_@@_pos_arrow_int < 6
+ { \@@_error:n { invalid~key~o } }
+ {
+ \str_set:Nn \l_@@_status_arrow_str { over }
+ \str_set_eq:NN \l_@@_previous_key_str \l_keys_key_str
+ }
+ }
+ { \@@_error:n { Incompatible~options~in~Arrow } } ,
% \end{macrocode}
%
% \medskip
@@ -3718,8 +3875,8 @@ version 2005/12/01 or later.
\seq_new:N \l_@@_options_Arrow_seq
\@@_set_seq_of_str_from_clist:Nn \l_@@_options_Arrow_seq
{
- adjust, end-adjust, i, jump, ll, lr, rl, rr, start-adjust, tikz, tikz-code,
- xoffset
+ adjust, end-adjust, i, jump, ll, lr, o , rl, rr, start-adjust, tikz,
+ tikz-code, xoffset
}
% \end{macrocode}
%
@@ -3753,6 +3910,7 @@ version 2005/12/01 or later.
rl .code:n = \@@_fix_pos_arrow:n 2 ,
lr .code:n = \@@_fix_pos_arrow:n 0 ,
i .code:n = \@@_fix_pos_arrow:n 5 ,
+ o .code:n = \str_set:Nn \l_@@_previous_key_str { o } ,
% \end{macrocode}
%
% \medskip
@@ -3848,7 +4006,7 @@ version 2005/12/01 or later.
% ``final'', ``status'', ``options'', ``label'' and ``input-line''. In order to
% compute the value of ``final'' (the destination row of the arrow), we have to
% take into account a potential option |jump|. In order to compute the value of
-% the field ``status'', we have to take into account options as |ll|, |rl|,
+% the field ``status'', we have to take into account options |ll|, |rl|,
% |rr|, |lr|, etc. or |new-group|.
%
% We will do that job with a first analyze of the options of the command
@@ -3878,8 +4036,8 @@ version 2005/12/01 or later.
\prop_put:NnV \l_tmpa_prop { final } \l_tmpa_int
% \end{macrocode}
%
-% \item The ``status'' of the arrow, with 3 possible values: empty,
-% |independent|, or |new-group|.
+% \item The ``status'' of the arrow, with 4 possible values: empty,
+% |independent|, |new-group| or |over|.
% \begin{macrocode}
\prop_put:NnV \l_tmpa_prop { status } \l_@@_status_arrow_str
% \end{macrocode}
@@ -3895,10 +4053,17 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \item The number of the line where the command |\Arrow| is issued in the TeX
-% source (as of now, this is only useful for an error message).
+% source (as of now, this is only useful for some error messages).
% \begin{macrocode}
\prop_put:Nnx \l_tmpa_prop { input-line } \msg_line_number:
% \end{macrocode}
+%
+% \item The total width of the arrow (with the label)... but we don't know it
+% now and that's why we put |0 pt|. There are used for the arrows of type~|o|.
+% \begin{macrocode}
+ \prop_put:Nnn \l_tmpa_prop { width } { 0 pt }
+% \end{macrocode}
+%
% \end{enumerate}
%
% The property list has been created in a local variable for convenience. Now,
@@ -3986,14 +4151,13 @@ version 2005/12/01 or later.
% The variable |\l_@@_input_line_str| will be used only to store, for each
% command |\Arrow| the line (in the TeX file) where the command is issued. This
% information will be stored in the field ``input-line'' of the arrow. As of
-% now, this information is used only in the error message of an arrow impossible
-% to draw (because it arrives after the last row of the environment).
+% now, this information is used only in some error messages.
% \begin{macrocode}
\str_clear_new:N \l_@@_input_line_str
% \end{macrocode}
%
%
-% The initialization of the counters |\g_@@_arrow_int|, |\g_@@_line_int|,
+% Initialization of |\g_@@_arrow_int|, |\g_@@_line_int|,
% |\g_@@_col_int| and |\g_@@_static_col_int|. However, we have to save their
% previous values with the stacks created for this end.
% \begin{macrocode}
@@ -4822,12 +4986,12 @@ version 2005/12/01 or later.
\bool_if:NT \l_@@_qedhere_bool
{ \hbox_overlap_left:n \@@_qedhere_i: }
%</LaTeX>
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfcoordinate
- { wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int - v }
- \pgfpointorigin
- \endpgfpicture
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate
+ { wa - \l_@@_prefix_str - \int_use:N \g_@@_line_int - v }
+ \pgfpointorigin
+ \endpgfpicture
%<*LaTeX>
}
%</LaTeX>
@@ -4859,7 +5023,7 @@ version 2005/12/01 or later.
%<*LaTeX>
\cs_new_protected:Npn \@@_analyze_end:Nn #1 #2
{
- \exp_args:NV \str_if_eq:nnT \l_@@_type_env_str { #2 }
+ \str_if_eq:VnT \l_@@_type_env_str { #2 }
{
\@@_error:n { newline~at~the~end~of~env }
\group_begin:
@@ -5224,7 +5388,9 @@ version 2005/12/01 or later.
{ pgf @ sh @ ns @ wa - \l_@@_prefix_str - \l_tmpa_int - v }
{ \@@_fatal:n { Inexistent~v-node } }
{
- \pgfpointanchor { wa - \l_@@_prefix_str - \l_tmpa_int - v } { center }
+ \pgfpointanchor
+ { wa - \l_@@_prefix_str - \l_tmpa_int - v }
+ { center }
\dim_compare:nNnT \pgf@x < \g_@@_right_x_dim
{ \dim_gset_eq:NN \g_@@_right_x_dim \pgf@x }
}
@@ -5562,7 +5728,8 @@ version 2005/12/01 or later.
{ g_@@_arrow _ \l_@@_prefix_str _ \int_use:N \l_@@_arrow_int _ prop }
{ input-line } \l_@@_input_line_str
% \end{macrocode}
-%
+%
+%
% \bigskip
% We recall that, after the construction of the |\halign|, |\g_@@_line_int| is
% the total number of lines of the environment. Therefore, the conditionnal
@@ -5576,7 +5743,7 @@ version 2005/12/01 or later.
\int_compare:nNnF \l_@@_pos_arrow_int = 8
{ \@@_error:n { Too~few~lines~for~an~arrow } }
}
- \@@_code_for_possible_arrow:
+ \@@_treat_an_arrow_in_scan:
% \end{macrocode}
%
% \bigskip
@@ -5594,16 +5761,23 @@ version 2005/12/01 or later.
% situation occurs when all the arrows of the potential group arrive after the
% last line of the environment).
% \begin{macrocode}
- \bool_lazy_and:nnT
- { \bool_not_p:n { \int_compare_p:nNn \l_@@_pos_arrow_int = 7 } }
- { \int_compare_p:nNn \l_@@_first_arrow_of_group_int > 0 }
+ \bool_if:nT
+ {
+ ! \int_compare_p:nNn \l_@@_pos_arrow_int = 7
+ &&
+ \int_compare_p:nNn \l_@@_first_arrow_of_group_int > 0
+ }
{ \@@_draw_arrows:nn \l_@@_first_arrow_of_group_int \g_@@_arrow_int }
}
% \end{macrocode}
%
% \bigskip
+% The following command is only for the lisibility of the code. It's used only
+% once. Its name may be misleading. Indeed, it treats an arrow in the scan but
+% it \emph{may} trigger the construction of all arrows of a group if it detects
+% that a group has just been completed (with |\@@_draw_arrows:nn|)
% \begin{macrocode}
-\cs_new_protected:Npn \@@_code_for_possible_arrow:
+\cs_new_protected:Npn \@@_treat_an_arrow_in_scan:
{
% \end{macrocode}
% We test whether the previous arrow was in fact the last arrow of a group. In
@@ -5676,11 +5850,10 @@ version 2005/12/01 or later.
{
% \end{macrocode}
%
-% If the arrow is independent, we don't take into account this arrow for the
+% If the arrow is independent, we don't take into account that arrow for the
% detection of the end of the group.
% \begin{macrocode}
- \bool_if:nF
- { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } }
+ \str_if_eq:VnF \l_@@_status_arrow_str { independent }
{
% \end{macrocode}
% If the arrow is not independent, the arrow belongs to the current group and we
@@ -5710,7 +5883,7 @@ version 2005/12/01 or later.
% 8), we don't initialize |\l_@@_x_dim| because we want to use the same value of
% |\l_@@_x_dim| (computed during the first step) for all the groups.
% \begin{macrocode}
- \bool_if:nF { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } }
+ \str_if_eq:VnF \l_@@_status_arrow_str { independent }
{
\int_compare:nNnF \l_@@_pos_arrow_int = 8
{ \@@_update_x:nn \l_@@_initial_int \l_@@_final_int }
@@ -5767,6 +5940,9 @@ version 2005/12/01 or later.
{ g_@@_arrow _ \l_@@_prefix_str _ \int_use:N \l_@@_arrow_int _ prop }
{ final } \l_tmpa_tl
\int_set:Nn \l_@@_final_int \l_tmpa_tl
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ \int_use:N \l_@@_arrow_int _ prop }
+ { status } \l_@@_status_arrow_str
% \end{macrocode}
%
% \bigskip
@@ -5775,20 +5951,31 @@ version 2005/12/01 or later.
% that, after the construction of the |\halign|, |\g_@@_line_int| is the total
% number of lines of the environment).
% \begin{macrocode}
- \int_compare:nT { \l_@@_final_int <= \g_@@_line_int } \@@_draw_arrows_i:
+ \int_compare:nNnF \l_@@_final_int > \g_@@_line_int
+% \end{macrocode}
+%
+% \bigskip
+% If the arrow is of type |over| (key |o|), we don't draw that arrow now (those
+% arrows will be drawn after all the other arrows).
+% \begin{macrocode}
+ {
+ \str_if_eq:VnTF \l_@@_status_arrow_str { over }
+ { \seq_put_right:NV \l_@@_o_arrows_seq \l_@@_arrow_int }
+ \@@_draw_arrow:
+ }
\int_incr:N \l_@@_arrow_int
}
+ \@@_draw_o_arrows_of_the_group:
\group_end:
}
% \end{macrocode}
%
% \bigskip
-% The macro |\@@_draw_arrows_i:| is only for the lisibility of the code. The
-% first |\group_begin:| is for the options of the arrows (but we remind that the
-% options |ll|, |rr|, |rl|, |lr|, |i| and |jump| have already been extracted and
-% are not present in the field |options| of the property list of the arrow).
+% The first |\group_begin:| is for the options of the arrows (but we remind that
+% the options |ll|, |rr|, |rl|, |lr|, |i| and |jump| have already been extracted
+% and are not present in the field |options| of the property list of the arrow).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_draw_arrows_i:
+\cs_new_protected:Npn \@@_draw_arrow:
{
\group_begin:
% \end{macrocode}
@@ -5863,9 +6050,6 @@ version 2005/12/01 or later.
\tl_set:Nx \l_@@_final_tl
{ \int_use:N \l_@@_final_int - \bool_if:NTF \l_@@_final_r_bool rl }
% \end{macrocode}
-% We use ``|.south|'' and ``|.north|'' because we want a small gap between two
-% consecutive arrows (and the Tikz nodes created have the shape of small
-% vertical segments: use option |show-nodes| to visualize the nodes).
%
% \bigskip
% The label of the arrow will be stored in |\l_tmpa_tl|.
@@ -6024,11 +6208,25 @@ version 2005/12/01 or later.
%<*plain-TeX>
\tikzpicture
%</plain-TeX>
- [
- @@_standard ,
- every~path / .style = WithArrows / arrow
- ]
+ [
+ @@_standard ,
+ every~path / .style = WithArrows / arrow
+ ]
+% \end{macrocode}
+% You keep track of the bouding box because we want to compute the total width
+% of the arrow (with the label) for the arrows of type |over|.
+% \begin{macrocode}
+ \pgf@relevantforpicturesizetrue
#1
+ \dim_compare:nNnTF \pgf@picminx = { 16000 pt }
+ { \dim_set_eq:NN \l_tmpa_dim \c_zero_dim }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@picmaxx - \pgf@picminx } }
+ \dim_add:Nn \l_tmpa_dim \l_@@_xoffset_dim
+ \prop_gput:cnV
+ { g_@@_arrow _ \l_@@_prefix_str _ \int_use:N \l_@@_arrow_int _ prop }
+ { width }
+ \l_tmpa_dim
+ \pgfresetboundingbox
%<*LaTeX>
\end{tikzpicture}
%</LaTeX>
@@ -6052,7 +6250,7 @@ version 2005/12/01 or later.
% |\l_@@_tikz_code_tl| (which corresponds to the option |tikz-code|).
% \begin{macrocode}
\bool_lazy_and:nnT \l_@@_wrap_lines_bool \l_@@_in_DispWithArrows_bool
- { \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_wrap_lines_tl }
+ { \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_wrap_lines_tl }
% \end{macrocode}
%
% \medskip
@@ -6110,14 +6308,26 @@ version 2005/12/01 or later.
% \begin{macrocode}
\dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
{
- \path ( @@_label.west )
+ \path ( @@_label.west )
+%<*LaTeX>
+ node [ anchor = west ]
+ {
+ \begin { varwidth } { \l_tmpa_dim }
+ #3
+ \end { varwidth }
+ } ;
+%</LaTeX>
+%<*plain-TeX>
node [ anchor = west , text~width = \dim_use:N \l_tmpa_dim ]
- { #3 } ;
+ { #3 } ;
+%</plain-TeX>
}
}
% \end{macrocode}
%
% \bigskip
+% \subsubsection{The command update_x}
+%
% The command |\@@_update_x:nn| will analyze the lines between |#1| and
% |#2| in order to modify |\l_@@_x_dim| in consequence. More precisely,
% |\l_@@_x_dim| is increased if a line longer than the current value of
@@ -6140,8 +6350,185 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% \subsubsection{We draw the arrows of type o}
+%
+% We recall that the arrows of type~|o| will be drawn \emph{over} (hence the
+% letter |o|) the other arrows. The arrows of type~|o| are available only when
+% the option |group| or the option |groups| is in force. The arrows of type~|o|
+% will be drawn group by group. The command |\@@_draw_o_arrows_of_the_group:| is
+% called after the construction of the (other) arrows of the group.
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_o_arrows_of_the_group:
+ {
+% \end{macrocode}
+%
+% The numbers of the arrows of type |o| we have to draw are in the sequence
+% |\l_@@_o_arrows_seq|. We have to sort that sequence because the order in which
+% these arrows will be drawn matters.
+%
+% \begin{itemize}
+% \item The arrows which arrive first must be drawn first.
+% \item For arrows with the same final line, the arrows with lower initial line
+% must be drawn after (because they encompass the previous ones).
+% \end{itemize}
+%
+%
+% The second point ensures the expected output in situations such as in the
+% following example :
%
% \bigskip
+% \begin{BVerbatim}[boxwidth=6cm,baseline=c]
+% $\begin{WithArrows}[groups]
+% A & = B \Arrow[o,jump=3]{one}\\
+% & = C \Arrow[o,jump=2]{two}\\
+% & = D \Arrow{three} \\
+% & = E + E
+% \end{WithArrows}$
+% \end{BVerbatim}
+% \hspace{2cm}
+% $\begin{WithArrows}[groups,c]
+% A & = B \Arrow[o,jump=3]{one}\\
+% & = C \Arrow[o,jump=2]{two}\\
+% & = D \Arrow{three} \\
+% & = E + E
+% \end{WithArrows}$
+%
+% \bigskip
+% \begin{macrocode}
+ \seq_sort:Nn \l_@@_o_arrows_seq
+ {
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##1 _ prop }
+ { final } \l_tmpa_tl
+% \end{macrocode}
+% We recall that |\prop_get:cnN| retrieves token lists (here |\l_tmpa_tl| and
+% |\l_tmpb_tl|). We don't need to do an explicit conversion in \pkg{expl3}
+% integers because such token lists can be used directly in |\int_compare:nNnTF|.
+% \begin{macrocode}
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##2 _ prop }
+ { final } \l_tmpb_tl
+ \int_compare:nNnTF \l_tmpa_tl < \l_tmpb_tl
+ \sort_return_same:
+ {
+ \int_compare:nNnTF \l_tmpa_tl > \l_tmpb_tl
+ \sort_return_swapped:
+ {
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##1 _ prop }
+ { initial } \l_tmpa_tl
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##2 _ prop }
+ { initial } \l_tmpb_tl
+ \int_compare:nNnTF \l_tmpa_tl < \l_tmpb_tl
+ \sort_return_swapped:
+ \sort_return_same:
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Now, we can draw the arrows of type~|o| of the group in the order of the
+% sequence.
+% \begin{macrocode}
+ \seq_map_inline:Nn \l_@@_o_arrows_seq
+ {
+% \end{macrocode}
+% We retrieve the initial row and the final row of the arrow.
+% \begin{macrocode}
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##1 _ prop }
+ { initial } \l_tmpa_tl
+ \int_set:Nn \l_@@_initial_int \l_tmpa_tl
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##1 _ prop }
+ { final } \l_tmpa_tl
+ \int_set:Nn \l_@@_final_int \l_tmpa_tl
+% \end{macrocode}
+% The string |\l_@@_input_line_str| will be used only in some error messages.
+% \begin{macrocode}
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ##1 _ prop }
+ { input-line } \l_@@_input_line_str
+% \end{macrocode}
+% We have to compute the maximal width of all the arrows (with their labels)
+% which are covered by our arrow. We will compute that dimension in
+% |\g_tmpa_dim|. We need global dimension because we will have to exit a
+% |\pgfpicture|.
+% \begin{macrocode}
+ \dim_gzero:N \g_tmpa_dim
+% \end{macrocode}
+% We will raise the boolean |\g_tmpa_bool| if we find an arrow ``under'' our
+% arrow (we should find at least once since you are drawing an arrow of
+% type~|o|: if not, we will raise an error\footnote{Maybe we will change that in
+% future versions.}).
+% \begin{macrocode}
+ \bool_set_false:N \g_tmpa_bool
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \int_step_inline:nnn \l_@@_first_arrow_int \l_@@_last_arrow_int
+ {
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ####1 _ prop }
+ { initial } \l_tmpa_tl
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ####1 _ prop }
+ { final } \l_tmpb_tl
+ \prop_get:cnN
+ { g_@@_arrow _ \l_@@_prefix_str _ ####1 _ prop }
+ { status } \l_@@_status_arrow_str
+ \bool_if:nT
+ {
+ ! \int_compare_p:n { ##1 = ####1 }
+ && \int_compare_p:n { \l_@@_initial_int <= \l_tmpa_tl }
+ && \int_compare_p:n { \l_tmpb_tl <= \l_@@_final_int }
+% \end{macrocode}
+% We don't take into account the independent arrows because we have only
+% computed the \emph{width} of the arrows and that's why our arrow of type~|o|
+% will be positionned only relatively to the current group.
+% \begin{macrocode}
+ && ! \str_if_eq_p:Vn \l_@@_status_arrow_str { independent }
+ }
+ {
+% \end{macrocode}
+% The total width of the arrow (with its label) has been stored in a ``field''
+% of the arrow.
+% \begin{macrocode}
+ \bool_gset_true:N \g_tmpa_bool
+ \prop_get:cnN
+ { g_@@ _ arrow _ \l_@@_prefix_str _ ####1 _ prop }
+ { width }
+ \l_tmpa_tl
+% \end{macrocode}
+% We have to do a global affectation in order to exit the |pgfpicture|.
+% \begin{macrocode}
+ \dim_gset:Nn \g_tmpa_dim { \dim_max:nn \g_tmpa_dim \l_tmpa_tl }
+ }
+ }
+ \endpgfpicture
+% \end{macrocode}
+% The boolean |\g_tmpa_bool| is raised if at least one arrow has been found
+% ``under'' our arrow (it should be the case since we are drawing an arrow of
+% type~|o|).
+% \begin{macrocode}
+ \bool_if:NTF \g_tmpa_bool
+ {
+ \int_set:Nn \l_@@_arrow_int { ##1 }
+ \dim_set_eq:NN \l_@@_xoffset_dim \g_tmpa_dim
+ \dim_add:Nn \l_@@_xoffset_dim \l_@@_xoffset_for_o_arrows_dim
+% \end{macrocode}
+% \begin{macrocode}
+ \@@_draw_arrow:
+ }
+ { \@@_error:n { o~arrow~with~no~arrow~under } }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
% The command |\WithArrowsLastEnv| is not used by the package \pkg{witharrows}.
% It's only a facility given to the final user. It gives the number of the last
% environment |{WithArrows}| at
@@ -6153,7 +6540,7 @@ version 2005/12/01 or later.
{ \int_use:N \g_@@_last_env_int }
%</LaTeX>
%<*plain-TeX>
-\cs_new:Npn \WithArrowsLastEnv { \int_use:N \g_@@_last_env_int }
+\cs_new:Npn \WithArrowsLastEnv { \int_use:N \g_@@_last_env_int }
%</plain-TeX>
% \end{macrocode}
%
@@ -6525,6 +6912,15 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { invalid~key~o }
+ {
+ The~key~'o'~for~individual~arrows~can~be~used~only~in~mode~
+ 'group'~or~in~mode~'groups'.\\
+ \c_@@_option_ignored_str
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { Value~for~a~key }
{
The~key~'\l_keys_key_str'~should~be~used~without~value. \\
@@ -6561,7 +6957,6 @@ version 2005/12/01 or later.
\seq_use:Nnnn \l_@@_options_WithArrows_seq {~and~} {,~} {~and~}.
}
% \end{macrocode}
-%
% \begin{macrocode}
\@@_msg_new:nnn { Unknown~option~DispWithArrows }
{
@@ -6626,7 +7021,7 @@ version 2005/12/01 or later.
This~error~is~fatal.
}
% \end{macrocode}
-%
+%
% \begin{macrocode}
\@@_msg_new:nn { Negative~jump }
{
@@ -6656,13 +7051,22 @@ version 2005/12/01 or later.
{ Too~few~lines~for~an~arrow }
{
Line~\l_@@_input_line_str\
- :~an~arrow~specified~in~the~row~\int_use:N \l_@@_initial_int\
+ :~an~arrow~specifiead~in~the~row~\int_use:N \l_@@_initial_int\
of~your~environment~\{\l_@@_type_env_str\}~can't~be~drawn~
because~it~arrives~after~the~last~row~of~the~environment. \\
If~you~go~on,~this~arrow~will~be~ignored.
}
% \end{macrocode}
%
+% \begin{macrocode}
+\@@_msg_new:nn { o~arrow~with~no~arrow~under }
+ {
+ Line~\l_@@_input_line_str\
+ :~there~is~no~arrow~'under'~your~arrow~of~type~'o'.\\
+ If~you~go~on,~this~arrow~won't~be~drawn.
+ }
+% \end{macrocode}
+%
% \begin{macrocode}
\@@_msg_new:nn { WithArrows~outside~math~mode }
{
@@ -6676,7 +7080,7 @@ version 2005/12/01 or later.
\@@_msg_new:nn { DispWithArrows~in~math~mode }
{
The~environment~\{\l_@@_type_env_str\}~should~be~used~only~outside~math~
- mode~like~the~environment~\{align\}~of~amsmath. \\
+ mode~like~the~environments~\{align\}~and~\{align*\}~of~amsmath. \\
This~error~is~fatal.
}
% \end{macrocode}
@@ -6936,11 +7340,10 @@ version 2005/12/01 or later.
% corresponding code is given here. It is independent of the main code of the
% extension \pkg{witharrows}.
%
-% This code is the only part of the code of \pkg{witharrows} which uses the
-% package \pkg{varwidth} and also the Tikz library |calc|. That's why we have
-% decided not to load by default this package and this library. If they are not
-% loaded, the user will have an error only when using the option |up| or the
-% option |down|.
+% This code is the only part of the code of \pkg{witharrows} which uses the the
+% Tikz library |calc|. That's why we have decided not to load by default this
+% library. If it is not loaded, the user will have an error only when using the
+% option |up| or the option |down|.
%
% \bigskip
% The keys |up| and |down| can be used with a value. This value is a list of
@@ -7002,7 +7405,7 @@ version 2005/12/01 or later.
{
\dim_set:Nn \l_tmpa_dim { \x2 - \x1 }
\begin { varwidth } \l_tmpa_dim
-% \end{macrocode}
+% \end{macrocode}a
% |\narrowragged| is a command of the package \pkg{varwidth}.
% \begin{macrocode}
\narrowragged
@@ -7227,51 +7630,35 @@ version 2005/12/01 or later.
\str_if_empty:NT \l_@@_previous_key_str
{
\str_set:Nn \l_@@_previous_key_str { up }
-%<*LaTeX>
- \bool_if:NTF \c_@@_varwidth_loaded_bool
+ \cs_if_exist:cTF { tikz@library@calc@loaded }
{
-%</LaTeX>
- \cs_if_exist:cTF { tikz@library@calc@loaded }
- {
- \keys_set:nV { WithArrows / up-and-down } \l_keys_value_tl
- \int_set:Nn \l_@@_pos_arrow_int 1
+ \keys_set:nV { WithArrows / up-and-down } \l_keys_value_tl
+ \int_set:Nn \l_@@_pos_arrow_int 1
% \end{macrocode}
% We have to set |\l_@@_wrap_lines_bool| to |false| because, otherwise, if the
% option |wrap_lines| is used at a higher level (global or environment), we will
% have a special affectation to |tikz-code| that will overwrite our affectation.
% \begin{macrocode}
- \bool_set_false:N \l_@@_wrap_lines_bool
+ \bool_set_false:N \l_@@_wrap_lines_bool
% \end{macrocode}
% The main action occurs now. We change the value of the |tikz-code|.
% \begin{macrocode}
- \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_up_tl
- }
- { \@@_error:n { calc~not~loaded } }
-%<*LaTeX>
+ \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_up_tl
}
- { \@@_error:n { varwidth~not~loaded } }
-%</LaTeX>
+ { \@@_error:n { calc~not~loaded } }
} ,
down .code:n =
\str_if_empty:NT \l_@@_previous_key_str
{
\str_set:Nn \l_@@_previous_key_str { down }
-%<*LaTeX>
- \bool_if:NTF \c_@@_varwidth_loaded_bool
+ \cs_if_exist:cTF { tikz@library@calc@loaded }
{
-%</LaTeX>
- \cs_if_exist:cTF { tikz@library@calc@loaded }
- {
- \keys_set:nV { WithArrows / up-and-down } \l_keys_value_tl
- \int_set:Nn \l_@@_pos_arrow_int 1
- \bool_set_false:N \l_@@_wrap_lines_bool
- \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_down_tl
- }
- { \@@_error:n { calc~not~loaded } }
-%<*LaTeX>
+ \keys_set:nV { WithArrows / up-and-down } \l_keys_value_tl
+ \int_set:Nn \l_@@_pos_arrow_int 1
+ \bool_set_false:N \l_@@_wrap_lines_bool
+ \tl_set_eq:NN \l_@@_tikz_code_tl \c_@@_tikz_code_down_tl
}
- { \@@_error:n { varwidth~not~loaded } }
-%</LaTeX>
+ { \@@_error:n { calc~not~loaded } }
}
}
% \end{macrocode}
@@ -7282,15 +7669,6 @@ version 2005/12/01 or later.
\seq_put_right:Nn \l_@@_options_Arrow_seq { up }
% \end{macrocode}
%
-%
-% \begin{macrocode}
-\@@_msg_new:nn { varwidth~not~loaded }
- {
- You~can't~use~the~option~'\l_keys_key_str'~because~
- you~don't~have~loaded~the~package~'varwidth'. \\
- \c_@@_option_ignored_str
- }
-% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { calc~not~loaded }
@@ -7508,6 +7886,11 @@ version 2005/12/01 or later.
%
% Correction of a bug with |{DispWithArrows}| : cf. question 535989 on |TeX StackExchange|.
%
+% \subsection*{Changes between 2.4 and 2.5}
+%
+% Arrows of type |o| which are \emph{over} other arrows.
+%
+% \pkg{witharrows} now requires and loads \pkg{varwidth}
%
%
% \PrintIndex