texlive[48422] Master/texmf-dist: witharrows (17aug18)

commits+karl at tug.org commits+karl at tug.org
Sat Aug 18 00:07:14 CEST 2018


Revision: 48422
          http://tug.org/svn/texlive?view=revision&revision=48422
Author:   karl
Date:     2018-08-18 00:07:14 +0200 (Sat, 18 Aug 2018)
Log Message:
-----------
witharrows (17aug18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
    trunk/Master/texmf-dist/source/latex/witharrows/witharrows.dtx
    trunk/Master/texmf-dist/tex/latex/witharrows/witharrows.sty

Modified: trunk/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/witharrows/witharrows.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/witharrows/witharrows.dtx	2018-08-17 22:07:02 UTC (rev 48421)
+++ trunk/Master/texmf-dist/source/latex/witharrows/witharrows.dtx	2018-08-17 22:07:14 UTC (rev 48422)
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{1.8}
-\def\myfiledate{2018/07/25}
+\def\myfileversion{1.9}
+\def\myfiledate{2018/08/17}
 %
 %
 %<*batchfile>
@@ -26,7 +26,7 @@
 \usedir{tex/latex/witharrows}
 \preamble
 
-Copyright (C) 2017 by F. Pantigny
+Copyright (C) 2017-2018 by F. Pantigny
 -----------------------------------
 
 This file may be distributed and/or modified under the
@@ -265,6 +265,10 @@
 %   & = a^2 + 2ab + b^2 + 2a + 2b +1 
 % \end{WithArrows}$
 %
+% \bigskip
+% In the environments |{DispWithArrows}| and |{DispWithArrows*}|, there is an option |wrap-line|. With this option,
+% the lines of the labels are automaticly wrapped on the right: see p.~\pageref{wrap-lines}.
+% 
 % \interitem
 % If we want to change the font of the text associated to the arrow, we can, of course, put a command like
 % |\bfseries|, |\large| or |\sffamily| at the beginning of the text. But, by default, the texts are composed with a
@@ -957,7 +961,7 @@
 %
 %  
 % \interitem
-% The package \pkg{witharrows} gives also another command available only in |CodeAfter| : the command
+% The package \pkg{witharrows} gives also another command available only in |CodeAfter|: the command
 % |\MultiArrow|. This command draws a ``rak''. The list of the rows of the environment concerned by this rak are
 % given in the first argument of the command |\MultiArrow|. This list is given with the syntax of the list in a
 % |\foreach| command of \pkg{pgfkeys}.
@@ -1034,28 +1038,28 @@
 % \end{WithArrows}\]
 %
 % \medskip
-% The package \pkg{witharrows} provides some tools facilitating the use of 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 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 ;
+% 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}.} ;
+% option |TikzCode|. This style is modified (in TeX scopes) by the option |tikz| of \pkg{witharrows}.};
 %
-% \item the Tikz style |WithArrows/arrow/tips| is the style for the style of the arrow (loaded by |WithArrows/arrow|).
+% \item the Tikz style |WithArrows/arrow/tips| is the style for the tip of the arrow (loaded by |WithArrows/arrow|).
 % \end{itemize}
 %
 % For example, we can draw an arrow from \texttt{wa-\WithArrowsLastEnv-2-1-2-r.south} to
-% \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command (requires the Tikz library |calc|).
+% \texttt{wa-\WithArrowsLastEnv-3-2-r.north} with the following Tikz command.
 %
 % \begin{Verbatim}
 % \begin{tikzpicture}[remember picture,overlay]
 % \draw [WithArrows/arrow] 
-%       ($(wa-\WithArrowsLastEnv-2-1-2-r.south)+(3mm,0)$) 
-%    to ($(wa-\WithArrowsLastEnv-3-2-r.north)+(3mm,0)$) ;
+%       ([xshift=3mm]wa-\WithArrowsLastEnv-2-1-2-r.south)
+%    to ([xshift=3mm]wa-\WithArrowsLastEnv-3-2-r.north) ;
 % \end{tikzpicture}
 % \end{Verbatim}
 %
@@ -1091,8 +1095,8 @@
 %
 % \begin{tikzpicture}[remember picture,overlay]
 % \draw [WithArrows/arrow] 
-%       ($(wa-\WithArrowsLastEnv-2-1-2-r.south)+(3mm,0)$) 
-%    to ($(wa-\WithArrowsLastEnv-3-2-r.north)+(3mm,0)$) ;
+%       ([xshift=3mm]wa-\WithArrowsLastEnv-2-1-2-r.south)
+%    to ([xshift=3mm]wa-\WithArrowsLastEnv-3-2-r.north) ;
 % \end{tikzpicture}
 %
 % \medskip
@@ -1262,6 +1266,37 @@
 %
 % It is not compatible with \pkg{showkeys} (not all the labels are shown).
 %
