diff options
author | Karl Berry <karl@freefriends.org> | 2023-06-14 20:13:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-06-14 20:13:32 +0000 |
commit | 1bc679a3072ee3db3e2c8e5bc7584d8514c01637 (patch) | |
tree | e6570d417c858091a5759d5356b7c0bd4faabff4 /Master/texmf-dist/source/latex/string-diagrams | |
parent | bdac67d60134d07b6372cd89c409ccceb3220ad7 (diff) |
string-diagrams (14jun23)
git-svn-id: svn://tug.org/texlive/trunk@67363 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/string-diagrams')
-rw-r--r-- | Master/texmf-dist/source/latex/string-diagrams/string-diagrams.dtx | 69 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/string-diagrams/string-diagrams.ins | 2 |
2 files changed, 50 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.dtx b/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.dtx index 7bad0f7a637..d6480673a23 100644 --- a/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.dtx +++ b/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment %% ============================================================================= %% -%% string-diagrams 0.2.0 (2023/06/12) +%% string-diagrams 0.2.1 (2023/06/13) %% %% Copyright (C) 2023 by Paolo Brasolin <paolo.brasolin@gmail.com> %% SPDX-License-Identifier: LPPL-1.3c @@ -75,6 +75,8 @@ \documentclass[a4paper,full]{l3doc} \usepackage{parskip} +\NewDocumentCommand{\TikZ}{}{Ti\emph{k}Z} + \EnableCrossrefs \CodelineIndex \RecordChanges @@ -168,7 +170,7 @@ % \end{tikzpicture} % \end{tcblisting} % -% You can draw multiple boxes using any of your standard Ti\emph{k}Z positioning techniques. +% You can draw multiple boxes using any of your standard \TikZ\ positioning techniques. % Don't forget to label the nodes so you can easily reference them. % % \begin{tcblisting}{example} @@ -247,13 +249,13 @@ % % \end{function} % -% \begin{function}[added=2023-05-31]{\wires} +% \begin{function}[added=2023-05-31,updated=2023-06-13]{\wires} % \begin{syntax} -% \cs{wires}\oarg{Ti\emph{k}Z keys}\marg{connectivity}\marg{loose ends} +% \cs{wires}\oarg{\TikZ\ keys}\marg{connectivity}\marg{loose ends} % \end{syntax} % % To connect boxes, you can use the \cmd\wires\ macro. -% The first argument is Ti\emph{k}Z styling for the wires; the second argument is a nested dicionary specifying the connectivity; the third argument is a list of the loose ends to draw. +% The first argument is \TikZ\ styling for the wires; the second argument is a nested dicionary specifying the connectivity; the third argument is a list of the loose ends to draw. % \texttt{box}es have the following anchors: \texttt{west}, \texttt{west.0}, \texttt{west.1}, \texttt{east}, \texttt{east.0}, and \texttt{east.1}. % % \begin{tcblisting}{example} @@ -262,7 +264,7 @@ % \node[box=0/1/0/2] (B) at (+2, 0) {B}; % \node[box=0/1/0/1] (C) at ( 0,+1) {C}; % \node[box=0/1/0/1] (D) at ( 0,-1) {D}; -% \wires[]{ +% \wires{ % A = { east.1 = C.west, east.2 = D.west }, % C = { east = B.west.1 }, % D = { east = B.west.2 }, @@ -322,8 +324,8 @@ % \begin{macrocode} \ProvidesExplPackage {string-diagrams} - {2023/06/12} - {0.2.0} + {2023/06/13} + {0.2.1} {Draw string diagrams using TikZ} % \end{macrocode} % @@ -401,7 +403,7 @@ % \end{macro} % % \begin{macro}{box} -% \changes{0.2.0}{2023/06/12}{make ports configurable through Ti\emph{k}Z keys} +% \changes{0.2.0}{2023/06/12}{make ports configurable through \TikZ\ keys} % % Define a rectangular shape with configurable ports. % \begin{macrocode} @@ -487,31 +489,34 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\wires} -% Define our main actor. +% \begin{macro}{\@@_draw_bound_wires:nn} +% Draws bound wires. +% \begin{arguments} +% \item \TikZ\ keys +% \item dictionary of port labels +% \end{arguments} % \begin{macrocode} -\NewDocumentCommand{\wires}{ o m m } -{ +\cs_new:Nn \@@_draw_bound_wires:nn { \prop_set_from_keyval:Nn \l_tmpa_prop { #2 } \prop_map_inline:Nn \l_tmpa_prop { \prop_set_from_keyval:Nn \l_tmpb_prop { ##2 } \prop_map_inline:Nn \l_tmpb_prop { - \regex_match_case:nnTF + \regex_match_case:nn { { \. north } { \tl_gset:Nn \g_tmpa_tl { 90 } } { \. south } { \tl_gset:Nn \g_tmpa_tl { -90 } } { \. west } { \tl_gset:Nn \g_tmpa_tl { 180 } } { \. east } { \tl_gset:Nn \g_tmpa_tl { 0 } } - } { ####2 } {} {} - \regex_match_case:nnTF + } { ####2 } + \regex_match_case:nn { { north } { \tl_gset:Nn \g_tmpb_tl { 90 } } { south } { \tl_gset:Nn \g_tmpb_tl { -90 } } { west } { \tl_gset:Nn \g_tmpb_tl { 180 } } { east } { \tl_gset:Nn \g_tmpb_tl { 0 } } - } { ####1 } {} {} + } { ####1 } \draw [ out={\tl_use:N \g_tmpb_tl}, in={\tl_use:N \g_tmpa_tl}, @@ -519,9 +524,21 @@ ] (##1.####1) to (####2); } } - \clist_set:Nn \l_tmpa_clist { #3 } +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_draw_loose_wires:nn} +% Draws loose wires. +% \begin{arguments} +% \item \TikZ\ keys +% \item list of port labels +% \end{arguments} +% \begin{macrocode} +\cs_new:Nn \@@_draw_loose_wires:nn { + \clist_set:Nn \l_tmpa_clist { #2 } \clist_map_inline:Nn \l_tmpa_clist { - \regex_match_case:nnTF + \regex_match_case:nn { { \. north } { \draw[#1] (##1) -- +( 0,+1); } % TODO: cleaner solution? { \. south } @@ -531,12 +548,24 @@ } % TODO: not sure why this works { \. west } { \draw[#1] (##1) -- +(-1, 0); } { \. east } { \draw[#1] (##1) -- +(+1, 0); } - } { ##1 } {} {} + } { ##1 } } } % \end{macrocode} % \end{macro} % +% \begin{macro}{\wires} +% \changes{0.2.1}{2023/06/13}{now correctly handles optional style parameter} +% Define our main actor. +% \begin{macrocode} +\NewDocumentCommand{\wires}{ O{} m m } +{ + \@@_draw_bound_wires:nn { #1 } { #2 } + \@@_draw_loose_wires:nn { #1 } { #3 } +} +% \end{macrocode} +% \end{macro} +% % Close the \pkg{DocStrip} guards and call it a day. % \begin{macrocode} %</package> diff --git a/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.ins b/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.ins index 9d4304f5915..96d08b2a9f7 100644 --- a/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.ins +++ b/Master/texmf-dist/source/latex/string-diagrams/string-diagrams.ins @@ -8,7 +8,7 @@ %% %% ============================================================================= %% -%% string-diagrams 0.2.0 (2023/06/12) +%% string-diagrams 0.2.1 (2023/06/13) %% %% Copyright (C) 2023 by Paolo Brasolin <paolo.brasolin@gmail.com> %% SPDX-License-Identifier: LPPL-1.3c |