texlive[69123] Master/texmf-dist: messagepassing (14dec23)
commits+karl at tug.org
commits+karl at tug.org
Thu Dec 14 21:58:57 CET 2023
Revision: 69123
https://tug.org/svn/texlive?view=revision&revision=69123
Author: karl
Date: 2023-12-14 21:58:57 +0100 (Thu, 14 Dec 2023)
Log Message:
-----------
messagepassing (14dec23)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/messagepassing/messagepassing.pdf
trunk/Master/texmf-dist/source/latex/messagepassing/messagepassing.dtx
trunk/Master/texmf-dist/tex/latex/messagepassing/messagepassing.sty
Modified: trunk/Master/texmf-dist/doc/latex/messagepassing/messagepassing.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/messagepassing/messagepassing.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/messagepassing/messagepassing.dtx 2023-12-14 02:27:07 UTC (rev 69122)
+++ trunk/Master/texmf-dist/source/latex/messagepassing/messagepassing.dtx 2023-12-14 20:58:57 UTC (rev 69123)
@@ -14,7 +14,7 @@
% \iffalse
%<package> \NeedsTeXFormat{LaTeX2e}
-%<package> \ProvidesPackage{messagepassing}[2022/02/18 v1.0 A package to draw message passing diagrams]
+%<package> \ProvidesPackage{messagepassing}[2023/12/13 v1.2 A package to draw message passing diagrams]
%<package> \RequirePackage{tikz}
%<package> \usetikzlibrary{quotes, calc, arrows.meta}
%<package> \RequirePackage{xparse}
@@ -60,6 +60,8 @@
% Right brace \} Tilde \~}
%
%
+% \changes{v1.2}{2023/12/13}{Add optional display names in processes and message node options}
+% \changes{v1.1}{2022/07/20}{Consistent spelling of "colour"}
% \changes{v1.0}{2022/02/18}{Initial version for publication}
%
% \GetFileInfo{messagepassing.sty}
@@ -117,7 +119,7 @@
% bottom, instead of from left to right. Doing so, almost all
% labels\footnote{Annotations are not rotated, unless explicitly asked.} are
% rotated as well. If, \emph{in addition}, \verb+annotatevertical+ is set, then
-% annotations (including named of colouredboxes) are rotated as well.
+% annotations (including names of colouredboxes) are rotated as well.
% \subsection{Basic usage}
% \subsubsection{Creating a diagram.}
@@ -150,8 +152,12 @@
% \subparagraph{Creating a new process.}
% Each process is characterised by its name.
% \DescribeMacro{\newprocess} The simplest macro to create a new process is then
-% |\newprocess| \marg{name}, where \marg{name} is the name of the process (resp.
-% \(p\), \(q\), and \(r\) in Figure~\ref{mp:ex1}).
+% |\newprocess| \marg{name} \oarg{display name}, where \marg{name} is the name
+% of the process (resp. \(p\), \(q\), and \(r\) in Figure~\ref{mp:ex1}). If
+% \oarg{display name} is provided, it is used as the name when rendering the
+% figure, while \marg{name} is used internally to refer to the process. This
+% allows you to use names that can not be used internally (e.g.\ with maths or
+% things like that).
%
% In addition, we often draw a horizontal\footnote{By default, the line is vertical if
% the option |vertical| is used.} line that represent the running process.
@@ -160,21 +166,21 @@
% creates a line of length \emph{length} for process \emph{process}.}, we also
% provide a simple macro that performs both actions:
% \DescribeMacro{\newprocesswithlength}
-% |\newprocesswithlength|\marg{name}\marg{length}.
+% |\newprocesswithlength|\marg{name}\oarg{display name}\marg{length}.
%
% An other alternative is to name the state in which the process starts (in
% Fig~\ref{mp:ex1}, we call those states \(si\) as \emph{state intervals}).
% Again, this can be achieved using individual commands, but we also provide
% \DescribeMacro{\newprocesswithstateinterval}
-% |\newprocesswithstateinterval|\marg{name}\marg{state name}.
+% |\newprocesswithstateinterval|\marg{name}\oarg{display name}\marg{state name}.
%
% Finally, an other way to create a process is to create a process that
% (eventually) fails, which is represented by the process' line terminating
% early with a cross. For that, we provide \DescribeMacro{\newprocesswithcrash}
-% |\newprocesswithcrash|\marg{name}\marg{length}\marg{crash coordinate name}.
-% The first two arguments are similar to |\newprocesswithlength|, and the latter
-% one is used to provide a name for the coordinate where the crash occurs. This
-% name can later be used to place nodes.
+% |\newprocesswithcrash|\marg{name}\oarg{display name}\marg{length}\marg{crash coordinate name}.
+% The first arguments are similar to |\newprocesswithlength|, and the last one
+% is used to provide a name for the coordinate where the crash occurs. This name
+% can later be used to place nodes.
%
% Of course, we can imagine other combinations (e.g. a process with a length and
% a state interval). We do not provide individual commands for each combination,
@@ -205,17 +211,22 @@
% according to their timestamp\footnote{Notice that nothing prevents sending
% messages in the past, simply set a receiving time before the sending time.}.
%
+% For instance, in Figure~\ref{fig:ex_msg}, we use |\send{p}{1}{q}{2}|.
+%
% In addition, we can label the arrow with the message that is sent with
% \DescribeMacro{\sendwithname}
% |\sendwithname|\marg{sender}\marg{send time}\marg{receiver}\marg{receive
-% time}\marg{label}.
-% For instance, in Figure~\ref{fig:ex_msg}, we use |\send{p}{1}{q}{2}|.
+% time}\marg{label}\oarg{label options}. The \marg{label} contains the label
+% that should be displayed. The package provides default positioning options for
+% the label, which should be acceptable for most cases. Those positioning
+% options can be overridden by \oarg{label options}, which should be \TikZ node
+% options.
%
% Finally, we sometimes distinguish \emph{out-of-band} messages, e.g. messages
% that do not carry informations, but that are for instance used for metadata,
% etc.. We provide the macro
% \DescribeMacro{\sendoutofband}|\sendoutofband|\marg{sender}\marg{send time}\marg{receiver}\marg{receive
-% time}\marg{label}, which behaves similarly to |\sendwithname|, but prints the
+% time}\marg{label}\oarg{label options}, which behaves similarly to |\sendwithname|, but prints the
% message in an other colour.
%
% \begin{figure}
@@ -315,7 +326,7 @@
% A checkpoint can be added with
% \DescribeMacro{\checkpoint}|\checkpoint|\marg{process}\marg{time}\marg{name},
% where \emph{process} is the name of the process which takes a checkpoint,
-% \emph{time} is the the time at which the checkpoint is taken, and \emph{name}
+% \emph{time} is the time at which the checkpoint is taken, and \emph{name}
% is the name of the checkpoint, that is printed next to it, and can be used as
% a coordinate. Notice that the name is printed in a math environment, as we
% expect most checkpoints names to be indexed, e.g.\(c_1\), \(c_2\), etc.
@@ -425,12 +436,12 @@
% Two parts of the package use colours: colouredboxes and out-of-band messages. By
% default both are shades of red. We provide commands to change that if desired.
%
-% \DescribeMacro{\colouredboxcolor}|\colouredboxcolor|\marg{colour} changes the colour
+% \DescribeMacro{\colouredboxcolour}|\colouredboxcolour|\marg{colour} changes the colour
% used for colouredboxes. Notice that this sets both the background colour (which is
% a light variant of the provided colour) and the text colour (which uses the
% provided colour).
%
-% \DescribeMacro{\oobcolor}|\oobcolor|\marg{colour} changes the colour used for
+% \DescribeMacro{\oobcolour}|\oobcolour|\marg{colour} changes the colour used for
% out-of-band messages.
%
% \subsubsection{Coordinates}
@@ -579,14 +590,14 @@
\newcommand{\mp at annotaterotation}{0}
\fi
-\newcommand{\mp at oobcolor}{red}
-\newcommand{\oobcolor}[1]{
- \renewcommand\mp at oobcolor{#1}
+\newcommand{\mp at oobcolour}{red}
+\newcommand{\oobcolour}[1]{
+ \renewcommand\mp at oobcolour{#1}
}
-\newcommand{\mp at colouredboxcolor}{red}
-\newcommand{\colouredboxcolor}[1]{
- \renewcommand\mp at colouredboxcolor{#1}
+\newcommand{\mp at colouredboxcolour}{red}
+\newcommand{\colouredboxcolour}[1]{
+ \renewcommand\mp at colouredboxcolour{#1}
}
\newif\iftimeline
@@ -655,38 +666,42 @@
%
% \begin{macrocode}
%% #1: name
-\newcommand{\newprocess}[1]{
+%% #2: display name
+\NewDocumentCommand{\newprocess}{m o}{
\addtocounter{processnb}{1}
\coordinate (#1) at (0, -\value{processnb});
- \draw (#1) node[anchor=\mp at processnameanchor] {$#1$};
+ \draw (#1) node[anchor=\mp at processnameanchor] {\IfValueTF{#2}{#2}{$#1$}};
}
% \end{macrocode}
%
% \begin{macrocode}
%% #1: name
-%% #2: width
-\newcommand{\newprocesswithlength}[2]{
- \newprocess{#1}
- \processlength{#1}{#2}
+%% #2: display name
+%% #3: width
+\NewDocumentCommand{\newprocesswithlength}{m o m}{
+ \newprocess{#1}[#2]
+ \processlength{#1}{#3}
}
% \end{macrocode}
%
% \begin{macrocode}
%% #1: name
-%% #2: state interval name
-\newcommand{\newprocesswithstateinterval}[2]{
- \newprocess{#1}
- \stateinterval{#1}{0}{#2}
+%% #2: display name
+%% #3: state interval name
+\NewDocumentCommand{\newprocesswithstateinterval}{m o m}{
+ \newprocess{#1}[#2]
+ \stateinterval{#1}{0}{#3}
}
% \end{macrocode}
%
% \begin{macrocode}
%% #1: name
-%% #2: width
-%% #3: crash name
-\newcommand{\newprocesswithcrash}[3]{
- \newprocess{#1}{#2}
- \crash{#1}{#2}{#3}
+%% #2: display name
+%% #3: width
+%% #4: crash name
+\NewDocumentCommand{\newprocesswithcrash}{m o m m}{
+ \newprocess{#1}[#2]{#3}
+ \crash{#1}{#3}{#4}
}
% \end{macrocode}
%
@@ -706,8 +721,13 @@
%% #3: receiver's name
%% #4: receive date
%% #5: message name
-\newcommand{\sendwithname}[5]{
- \draw[->] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
+%% #6: message name display options
+\NewDocumentCommand{\sendwithname}{m m m m m o}{
+ \IfValueTF{#6}{
+ \draw[->] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3, #6] {#5};
+ }{
+ \draw[->] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
+ }
}
% \end{macrocode}
%
@@ -738,8 +758,9 @@
%% #4: receive date
%% #5: state interval name
%% #6: message name
-\newcommand{\sendwithstateintervalandname}[6] {
- \sendwithname{#1}{#2}{#3}{#4}{#6}
+%% #7: message name display options
+\NewDocumentCommand{\sendwithstateintervalandname}{m m m m m m o} {
+ \sendwithname{#1}{#2}{#3}{#4}{#6}[#7]
\stateinterval{#3}{#4}{#5}
}
% \end{macrocode}
@@ -750,8 +771,13 @@
%% #3: receiver's name
%% #4: receive date
%% #5: OoB message name
-\newcommand{\sendoutofband}[5]{
- \draw[->, color=\mp at oobcolor] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
+%% #6: OoB message name display options
+\NewDocumentCommand{\sendoutofband}{m m m m m o}{
+ \IfValueTF{#6}{
+ \draw[->, color=\mp at oobcolour] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3, #6] {#5};
+ }{
+ \draw[->, color=\mp at oobcolour] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
+ }
}
% \end{macrocode}
%
@@ -826,7 +852,7 @@
%% #5: caption
\newcommand{\colouredbox}[5]{
\begin{pgfonlayer}{background}
- \fill[color=\mp at colouredboxcolor!20] ($(#1) + (#3, 0)$) rectangle ($(#2) + (#4, 0)$) node[midway, color = \mp at colouredboxcolor, rotate=\mp at annotaterotation]{#5};
+ \fill[color=\mp at colouredboxcolour!20] ($(#1) + (#3, 0)$) rectangle ($(#2) + (#4, 0)$) node[midway, color = \mp at colouredboxcolour, rotate=\mp at annotaterotation]{#5};
\end{pgfonlayer}
}
% \end{macrocode}
Modified: trunk/Master/texmf-dist/tex/latex/messagepassing/messagepassing.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/messagepassing/messagepassing.sty 2023-12-14 02:27:07 UTC (rev 69122)
+++ trunk/Master/texmf-dist/tex/latex/messagepassing/messagepassing.sty 2023-12-14 20:58:57 UTC (rev 69123)
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}
- \ProvidesPackage{messagepassing}[2022/02/18 v1.0 A package to draw message passing diagrams]
+ \ProvidesPackage{messagepassing}[2023/12/13 v1.2 A package to draw message passing diagrams]
\RequirePackage{tikz}
\usetikzlibrary{quotes, calc, arrows.meta}
\RequirePackage{xparse}
@@ -85,14 +85,14 @@
\newcommand{\mp at annotaterotation}{0}
\fi
-\newcommand{\mp at oobcolor}{red}
-\newcommand{\oobcolor}[1]{
-\renewcommand\mp at oobcolor{#1}
+\newcommand{\mp at oobcolour}{red}
+\newcommand{\oobcolour}[1]{
+\renewcommand\mp at oobcolour{#1}
}
-\newcommand{\mp at colouredboxcolor}{red}
-\newcommand{\colouredboxcolor}[1]{
-\renewcommand\mp at colouredboxcolor{#1}
+\newcommand{\mp at colouredboxcolour}{red}
+\newcommand{\colouredboxcolour}[1]{
+\renewcommand\mp at colouredboxcolour{#1}
}
\newif\iftimeline
@@ -153,29 +153,33 @@
}
\ExplSyntaxOff
%% #1: name
-\newcommand{\newprocess}[1]{
+%% #2: display name
+\NewDocumentCommand{\newprocess}{m o}{
\addtocounter{processnb}{1}
\coordinate (#1) at (0, -\value{processnb});
-\draw (#1) node[anchor=\mp at processnameanchor] {$#1$};
+\draw (#1) node[anchor=\mp at processnameanchor] {\IfValueTF{#2}{#2}{$#1$}};
}
%% #1: name
-%% #2: width
-\newcommand{\newprocesswithlength}[2]{
-\newprocess{#1}
-\processlength{#1}{#2}
+%% #2: display name
+%% #3: width
+\NewDocumentCommand{\newprocesswithlength}{m o m}{
+\newprocess{#1}[#2]
+\processlength{#1}{#3}
}
%% #1: name
-%% #2: state interval name
-\newcommand{\newprocesswithstateinterval}[2]{
-\newprocess{#1}
-\stateinterval{#1}{0}{#2}
+%% #2: display name
+%% #3: state interval name
+\NewDocumentCommand{\newprocesswithstateinterval}{m o m}{
+\newprocess{#1}[#2]
+\stateinterval{#1}{0}{#3}
}
%% #1: name
-%% #2: width
-%% #3: crash name
-\newcommand{\newprocesswithcrash}[3]{
-\newprocess{#1}{#2}
-\crash{#1}{#2}{#3}
+%% #2: display name
+%% #3: width
+%% #4: crash name
+\NewDocumentCommand{\newprocesswithcrash}{m o m m}{
+\newprocess{#1}[#2]{#3}
+\crash{#1}{#3}{#4}
}
%% #1: sender's name
%% #2: send date
@@ -189,9 +193,14 @@
%% #3: receiver's name
%% #4: receive date
%% #5: message name
-\newcommand{\sendwithname}[5]{
+%% #6: message name display options
+\NewDocumentCommand{\sendwithname}{m m m m m o}{
+\IfValueTF{#6}{
+\draw[->] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3, #6] {#5};
+}{
\draw[->] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
}
+}
%% #1: process name
%% #2: process width
\newcommand{\processlength}[2]{
@@ -212,8 +221,9 @@
%% #4: receive date
%% #5: state interval name
%% #6: message name
-\newcommand{\sendwithstateintervalandname}[6] {
-\sendwithname{#1}{#2}{#3}{#4}{#6}
+%% #7: message name display options
+\NewDocumentCommand{\sendwithstateintervalandname}{m m m m m m o} {
+\sendwithname{#1}{#2}{#3}{#4}{#6}[#7]
\stateinterval{#3}{#4}{#5}
}
%% #1: sender's name
@@ -221,9 +231,14 @@
%% #3: receiver's name
%% #4: receive date
%% #5: OoB message name
-\newcommand{\sendoutofband}[5]{
-\draw[->, color=\mp at oobcolor] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
+%% #6: OoB message name display options
+\NewDocumentCommand{\sendoutofband}{m m m m m o}{
+\IfValueTF{#6}{
+\draw[->, color=\mp at oobcolour] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3, #6] {#5};
+}{
+\draw[->, color=\mp at oobcolour] (#1) +(#2, 0) -- ($ (#3) +(#4, 0) $) node[anchor=\mp at messagelabelanchor, pos=0.3] {#5};
}
+}
%% #1: process's name
%% #2: state interval date
%% #3: state interval name
@@ -276,7 +291,7 @@
%% #5: caption
\newcommand{\colouredbox}[5]{
\begin{pgfonlayer}{background}
-\fill[color=\mp at colouredboxcolor!20] ($(#1) + (#3, 0)$) rectangle ($(#2) + (#4, 0)$) node[midway, color = \mp at colouredboxcolor, rotate=\mp at annotaterotation]{#5};
+\fill[color=\mp at colouredboxcolour!20] ($(#1) + (#3, 0)$) rectangle ($(#2) + (#4, 0)$) node[midway, color = \mp at colouredboxcolour, rotate=\mp at annotaterotation]{#5};
\end{pgfonlayer}
}
%% #1: Timeline length
More information about the tex-live-commits
mailing list.