+% \bigskip
+% The environments |{DispWithArrows}| and |{DispWithArrows*}| provide an option |wrap-lines|. With this option,
+% the lines of the label are automaticly wrapped on the right.\label{wrap-lines}
+%
+% \begin{Verbatim}
+% \begin{DispWithArrows*}[displaystyle,~emphase#wrap-lines@]
+% S_n
+% & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right)
+% \Arrow{sum of terms of a geometric progression of ratio $e^{i\frac{2\pi}n}$}\\
+% & = \frac1n \Re \left( \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}
+%                             {1-e^{i\frac{\pi}{2n}}}\right)
+% \Arrow{This line has been wrapped automaticly.} \\
+% & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right) 
+% \end{DispWithArrows*}
+% \end{Verbatim}
+% 
+%
+% \begin{DispWithArrows*}[displaystyle,wrap-lines]
+% S_n
+% & = \frac1n \Re \left(\sum_{k=0}^{n-1}\bigl(e^{i\frac{\pi}{2n}}\bigr)^k\right)
+% \Arrow{sum of terms of a geometric progression of ratio $e^{i\frac{2\pi}n}$}\\
+% & = \frac1n \Re \left( \frac{1-\bigl(e^{i\frac{\pi}{2n}}\bigr)^n}{1-e^{i\frac{\pi}{2n}}}\right)
+% \Arrow{This line has been wrapped automaticly.} \\
+% & = \frac1n \Re \left(\frac{1-i}{1-e^{i\frac{\pi}{2n}}}\right) 
+% \end{DispWithArrows*}
+% 
+% \bigskip
+% The option |wrap-lines| doesn't apply to the environments |{WithArrows}| nested in an environment
+% |{DispWithArrows}| or |{DispWithArrows*}|. However, it applies to the instructions |\Arrow| and |\MultiArrow| of
+% the |CodeAfter| of the environments |{DispWithArrows}| or |{DispWithArrows*}|.
+% 
 % \section{Advanced features}
 %
 %
@@ -1269,7 +1304,9 @@
 %
 % \label{TikzCode}
 %
-% The option |TikzCode| allows the user to change the shape of the arrows.
+% The option |TikzCode| allows the user to change the shape of the arrows.\footnote{If the option |wrap-lines| is
+% used in an environment |{DispWithArrows}| or |{DispWithArrows*}|, the option |TikzCode| will have no effect for
+% the arrows of this environment but only for the arrows in the nested environments |{WithArrows}|.}
 %
 % \smallskip
 % The value of this option must be a valid Tikz drawing instruction (with the final semi-colon) with three markers
@@ -1276,7 +1313,7 @@
 % |#1|, |#2| and |#3| for the start point, the end point and the label of the arrow.
 %
 % \bigskip
