diff options
Diffstat (limited to 'macros/generic/witharrows/witharrows.dtx')
-rw-r--r-- | macros/generic/witharrows/witharrows.dtx | 387 |
1 files changed, 278 insertions, 109 deletions
diff --git a/macros/generic/witharrows/witharrows.dtx b/macros/generic/witharrows/witharrows.dtx index 8dc046bd9d..96fd85f7f6 100644 --- a/macros/generic/witharrows/witharrows.dtx +++ b/macros/generic/witharrows/witharrows.dtx @@ -1,4 +1,4 @@ -% \iffalse meta-comment +%\iffalse meta-comment % % Copyright (C) 2017-2019 by F. Pantigny % ----------------------------------- @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{2.0} -\def\myfiledate{2019/07/30} +\def\myfileversion{2.1} +\def\myfiledate{2019/10/21} % % %<*batchfile> @@ -55,6 +55,7 @@ version 2005/12/01 or later. \usepackage{amssymb} \usepackage[only,llbracket,rrbracket]{stmaryrd} \usepackage{varwidth} +\labelformat{equation}{(#1)} \NewDocumentEnvironment {scope} {} {} {} \def\interitem{\vskip 7mm plus 2 mm minus 3mm} \def\emphase{\bgroup\color{RoyalPurple}\let\next=} @@ -75,13 +76,15 @@ version 2005/12/01 or later. % % \maketitle % -% \hypersetup{ -% pdfinfo = { -% Title = { The extension 'witharrows' }, -% Subject = { A extension for plain-TeX and LaTeX} , -% Author = { F. Pantigny } +% \hypersetup +% { +% pdfinfo = +% { +% Title = { The extension 'witharrows' } , +% Subject = { An extension for plain-TeX and LaTeX} , +% Author = { F. Pantigny } +% } % } -% } % % % \begin{abstract} @@ -93,7 +96,8 @@ 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 @@ -263,7 +267,11 @@ version 2005/12/01 or later. % \interitem % It's possible to use the Tikz option ``|text width|'' to control the width of % the text associated to the arrow.\footnote{It's possible to avoid the -% hyphenations of the words with the option ``|align = flush left|'' of Tikz.} +% hyphenations of the words: use the Tikz option ``|align = flush left|'' in +% LaTeX and ``|align = {flushleft,nothyphenated}|'' in ConTeXt.} +% \newcounter{fnnohyphen} +% \setcounter{fnnohyphen}{\thefootnote} +% % % % \begin{Verbatim} % $\begin{WithArrows} @@ -680,9 +688,10 @@ version 2005/12/01 or later. % \bigskip % In an environment which uses the option |group| or the option |groups|, it's % still possible to give an option of position (|ll|, |lr|, |rl|, |rr| or |i|) -% to an individual arrow. Such arrow will be drawn irrespective of the groups. -% It's also possible to start a new group by applying the option |new-group| to -% an given arrow. +% to an individual arrow\footnote{Such an arrow will be called +% \emph{independent} in the technical documentation}. Such arrow will be drawn +% irrespective of the groups. It's also possible to start a new group by +% applying the option |new-group| to an given arrow. % % \bigskip % If desired, the option |group| or the option |groups| can be given to the @@ -692,11 +701,11 @@ version 2005/12/01 or later. % % % \vspace{1cm} -% In the following example, we have used the option |group| for the environment -% and the option |rr| for the last arrow (that's why the last arrow is not +% In the following example, we have used the option |groups| for the environment +% and the option |new-group| for the last arrow (that's why the last arrow is not % aligned with the others). % -% $\begin{WithArrows}[interline=1mm,group] +% $\begin{WithArrows}[interline=1mm,groups] % \sum\limits_{k=0}^n\frac{\cos kx}{\cos^k x} % & = \sum\limits_{k=0}^n \frac{\Re (e^{ikx})}{(\cos x)^k} % \Arrow{$(\cos x)^k$ is real} \\ @@ -711,7 +720,7 @@ version 2005/12/01 or later. % & = \Re \left(\frac{\frac{\cos^{n+1}x-e^{i(n+1)x}}{\cos^{n+1}x}}{\frac{\cos x-e^{ix}}{\cos x}}\right) % \Arrow{$\Re(kz) = k\cdot\Re(z)$ if $k$ is real} \\ % & = \frac1{\cos^n x}\Re \left(\frac{\cos^{n+1}x-e^{i(n+1)x}}{\cos x-e^{ix}}\right) -% \Arrow[rr]{algebraic form of the complexes} \\ +% \Arrow[new-group]{algebraic form of the complexes} \\ % & =\frac1{\cos^n x}\Re\left(\frac{\cos^{n+1}x-(\cos(n+1)x+i\sin(n+1)x)}{\cos x-(\cos x+i\sin x)}\right) \\ % & =\frac1{\cos^n x}\Re\left(\frac{(\cos^{n+1}x-\cos(n+1)x)-i\sin(n+1)x}{-i\sin x}\right) \\ % & = \frac1{\cos^nx}\cdot\frac{\sin(n+1)x}{\sin x} @@ -996,7 +1005,7 @@ version 2005/12/01 or later. % % \bigskip % 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 : +% environment. For example, one may want to draw the following arrow :\par\nobreak % % \bigskip % $\begin{WithArrows}[code-after = \Arrow[v]{1-2}{2-2}{division by $2$} ] @@ -1209,7 +1218,7 @@ version 2005/12/01 or later. % \begin{itemize} % \item the command |\WithArrowsLastEnv| gives the number of the last % environment of level~$0$ (\emph{i.e.} which is not included in another -% environnment of the package \pkg{witharrows}); +% environment of the package \pkg{witharrows}); % % \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 @@ -1362,12 +1371,13 @@ version 2005/12/01 or later. % A & = (a+1)^2 \Arrow{we expand} \notag \\ % & = a^2 + 2a + 1 \tag{$\star$} \label{my-equation} % \end{DispWithArrows} -% A link to the equation \eqref{my-equation}. This link has been composed with -% |\eqref{my-equation}| (the command |\eqref| is a command of \pkg{amsmath}). +% A link to the equation \ref{my-equation}.\footnote{In this document, the +% references has been customized with |\labelformat{equation}{(#1)}|} +% % % \medskip % If \pkg{amsmath} (or \pkg{mathtools}) is loaded, it's also possible to use -% |\tag*| which, as in \pkg{amsmath}, typesets the tag without the parenthesis. +% |\tag*| which, as in \pkg{amsmath}, typesets the tag without the parentheses. % For example, it's possible to use it to put the symbol |\square| of % \pkg{amssymb}. This symbol is often used to mark the end of a % proof.\footnote{Notice that the environment |{DispWithArrows}| is compatible @@ -1502,7 +1512,7 @@ version 2005/12/01 or later. % \begin{DispWithArrows}[displaystyle] % S_{2(p+1)} % & =\sum_{k=1}^{2(p+1)} (-1)^k k^2 \\ -% & \smash[b]{=\sum_{k=1}^{2p}(-1)^kk˛ +% & \smash[b]{=\sum_{k=1}^{2p}(-1)^kk % +(-1)^{2p+1}(2p+1)^2+(-1)^{2p+2}(2p+2)^2} ~emphase#\tagnextline@ \\ % &= S_{2p}-(2p+1)^2+(2p+2)^2\\ % &=p(2p+1)-(2p+1)^2+(2p+2)^2\\ @@ -1530,8 +1540,7 @@ version 2005/12/01 or later. % \bigskip % The environments |{DispWithArrows}| and |{DispWithArrows*}| provide an option % |wrap-lines|. With this option, the lines of the label are automatically -% wrapped on the right.\footnote{It's possible to avoid the hyphenations of the -% words with the option ``|align = flush left|'' of Tikz.}\label{wrap-lines} +% wrapped on the right.\footnotemark[\thefnnohyphen]\label{wrap-lines} % % \begin{Verbatim} % \begin{DispWithArrows*}[displaystyle,~emphase#wrap-lines@] @@ -1626,7 +1635,7 @@ version 2005/12/01 or later. % % \bigskip % Concerning the references, the package \pkg{witharrows} is compatible with the -% extensions \pkg{autonum}, \pkg{cleveref}, \pkg{fancyref}, \pkg{fncylab}, +% extensions \pkg{autonum}, \pkg{cleveref}, \pkg{fancyref}, % \pkg{hyperref}, \pkg{listlbls}, \pkg{prettyref}, \pkg{refcheck}, % \pkg{refstyle}, \pkg{showlabels}, \pkg{smartref}, \pkg{typedref} and % \pkg{varioref}, and with the options |showonlyrefs| and |showmanualtags| of @@ -1700,9 +1709,9 @@ version 2005/12/01 or later. % % \bigskip % The whole system is the equation \eqref{system} (this reference has been coded -% by |\eqref{system}|) whereas the last equation is the equation -% \eqref{last-equation} (this reference has been coded by -% |\eqref{last-equation}|). The command |\ref*| used in the code above is +% by |\ref{system}|) whereas the last equation is the equation +% \ref{last-equation} (this reference has been coded by +% |\ref{last-equation}|). The command |\ref*| used in the code above is % provided by \pkg{hyperref}. It's a variant of |\ref| which doesn't create % interactive link. % @@ -1721,13 +1730,13 @@ version 2005/12/01 or later. % The extension \pkg{witharrows} can be used with plain-TeX. In this case, the % extension must be loaded with |\input|: % \begin{Verbatim} -% \input{witharrows.tex} +% \input{witharrows} % \end{Verbatim} % % \medskip % In plain-TeX, there is not environments as in LaTeX. Instead of using the % environment |{Witharrows}|, with |\begin{WithArrows}| and |\end{WithArrows}|, -% one should use a pseudo-environnement delimited by |\WithArrows| and +% one should use a pseudo-environment delimited by |\WithArrows| and % |\endWithArrows| (idem for |{DispWithArrows}|). % % \begin{Verbatim} @@ -1916,14 +1925,71 @@ version 2005/12/01 or later. % It's also possible to use the option |adjust| which sets both |start-adjust| % and |end-ajust|. % -% \bigskip -% Since the mechanism of |start-adjust| and |end-ajust| has been added in -% version 1.13 of \pkg{witharrows}, that version is not stricty compatible with -% older versions. However, it's possible to restore the previous behaviour -% simply by setting |start-adjust| and |end-adjust| to $0$~pt: +% \interitem +% Since the version 2.1 of \pkg{witharrows}, an arrow of |jump| equal to~$1$ has +% a maximal length\footnote{We call \emph{length} of an arrow the difference +% between the $y$-value of its start point and the $y$~value of its end point.} +% equal to the parameter |max-length-of-arrow|. The default value of this +% parameter est $2$~cm. +% +% In the following example, the value of |max-length-of-arrow| has been fixed to +% $1.5$~cm. % \begin{Verbatim} -% \WithArrowsOptions{adjust = 0pt} +% \[\begin{WithArrows}[~emphase#max-length-of-arrow = 1.5cm@] +% A +% & = +% \begin{vmatrix} +% 1 & a & a^2 & a^3 & a^4 \\ +% 1 & b & b^2 & b^3 & b^4 \\ +% 1 & c & c^2 & c^3 & c^4 \\ +% 1 & d & d^2 & d^3 & d^4 \\ +% 1 & e & e^2 & e^3 & e^4 +% \end{vmatrix} +% \Arrow{ +% $L_2 \gets L_2-L_1$ \\ +% $L_3 \gets L_3-L_1$ \\ +% $L_4 \gets L_4-L_1$ \\ +% $L_5 \gets L_5-L_1$ % don't put \\ ici +% } \\ +% & = +% \begin{vmatrix} +% 1 & a & a^2 & a^3 & a^4 \\ +% 0 & b-a & b^2-a^2 & b^3-a^3 & b^4-a^4 \\ +% 0 & c-a & c^2-a^2 & c^3-a^3 & c^4-a^4 \\ +% 0 & d-a & d^2-a^2 & d^3-a^3 & d^4-a^4 \\ +% 0 & e-a & e^2-a^2 & e^3-a^3 & e^4-a^4 +% \end{vmatrix} +% \end{WithArrows}\] % \end{Verbatim} +% +% +% \bigskip +% \[\begin{WithArrows}[max-length-of-arrow = 1.5cm] +% A +% & = +% \begin{vmatrix} +% 1 & a & a^2 & a^3 & a^4 \\ +% 1 & b & b^2 & b^3 & b^4 \\ +% 1 & c & c^2 & c^3 & c^4 \\ +% 1 & d & d^2 & d^3 & d^4 \\ +% 1 & e & e^2 & e^3 & e^4 +% \end{vmatrix} +% \Arrow{ +% $L_2 \gets L_2-L_1$ \\ +% $L_3 \gets L_3-L_1$ \\ +% $L_4 \gets L_4-L_1$ \\ +% $L_5 \gets L_5-L_1$ +% } \\ +% & = +% \begin{vmatrix} +% 1 & a & a^2 & a^3 & a^4 \\ +% 0 & b-a & b^2-a^2 & b^3-a^3 & b^4-a^4 \\ +% 0 & c-a & c^2-a^2 & c^3-a^3 & c^4-a^4 \\ +% 0 & d-a & d^2-a^2 & d^3-a^3 & d^4-a^4 \\ +% 0 & e-a & e^2-a^2 & e^3-a^3 & e^4-a^4 +% \end{vmatrix} +% \end{WithArrows}\] +% % % \bigskip % \subsection{Footnotes in the environments of witharrows} @@ -2326,7 +2392,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 to have, for -% example, numbers in parenthesis, the best way is to change the value of +% example, numbers in round brackets, the best way is to change the value of % |tikz-code|: % % \begin{Verbatim} @@ -2436,7 +2502,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_msg_redirect_name:nn { \msg_redirect_name:nnn { witharrows } } \cs_new_protected:Npn \@@_error:n { \msg_error:nn { witharrows } } -\cs_new_protected:Npn \@@_warning:n { \msg_error:nn { witharrows } } +\cs_new_protected:Npn \@@_warning:n { \msg_warning:nn { witharrows } } \cs_new_protected:Npn \@@_fatal:n { \msg_fatal:nn { witharrows } } \cs_new_protected:Npn \@@_error:nn { \msg_error:nnn { witharrows } } \cs_generate_variant:Nn \@@_error:nn { n x } @@ -2533,7 +2599,7 @@ version 2005/12/01 or later. } % \end{macrocode} % The flag |\g_@@_footnote_bool| is raised and so, we will only have to test -% |\g_@@_footnote_bool| in order to know if we have to insert an environnement +% |\g_@@_footnote_bool| in order to know if we have to insert an environment % |{savenotes}| (the |\begin{savenotes}| is in |\@@_pre_halign:n| and % |\end{savenotes}| at the end of the environments |{WithArrows}| and % |{DispWithArrows}|). @@ -2607,7 +2673,7 @@ version 2005/12/01 or later. } { \cs_new_protected:Npn \@@_strcmp:nn #1 #2 - { \pdftex_strcmp:D { #1 } { #2 } } + { \tex_strcmp:D { #1 } { #2 } } } % \end{macrocode} % @@ -3062,6 +3128,9 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { WithArrows / Global } { + max-length-of-arrow .dim_set:N = \l_@@_max_length_of_arrow_dim , + max-length-of-arrow .value_required:n = true , + max-length-of-arrow .initial:n = 2 cm , ygap .dim_set:N = \l_@@_ygap_dim , ygap .value_required:n = true , ygap .initial:n = 0.4 ex , @@ -3342,7 +3411,7 @@ version 2005/12/01 or later. displaystyle, end-adjust, format, group, groups, i, interline, jot, ll, - lr, more-columns, name, + lr, max-length-of-arrow, more-columns, name, no-arrows, rl, rr, show-node-names, show-nodes, start-adjust, t, tikz, tikz-code, @@ -3381,9 +3450,9 @@ version 2005/12/01 or later. { code-after, code-before, command-name, tikz-code, adjust, displaystyle, end-adjust, fleqn, group, format, groups, i, interline, jot, - left-brace, ll, lr, mathindent, name, no-arrows, replace-left-brace-by, rl, - rr, show-node-names, show-nodes, start-adjust, tikz, wrap-lines, xoffset, - ygap, ystart, + left-brace, ll, lr, max-length-of-arrow, mathindent, name, no-arrows, + replace-left-brace-by, rl, rr, show-node-names, show-nodes, start-adjust, + tikz, wrap-lines, xoffset, ygap, ystart, %<*LaTeX>> allow-multiple-labels, tagged-lines, nonumber, notag %</LaTeX> @@ -3413,8 +3482,8 @@ version 2005/12/01 or later. { allow-duplicate-names, b, c, command-name, more-columns, tikz-code, adjust, displaystyle, end-adjust, fleqn, group, groups, i, interline, jot, ll, lr, - mathindent, no-arrows, rl, rr, show-node-names, show-nodes, start-adjust, t, - tikz, wrap-lines, xoffset, ygap, ystart, + mathindent, max-length-of-arrow, no-arrows, rl, rr, show-node-names, + show-nodes, start-adjust, t, tikz, wrap-lines, xoffset, ygap, ystart, %<*LaTeX>> allow-multiple-labels, nonumber, notag, standard-behaviour-with-items, tagged-lines @@ -3485,28 +3554,19 @@ version 2005/12/01 or later. tikz-code .value_required:n = true , tikz .code:n = \prg_do_nothing: , tikz .value_required:n = true , -% \end{macrocode} -% -% \medskip -% The option |xoffset| is not allowed when the option |group| or the option -% |groups| is used (since it would be meaningless). -% \begin{macrocode} - xoffset .code:n = - \int_compare:nNnT \l_@@_pos_arrow_int > 5 - { \@@_error:n { Option~xoffset~forbidden } } , - xoffset .value_required:n = true , start-adjust .code:n = \prg_do_nothing: , start-adjust .value_required:n = true , end-adjust .code:n = \prg_do_nothing: , end-adjust .value_required:n = true , adjust .code:n = \prg_do_nothing: , adjust .value_required:n = true , + xoffset .code:n = , unknown .code:n = \@@_sort_seq:N \l_@@_options_Arrow_seq \seq_if_in:NVTF \l_@@_options_WithArrows_seq \l_keys_key_tl { \str_set:Nn \l_tmpa_str - { ~However,~this~key~can~be~used~in~the~options~of~\{WithArrows\}. } + { ~However,~this~key~can~be~used~in~the~options~of~{WithArrows}. } } { \str_clear:N \l_tmpa_str } \@@_error:n { Unknown~option~in~Arrow } @@ -3558,15 +3618,23 @@ version 2005/12/01 or later. i .code:n = \@@_fix_pos_arrow:n 5 , % \end{macrocode} % -% \medskip -% The option |xoffset| is not allowed when the option |group| or the option -% |groups| is used (since it would be meaningless). An error has been raised -% during the first pass. Here, we manage to avoid a second error which -% would be redundant. +% \medskip +% The option |xoffset| is not allowed when the option |group| or the option +% |groups| is used except, if the arrow is independent or if there is only one +% arrow. % \begin{macrocode} xoffset .code:n = - \int_compare:nNnF \l_@@_pos_arrow_int > 5 + \bool_if:nTF + { + \int_compare_p:nNn \g_@@_arrow_int > 1 + && + \int_compare_p:nNn \l_@@_pos_arrow_int > 5 + && + ! \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } + } + { \@@_error:n { Option~xoffset~forbidden } } { \dim_set:Nn \l_@@_xoffset_dim { #1 } } , + xoffset .value_required:n = true , start-adjust .dim_set:N = \l_@@_start_adjust_dim, end-adjust .dim_set:N = \l_@@_end_adjust_dim, adjust .code:n = @@ -3733,7 +3801,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_pre_halign:n #1 % \end{macrocode} % -% First, the initialisation of |\l_@@_type_env_str| which is the name of the +% First, the initialization of |\l_@@_type_env_str| which is the name of the % encompassing environment. In fact, this token list is used only in the error % messages. % \begin{macrocode} @@ -3781,14 +3849,14 @@ 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 a arrow impossible +% 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). % \begin{macrocode} \str_clear_new:N \l_@@_input_line_str % \end{macrocode} % % -% The initialisation of the counters |\g_@@_arrow_int|, |\g_@@_line_int| and +% The initialization of the counters |\g_@@_arrow_int|, |\g_@@_line_int| and % |\g_@@_col_int|. However, we have to save their previous values with the % stacks created for this end. % \begin{macrocode} @@ -4314,7 +4382,20 @@ version 2005/12/01 or later. % \bigskip % It there is really arrows in the environment, we draw the arrows. % \begin{macrocode} - \int_compare:nNnT \g_@@_arrow_int > 0 \@@_scan_arrows: + \int_compare:nNnT \g_@@_arrow_int > 0 + { +% \end{macrocode} +% If there is only one arrow, the options |group| and |groups| do not really +% make sense and it will be quicker to act as if we were in option |i| (moreover, +% it allows the option |xoffset| for the unique arrow). +% \begin{macrocode} + \int_compare:nNnT \g_@@_arrow_int = 1 + { + \int_compare:nNnT \l_@@_pos_arrow_int > 5 + { \int_set:Nn \l_@@_pos_arrow_int 5 } + } + \@@_scan_arrows: + } % \end{macrocode} % % \bigskip @@ -4491,8 +4572,7 @@ version 2005/12/01 or later. % |\refstepcounter| done by some packages (the incrementation of the counter has % been done yet). % -% First an action which is in the definition of |\refstepcounter|. The command -% |\p@equation| is redefined by some extensions like \pkg{fncylab}. +% First an action which is in the definition of |\refstepcounter|. % \begin{macrocode} \cs_set:Npx \@currentlabel { \p@equation \g_tmpa_tl } % \end{macrocode} @@ -4618,7 +4698,13 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_analyze_end:Nn #1 #2 { \exp_args:NV \str_if_eq:nnT \l_@@_type_env_str { #2 } - { \@@_warning:n { newline~at~the~end~of~env } } + { + \@@_warning:n { newline~at~the~end~of~env } + \group_begin: + \globaldefs = 1 + \@@_msg_redirect_name:nn { newline~at~the~end~of~env } { none } + \group_end: + } % \end{macrocode} % We reput in the stream the |\end{...}| we have extracted. % \begin{macrocode} @@ -5069,9 +5155,9 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \bigskip -% The command |\@@_notag:| will be linked to the command |\notag| and also to -% in the environments |{WithArrows}| and |{DispWithArrows}|. +% \bigskip +% The command |\@@_notag:| will be linked to the command |\notag| in +% the environments |{WithArrows}| and |{DispWithArrows}|. % \begin{macrocode} %<*LaTeX> \cs_new_protected:Npn \@@_notag: @@ -5079,7 +5165,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The command |\@@_nonumber:| will be linked to the command |\nonumber| and also to +% The command |\@@_nonumber:| will be linked to the command |\nonumber| % in the environments |{WithArrows}| and |{DispWithArrows}|. % \begin{macrocode} \cs_new_protected:Npn \@@_nonumber: @@ -5276,7 +5362,7 @@ version 2005/12/01 or later. % \medskip % The boolean |\l_@@_new_group_bool| is a switch that we will use the indicate % that a group is finished (and the lines of that group have to be drawn). This -% boolean is not directed connected to the option |new-group| of an individual +% boolean is not directly connected to the option |new-group| of an individual % arrow. % \begin{macrocode} \bool_set_true:N \l_@@_new_group_bool @@ -5432,7 +5518,7 @@ version 2005/12/01 or later. { \str_if_eq_p:Vn \l_@@_status_arrow_str { independent } } { % \end{macrocode} -% If the arrow is not independant, the arrow belongs to the current group and we +% If the arrow is not independent, the arrow belongs to the current group and we % have to take it into account in some variables. % \begin{macrocode} \int_compare:nT @@ -5667,6 +5753,10 @@ version 2005/12/01 or later. % \end{itemize} % % \begin{macrocode} + \dim_gzero_new:N \g_@@_x_initial_dim + \dim_gzero_new:N \g_@@_x_final_dim + \dim_gzero_new:N \g_@@_y_initial_dim + \dim_gzero_new:N \g_@@_y_final_dim %<*LaTeX> \begin { tikzpicture } [ @@_standard ] %</LaTeX> @@ -5674,31 +5764,67 @@ version 2005/12/01 or later. \tikzpicture [ @@_standard ] %</plain-TeX> \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_initial_tl ) - \tl_gset:Nx \g_tmpa_tl - { - \int_compare:nNnTF \l_@@_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l_@@_x_dim } , - \bool_if:NTF \l_tmpa_bool - { \dim_eval:n { \pgf@y + \l_@@_start_adjust_dim } } - { \dim_use:N \pgf@y } - } + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_y_initial_dim \pgf@y \tikz@scan@one@point \pgfutil@firstofone ( \l_@@_final_tl ) - \tl_gset:Nx \g_tmpb_tl - { - \int_compare:nNnTF \l_@@_pos_arrow_int < 5 - { \dim_use:N \pgf@x } - { \dim_use:N \l_@@_x_dim } , - \bool_if:NTF \l_tmpb_bool - { \dim_eval:n { \pgf@y - \l_@@_end_adjust_dim } } - { \dim_use:N \pgf@y } - } + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \dim_gset:Nn \g_@@_y_final_dim \pgf@y %<*LaTeX> \end { tikzpicture } %</LaTeX> %<*plain-TeX> \endtikzpicture %</plain-TeX> + \bool_if:nTF + { \dim_compare_p:nNn { \g_@@_y_initial_dim - \g_@@_y_final_dim } + > \l_@@_max_length_of_arrow_dim + && + \int_compare_p:nNn { \l_@@_final_int - \l_@@_initial_int } = 1 + } + { + \tl_gset:Nx \g_tmpa_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \g_@@_x_initial_dim } + { \dim_use:N \l_@@_x_dim } , + \dim_eval:n + { + ( \g_@@_y_initial_dim + \g_@@_y_final_dim ) / 2 + + ( \l_@@_max_length_of_arrow_dim / 2 ) + } + } + \tl_gset:Nx \g_tmpb_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \g_@@_x_final_dim } + { \dim_use:N \l_@@_x_dim } , + \dim_eval:n + { + ( \g_@@_y_initial_dim + \g_@@_y_final_dim ) / 2 + - ( \l_@@_max_length_of_arrow_dim / 2 ) + } + } + } + { + \tl_gset:Nx \g_tmpa_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \g_@@_x_initial_dim } + { \dim_use:N \l_@@_x_dim } , + \bool_if:NTF \l_tmpa_bool + { \dim_eval:n { \g_@@_y_initial_dim + \l_@@_start_adjust_dim } } + { \dim_use:N \g_@@_y_initial_dim } + } + \tl_gset:Nx \g_tmpb_tl + { + \int_compare:nNnTF \l_@@_pos_arrow_int < 5 + { \dim_use:N \g_@@_x_final_dim } + { \dim_use:N \l_@@_x_dim } , + \bool_if:NTF \l_tmpb_bool + { \dim_eval:n { \g_@@_y_final_dim - \l_@@_end_adjust_dim } } + { \dim_use:N \g_@@_y_final_dim } + } + } % \end{macrocode} % % \bigskip @@ -5963,7 +6089,7 @@ version 2005/12/01 or later. 3 { \bool_set_true:N \l_@@_final_r_bool } } % \end{macrocode} -% We prevent drawing a arrow from a line to itself. +% We prevent drawing an arrow from a line to itself. % \begin{macrocode} \tl_if_eq:nnTF { #2 } { #3 } { \@@_error:nn { Both~lines~are~equal } { #2 } } @@ -6045,16 +6171,32 @@ version 2005/12/01 or later. % \end{macrocode} % The user of the command |\MultiArrow| (in |code-after|) will be able to specify % the list of lines with the same syntax as the loop |\foreach| of \pkg{pgffor}. +% First, we test with a regular expression whether the format of the list of +% lines is correct. +% \begin{macrocode} + \exp_args:Nnx + \regex_match:nnTF + { \A \d+ (\,\d+)* ( \, \.\.\. (\,\d+)+ )* \Z } + { #1 } + { \@@_MultiArrow_i:nn { #1 } { #2 } } + { \@@_error:nx { Invalid~specification~for~MultiArrow } { #1 } } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_MultiArrow_i:nn #1 #2 + { +% \end{macrocode} % That's why we construct a ``clist'' of \pkg{expl3} from the specification of % list given by the user. The construction of the ``clist'' must be global in -% order to exit the |\foreach| and that's why we construct the list in +% order to exit the |\foreach| and that's why we will construct the list in % |\g_tmpa_clist|. % \begin{macrocode} - \foreach \x in { #1 } + \foreach \x in { #1 } { \cs_if_free:cTF { pgf@sh@ns@wa - \l_@@_prefix_str - \x - l } - { \@@_error:nx { Wrong~line~specification~in~MultiArrow } \x } - { \clist_gput_right:Nx \g_tmpa_clist \x } + { \@@_error:nx { 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 @@ -6221,8 +6363,8 @@ version 2005/12/01 or later. %<*LaTeX> \@@_msg_new:nn { newline~at~the~end~of~env } { - Your~environment~\{\l_@@_type_env_str\}~should~not~end~with~ - a~\token_to_str:N \\.\\ + The~environments~of~witharrows~(\{WithArrows\}~and~ + \{DispWithArrows\})~should~not~end~by~\token_to_str:N \\.\\ This~warning~might~become~an~error~in~a~future~version. } %</LaTeX> @@ -6542,15 +6684,23 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% The following error when the user tries to use the option |xoffset| in mode +% |group| or |groups| (in fact, it's possible to use the option |xoffset| if +% there is only \emph{one} arrow: of course, the option |group| and |groups| do +% not make sense in this case but, maybe, the option was set in a +% |\WithArrowsOptions|). % \begin{macrocode} \@@_msg_new:nn { Option~xoffset~forbidden } { You~can't~use~the~option~'xoffset'~in~the~command~ - \l_@@_string_Arrow_for_msg_str\ - while~you~are~using~the~option~ + \l_@@_string_Arrow_for_msg_str\ in~the~row~\int_use:N \g_@@_line_int\ + of~your~environment~\{\l_@@_type_env_str\}~ + because~you~are~using~the~option~ ' \int_compare:nNnTF \l_@@_pos_arrow_int = 7 { group } - { groups } '. \\ + { groups } '.~It's~possible~for~an~independent~arrow~or~if~there~is~ + only~one~arrow. \\ \c_@@_option_ignored_str } % \end{macrocode} @@ -6783,6 +6933,16 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { Invalid~specification~for~MultiArrow } + { + The~specification~of~rows~for~\token_to_str:N\MultiArrow\ + (i.e.~#1)~is~invalid. \\ + \c_@@_command_ignored_str + } +% \end{macrocode} +% +% +% \begin{macrocode} %<*plain-TeX> \catcode `\@ = 12 \ExplSyntaxOff @@ -6949,7 +7109,7 @@ version 2005/12/01 or later. % % \subsection*{Changes between 1.16 and 1.17} % -% Option |format| +% Option |format|. % % \subsection*{Changes between 1.17 and 1.18} % @@ -6959,19 +7119,28 @@ version 2005/12/01 or later. % % Warning when |{WithArrows}| or |{DispWithArrows}| ends by "\\". % -% No space before an environnement |{DispWithArrows}| if we are at the beginning +% No space before an environment |{DispWithArrows}| if we are at the beginning % of a |{minipage}|. % % \subsection*{Changes between 1.18 and 2.0} % % A version of \pkg{witharrows} is available for plain-TeX. % +% +% \subsection*{Changes between 2.0 and 2.1 } +% +% Option |max-length-of-arrow|. +% +% Validation with regular expression for the first argument of |\MultiArrow|. +% % \PrintIndex % % \tableofcontents % % \endinput % Local Variables: -% TeX-fold-mode: nil +% TeX-fold-mode: t +% TeX-fold-preserve-comments: nil % fill-column: 80 +% ispell-local-dictionary: english % End: |