diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-11 23:31:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-11 23:31:00 +0000 |
commit | 2e87389219b9749fadf9591d512cb69389c234eb (patch) | |
tree | a50a55aa87a75dd72bfa1cddb98156d62d955e65 | |
parent | 6798007834a9b1da2b42939f9408a4a46391ca7f (diff) |
witharrows (12jan18)
git-svn-id: svn://tug.org/texlive/trunk@46286 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/witharrows/witharrows.pdf | bin | 220037 -> 226378 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/witharrows/witharrows.dtx | 305 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/witharrows/witharrows.sty | 166 |
3 files changed, 306 insertions, 165 deletions
diff --git a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf Binary files differindex 583cc1dc849..feb137d799c 100644 --- a/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf +++ b/Master/texmf-dist/doc/latex/witharrows/witharrows.pdf diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx index 5dd68ff86ab..0af363d1b94 100644 --- a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx +++ b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{1.2} -\def\myfiledate{2017/11/29} +\def\myfileversion{1.3} +\def\myfiledate{2018/01/11} % % %<*batchfile> @@ -80,12 +80,13 @@ version 2005/12/01 or later. % \end{abstract} % % -% \vskip1cm +% \vskip1cm % This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by the classical workflow % |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two compilations may be necessary. This package requires the % packages \pkg{expl3}, \pkg{xparse}, \pkg{footnote}\footnote{The package footnote is used to extract the notes -% from the environments \texttt{\{WithArrows\}}.} and \pkg{tikz}. The following Tikz libraries are also required: -% \pkg{calc}, \pkg{arrows.meta} and \pkg{bending}. +% from the environments \texttt{\{WithArrows\}}. This package must be loaded \emph{after} the package +% \pkg{xcolor}.} and \pkg{tikz}. The following Tikz libraries are also required: \pkg{calc}, \pkg{arrows.meta} and +% \pkg{bending}. % % \bigskip % This package gives an environment |{WithArrows}| to construct alignments of equations with arrows for the @@ -105,8 +106,8 @@ version 2005/12/01 or later. % % % \medskip -% The arrow has been drawn with the command |\Arrow| on the line from which it starts. The command |\Arrow| can be -% used anywhere on the line but the best way is to put it at the end. +% The arrow has been drawn with the command |\Arrow| on the line from which it starts. The command |\Arrow| must be used +% in the second column (the best way is to put it at the end of the second cell of the line as in the previous exemple). % % % \section{Options for the shape of the arrows} @@ -115,14 +116,14 @@ version 2005/12/01 or later. % mandatory argument. % % The option |jump| gives the number\footnote{It's not possible to give a non-positive value to \texttt{jump}. See -% below the way to draw an arrow which goes backwards.} of lines the arrow must jump (the default value is, of -% course,~$1$). +% below (p.~\pageref{Backwards}) the way to draw an arrow which goes backwards.} of lines the arrow must jump (the +% default value is, of course,~$1$). % % % \begin{Verbatim} % $\begin{WithArrows} % A & = \bigl((a+b)+1\bigr)^2 \Arrow[~emphase#jump=2@]{we expand} \\ -% & = (a+b)^2 + 2(a+b) +1 \\ +% & = (a+b)^2 + 2(a+b) +1 \\ % & = a^2 + 2ab + b^2 + 2a + 2b +1 % \end{WithArrows}$ % \end{Verbatim} @@ -192,7 +193,8 @@ version 2005/12/01 or later. % \interitem % It's also possible to change the arrowheads. For example, we can draw an arrow which goes backwards with the Tikz % option~|<-|. -% % +% \label{Backwards} +% % \begin{Verbatim} % $\begin{WithArrows} % A & = (a+1)^2 \Arrow~emphase#[tikz=<-]@{we factorize} \\ @@ -424,14 +426,17 @@ version 2005/12/01 or later. % \tikzset{TipsOfWithArrows/.style= { > = {Latex[scale=1.2,bend]}} } % \end{Verbatim} % -% The names of the Tikz nodes created by \pkg{witharrows} in the whole document are explained below. +% The names of the Tikz nodes created by \pkg{witharrows} in the whole document are explained +% p.~\pageref{NamesOfTheNodes}. % % % \section{Precise positioning of the arrows} % % % The environment |{WithArrows}| defines, during the composition of the array, two series of nodes materialized in -% red in the following example.\footnote{The option \texttt{shownodes} can be used to materialize the nodes.} +% red in the following example.\footnote{The option \texttt{shownodes} can be used to materialize the nodes. The +% nodes are in fact Tikz nodes of shape ``rectangle'', but with zero width. An arrow between two nodes starts at +% the \emph{south} anchor of the first node and arrives at the \emph{north} anchor of the second node.} % % \smallskip % $\begin{WithArrows}[displaystyle,shownodes] @@ -549,9 +554,8 @@ version 2005/12/01 or later. % the default value. In this case, it's still possible to come back to the default behaviour for a given % environment |{WithArrows}| with the option |rr|: |\begin{WithArrows}{rr}| % -% \section{Comparison with the environment \{aligned\}} -% % +% \section{Comparison with the environment \{aligned\}} % % |{WithArrows}| bears similarities with the environment |{aligned}| of the extension \pkg{amsmath}. These are only % similarities because |{WithArrows}| has not been written upon the environment |{aligned}|.\footnote{In fact, it's @@ -591,12 +595,14 @@ version 2005/12/01 or later. % \end{WithArrows}$ % \end{Verbatim} % +% % $\begin{WithArrows}[displaystyle,jot=2ex] % F & = \frac12G \Arrow{we expand}\\ % & = H + \frac12K \Arrow{we go on}\\ % & = K % \end{WithArrows}$ % +% % \bigskip % However, this new value of |\jot| will also be used in other alignments included in the % environment~|{WithArrows}|: @@ -735,8 +741,6 @@ version 2005/12/01 or later. % \right.$ % % -% -% % \section{Examples} % % \subsection{With only one column} @@ -761,7 +765,7 @@ version 2005/12/01 or later. % % \subsection{MoveEqLeft} % -% It's possible to use |\MoveEqLeft| of \pkg{mathtools} (if we don't want ampersand on the firt line): +% It's possible to use |\MoveEqLeft| of \pkg{mathtools} (if we don't want ampersand on the first line): % % % \begin{Verbatim}[formatcom=\small\color{gray}] % $\begin{WithArrows}[jot=2mm] @@ -902,8 +906,50 @@ version 2005/12/01 or later. % \end{scope} % % +% +%\section{Fine tuning} +% +% The version 1.3 of \pkg{witharrows} give two new options for a fine tuning of the arrows : +% +% \begin{itemize} +% \item the option |ystart| set the vertical distance between the base line of the text and the start of the arrow +% (default value : 0.4 ex). +% \item the option |ygap| set the vertical distance between two consecutive arrows (default value : 0.4 ex). +% \end{itemize} +% +% These options can be set at the document level or at the environment level. +% +% \bigskip +% $\begin{WithArrows}[interline=1mm] +% (\cos x + \sin x)^2 & = \cos^2 x +2 \cos x \sin x + \sin^2 x\Arrow{}\tikz[remember picture] \coordinate (A) ; \\ +% & = \cos^2x + \sin^2x + 2\sin x\cos x \Arrow{} \\ +% & = 1 + \sin(2x) +% \end{WithArrows}$ +% +% \begin{tikzpicture}[remember picture,overlay,blue] +% \draw (wa-\WithArrowsLastEnv-1-r.south) to ++(1,0) coordinate (B) to ++(0.1,0) ;; +% \draw (A) to ++(1,0) coordinate (C) to ++(0.1,0) ;; +% \draw (B) -- (C) ; +% \draw[<-] (B) to ++(0,0.2) ; +% \draw[<-] (C) to ++(0,-0.2) ; +% \path (C) node[right=1mm] {\texttt{ystart}} ; +% \draw (wa-\WithArrowsLastEnv-2-r.north) to ++(3,0) coordinate (E) to ++(0.1,0); +% \draw (wa-\WithArrowsLastEnv-2-r.south) to ++(3,0) coordinate (F) to ++(0.1,0); +% \draw (E) -- (F) ; +% \draw[<-] (E) to ++(0,0.2) ; +% \draw[<-] (F) to ++(0,-0.2) ; +% \path (F) node[right=1mm] {\texttt{ygap}} ; +% \end{tikzpicture} +% +% +% \bigskip +% \emph{Remark} : It's also possible to use the options ``|shorten <|'' and ``|shorten >|'' of Tikz (via the option +% |tikz| of \pkg{witharrows}). +% % \section{An technical remark about the names of the nodes} % +% \label{NamesOfTheNodes} +% % Environments |{WithArrows}| can be nested, and, therefore, we have a ``nesting tree'' for the environments % |{WithArrows}| of the whole document. This nesting tree is used to give a unique name to each node in the % document. @@ -960,6 +1006,7 @@ version 2005/12/01 or later. % \end{tikzpicture} % \end{Verbatim} % +% % \section{Implementation} % % \subsection{Declaration of the package and extensions loaded} @@ -987,7 +1034,7 @@ version 2005/12/01 or later. % % \bigskip % The package \pkg{xparse} will be used to define the environment |{WithArrows}| and the document-level commands -% (|\Arrow|, |\WithArrowsOptions| ans |\WithArrowsLastEnv|). +% (|\Arrow|, |\WithArrowsOptions| and |\WithArrowsLastEnv|). % \begin{macrocode} \RequirePackage{xparse} % \end{macrocode} @@ -1001,14 +1048,17 @@ version 2005/12/01 or later. % % \subsection{Some technical definitions} % -% We define a Tikz style |@@_node_style| for the nodes that will be created in the |\halign|. +% We define a Tikz style |@@_node_style| for the nodes that will be created in the |\halign|. The nodes are Tikz +% nodes of shape ``rectangle'' but with zero width. An arrow between two nodes starts from the \emph{south} anchor +% of the first node and arrives at the \emph{north} anchor of the second node. % \begin{macrocode} -\tikzstyle{@@_node_style}=[rectangle, - inner~sep = 0 pt, - minimum~height = 3 pt, - minimum~width = 0pt, - red, - \bool_if:NT \l_@@_shownodes_bool {draw}] +\tikzset{@@_node_style/.style={ + above = \l_@@_ystart_dim, + inner~sep = 0 pt, + minimum~width = 0pt, + minimum~height = \l_@@_ygap_dim, + red, + \bool_if:NT \l_@@_shownodes_bool {draw}}} % \end{macrocode} % The color of the nodes is red, but in fact, the nodes will be drawn only when the option |shownodes| is used % (this option is useful for debugging). @@ -1105,6 +1155,21 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The gap between two consecutive arrows. +% \begin{macrocode} +\dim_new:N \l_@@_ygap_dim +\dim_set:Nn \l_@@_ygap_dim {0.4 ex} +% \end{macrocode} +% +% \bigskip +% The vertical position of the starting point of an arrow. +% \begin{macrocode} +\dim_new:N \l_@@_ystart_dim +\dim_set:Nn \l_@@_ystart_dim {0.4 ex} +% \end{macrocode} +% +% +% \bigskip % The following dimension is the value of the translation of the whole arrow to the right (of course, it's a % dimension and not a skip). % \begin{macrocode} @@ -1199,6 +1264,20 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The gap between two consecutive arrows. +% \begin{macrocode} + ygap .dim_set:N = \l_@@_ygap_dim, + ygap .value_required:n = true, +% \end{macrocode} +% +% \bigskip +% The vertical position of the starting point of an arrow. +% \begin{macrocode} + ystart .dim_set:N = \l_@@_ystart_dim, + ystart .value_required:n = true, +% \end{macrocode} +% +% \bigskip % Usually, the number of columns in a |{WithArrows}| environment is limited to 2. Nevertheless, it's possible to % have more columns with the option |MoreColumns|. % \begin{macrocode} @@ -1370,7 +1449,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% We process the options when the package is loaded (with |\usepackage|) but we recommend to use |\WithArrowsOptions| instead. +% We process the options when the package is loaded (with |\usepackage|) but we recommend to use +% |\WithArrowsOptions| instead. % \begin{macrocode} \ProcessKeysOptions {WithArrows} % \end{macrocode} @@ -1455,12 +1535,24 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \medskip +% \begin{macrocode} +\cs_new_protected:Nn \@@_Arrow_first_column: +% \end{macrocode} +% All messages of LaTeX3 must be \emph{fully expandable} and that's why we do the affectation (necessary for a +% comparison) before the |\msg_error:nn|. +% \begin{macrocode} + {\tl_set:Nn \l_tmpa_tl {Arrow} + \msg_error:nn {witharrows} {Arrow~in~first~column} + \@@_Arrow} +% \end{macrocode} +% % % \subsection{The environnement \{WithArrows\}} % % % The environment |{WithArrows}| starts with the initialisation of the three counters |\g_@@_arrow_int|, -% |\g_@@_line_int| dans |\g_@@_line_bis_int|. However, we have to save their previous values with the three stacks +% |\g_@@_line_int| and |\g_@@_line_bis_int|. However, we have to save their previous values with the three stacks % created for this end. % \begin{macrocode} \NewDocumentEnvironment {WithArrows} {O{}} @@ -1581,6 +1673,7 @@ version 2005/12/01 or later. % manage a stack for this counter. % \begin{macrocode} \int_gincr:N \g_@@_line_int + \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column: \strut\hfil $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$ & @@ -1599,9 +1692,9 @@ version 2005/12/01 or later. % We create the ``left node'' of the line (when using macros in Tikz node names, the macros have to be fully % expandable: here, |\tl_use:N| and |\int_use:N| are fully expandable). % \begin{macrocode} - \tikz[remember~picture] - \node [@@_node_style] - (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-l) {} ; + \tikz[remember~picture,overlay] + \node[@@_node_style] + (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-l) {} ; \hfil % \end{macrocode} % @@ -1609,9 +1702,9 @@ version 2005/12/01 or later. % Now, after the |\hfil|, we create the ``right node'' and, if the option |shownodenames| is raised, the name of % the node is written in the document (useful for debugging). % \begin{macrocode} - \tikz[remember~picture,label~position=right] - \node [@@_node_style] - (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-r) {} ; + \tikz[remember~picture,overlay] + \node[@@_node_style] + (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\g_@@_line_int-r) {} ; \bool_if:NT \l_@@_shownodenames_bool {\hbox_overlap_right:n {\small wa-\tl_use:N\l_@@_prefix_tl -\int_use:N\g_@@_line_int}} @@ -1628,9 +1721,9 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \bigskip -% We begin the second part of the environment |{WithArrows}|. We have two |\egroup|: one for the |\halign| and -% one for the |\vtop| (or |\vcenter| or |\vbox|). +% \bigskip +% We begin the second part of the environment |{WithArrows}|. We have two |\egroup|\,: one for the +% |\halign| and one for the |\vtop| (or |\vcenter| or |\vbox|). % \begin{macrocode} {\crcr \egroup @@ -1788,7 +1881,7 @@ version 2005/12/01 or later. % new group in two circonstancies : if we are at the first arrow of the environment (that's why the flag is raised % before the beginning of the loop) an if we have just finished a group (that's why the flag is raised in the % previous conditionnal). At the beginning of a group, we have to initialize four variables: -% |\l_@@_first_arrow_int|, |\l_@@_first_line_of_group_int|, |\l_@@_last_line_of_group| dans |\g_@@_x_dim| (global +% |\l_@@_first_arrow_int|, |\l_@@_first_line_of_group_int|, |\l_@@_last_line_of_group| and |\g_@@_x_dim| (global % for technical reasons). The last two will evolve during the construction of the group. % \begin{macrocode} \bool_if:nTF \l_@@_new_group_bool @@ -1881,15 +1974,15 @@ version 2005/12/01 or later. % If the arrow ends after the last line of the environment, we raise an error. % \begin{macrocode} \int_compare:nNnT \l_@@_final_int > \g_@@_line_int - {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}} + {\msg_fatal:nn {witharrows} {Too~few~lines~for~an~arrow}} % \end{macrocode} % % \bigskip % We prepare the process of the options of the current arrow. % \begin{macrocode} - \group_begin: - \int_set:Nn \l_@@_previous_pos_arrows_int {-1} - \int_set:Nn \l_@@_level_int 2 + \group_begin: + \int_set:Nn \l_@@_previous_pos_arrows_int {-1} + \int_set:Nn \l_@@_level_int 2 % \end{macrocode} % % \bigskip @@ -1897,22 +1990,22 @@ version 2005/12/01 or later. % three times. An x-expansion is not possible because there can be tokens like |\bfseries| in the option |font| of % the option |tikz|. This expansion is a bit tricky. % \begin{macrocode} - \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl - _\int_use:N\l_@@_arrow_int _prop} {options} \l_tmpa_tl - \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl} + \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl + _\int_use:N\l_@@_arrow_int _prop} {options} \l_tmpa_tl + \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl} % \end{macrocode} % % % We create two booleans to indicate the position of the initial node and final node of the arrow in cases of % options |rr|, |rl|, |lr| or |ll|: % \begin{macrocode} -\bool_set_false:N \l_@@_initial_r_bool -\bool_set_false:N \l_@@_final_r_bool -\int_case:nn \l_@@_pos_arrows_int - {0 {\bool_set_true:N \l_@@_initial_r_bool - \bool_set_true:N \l_@@_final_r_bool} - 2 {\bool_set_true:N \l_@@_initial_r_bool} - 3 {\bool_set_true:N \l_@@_final_r_bool}} + \bool_set_false:N \l_@@_initial_r_bool + \bool_set_false:N \l_@@_final_r_bool + \int_case:nn \l_@@_pos_arrows_int + {0 {\bool_set_true:N \l_@@_initial_r_bool + \bool_set_true:N \l_@@_final_r_bool} + 2 {\bool_set_true:N \l_@@_initial_r_bool} + 3 {\bool_set_true:N \l_@@_final_r_bool}} % \end{macrocode} % % \bigskip @@ -1921,17 +2014,17 @@ version 2005/12/01 or later. % the option |groups| is used). This variable is global for technical reasons: we have to do assignments in a Tikz % node. % \begin{macrocode} - \int_compare:nNnT \l_@@_pos_arrows_int = 4 - { + \int_compare:nNnT \l_@@_pos_arrows_int = 4 + { % \end{macrocode} % % \medskip % First, we calculate the initial value for |\g_@@_x_dim|. We use a Tikz command, but, in fact, nothing is drawn. % We use this Tikz command only to read the abscissa of a Tikz node. % \begin{macrocode} - \tikz[remember~picture] - \path let \p1 = (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int-l) - in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ; + \tikz[remember~picture] + \path let \p1 = (wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int-l) + in \pgfextra {\dim_gset:Nn \g_@@_x_dim {\x1}} ; % \end{macrocode} % A global assignment is necessary because of Tikz. % @@ -1939,21 +2032,21 @@ version 2005/12/01 or later. % |\l_@@_final_int|... but we have written a command dedicated to this work because it will also be used in % |\@@_draw_arrows:|. % \begin{macrocode} - \@@_actualise_x_value:nn \l_@@_initial_int \l_@@_final_int - } + \@@_actualise_x_value:nn \l_@@_initial_int \l_@@_final_int + } % \end{macrocode} % % \bigskip % |\l_@@_initial_tl| contains the name of the Tikz node from which the arrow starts (in normal cases... -% because with option |group| or option |i|, the point will perhaps have an other $x$-value --- but always the +% because with the option |i|, |group| and |groups|, the point will perhaps have an other $x$-value --- but always the % same |y|-value). Idem for |\l_@@_final_tl|. % \begin{macrocode} - \tl_set:Nx \l_@@_initial_tl - {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int- - \bool_if:NTF\l_@@_initial_r_bool rl} - \tl_set:Nx \l_@@_final_tl - {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_final_int- - \bool_if:NTF\l_@@_final_r_bool rl . north} + \tl_set:Nx \l_@@_initial_tl + {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_initial_int- + \bool_if:NTF\l_@@_initial_r_bool rl .south} + \tl_set:Nx \l_@@_final_tl + {wa-\tl_use:N\l_@@_prefix_tl-\int_use:N\l_@@_final_int- + \bool_if:NTF\l_@@_final_r_bool rl .north} % \end{macrocode} % We use ``|. north|'' because we want a small gap between two consecutive arrows (and the Tikz nodes created have % the shape of small vertical segments: use option |shownodes| to visualize the nodes). @@ -1961,15 +2054,15 @@ version 2005/12/01 or later. % \bigskip % We can now draw the arrow in a |{tikzpicture}|: % \begin{macrocode} - \begin{tikzpicture}[remember~picture, - overlay, - align=left, - auto=left, - font = {\small\itshape}, - TipsOfWithArrows, - ->, - looseness=1, - bend~left=45] + \begin{tikzpicture}[remember~picture, + overlay, + align=left, + auto=left, + font = {\small\itshape}, + TipsOfWithArrows, + ->, + looseness=1, + bend~left=45] % \end{macrocode} % % Of course, the arrow is drawn with the command |\draw| of Tikz. The syntax for this command is: @@ -1986,14 +2079,14 @@ version 2005/12/01 or later. % the $x$-value and $y$-value of these two points can be read in |\x1|, |\x2|, |\y1| and |\y2|. This is the way to % have the coordinates of a node defined in Tikz. % \begin{macrocode} - \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop} - {label} \l_tmpa_tl - \draw \exp_after:wN [\l_@@_options_tikz_tl] - let \p1 = (\tl_use:N \l_@@_initial_tl), - \p2 = (\tl_use:N \l_@@_final_tl) in - (\int_compare:nNnTF \l_@@_pos_arrows_int > 3 - {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y1} - {\x1 + \dim_use:N \l_@@_xoffset_dim, \y1} ) + \prop_get:cnN {g_@@_arrow_\l_@@_prefix_tl _\int_use:N\l_@@_arrow_int _prop} + {label} \l_tmpa_tl + \draw \exp_after:wN [\l_@@_options_tikz_tl] + let \p1 = (\tl_use:N \l_@@_initial_tl), + \p2 = (\tl_use:N \l_@@_final_tl) in + (\int_compare:nNnTF \l_@@_pos_arrows_int > 3 + {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y1} + {\x1 + \dim_use:N \l_@@_xoffset_dim, \y1} ) % \end{macrocode} % There are two ways to give the content of the node: the classical way, with curly braces, and the option ``node % contents''. However, both are not strictly equivalent: when |\usetikzlibrary{babel}| is used, the tokens of the @@ -2002,18 +2095,18 @@ version 2005/12/01 or later. % the second method. \footnote{cf.: % |tex.stackexchange.com/questions/298177/how-to-get-around-a-problem-with-usetikzlibrarybabel|} % \begin{macrocode} - to node [node~contents = {\tl_use:N \l_tmpa_tl}] {} - (\int_compare:nNnTF \l_@@_pos_arrows_int > 3 - {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y2} - {\x2 + \dim_use:N \l_@@_xoffset_dim, \y2} ) ; - \end{tikzpicture} + to node [node~contents = {\tl_use:N \l_tmpa_tl}] {} + (\int_compare:nNnTF \l_@@_pos_arrows_int > 3 + {\dim_use:N \g_@@_x_dim + \dim_use:N \l_@@_xoffset_dim, \y2} + {\x2 + \dim_use:N \l_@@_xoffset_dim, \y2} ) ; + \end{tikzpicture} % \end{macrocode} % % \smallskip % We close the TeX group opened for the options given to |\Arrow[...]| (local level of the options). % \begin{macrocode} - \group_end: - \int_incr:N \l_@@_arrow_int + \group_end: + \int_incr:N \l_@@_arrow_int } \group_end: } @@ -2074,7 +2167,7 @@ version 2005/12/01 or later. % \begin{macrocode} \msg_new:nnn {witharrows} {Arrow~used~outside~{WithArrows}~environment} - {The~command~\string\Arrow\space~should~be~used~only~directly~ + {The~command~\token_to_str:N\Arrow\ should~be~used~only~directly~ in~\{WithArrows\}~environment~and~not~in~a~subenvironment.~However,~you~ can~go~on.} % \end{macrocode} @@ -2083,7 +2176,7 @@ version 2005/12/01 or later. \msg_new:nnn {witharrows} {The~option~"jump"~must~be~non~negative} {You~can't~use~a~strictly~negative~value~for~the~option~"jump"~of~command~ - \string\Arrow.~ You~can~create~an~arrow~going~backwards~with~ + \token_to_str:N\Arrow.~ You~can~create~an~arrow~going~backwards~with~ the~option~"<-"~of~Tikz.} % \end{macrocode} % @@ -2116,9 +2209,9 @@ version 2005/12/01 or later. 6 {groups}}"~ previously~set~in~the~same~ \int_case:nn\l_@@_level_int - {0 {command~\string\WithArrowsOptions} + {0 {command~\token_to_str:N\WithArrowsOptions} 1 {declaration~of~options~of~the~environment~\{WithArrows\}} - 2 {command~\string\Arrow}}.~ + 2 {command~\token_to_str:N\Arrow}}.~ If~you~go~on,~I~will~overwrite~the~first~option.} % \end{macrocode} % @@ -2129,7 +2222,7 @@ version 2005/12/01 or later. (because~the~nodes~are~created~in~the~second~column).~You~can~go~on~but~maybe~ you~will~have~an~pgf~error~for~an~undefined~shape.} {The~ampersand~can~be~implicit~ - (e.g.~if~you~use~\string\MoveEqLeft\space~of~mathtools).} + (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} % \end{macrocode} % % \begin{macrocode} @@ -2158,6 +2251,21 @@ version 2005/12/01 or later. {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~meaningless~in~the~context.~ If~you~go~on,~it~will~be~ignored.} % \end{macrocode} +% +% \begin{macrocode} +\msg_new:nnn {witharrows} + {Arrow~in~first~column} + {You~should~not~use~the~command~\token_to_str:N\Arrow\ + \tl_if_eq:NNF \l_@@_CommandName_tl \l_tmpa_tl + {(renamed~in~\str_use:N \c_backslash_str + \tl_use:N \l_@@_CommandName_tl)~} + ~in~the~first~column~but~only~in~the~second~column.~ + This~is~a~restriction~of~the~version~1.3~of~the~ + package~witharrows~(in~the~aim~of~developping~further~ + ~a~new~functionality~with~\token_to_str:N\Arrow\ in~the~ + first~column).\\ + However~you~can~go~on~for~this~time.} +% \end{macrocode} % % % @@ -2184,6 +2292,13 @@ version 2005/12/01 or later. % New option |groups| (with a \emph{s}) % % Better error messages +% +% \subsection{Changes between versions 1.1 and 1.2} +% +% New options |ygap| and |ystart| for fine tuning. +% +% Minor bugs. +% % \endinput % % Local Variables: diff --git a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty index b18863db15c..8f4add2a4bf 100644 --- a/Master/texmf-dist/tex/latex/witharrows/witharrows.sty +++ b/Master/texmf-dist/tex/latex/witharrows/witharrows.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{1.2} -\def\myfiledate{2017/11/29} +\def\myfileversion{1.3} +\def\myfiledate{2018/01/11} \RequirePackage{tikz} \usetikzlibrary{calc,arrows.meta,bending} \RequirePackage{l3keys2e} @@ -30,12 +30,13 @@ {Draws arrows for explanations on the right} \RequirePackage{xparse} \RequirePackage{footnote} -\tikzstyle{__wa_node_style}=[rectangle, - inner~sep = 0 pt, - minimum~height = 3 pt, - minimum~width = 0pt, - red, - \bool_if:NT \l__wa_shownodes_bool {draw}] +\tikzset{__wa_node_style/.style={ + above = \l__wa_ystart_dim, + inner~sep = 0 pt, + minimum~width = 0pt, + minimum~height = \l__wa_ygap_dim, + red, + \bool_if:NT \l__wa_shownodes_bool {draw}}} \tikzset{TipsOfWithArrows/.style= { > = {Straight~Barb[scale=1.2,bend]}} } \cs_if_free:NT \spread@equation {\cs_set:Npn \spread@equation{\openup\jot @@ -49,6 +50,10 @@ \int_new:N \l__wa_pos_env_int \int_new:N \l__wa_pos_arrows_int \int_new:N \l__wa_previous_pos_arrows_int +\dim_new:N \l__wa_ygap_dim +\dim_set:Nn \l__wa_ygap_dim {0.4 ex} +\dim_new:N \l__wa_ystart_dim +\dim_set:Nn \l__wa_ystart_dim {0.4 ex} \dim_new:N \l__wa_xoffset_dim \dim_set:Nn \l__wa_xoffset_dim {3mm} \bool_new:N \l__wa_shownodes_bool @@ -70,6 +75,10 @@ c .value_forbidden:n = true, b .code:n = {\int_set:Nn \l__wa_pos_env_int 2}, b .value_forbidden:n = true, + ygap .dim_set:N = \l__wa_ygap_dim, + ygap .value_required:n = true, + ystart .dim_set:N = \l__wa_ystart_dim, + ystart .value_required:n = true, MoreColumns .bool_set:N = \l__wa_MoreColumns_bool, MoreColumns .value_forbidden:n = true, CommandName .tl_set:N = \l__wa_CommandName_tl, @@ -159,6 +168,10 @@ {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\g__wa_arrow_int _prop} \l_tmpa_prop } +\cs_new_protected:Nn \__wa_Arrow_first_column: + {\tl_set:Nn \l_tmpa_tl {Arrow} + \msg_error:nn {witharrows} {Arrow~in~first~column} + \__wa_Arrow} \NewDocumentEnvironment {WithArrows} {O{}} { \seq_gput_right:NV \g__wa_arrow_int_seq \g__wa_arrow_int \int_gzero:N \g__wa_arrow_int @@ -195,18 +208,19 @@ \spread@equation \ialign\bgroup \int_gincr:N \g__wa_line_int + \cs_set_eq:cN \l__wa_CommandName_tl \__wa_Arrow_first_column: \strut\hfil $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {##}$ & \int_gincr:N \g__wa_line_bis_int $\bool_if:NT \l__wa_displaystyle_bool \displaystyle {{}##}$ - \tikz[remember~picture] - \node [__wa_node_style] - (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-l) {} ; + \tikz[remember~picture,overlay] + \node[__wa_node_style] + (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-l) {} ; \hfil - \tikz[remember~picture,label~position=right] - \node [__wa_node_style] - (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-r) {} ; + \tikz[remember~picture,overlay] + \node[__wa_node_style] + (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\g__wa_line_int-r) {} ; \bool_if:NT \l__wa_shownodenames_bool {\hbox_overlap_right:n {\small wa-\tl_use:N\l__wa_prefix_tl -\int_use:N\g__wa_line_int}} @@ -302,57 +316,57 @@ {final} \l_tmpa_tl \int_set:Nn \l__wa_final_int {\l_tmpa_tl} \int_compare:nNnT \l__wa_final_int > \g__wa_line_int - {\msg_error:nn {witharrows} {Too~few~lines~for~an~arrow}} - \group_begin: - \int_set:Nn \l__wa_previous_pos_arrows_int {-1} - \int_set:Nn \l__wa_level_int 2 - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl - _\int_use:N\l__wa_arrow_int _prop} {options} \l_tmpa_tl - \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl} -\bool_set_false:N \l__wa_initial_r_bool -\bool_set_false:N \l__wa_final_r_bool -\int_case:nn \l__wa_pos_arrows_int - {0 {\bool_set_true:N \l__wa_initial_r_bool - \bool_set_true:N \l__wa_final_r_bool} - 2 {\bool_set_true:N \l__wa_initial_r_bool} - 3 {\bool_set_true:N \l__wa_final_r_bool}} - \int_compare:nNnT \l__wa_pos_arrows_int = 4 - { - \tikz[remember~picture] - \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l) - in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; - \__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int - } - \tl_set:Nx \l__wa_initial_tl - {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int- - \bool_if:NTF\l__wa_initial_r_bool rl} - \tl_set:Nx \l__wa_final_tl - {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_final_int- - \bool_if:NTF\l__wa_final_r_bool rl . north} - \begin{tikzpicture}[remember~picture, - overlay, - align=left, - auto=left, - font = {\small\itshape}, - TipsOfWithArrows, - ->, - looseness=1, - bend~left=45] - \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} - {label} \l_tmpa_tl - \draw \exp_after:wN [\l__wa_options_tikz_tl] - let \p1 = (\tl_use:N \l__wa_initial_tl), - \p2 = (\tl_use:N \l__wa_final_tl) in - (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 - {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y1} - {\x1 + \dim_use:N \l__wa_xoffset_dim, \y1} ) - to node [node~contents = {\tl_use:N \l_tmpa_tl}] {} - (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 - {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y2} - {\x2 + \dim_use:N \l__wa_xoffset_dim, \y2} ) ; - \end{tikzpicture} - \group_end: - \int_incr:N \l__wa_arrow_int + {\msg_fatal:nn {witharrows} {Too~few~lines~for~an~arrow}} + \group_begin: + \int_set:Nn \l__wa_previous_pos_arrows_int {-1} + \int_set:Nn \l__wa_level_int 2 + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl + _\int_use:N\l__wa_arrow_int _prop} {options} \l_tmpa_tl + \exp_args:NNo \exp_args:No \keys_set_WithArrows: {\l_tmpa_tl} + \bool_set_false:N \l__wa_initial_r_bool + \bool_set_false:N \l__wa_final_r_bool + \int_case:nn \l__wa_pos_arrows_int + {0 {\bool_set_true:N \l__wa_initial_r_bool + \bool_set_true:N \l__wa_final_r_bool} + 2 {\bool_set_true:N \l__wa_initial_r_bool} + 3 {\bool_set_true:N \l__wa_final_r_bool}} + \int_compare:nNnT \l__wa_pos_arrows_int = 4 + { + \tikz[remember~picture] + \path let \p1 = (wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int-l) + in \pgfextra {\dim_gset:Nn \g__wa_x_dim {\x1}} ; + \__wa_actualise_x_value:nn \l__wa_initial_int \l__wa_final_int + } + \tl_set:Nx \l__wa_initial_tl + {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_initial_int- + \bool_if:NTF\l__wa_initial_r_bool rl .south} + \tl_set:Nx \l__wa_final_tl + {wa-\tl_use:N\l__wa_prefix_tl-\int_use:N\l__wa_final_int- + \bool_if:NTF\l__wa_final_r_bool rl .north} + \begin{tikzpicture}[remember~picture, + overlay, + align=left, + auto=left, + font = {\small\itshape}, + TipsOfWithArrows, + ->, + looseness=1, + bend~left=45] + \prop_get:cnN {g__wa_arrow_\l__wa_prefix_tl _\int_use:N\l__wa_arrow_int _prop} + {label} \l_tmpa_tl + \draw \exp_after:wN [\l__wa_options_tikz_tl] + let \p1 = (\tl_use:N \l__wa_initial_tl), + \p2 = (\tl_use:N \l__wa_final_tl) in + (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 + {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y1} + {\x1 + \dim_use:N \l__wa_xoffset_dim, \y1} ) + to node [node~contents = {\tl_use:N \l_tmpa_tl}] {} + (\int_compare:nNnTF \l__wa_pos_arrows_int > 3 + {\dim_use:N \g__wa_x_dim + \dim_use:N \l__wa_xoffset_dim, \y2} + {\x2 + \dim_use:N \l__wa_xoffset_dim, \y2} ) ; + \end{tikzpicture} + \group_end: + \int_incr:N \l__wa_arrow_int } \group_end: } @@ -382,13 +396,13 @@ a~global~level~or~for~an~environment.~However,~you~can~go~one~for~this~time.} \msg_new:nnn {witharrows} {Arrow~used~outside~{WithArrows}~environment} - {The~command~\string\Arrow\space~should~be~used~only~directly~ + {The~command~\token_to_str:N\Arrow\ should~be~used~only~directly~ in~\{WithArrows\}~environment~and~not~in~a~subenvironment.~However,~you~ can~go~on.} \msg_new:nnn {witharrows} {The~option~"jump"~must~be~non~negative} {You~can't~use~a~strictly~negative~value~for~the~option~"jump"~of~command~ - \string\Arrow.~ You~can~create~an~arrow~going~backwards~with~ + \token_to_str:N\Arrow.~ You~can~create~an~arrow~going~backwards~with~ the~option~"<-"~of~Tikz.} \msg_new:nnn {witharrows} {Too~few~lines~for~an~arrow} @@ -412,9 +426,9 @@ 6 {groups}}"~ previously~set~in~the~same~ \int_case:nn\l__wa_level_int - {0 {command~\string\WithArrowsOptions} + {0 {command~\token_to_str:N\WithArrowsOptions} 1 {declaration~of~options~of~the~environment~\{WithArrows\}} - 2 {command~\string\Arrow}}.~ + 2 {command~\token_to_str:N\Arrow}}.~ If~you~go~on,~I~will~overwrite~the~first~option.} \msg_new:nnnn {witharrows} {All~lines~must~have~an~ampersand} @@ -422,7 +436,7 @@ (because~the~nodes~are~created~in~the~second~column).~You~can~go~on~but~maybe~ you~will~have~an~pgf~error~for~an~undefined~shape.} {The~ampersand~can~be~implicit~ - (e.g.~if~you~use~\string\MoveEqLeft\space~of~mathtools).} + (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} \msg_new:nnn {witharrows} {Option~incompatible~with~"group(s)"} {You~try~to~use~the~option~"\tl_use:N\l_keys_key_tl"~while~ @@ -440,6 +454,18 @@ {Option~unknown} {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~meaningless~in~the~context.~ If~you~go~on,~it~will~be~ignored.} +\msg_new:nnn {witharrows} + {Arrow~in~first~column} + {You~should~not~use~the~command~\token_to_str:N\Arrow\ + \tl_if_eq:NNF \l__wa_CommandName_tl \l_tmpa_tl + {(renamed~in~\str_use:N \c_backslash_str + \tl_use:N \l__wa_CommandName_tl)~} + ~in~the~first~column~but~only~in~the~second~column.~ + This~is~a~restriction~of~the~version~1.3~of~the~ + package~witharrows~(in~the~aim~of~developping~further~ + ~a~new~functionality~with~\token_to_str:N\Arrow\ in~the~ + first~column).\\ + However~you~can~go~on~for~this~time.} \endinput %% %% End of file `witharrows.sty'. |