From 49401a31aacb9f38f0cb73c473504c3249b34284 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 29 Jul 2018 20:56:10 +0000 Subject: witharrows git-svn-id: svn://tug.org/texlive/trunk@48304 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/witharrows/witharrows.dtx | 351 +++++++++++++++------ .../source/latex/witharrows/witharrows.ins | 4 +- 2 files changed, 248 insertions(+), 107 deletions(-) (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx index 7e15855743c..5e795d4c10a 100644 --- a/Master/texmf-dist/source/latex/witharrows/witharrows.dtx +++ b/Master/texmf-dist/source/latex/witharrows/witharrows.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2017 by F. Pantigny +% Copyright (C) 2017-2018 by F. Pantigny % ----------------------------------- % % This file may be distributed and/or modified under the @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{1.7} -\def\myfiledate{2018/07/18} +\def\myfileversion{1.8} +\def\myfiledate{2018/07/25} % % %<*batchfile> @@ -584,9 +584,9 @@ version 2005/12/01 or later. % \bigskip % The environment |{WithArrows}| gives also a |groups| option (with a \emph{s} in the name). With this option, the % arrows are divided into several ``groups''. Each group is a set of connected\footnote{More precisely: for each -% arrow $a$, we note $i(a)$ the number of its initial row and $f(a)$ the number of its final line ; for two arrows +% arrow $a$, we note $i(a)$ the number of its initial row and $f(a)$ the number of its final line; for two arrows % $a$ and $b$, we say that $a \sim b$ when -% $\llbracket i(a),f(a)\rrbracket \cap \llbracket i(b),f(b)\rrbracket \neq \varnothing$ ; the groups are the +% $\llbracket i(a),f(a)\rrbracket \cap \llbracket i(b),f(b)\rrbracket \neq \varnothing$; the groups are the % equivalence classes of the transitive closure of $\sim$.} arrows. All the arrows of a given group are grouped on % a same vertical line and at a leftmost position. % @@ -604,7 +604,7 @@ version 2005/12/01 or later. % \bigskip % If desired, the option |group| or the option |groups| can be given to the command |\WithArrowsOptions| so that it will become % 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}| +% environment |{WithArrows}| with the option |rr|: |\begin{WithArrows}[rr]| % % % \section{Comparison with the environment \{aligned\}} @@ -779,7 +779,7 @@ version 2005/12/01 or later. % % % \medskip -% The following is composed with |{WithArrows}[c,displaystyle]|. The results are stricly identical.\footnote{In +% The following is composed with |{WithArrows}[c,displaystyle]|. The results are strictly identical.\footnote{In % versions of \pkg{amsmath} older than the 5~nov.~2016, an thin space was added on the left of an environment % |{aligned}|. The new versions do not add this space and neither do |{WithArrows}|.}\par\nobreak % @@ -1170,7 +1170,8 @@ version 2005/12/01 or later. % \pkg{mathtools}) is loaded, it's also possible to use |\tag*| which, as in \pkg{amsmath}, typesets the tag % without the parenthesis.} % -% It's also possible to put a label to the line of an equation with the command |\label|. +% It's also possible to put a label to the line of an equation with the command |\label|.\footnote{As in the +% environment |{align}| of \pkg{amsmath}, it's not possible to put two commands |\label| in the same line.} % % These commands must be in the second column of the environment. % \begin{Verbatim} @@ -1188,8 +1189,9 @@ version 2005/12/01 or later. % |\eqref| is a command of \pkg{amsmath}). % % \medskip -% It's also possible to suppress all the numbers with the option |notag| (or |nonumber|), at the global or -% environment level. There is also an environment |{DispWithArrows*}| which suppresses all the numbers. +% It's also possible to suppress all the autogenerated numbers with the option |notag| (or |nonumber|), at the +% global or environment level. There is also an environment |{DispWithArrows*}| which suppresses all these +% numbers.\footnote{Even in this case, it's possible to put a ``manual tag'' with the command |\tag|.} % \begin{Verbatim} % \begin{~emphase#DispWithArrows*@} % A & = (a+1)^2 \Arrow{we expand} \\ @@ -1204,8 +1206,8 @@ version 2005/12/01 or later. % % \medskip % With the option |fleqn|, the environment is composed flush left (in a way similar to the option |fleqn| of the -% class \cls{article}). In this case, the left margin can be controlled with the option |mathindent| (with a name -% inspired by the parameter |\mathindent| of standard LaTeX). The default value of this parameter is 25~pt. +% standard classes of LaTeX). In this case, the left margin can be controlled with the option |mathindent| (with a +% name inspired by the parameter |\mathindent| of standard LaTeX). The default value of this parameter is 25~pt. % % \begin{Verbatim} % \begin{DispWithArrows}[~emphase#fleqn,mathindent = 1cm@] @@ -1226,27 +1228,40 @@ version 2005/12/01 or later. % equations for the arrows) while still centering the classical equations. % % \bigskip -% If the package \pkg{amsmath} is loaded, it's possible to use the command |\intertext| in the environments -% |{DispWithArrows}| and |{DispWithArrows*}| (and even the |\intertext| of \pkg{nccmath} if this package is loaded). +% If the package \pkg{amsmath} is loaded, it's possible to use the environment |{subequations}| and the command +% |\intertext| in the environments |{DispWithArrows}| and |{DispWithArrows*}| (and even the |\intertext| of +% \pkg{nccmath} if this package is loaded). % % If the option |leqno| is used (for the document or when the package \pkg{amsmath} is loaded), the labels will be % composed on the left also for the environments |{DispWithArrows}| et |{DispWithArrows*}|. % -% \bigskip +% \bigskip % The environment |{DispWithArrows}| is similar to the environment |{align}| of \pkg{amsmath}. However, -% |{DispWithArrows}| is not constructed upon |{align}| (in fact, it's possible \pkg{witharrows} without -% \pkg{amsmath}). -% -% There are differences between |{DispWithArrows}| and |{align}|. The environment |{DispWithArrows}| allows only 2 -% columns. With |{DispWithArrows}|, there is no control of a collision between an equation and its tag. An -% environment |{DispWithArrows}| is always unbreakable (even with |\allowdisplaybreaks| of \pkg{amsmath}). The -% commands |\label|, |\tag|, |\notag|, |\nonumber| are allowed only in the second column. The labels of -% |{DispWithArrows}| are not always drawn by \pkg{showkeys}. +% |{DispWithArrows}| is not constructed upon |{align}| (in fact, it's possible to use \pkg{witharrows} without +% \pkg{amsmath}). +% +% There are differences between |{DispWithArrows}| and |{align}|. +% \begin{itemize} +% \item The environment |{DispWithArrows}| allows only two columns. +% \item With |{DispWithArrows}|, there is no control of a collision between an equation and its tag. +% \item An environment |{DispWithArrows}| is always unbreakable (even with |\allowdisplaybreaks| of \pkg{amsmath}). +% \item The commands |\label|, |\tag|, |\notag|, |\nonumber| are allowed only in the second column. +% \item % \begin{bfseries} % Last but not least, by default, the elements of a \texttt{\{DispWithArrows\}} are composed in \texttt{textstyle} and not in % \texttt{displaystyle} (it's possible to change this point with the option \texttt{displaystyle}). % \end{bfseries} +% \end{itemize} % +% \bigskip +% Concerning the references, the package \pkg{witharrows} is compatible with the extensions \pkg{autonum}, +% \pkg{cleveref}, \pkg{fancyref}, \pkg{hyperref}, \pkg{prettyref}, \pkg{refstyle}, \pkg{typedref} and +% \pkg{varioref}, and with the options |showonlyrefs| and |showmanualtags| of \pkg{mathtools}.\footnote{We recall +% that \pkg{varioref}, \pkg{hyperref}, \pkg{cleveref} and \pkg{autonum} must be loaded in this order. The package +% \pkg{witharrows} can be loaded anywhere.} +% +% It is not compatible with \pkg{showkeys} (not all the labels are shown). +% % \section{Advanced features} % % @@ -1687,8 +1702,8 @@ version 2005/12/01 or later. % % \begin{macrocode} \keys_define:nn {WithArrows/package} - {footnote .bool_gset:N = \g_@@_footnote_bool, - footnotehyper .bool_gset:N = \g_@@_footnotehyper_bool} + {footnote .bool_gset:N = \g_@@_footnote_bool, + footnotehyper .bool_gset:N = \g_@@_footnotehyper_bool} % \end{macrocode} % % \bigskip @@ -1753,11 +1768,25 @@ version 2005/12/01 or later. \bool_gset_true:N \g_@@_footnote_bool} % \end{macrocode} % The flag |\g_@@_footnote_bool| is raised and so, we will only have to test |\g_@@_footnote_bool| in order to -% known if we have to insert an environnement |{savenotes}| (see the definition of environnement |{WithArrows}|). +% known if we have to insert an environnement |{savenotes}| (the |\begin{savenotes}| is in |\@@_pre_environment:n| +% and |\end{savenotes}| in |\@@_post_environment:| which are executed at the beginning and at the end of the +% environments |{WithArrows}| and |{DispWithArrows}|). % % \bigskip % \subsection{Some technical definitions} % +% We create booleans in order to known if some packages are loaded. For example, for the package \pkg{amsmath}, +% the boolean is called |\c_@@_amsmath_loaded_bool|.\footnote{It's not possible to use |\@ifpackageloaded| in the +% core of the functions because |\@ifpackageloaded| is available only in the preamble.} +% \begin{macrocode} +\AtBeginDocument{\clist_map_inline:nn + {amsmath,mathtools,autonum,cleveref,hyperref,typedref} + {\bool_new:c {c_@@_#1_loaded_bool} + \@ifpackageloaded {#1} + {\bool_set_true:c {c_@@_#1_loaded_bool}} + {}}} +% \end{macrocode} +% % 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. @@ -1807,13 +1836,14 @@ version 2005/12/01 or later. % possible to use the environments of \pkg{amsmath} (e.g. |{aligned}|) in an environment |{WithArrows}|. % % Nevertheless, we want the extension \pkg{witharrows} available without \pkg{amsmath}. That's why we give a -% definition of |\spread@equation| (this definition will be loaded only if \pkg{amsmath} --- or \pkg{mathtools} --- has -% not been loaded yet). +% definition of |\spread@equation| if \pkg{amsmath} is not loaded (you put the code in a |\AtBeginDocument| because +% the flag |\c_@@_amsmath_loaded_bool| is itself set in a |\AtBeginDocument|). % \begin{macrocode} -\cs_if_free:NT \spread@equation - {\cs_set_protected:Npn \spread@equation - {\openup\jot - \cs_set_protected:Npn \spread@equation {}}} +\AtBeginDocument + {\bool_if:NF \c_@@_amsmath_loaded_bool + {\cs_set_protected:Npn \spread@equation + {\openup\jot + \cs_set_protected:Npn \spread@equation {}}}} % \end{macrocode} % Don't put |\cs_set_eq:NN \spread@equation \prog_do_nothing:| in the last line because this would raise errors % with nested environments. @@ -1822,6 +1852,7 @@ version 2005/12/01 or later. % \bigskip % \subsection{Variables} % +% % The boolean |\l_@@_in_witharrows_bool| will be raised if (and only if) we are in an environment |{WithArrows}| % (and not in an environment |{DispWithArrows}| or |{DispWithArrows*}|). % \begin{macrocode} @@ -1953,10 +1984,27 @@ version 2005/12/01 or later. % % \bigskip % The command |\@@_label:n| will be linked to |\label| in the second column of the |\halign| of the environment -% |{DispWithArrows}|. This command will store its argument in the token list |\l_@@_label_tl|. +% |{DispWithArrows}|. It's possible to put several labels for the same line (it's not possible in the environments +% of \pkg{amsmath}). That's why we store the differents labels of a same line in a sequence |\l_@@_labels_seq|. +% \begin{macrocode} +\seq_new:N \l_@@_labels_seq +\cs_set:Nn \@@_label:n {\seq_if_empty:NF \l_@@_labels_seq + {\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} -\tl_new:N \l_@@_label_tl -\cs_set:Nn \@@_label:n {\tl_set:Nn \l_@@_label_tl {#1}} + \bool_if:nT \c_@@_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\cs_if_exist:cTF {MT_r_#1} + {\bool_set_false:N \l_@@_notag_bool} + {\bool_set_true:N \l_@@_notag_bool}}} + \bool_if:nT \c_@@_autonum_loaded_bool + {\cs_if_exist:cTF {autonum@#1Referenced} + {\bool_set_false:N \l_@@_notag_bool} + {\bool_set_true:N \l_@@_notag_bool}}} % \end{macrocode} % % @@ -1968,14 +2016,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The dimension |\l_@@_mathindent_dim| is used only by the environments |{DispWithArrows}| : it's the left margin of +% The dimension |\l_@@_mathindent_dim| is used only by the environments |{DispWithArrows}|: it's the left margin of % the environments |{DispWithArrows}| if the environment |{DispWithArrows}| is composed flush left (option |fleqn|). % \begin{macrocode} \dim_new:N \l_@@_mathindent_dim \dim_set:Nn \l_@@_mathindent_dim {25pt} % \end{macrocode} % -% % \bigskip % \subsection{The definition of the options} % @@ -2182,6 +2229,19 @@ version 2005/12/01 or later. {\bool_set_false:N \l_@@_notag_bool}}}, notag .default:n = true, nonumber .meta:n = notag, +% \end{macrocode} +% +% \bigskip +% The option |AllowMultipleLabels| indicates wether multiple labels are allowed for the same line of an environment +% |{DispWithArrows}| or |{DispWithArrows*}|. +% \begin{macrocode} + AllowMultipleLabels .code:n = {\bool_if:NTF \l_@@_in_witharrows_bool + {\msg_error:nn {witharrows} {Option~will~be~ignored}} + {\msg_redirect_name:nnn {witharrows} + {Multiple~labels} + {none}}}, + AllowMultipleLabels .value_forbidden:n = true, + fleqn .default:n = true, unknown .code:n = \msg_error:nn {witharrows} {Option~unknown} } % \end{macrocode} @@ -2575,18 +2635,11 @@ 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} - \tl_if_empty:NTF \l_@@_name_tl - {\tikz [remember~picture,overlay] - \node [@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l] {} ;} -% \end{macrocode} -% If the environment |{WithArrows}| has a name (given with the option |name|), the node has also an alias -% constructed with this name. -% \begin{macrocode} - {\tikz [remember~picture,overlay] - \node [@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l, - alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-l] {} ;} + \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 % \end{macrocode} % @@ -2594,14 +2647,11 @@ 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} - \tl_if_empty:NTF \l_@@_name_tl - {\tikz [remember~picture,overlay] - \node [@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r] {} ;} - {\tikz [remember~picture,overlay] - \node [@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r, - alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-r] {} ;} + \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}} @@ -2750,38 +2800,66 @@ version 2005/12/01 or later. {&} { % \end{macrocode} -% Here, we can't use |\refstepcounter{equation}| (even the |\refstepcounter| modified by |\hyperref|) because if -% the user has issued a |\tag| command, we have to use |\l_@@_tag_tl| and not |\theequation|. That's why we do the -% incrementation of the counter ``manually'' and, the, we insert some code inspired by the code of |\refstepcounter|. +% Here, we can't use |\refstepcounter{equation}| because if the user has issued a |\tag| command, we have to use +% |\l_@@_tag_tl| and not |\theequation|. That's why we have to do the job done by |\refstepcounter| manually. +% +% First, the incrementation of the counter (potentialy). % \begin{macrocode} \tl_if_empty:NT \l_@@_tag_tl {\int_gincr:N \c@equation} % \end{macrocode} % -% We store in |\g_tmpa_tl| the tag we will have to compose at the end in the line. We use a global variable because +% We store in |\g_tmpa_tl| the tag we will have to compose at the end of the line. We use a global variable because % we will use it in the \emph{next} cell (after the |&|). % \begin{macrocode} \cs_gset:Npx \g_tmpa_tl {\tl_if_empty:NTF \l_@@_tag_tl \theequation \l_@@_tag_tl} - \tl_if_empty:NF \l_@@_label_tl +% \end{macrocode} +% It's possible to put several labels for the same line (it's not possible in the environments +% of \pkg{amsmath}). That's why the differents labels of a same line are stored in a sequence |\l_@@_labels_seq|. +% \begin{macrocode} + \seq_if_empty:NF \l_@@_labels_seq { % \end{macrocode} -% The following code is inspired from the definition of |\refstepcounter| in |source2e|. +% Now, we do the job done by |\refstepcounter| and by the redefinitions of |\refstepcounter| done by some packages +% (the incrementation of the counter has been done yet). +% +% First an action which is in the definition of |\refstepcounter| in |source2e|. % \begin{macrocode} - \cs_set_eq:NN \@currentlabel \g_tmpa_tl + \cs_set:Npx \@currentlabel {\p@equation \g_tmpa_tl} % \end{macrocode} -% The following code is inspired from the redefinition of |\refstepcounter| done by \pkg{hyperref}. It is executed -% only if \pkg{hyperref} has been loaded. +% Then, an action done by \pkg{hyperref} in its redefinition of |\refstepcounter|. % \begin{macrocode} - \cs_if_exist:NT \hyper@refstepcounter + \bool_if:NT \c_@@_hyperref_loaded_bool {\cs_set:Npn \This@name {equation} \hyper@refstepcounter{equation}} % \end{macrocode} -% Now, we can issue the command |\label|. +% +% Then, an action done by \pkg{cleveref} in its redefinition of |\refstepcounter|. The package \pkg{cleveref} +% creates in the |aux| file a command |\cref@currentlabel| similar to |\@current| but with more informations. +% \begin{macrocode} + \bool_if:NT \c_@@_cleveref_loaded_bool + {\cref@constructprefix{equation}{\cref@result} + \@ifundefined{cref@equation@alias} + {\def\@tempa{equation}} + {\def\@tempa{\csname cref@equation@alias\endcsname}} + \protected@edef\cref@currentlabel{[\@tempa][\arabic{equation}][\cref@result] + \p@equation \g_tmpa_tl}} +% \end{macrocode} +% +% Then, an action done by \pkg{typedref} in its redefinition of |\refstepcounter|. The command |\sr@name| is a +% prefix added to the name of the label by the redefinition of |\label| done by \pkg{typedref}. +% \begin{macrocode} + \bool_if:NT \c_@@_typedref_loaded_bool + {\cs_set:Npn \sr@name {equation}} +% \end{macrocode} +% Now, we can issue the command |\label| (some package may have redefined |\label|, for example \pkg{typedref}) for +% each item in the sequence of the labels (it's possible to put several labels to the same line and that's why the +% labels are in the sequence |\l_@@_labels_seq|). % \begin{macrocode} - \@@_old_label {\l_@@_label_tl}} + \seq_map_function:NN \l_@@_labels_seq \@@_old_label} % \end{macrocode} % We store the boolean |\l_@@_tag_star_bool| in the global variable |\g_tmpa_bool| because we will use it in the % \emph{next} cell (after the |&|). @@ -2816,10 +2894,23 @@ version 2005/12/01 or later. \NewDocumentEnvironment {DispWithArrows} {O{}} { % \end{macrocode} -% The command |\intertext@| is a command of \pkg{amsmath} which loads the definition of |\intertext| (if it is -% loaded, the package \pkg{nccmath} gives a new defintion of |\intertext@|). +% If \pkg{mathtools} has been loaded with the option |showonlyrefs|, we deactivate the code of \pkg{mathtools} for +% the option |showonlyrefs| with the command |\MT_showonlyrefs_false:| (it will be reactivated at the end of +% the environment). +% \begin{macrocode} + \bool_if:nT \c_@@_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\MT_showonlyrefs_false: +% \end{macrocode} +% However, we have to re-raise the flag |{show_only_refs}| of \pkg{mhsetup} because it has been switched off by +% |\MT_showonlyrefs_false:| and we will use it in the code of the new version of |\label|. +% \begin{macrocode} + \MH_set_boolean_T:n {show_only_refs} + \bool_set_true:N \l_@@_notag_bool}} +% \end{macrocode} +% The command |\intertext@| is a command of \pkg{amsmath} which loads the definition of |\intertext|. % \begin{macrocode} - \cs_if_exist_use:N \intertext@ + \bool_if:NT \c_@@_amsmath_loaded_bool \intertext@ \if_mode_math: \msg_error:nn {witharrows} {{DispWithArrows}~used~in~math~mode} @@ -2827,9 +2918,15 @@ version 2005/12/01 or later. \bool_set_false:N \l_@@_in_witharrows_bool \@@_pre_environment:n {#1} % \end{macrocode} +% We don't use |\[| of LaTeX because some extensions, like \pkg{autonum}, do a redefinition of |\[|. However, we +% put the two following lines which are in the definition of |\[|. +% \begin{macrocode} + \nointerlineskip + \makebox[.6\linewidth]{} + $$ +% \end{macrocode} % We use a |\vcenter| in order to prevent page breaks in the environment. % \begin{macrocode} - \begin{displaymath} \vcenter \bgroup \spread@equation \bool_if:NTF \l_@@_fleqn_bool @@ -2839,7 +2936,7 @@ version 2005/12/01 or later. % If \pkg{amsmath} is loaded, the LaTeX version of |\label| is stored in |\ltx@label|. If not, it's, of course, % stored in |\label|. We store this definition of |\label| because we will redefine |\label| in the environment. % \begin{macrocode} - \cs_if_exist:NTF \ltx@label + \bool_if:NTF \c_@@_amsmath_loaded_bool {\cs_set_eq:NN \_@@_old_label \ltx@label} {\cs_set_eq:NN \_@@_old_label \label} \cs_set:Npn \notag {\msg_error:nnn {witharrows} @@ -2859,7 +2956,7 @@ version 2005/12/01 or later. \cs_set_eq:cN \l_@@_CommandName_tl \@@_Arrow_first_column: \strut \bool_if:NT \l_@@_fleqn_bool - {\hspace{\l_@@_mathindent_dim}} + {\skip_horizontal:n \l_@@_mathindent_dim} \hfil $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {##}$ \tabskip = \c_zero_skip @@ -2871,23 +2968,17 @@ version 2005/12/01 or later. $\bool_if:NT \l_@@_displaystyle_bool \displaystyle {{}##}$ \tabskip = 0 pt plus 1000 pt minus 1000 pt \int_gincr:N \g_@@_line_bis_int - \tl_if_empty:NTF \l_@@_name_tl - {\tikz [remember~picture,overlay] - \node [_@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l] {} ;} - {\tikz [remember~picture,overlay] - \node [_@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-l, - alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-l] {} ;} + \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 - \tl_if_empty:NTF \l_@@_name_tl - {\tikz [remember~picture,overlay] - \node [_@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r] {} ;} - {\tikz [remember~picture,overlay] - \node [_@@_node_style, - name = wa-\l_@@_prefix_str-\int_use:N\g_@@_line_int-r, - alias = \l_@@_name_tl-\int_use:N\g_@@_line_int-r] {} ;} + \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}} @@ -2905,8 +2996,19 @@ version 2005/12/01 or later. % The following |\egroup| is for the |\vcenter| (aimed to prevent page breaks). % \begin{macrocode} \egroup - \end{displaymath} + $$ +% \end{macrocode} +% The code in |\@@_post_environment:| is common to |{WithArrows}| and |{DispWithArrows}|. +% \begin{macrocode} \@@_post_environment: +% \end{macrocode} +% If \pkg{mathtools} has been loaded with the option |showonlyrefs|, we reactivate the code of \pkg{mathtools} for +% the option |showonlyrefs| with the command |\MT_showonlyrefs_true:| (it has been desactivated in the beginning of +% the environment). +% \begin{macrocode} + \bool_if:nT \c_@@_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + \MT_showonlyrefs_true:} \ignorespacesafterend } % \end{macrocode} @@ -2916,7 +3018,13 @@ version 2005/12/01 or later. % The command |\@@_tag| will be linked to |\tag| in the environment |{DispWithArrows}|. % \begin{macrocode} \NewDocumentCommand \@@_tag {sm} - {\bool_set_false:N \l_@@_notag_bool + {\tl_if_empty:NF \l_@@_tag_tl + {\msg_error:nnn {witharrows} {Multiple~tags} {#2}} + \bool_set_false:N \l_@@_notag_bool + \bool_if:nT \c_@@_mathtools_loaded_bool + {\MH_if_boolean:nT {show_only_refs} + {\MH_if_boolean:nF {show_manual_tags} + {\bool_set_true:N \l_@@_notag_bool}}} \tl_set:Nn \l_@@_tag_tl {#2} \bool_set:Nn \l_@@_tag_star_bool {#1} % \end{macrocode} @@ -2924,14 +3032,15 @@ version 2005/12/01 or later. % by desactivating the command |\tagform@| inserted by \pkg{amsmath} in the (two versions of the) command % |\@eqnnum|.\footnote{There are two versions of |@eqnnum|, a standard version and a version for the option |leqno|.} % \begin{macrocode} - \bool_if:nT {#1 && ! \cs_if_exist_p:N \tagform@} + \bool_if:nT {#1 && ! \bool_if_p:N \c_@@_amsmath_loaded_bool} { \msg_error:nn {witharrows} {tag*~without~amsmath} } } % \end{macrocode} % % % \bigskip -% With the environment |{DispWithArrows*}|, the equations are not numbered. +% With the environment |{DispWithArrows*}|, the equations are not numbered. We don't put |\begin{DispWithArrows}| +% and |\end{DispWithArrows}| because there is a |\@currenvir| in an error message. % \begin{macrocode} \NewDocumentEnvironment {DispWithArrows*} {} {\WithArrowsOptions{notag} @@ -3117,7 +3226,7 @@ version 2005/12/01 or later. % % \bigskip % The macro |\@@_draw_arrows_i:| is only for the lisibility of the code. This macro will draw the current arrow -% if the arrow is not impossible (that is to say if the Tikz node exists). The first |\group_begin:| is for the +% if the arrow is not impossible (that is to say if the Tikz nodes exist). The first |\group_begin:| is for the % options of the arrow. % \begin{macrocode} \cs_new:Nn \@@_draw_arrows_i: @@ -3469,8 +3578,8 @@ version 2005/12/01 or later. % \begin{macrocode} \msg_new:nnn {witharrows} {Third~column~in~an~environment~{DispWithArrows}} - {An~environment~\{DispWithArrows\}~or~\{DispWithArrows*\}~can~only~have~two~columns.~ - If~you~go~on,~you~may~have~an~incorrect~output.} + {An~environment~\{DispWithArrows\}~or~\{DispWithArrows*\}~can~only~ + have~two~columns.~If~you~go~on,~you~may~have~an~incorrect~output.} % \end{macrocode} % % \begin{macrocode} @@ -3518,21 +3627,24 @@ version 2005/12/01 or later. 5 {i} 6 {group} 7 {groups}}"~ - previously~set~in~the~same~ + set~in~the~same~ \int_case:nn\l_@@_level_int {1 {command~\token_to_str:N\WithArrowsOptions} - 2 {declaration~of~options~of~the~environment~\{WithArrows\}} + 2 {declaration~of~options~of~the~environment~ + \{\@currenvir\}} 3 {command~\token_to_str:N\Arrow}}.~ - If~you~go~on,~I~will~overwrite~the~first~option.} + If~you~go~on,~I~will~use~the~option~"\tl_use:N\l_keys_key_tl".} % \end{macrocode} % % \begin{macrocode} \msg_new:nnnn {witharrows} {All~lines~must~have~an~ampersand} - {All~lines~of~an~environment~\{WithArrows\}~should~have~an~second~column~ - (because~the~nodes~are~created~in~the~second~column).~However,~you~can~go~but~you~will~ - have~an~error~if~one~of~your~arrows~needs~an~PGF~node~absent~by~lack~of~ampersand.~ - If~you~don't~want~to~see~this~message~again,~you~can~use~the~option~ + {All~lines~of~an~environment~\{WithArrows\}~should~ + have~an~second~column~(because~the~nodes~are~created~ + in~the~second~column).~However,~you~can~go~but~you~will~ + have~an~error~if~one~of~your~arrows~needs~an~PGF~ + node~absent~by~lack~of~ampersand.~If~you~don't~want~to~ + see~this~message~again,~you~can~use~the~option~ AllowLineWithoutAmpersand.} {Moreover, the~ampersand~can~be~implicit~ (e.g.~if~you~use~\token_to_str:N\MoveEqLeft\ of~mathtools).} @@ -3639,6 +3751,27 @@ version 2005/12/01 or later. column~of~\{DispWithArrows\}~(and,~of~course,~in~the~ environments~of~amsmath).~If~you~go~on,~this~command~will~be~ignored.} % \end{macrocode} +% +% \begin{macrocode} +\msg_new:nnn {witharrows} + {Multiple~tags} + {You~can't~use~twice~the~command~\token_to_str:N\tag\ + in~a~line~of~the~environment~\{\@currenvir\}.~If~you~go~on,~the~tag~ + '#1'~will~be~used.} +% \end{macrocode} +% +% +% \begin{macrocode} +\msg_new:nnn {witharrows} + {Multiple~labels} + {Normaly,~we~can't~use~the~command~\token_to_str:N\label\ + twice~in~a~line~of~the~environment~\{\@currenvir\}.~ + However,~you~can~go~on.~ + 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).} +% \end{macrocode} +% % \section{History} % % \subsection{Changes between versions 1.0 and 1.1} @@ -3696,6 +3829,14 @@ version 2005/12/01 or later. % \subsection{Changes between 1.6.1 and 1.7} % % New environment |{DispWithArrows}|. +% +% \subsection{Changes between 1.7 and 1.8} +% +% The numbers and tags of the environment |{DispWithArrows}| are now compatible with all the major LaTeX packages +% concerning references (\pkg{autonum}, \pkg{cleveref}, \pkg{fancyref}, \pkg{hyperref}, \pkg{prettyref}, +% \pkg{refstyle}, \pkg{typedref} and \pkg{varioref}) and with the options |showonlyrefs| and |showmanualtags| of +% \pkg{mathtools}. +% % \endinput % % Local Variables: diff --git a/Master/texmf-dist/source/latex/witharrows/witharrows.ins b/Master/texmf-dist/source/latex/witharrows/witharrows.ins index 8e3a891c4dc..36e3de8aa20 100644 --- a/Master/texmf-dist/source/latex/witharrows/witharrows.ins +++ b/Master/texmf-dist/source/latex/witharrows/witharrows.ins @@ -1,5 +1,5 @@ %% -%% Copyright (C) 2017 by F. Pantigny +%% Copyright (C) 2017-2018 by F. Pantigny %% %% %% This file may be distributed and/or modified under the @@ -17,7 +17,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 conditions of the LaTeX Project Public License, either -- cgit v1.2.3