-% By default, the value is the following :
+% By default, the value is the following:
 % 
 % \smallskip
 % \qquad \verb|\draw (#1) to node {#3} (#2) ;|
@@ -1464,7 +1501,7 @@
 %
 % \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 raw, the end raw and the label of the arrow.
+% |#3| represent the start row, the end row and the label of the arrow.
 %
 %
 % \bigskip
@@ -1477,7 +1514,7 @@
 %        displaystyle,
 %        ygap = 2mm,
 %        ystart = 0mm,
-%        ~emphase#TikzCode = {\path[draw] (~#1) -- ++(4.5cm,0) |- (~#2) ;@
+%        ~emphase#TikzCode = {\draw (~#1) -- ++(4.5cm,0) |- (~#2) ;@
 %        ~emphase#            \path (~#1) -- (~#2) @
 %        ~emphase#                   node[text width = 4.2cm, right, midway] {~#3} ;}@]
 % S_n
@@ -1491,7 +1528,7 @@
 %        displaystyle,
 %        ygap = 2mm,
 %        ystart = 0mm,
-%        TikzCode = {\path[draw] (#1) -- ++(4.5cm,0) |- (#2) ;
+%        TikzCode = {\draw (#1) -- ++(4.5cm,0) |- (#2) ;
 %                    \path (#1) -- (#2) 
 %                           node[text width = 4.2cm, right, midway] {#3} ;}]
 % S_n
@@ -1510,7 +1547,7 @@
 % \bigskip
 % \subsubsection{Example 2}
 % 
-% In the following example, we change the shape of the arrow depending on wether the start raw is longer than the
+% In the following example, we change the shape of the arrow depending on wether the start row is longer than the
 % end row or not. This example requires the Tikz library \pkg{calc}.
 % 
 % \begin{Verbatim}
@@ -1654,7 +1691,7 @@
 %    \end{macrocode}
 %
 % \bigskip
-% Then, we can give the traditionnal declaration of a package written with |expl3|:
+% Then, we can give the traditional declaration of a package written with |expl3|:
 %    \begin{macrocode}
 \RequirePackage{l3keys2e}
 \ProvidesExplPackage
@@ -1992,9 +2029,7 @@
                            {\msg_error:nn {witharrows} {Multiple~labels}}
                         \seq_put_right:Nn \l_@@_labels_seq {#1}
 %    \end{macrocode}
-% In order to be compatible with the option |showonlyrefs|, we have to use internals of \pkg{mathtools}. By
-% security, we provide an option |code-of-mathtools| which can be switched off if the internals of \pkg{mathtools}
-% are changed.
+%
 %    \begin{macrocode}
                         \bool_if:nT \c_@@_mathtools_loaded_bool
                            {\MH_if_boolean:nT {show_only_refs} 
@@ -2024,6 +2059,12 @@
 %    \end{macrocode}
 % 
 % \bigskip
+% The boolean |\l_@@_wrap_lines_bool| corresponds to the option |wrap-lines|.
+%    \begin{macrocode}
+\bool_new:N \l_@@_wrap_lines_bool 
+%    \end{macrocode}
+%
+% \bigskip
 % \subsection{The definition of the options}
 %
 % There are four levels where options can be set:
@@ -2241,7 +2282,20 @@
                                                            {Multiple~labels}
                                                            {none}}},
       AllowMultipleLabels .value_forbidden:n = true,
-      fleqn   .default:n = true,
+%    \begin{macrocode}
+% 
+% \bigskip
+% With the option |wrap-lines|, a special |TikzCode| is used in the environments |{DispWithArrows}| and
+% |{DispWithArrows*}| and, with this |TikzCode|, the lines of the labels are automaticly wrapped on the right.
+%    \begin{macrocode}
+      wrap-lines   .code:n = {\bool_if:NTF \l_@@_in_witharrows_bool
+                             {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+                             {\tl_if_eq:nnTF {#1} {true}
+                                 {\bool_set_true:N \l_@@_wrap_lines_bool}
+                                 {\bool_set_false:N \l_@@_wrap_lines_bool}}},
+      wrap-lines   .default:n = true,
+%    \end{macrocode}
+%    \begin{macrocode}
       unknown .code:n  = \msg_error:nn {witharrows} {Option~unknown}
      }
 %    \end{macrocode}
@@ -2797,7 +2851,8 @@
 % If there is no tag to put, we use as well the third column because you want to raise an error if the user uses
 % more than two columns.
 %    \begin{macrocode}
-                {&}
+                {& \tikz [remember~picture,overlay]
+                   \coordinate [name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-v ]  ; }
                 {
 %    \end{macrocode}
 % Here, we can't use |\refstepcounter{equation}| because if the user has issued a |\tag| command, we have to use
@@ -2871,7 +2926,11 @@
 % We use |\@eqnnum| (we recall that there are two definitions of |\@eqnnum|, a standard definition and another, loaded
 % if the option |\leqno| is used).
 %    \begin{macrocode}
-                   \hbox_overlap_left:n \@eqnnum
+                   \hbox_overlap_left:n 
+                     { \tikz [@@_standard]
+                          \coordinate [name = \int_use:N \g_@@_line_int-v ]  ;
+                       \quad
+                       \@eqnnum}
              }}
        \cr\noalign{\skip_vertical:n {#1 + \l_@@_interline_skip}
        \scan_stop:}}
@@ -2998,6 +3057,26 @@
            \egroup 
            $$
 %    \end{macrocode}
+%
+% If the option |wrap-lines| is used (only in |{DispWithArrows}| and |{DispWithArrows*}|), we compute
+% |\g_@@_x_right_dim|. As a first approximation, |\g_@@_x_right_dim| is the $x$-value of the right side of the
+% current composition box. In fact, we must take into account the potential labels of the equations. That's why 
+% we compute |\g_@@_x_right_dim| with the |v|-nodes of each row specificaly built in this goal. |\g_@@_x_right_dim|
+% is the minimal value of the $x$-value of these nodes.
+%    \begin{macrocode}
+           \bool_if:NT \l_@@_wrap_lines_bool
+             {\dim_gzero_new:N \g_@@_x_right_dim 
+              \dim_gset:Nn \g_@@_x_right_dim \c_max_dim
+              \begin{tikzpicture} [@@_standard]
+              \int_step_variable:nnnNn 1 1 \g_@@_line_int \l_tmpa_int
+                    {\tikz at parse@node\pgfutil at firstofone (\l_tmpa_int-v)
+                     \dim_set:Nn \l_tmpa_dim \pgf at x
+                     \dim_compare:nNnT \l_tmpa_dim < \g_@@_x_right_dim
+                            {\dim_gset:Nn \g_@@_x_right_dim \l_tmpa_dim} }
+              \end{tikzpicture}}
+%    \end{macrocode}
+%
+% \bigskip
 % The code in |\@@_post_environment:| is common to |{WithArrows}| and |{DispWithArrows}|.
 %    \begin{macrocode}
            \@@_post_environment:
@@ -3382,11 +3461,30 @@
 %    \end{macrocode}
 %
 % \medskip
-% When we draw the arrow (with |\@@_draw_arrow:nnn|), we create first the function |\@@_tmpa:nnn| and, then, we use
+% When we draw the arrow (with |\@@_draw_arrow:nnn|), we first create the function |\@@_tmpa:nnn| and, then, we use
 % the function |\@@_tmpa:nnn| :
 %    \begin{macrocode}
 \cs_new_protected:Nn \@@_draw_arrow:nnn
-           {\exp_args:No \@@_def_function_tmpa:n \l_@@_tikz_code_tl
+           {
+%    \end{macrocode}
+% \medskip
+% If the option |wrap-lines| is used, we have to use a special version of |TikzCode|. Here is the use of
+% |\g_@@_x_right_dim| which has been computed previously with the |v|-nodes.
+%    \begin{macrocode}
+            \bool_if:nT {\l_@@_wrap_lines_bool && ! \l_@@_in_witharrows_bool}
+               {\tl_set:Nn \l_@@_tikz_code_tl
+                  {\draw (##1) to node (@@_label) {} (##2) ;
+                   \tikz at parse@node \pgfutil at firstofone (@@_label.west)
+                   \path (@@_label.west) 
+                    node [anchor = west, 
+                          text~width = \dim_eval:n {\g_@@_x_right_dim - \pgf at x - 0.3333 em}] 
+                    {##3} ; }}
+%    \end{macrocode}
+% |0.3333 em| is the default value of |inner sep| in the nodes of Tikz. Maybe we should put the exact Tikz parameter.
+% \medskip
+% Now, the main lines of this function |\@@_draw_arrow:nnn|.
+%    \begin{macrocode}
+            \exp_args:No \@@_def_function_tmpa:n \l_@@_tikz_code_tl
             \@@_tmpa:nnn {#1} {#2} {#3} }
 \cs_generate_variant:Nn \@@_draw_arrow:nnn {nno}
 %    \end{macrocode}
@@ -3526,7 +3624,7 @@
                              {\sort_return_swapped:}
                              {\sort_return_same:}}
 %    \end{macrocode}
-% We extract the minimum in |\l_tmpa_tl| (it must be a integer but we store it in a token list of \pkg{expl3}).
+% We extract the minimum in |\l_tmpa_tl| (it must be an integer but we store it in a token list of \pkg{expl3}).
 %    \begin{macrocode}
         \clist_pop:NN \g_tmpa_clist \l_tmpa_tl
 %    \end{macrocode}
@@ -3549,16 +3647,25 @@
 % Now, we draw the rest of the structure.
 %    \begin{macrocode}
         \begin{tikzpicture}[@@_standard,every~path/.style={WithArrows/arrow}] 
-          \draw [<->] ($(\l_tmpa_tl-r.south)+(\l_@@_xoffset_dim,0)$) 
-                       -- ++(5mm,0) 
-                       -- node {#2} ($(\l_tmpb_tl-r.south)+(\l_@@_xoffset_dim+5mm,0)$)
-                       -- ($(\l_tmpb_tl-r.south)+(\l_@@_xoffset_dim,0)$)  ;
+          \draw [<->] ([xshift = \l_@@_xoffset_dim]\l_tmpa_tl-r.south)
+                       -- ++(5mm,0)
+                       -- node (@@_label) {} 
+                          ([xshift = \l_@@_xoffset_dim+5mm]\l_tmpb_tl-r.south)
+                       -- ([xshift = \l_@@_xoffset_dim]\l_tmpb_tl-r.south)  ;
+          \tikz at parse@node \pgfutil at firstofone (@@_label.west)
+          \path (@@_label.west) 
+           node [anchor = west, 
+                 text~width = 
+                  {\bool_if:nTF {\l_@@_wrap_lines_bool && ! \l_@@_in_witharrows_bool}
+                                {\dim_eval:n {\g_@@_x_right_dim - \pgf at x - 0.3333 em}}
+                                {20 cm}}
+                ] {#2} ;
         \end{tikzpicture} } }
 
 \cs_new_protected:Nn \@@_MultiArrow_i:n
      {\begin{tikzpicture}[@@_standard,every~path/.style={WithArrows/arrow}] 
         \foreach \k in {#1}
-           {\draw[<-] ($(\k-r.south)+(\l_@@_xoffset_dim,0)$) -- ++(5mm,0) ;} ;
+           {\draw[<-] ([xshift = \l_@@_xoffset_dim]\k-r.south) -- ++(5mm,0) ;} ;
       \end{tikzpicture}}
 %    \end{macrocode}
 %
@@ -3772,6 +3879,125 @@
               environment~level~(this~doesn't~work~if~you~use~cleveref).}
 %    \end{macrocode}
 %
+%
+% \subsection{Environment \{CasesWithArrows\}}
+%
+%    \begin{macrocode}
+\coffin_new:N \l_@@_halign_coffin
+\NewDocumentEnvironment {CasesWithArrows} {m O{}}
+         {\hbox_set:Nn \l_tmpa_box {$\left\{\vcenter to 1cm {} \right.$}
+          \dim_zero_new:N \l_@@_delim_wd_dim
+          \dim_set:Nn \l_@@_delim_wd_dim {\box_wd:N \l_tmpa_box}
+          \box_clear_new:N \l_@@_left_part_box
+          \hbox_set:Nn \l_@@_left_part_box 
+                       {$\bool_if:NT \l_@@_displaystyle_bool \displaystyle #1 {}$}
+          \bool_if:nT \c_@@_mathtools_loaded_bool
+                 {\MH_if_boolean:nT {show_only_refs}
+                    {\MT_showonlyrefs_false:
+                      \MH_set_boolean_T:n {show_only_refs}
+                      \bool_set_true:N \l_@@_notag_bool}}
+           \bool_if:NT \c_@@_amsmath_loaded_bool \intertext@
+           \if_mode_math:
+               \msg_error:nn {witharrows}
+                             {{DispWithArrows}~used~in~math~mode}
+           \fi:
+           \bool_set_false:N \l_@@_in_witharrows_bool
+           %
+           \_@@_pre_environment:n {#2}
+           \nointerlineskip
+           \hbox_to_wd:nn {0.6\linewidth} {}
+           $$
+           \spread at equation
+           \vcoffin_set:Nnw \l_@@_halign_coffin \displaywidth
+              \bool_if:NTF \l_@@_fleqn_bool
+                     {\tabskip = \c_zero_skip}
+                     {\tabskip = 0 pt plus 1000 pt minus 1000 pt}
+              \bool_if:NTF \c_@@_amsmath_loaded_bool
+                 {\cs_set_eq:NN \_@@_old_label \ltx at label}
+                 {\cs_set_eq:NN \_@@_old_label \label}
+              \cs_set:Npn \notag {\msg_error:nnn {witharrows}
+                                                 {Command~not~allowed~in~{DispWithArrows}}
+                                                 {\notag}}
+              \cs_set:Npn \nonumber {\msg_error:nnn {witharrows}
+                                                    {Command~not~allowed~in~{DispWithArrows}}
+                                                    {\nonumber}}
+              \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows}
+                                                   {Command~not~allowed~in~{DispWithArrows}}
+                                                   {\tag}}
+              \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows}
+                                                     {Command~not~allowed~in~{DispWithArrows}}
+                                                     {\label}}
+              \halign to \displaywidth \bgroup
+                \int_gincr:N \g_@@_line_int
+                \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column:
+                \strut
+                \bool_if:NT \l_@@_fleqn_bool
+                      {\skip_horizontal:n \l_@@_mathindent_dim}
+                \hfil
+                \skip_horizontal:n {\box_wd:N \l_@@_left_part_box + \l_@@_delim_wd_dim}
+                $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$
+                \tabskip = \c_zero_skip
+               &
+                \cs_set:Npn \notag {\bool_set_true:N \l_@@_notag_bool}
+                \cs_set_eq:NN \nonumber \notag
+                \cs_set_eq:NN \tag \@@_tag
+                \cs_set_eq:NN \label \@@_label:n
+                $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {{}##}$
+                \tabskip = 0 pt plus 1000 pt minus 1000 pt
+                \int_gincr:N \g_@@_line_bis_int
+                \tikz [remember~picture,overlay]
+                     \node [@@_node_style,
+                            name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l,
+                            alias = {\tl_if_empty:NF \l_@@_name_tl
+                                       {\l_@@_name_tl-\int_use:N\g_@@_line_int-l}} ] {} ;
+                \hfil
+                \tikz [remember~picture,overlay]
+                      \node [@@_node_style,
+                             name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r,
+                             alias = {\tl_if_empty:NF \l_@@_name_tl
+                                        {\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}}
+               & ##
+                \tabskip = \c_zero_skip
+               && \msg_error:nn {witharrows} {Third~column~in~an~environment~{DispWithArrows}}
+                  \if_false: ## \fi:
+                \cr}
+          {   \\
+              \egroup
+              \unskip\unpenalty\unskip\unpenalty 
+              \box_set_to_last:N \l_tmpa_box
+              \nointerlineskip 
+              \box_use:N \l_tmpa_box 
+              \dim_gzero_new:N \g_@@_alignment_dim
+              \dim_gset:Nn \g_@@_alignment_dim {\box_wd:N \l_tmpa_box}
+              \box_clear_new:N \l_@@_new_box
+              \hbox_set:Nn \l_@@_new_box {\hbox_unpack_clear:N \l_tmpa_box} 
+              \dim_compare:nNnT {\box_wd:N \l_@@_new_box} < \g_@@_alignment_dim
+                   {\dim_gset:Nn \g_@@_alignment_dim {\box_wd:N \l_@@_new_box}}
+           \vcoffin_set_end:
+           \hbox_to_wd:nn \displaywidth 
+             {
+              \bool_if:NTF \l_@@_fleqn_bool
+                    {\skip_horizontal:n \l_@@_mathindent_dim}
+                    {\hfil}
+              \hbox_to_wd:nn \g_@@_alignment_dim 
+                   { \box_use_drop:N \l_@@_left_part_box
+                     \dim_set:Nn \l_tmpa_dim {   \box_ht:N \l_@@_halign_coffin
+                                               + \box_dp:N \l_@@_halign_coffin}
+                     $\left\{ \vcenter to \l_tmpa_dim {\vfil} \right.$}
+              \hfil}
+           \coffin_typeset:Nnnnn \l_@@_halign_coffin {l} {vc} {-\displaywidth} \c_zero_dim
+           $$
+           \_@@_post_environment:
+           \bool_if:nT \c_@@_mathtools_loaded_bool
+                    {\MH_if_boolean:nT {show_only_refs}
+                          \MT_showonlyrefs_true:}
+           \ignorespacesafterend
+           }
+%    \end{macrocode}
+%
 % \section{History}
 %
 % \subsection{Changes between versions 1.0 and 1.1}
@@ -3828,7 +4054,7 @@
 %
 % \subsection{Changes between 1.6.1 and 1.7}
 %
-% New environment |{DispWithArrows}|.
+% New environments |{DispWithArrows}| and |{DispWithArrows*}|.
 %
 % \subsection{Changes between 1.7 and 1.8}
 %
@@ -3837,6 +4063,9 @@
 % \pkg{refstyle}, \pkg{typedref} and \pkg{varioref}) and with the options |showonlyrefs| and |showmanualtags| of
 % \pkg{mathtools}.
 %
+% \subsection{Changes between 1.8 and 1.9}
+% 
+% New options |wrap-lines| for the environments |{DispWithArrows}| and |{DispWithArrows*}|.
 % \endinput
 %
 % Local Variables:

Modified: trunk/Master/texmf-dist/tex/latex/witharrows/witharrows.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/witharrows/witharrows.sty	2018-08-17 22:07:02 UTC (rev 48421)
+++ trunk/Master/texmf-dist/tex/latex/witharrows/witharrows.sty	2018-08-17 22:07:14 UTC (rev 48422)
@@ -18,8 +18,8 @@
 %% and version 1.3 or later is part of all distributions of
 %% LaTeX version 2005/12/01 or later.
 %% 
-\def\myfileversion{1.8}
-\def\myfiledate{2018/07/25}
+\def\myfileversion{1.9}
+\def\myfiledate{2018/08/17}
 \RequirePackage{tikz}
 \usetikzlibrary{arrows.meta,bending}
 \RequirePackage{l3keys2e}
@@ -140,6 +140,7 @@
 \bool_new:N \l__wa_fleqn_bool
 \dim_new:N \l__wa_mathindent_dim
 \dim_set:Nn \l__wa_mathindent_dim {25pt}
+\bool_new:N \l__wa_wrap_lines_bool
 \int_set:Nn \l__wa_level_int 1
 \keys_define:nn {WithArrows/GlobalOrEnv}
    {  t   .code:n            = {\bool_if:NTF \l__wa_in_witharrows_bool
@@ -229,7 +230,12 @@
                                                            {Multiple~labels}
                                                            {none}}},
       AllowMultipleLabels .value_forbidden:n = true,
-      fleqn   .default:n = true,
+      wrap-lines   .code:n = {\bool_if:NTF \l__wa_in_witharrows_bool
+                             {\msg_error:nn {witharrows} {Option~will~be~ignored}}
+                             {\tl_if_eq:nnTF {#1} {true}
+                                 {\bool_set_true:N \l__wa_wrap_lines_bool}
+                                 {\bool_set_false:N \l__wa_wrap_lines_bool}}},
+      wrap-lines   .default:n = true,
       unknown .code:n  = \msg_error:nn {witharrows} {Option~unknown}
      }
 \keys_define:nn {WithArrows/General}
@@ -425,7 +431,8 @@
       {\group_align_safe_end:
        \bool_if:NF \l__wa_in_witharrows_bool
            {\bool_if:NTF \l__wa_notag_bool
-                {&}
+                {& \tikz [remember~picture,overlay]
+                   \coordinate [name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-v ]  ; }
                 {
                  \tl_if_empty:NT \l__wa_tag_tl
                     {\int_gincr:N \c at equation}
@@ -452,7 +459,11 @@
                  \bool_gset_eq:NN \g_tmpa_bool \l__wa_tag_star_bool
                  & \cs_set_eq:NN \theequation \g_tmpa_tl
                    \bool_if:NT \g_tmpa_bool {\cs_set:Npn \tagform@ {}}
-                   \hbox_overlap_left:n \@eqnnum
+                   \hbox_overlap_left:n
+                     { \tikz [__wa_standard]
+                          \coordinate [name = \int_use:N \g__wa_line_int-v ]  ;
+                       \quad
+                       \@eqnnum}
              }}
        \cr\noalign{\skip_vertical:n {#1 + \l__wa_interline_skip}
        \scan_stop:}}
@@ -533,6 +544,16 @@
            \egroup
            \egroup
            $$
+           \bool_if:NT \l__wa_wrap_lines_bool
+             {\dim_gzero_new:N \g__wa_x_right_dim
+              \dim_gset:Nn \g__wa_x_right_dim \c_max_dim
+              \begin{tikzpicture} [__wa_standard]
+              \int_step_variable:nnnNn 1 1 \g__wa_line_int \l_tmpa_int
+                    {\tikz at parse@node\pgfutil at firstofone (\l_tmpa_int-v)
+                     \dim_set:Nn \l_tmpa_dim \pgf at x
+                     \dim_compare:nNnT \l_tmpa_dim < \g__wa_x_right_dim
+                            {\dim_gset:Nn \g__wa_x_right_dim \l_tmpa_dim} }
+              \end{tikzpicture}}
            \__wa_post_environment:
            \bool_if:nT \c__wa_mathtools_loaded_bool
                     {\MH_if_boolean:nT {show_only_refs}
@@ -675,7 +696,16 @@
               #1
            \end{tikzpicture}}}
 \cs_new_protected:Nn \__wa_draw_arrow:nnn
-           {\exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl
+           {
+            \bool_if:nT {\l__wa_wrap_lines_bool && ! \l__wa_in_witharrows_bool}
+               {\tl_set:Nn \l__wa_tikz_code_tl
+                  {\draw (##1) to node (__wa_label) {} (##2) ;
+                   \tikz at parse@node \pgfutil at firstofone (__wa_label.west)
+                   \path (__wa_label.west)
+                    node [anchor = west,
+                          text~width = \dim_eval:n {\g__wa_x_right_dim - \pgf at x - 0.3333 em}]
+                    {##3} ; }}
+            \exp_args:No \__wa_def_function_tmpa:n \l__wa_tikz_code_tl
             \__wa_tmpa:nnn {#1} {#2} {#3} }
 \cs_generate_variant:Nn \__wa_draw_arrow:nnn {nno}
 \cs_new_protected:Nn \__wa_update_x_value:nn
@@ -760,16 +790,25 @@
         \clist_pop:NN \g_tmpa_clist \l_tmpb_tl
         \exp_args:Nx \__wa_MultiArrow_i:n {\g_tmpa_clist}
         \begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}]
-          \draw [<->] ($(\l_tmpa_tl-r.south)+(\l__wa_xoffset_dim,0)$)
+          \draw [<->] ([xshift = \l__wa_xoffset_dim]\l_tmpa_tl-r.south)
                        -- ++(5mm,0)
-                       -- node {#2} ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim+5mm,0)$)
-                       -- ($(\l_tmpb_tl-r.south)+(\l__wa_xoffset_dim,0)$)  ;
+                       -- node (__wa_label) {}
+                          ([xshift = \l__wa_xoffset_dim+5mm]\l_tmpb_tl-r.south)
+                       -- ([xshift = \l__wa_xoffset_dim]\l_tmpb_tl-r.south)  ;
+          \tikz at parse@node \pgfutil at firstofone (__wa_label.west)
+          \path (__wa_label.west)
+           node [anchor = west,
+                 text~width =
+                  {\bool_if:nTF {\l__wa_wrap_lines_bool && ! \l__wa_in_witharrows_bool}
+                                {\dim_eval:n {\g__wa_x_right_dim - \pgf at x - 0.3333 em}}
+                                {20 cm}}
+                ] {#2} ;
         \end{tikzpicture} } }
 
 \cs_new_protected:Nn \__wa_MultiArrow_i:n
      {\begin{tikzpicture}[__wa_standard,every~path/.style={WithArrows/arrow}]
         \foreach \k in {#1}
-           {\draw[<-] ($(\k-r.south)+(\l__wa_xoffset_dim,0)$) -- ++(5mm,0) ;} ;
+           {\draw[<-] ([xshift = \l__wa_xoffset_dim]\k-r.south) -- ++(5mm,0) ;} ;
       \end{tikzpicture}}
 \msg_new:nnn {witharrows}
              {Third~column~in~an~environment~{WithArrows}}
@@ -910,6 +949,119 @@
               If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~
               "AllowMultipleLabels"~at~the~global~or~
               environment~level~(this~doesn't~work~if~you~use~cleveref).}
+\coffin_new:N \l__wa_halign_coffin
+\NewDocumentEnvironment {CasesWithArrows} {m O{}}
+         {\hbox_set:Nn \l_tmpa_box {$\left\{\vcenter to 1cm {} \right.$}
+          \dim_zero_new:N \l__wa_delim_wd_dim
+          \dim_set:Nn \l__wa_delim_wd_dim {\box_wd:N \l_tmpa_box}
+          \box_clear_new:N \l__wa_left_part_box
+          \hbox_set:Nn \l__wa_left_part_box
+                       {$\bool_if:NT \l__wa_displaystyle_bool \displaystyle #1 {}$}
+          \bool_if:nT \c__wa_mathtools_loaded_bool
+                 {\MH_if_boolean:nT {show_only_refs}
+                    {\MT_showonlyrefs_false:
+                      \MH_set_boolean_T:n {show_only_refs}
+                      \bool_set_true:N \l__wa_notag_bool}}
+           \bool_if:NT \c__wa_amsmath_loaded_bool \intertext@
+           \if_mode_math:
+               \msg_error:nn {witharrows}
+                             {{DispWithArrows}~used~in~math~mode}
+           \fi:
+           \bool_set_false:N \l__wa_in_witharrows_bool
+           %
+           \__wa_pre_environment:n {#2}
+           \nointerlineskip
+           \hbox_to_wd:nn {0.6\linewidth} {}
+           $$
+           \spread at equation
+           \vcoffin_set:Nnw \l__wa_halign_coffin \displaywidth
+              \bool_if:NTF \l__wa_fleqn_bool
+                     {\tabskip = \c_zero_skip}
+                     {\tabskip = 0 pt plus 1000 pt minus 1000 pt}
+              \bool_if:NTF \c__wa_amsmath_loaded_bool
+                 {\cs_set_eq:NN \__wa_old_label \ltx at label}
+                 {\cs_set_eq:NN \__wa_old_label \label}
+              \cs_set:Npn \notag {\msg_error:nnn {witharrows}
+                                                 {Command~not~allowed~in~{DispWithArrows}}
+                                                 {\notag}}
+              \cs_set:Npn \nonumber {\msg_error:nnn {witharrows}
+                                                    {Command~not~allowed~in~{DispWithArrows}}
+                                                    {\nonumber}}
+              \cs_set:Npn \tag ##1 {\msg_error:nnn {witharrows}
+                                                   {Command~not~allowed~in~{DispWithArrows}}
+                                                   {\tag}}
+              \cs_set:Npn \label ##1 {\msg_error:nnn {witharrows}
+                                                     {Command~not~allowed~in~{DispWithArrows}}
+                                                     {\label}}
+              \halign to \displaywidth \bgroup
+                \int_gincr:N \g__wa_line_int
+                \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow_first_column:
+                \strut
+                \bool_if:NT \l__wa_fleqn_bool
+                      {\skip_horizontal:n \l__wa_mathindent_dim}
+                \hfil
+                \skip_horizontal:n {\box_wd:N \l__wa_left_part_box + \l__wa_delim_wd_dim}
+                $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {##}$
+                \tabskip = \c_zero_skip
+               &
+                \cs_set:Npn \notag {\bool_set_true:N \l__wa_notag_bool}
+                \cs_set_eq:NN \nonumber \notag
+                \cs_set_eq:NN \tag \__wa_tag
+                \cs_set_eq:NN \label \__wa_label:n
+                $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$
+                \tabskip = 0 pt plus 1000 pt minus 1000 pt
+                \int_gincr:N \g__wa_line_bis_int
+                \tikz [remember~picture,overlay]
+                     \node [__wa_node_style,
+                            name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-l,
+                            alias = {\tl_if_empty:NF \l__wa_name_tl
+                                       {\l__wa_name_tl-\int_use:N\g__wa_line_int-l}} ] {} ;
+                \hfil
+                \tikz [remember~picture,overlay]
+                      \node [__wa_node_style,
+                             name = wa-\l__wa_prefix_str-\int_use:N\g__wa_line_int-r,
+                             alias = {\tl_if_empty:NF \l__wa_name_tl
+                                        {\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}}
+               & ##
+                \tabskip = \c_zero_skip
+               && \msg_error:nn {witharrows} {Third~column~in~an~environment~{DispWithArrows}}
+                  \if_false: ## \fi:
+                \cr}
+          {   \\
+              \egroup
+              \unskip\unpenalty\unskip\unpenalty
+              \box_set_to_last:N \l_tmpa_box
+              \nointerlineskip
+              \box_use:N \l_tmpa_box
+              \dim_gzero_new:N \g__wa_alignment_dim
+              \dim_gset:Nn \g__wa_alignment_dim {\box_wd:N \l_tmpa_box}
+              \box_clear_new:N \l__wa_new_box
+              \hbox_set:Nn \l__wa_new_box {\hbox_unpack_clear:N \l_tmpa_box}
+              \dim_compare:nNnT {\box_wd:N \l__wa_new_box} < \g__wa_alignment_dim
+                   {\dim_gset:Nn \g__wa_alignment_dim {\box_wd:N \l__wa_new_box}}
+           \vcoffin_set_end:
+           \hbox_to_wd:nn \displaywidth
+             {
+              \bool_if:NTF \l__wa_fleqn_bool
+                    {\skip_horizontal:n \l__wa_mathindent_dim}
+                    {\hfil}
+              \hbox_to_wd:nn \g__wa_alignment_dim
+                   { \box_use_drop:N \l__wa_left_part_box
+                     \dim_set:Nn \l_tmpa_dim {   \box_ht:N \l__wa_halign_coffin
+                                               + \box_dp:N \l__wa_halign_coffin}
+                     $\left\{ \vcenter to \l_tmpa_dim {\vfil} \right.$}
+              \hfil}
+           \coffin_typeset:Nnnnn \l__wa_halign_coffin {l} {vc} {-\displaywidth} \c_zero_dim
+           $$
+           \__wa_post_environment:
+           \bool_if:nT \c__wa_mathtools_loaded_bool
+                    {\MH_if_boolean:nT {show_only_refs}
+                          \MT_showonlyrefs_true:}
+           \ignorespacesafterend
+           }
 \endinput
 %%
 %% End of file `witharrows.sty'.



More information about the tex-live-commits mailing list