From 56c250a15c21205405acd7c0f05a958ef89387af Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 23 Feb 2024 22:01:24 +0000 Subject: mptrees (23feb24) git-svn-id: svn://tug.org/texlive/trunk@70091 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/metapost/mptrees/README.md | 5 +- .../doc/metapost/mptrees/mptrees-doc.pdf | Bin 146573 -> 203314 bytes .../doc/metapost/mptrees/mptrees-doc.tex | 461 ++++++++++- Master/texmf-dist/metapost/mptrees/mptrees.mp | 844 ++++++++++++++++++++- 4 files changed, 1261 insertions(+), 49 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/metapost/mptrees/README.md b/Master/texmf-dist/doc/metapost/mptrees/README.md index b982e778ca7..f74fa1c30c7 100644 --- a/Master/texmf-dist/doc/metapost/mptrees/README.md +++ b/Master/texmf-dist/doc/metapost/mptrees/README.md @@ -1,9 +1,8 @@ -Package mptrees - Version 23.04 - April 27, 2023 +Package mptrees - Version 24.02 - February 22, 2024 --- -This package provides MetaPost tools for drawing simple probability trees. -One main command, some variants and several parameters to control the output are provided. +This package provides MetaPost tools for drawing simple probability trees and graphs (in discrete geometry). --- diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf index 300937fc617..5a62a3b5176 100644 Binary files a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf and b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf differ diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex index 907e2eca9f1..1cc7339d014 100644 --- a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex +++ b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex @@ -17,7 +17,7 @@ \usepackage[bottom]{footmisc} \usepackage{mflogo} - + \usepackage[output-decimal-marker={,}]{siunitx} \usepackage{esvect} \usepackage{nicefrac} @@ -25,12 +25,11 @@ \usepackage{multicol} \setlength{\multicolsep}{3pt} \setlength{\columnsep}{0pt} - + \usepackage[toc]{multitoc} - + \usepackage{enumitem} -% \setlist[description]{font=\ttfamily\bfseries\color{blue}} - + \usepackage[svgnames]{xcolor} \usepackage{graphicx} @@ -38,7 +37,7 @@ \usepackage{url} \usepackage{verbatim} \usepackage{fancyvrb} - + \usepackage{array} \usepackage{colortbl} \usepackage{tabularx} @@ -53,7 +52,7 @@ beginfig(1);} \everyendmplib{endfig;} \mplibnumbersystem{decimal} - + \usepackage{tcolorbox} \tcbuselibrary{listings,skins}%,documentation} @@ -263,15 +262,14 @@ colback=red!10!white,colframe=red!50!black] - +\part{Trees} \section{Overview} -This package is intended to simplify the drawing of probability trees with \MP. It provides one main command and several parameters to control the output. +The first aim of this package is to simplify the drawing of probability trees (or other kind of "tree") with \MP. It provides one main command and several parameters to control the output. It can be used in standalone files with two compilations (\verb|latexmp| package is loaded) but also with Lua\LaTeX{} and \verb|luamplib| package. -%Some of the following constructions need to be enclosed between \verb|begintree| and \verb|endtree|. \begin{rpobjet}{tree[][](,,...)(,,,,...)}{picture} Probability tree located in column \verb|i| and row \verb|j| (see figure below). \verb|dim1|, \verb|dim2|,... can be numerics or pairs and control the dimension of the tree. \verb|ev1|, \verb|prob1|... can be strings or pictures and will be printed (using \verb|latexmp| if strings) at the end of the edge (the event) and above the edge (the probability). @@ -514,7 +512,7 @@ draw tree[2][1](3cm,2cm)(...); In the fisrt case, \verb|scaleev| is changed globally while in the second case, the change only applies to the first tree. - + \subsection{Event} \begin{mptparam}{scaleev}{numeric}{1} @@ -789,7 +787,7 @@ Note that double quotes have to be replaced by single quotes when this parameter \begin{mptparam}{brokenlineratio}{numeric}{0.2} If string \verb|branchtype| is set to \verb|broken|, \verb|brokenlineratio| indicates the ratio between the length of the first segment of the broken line and the total length of the horizontal space. \end{mptparam} - + \begin{exemple}[lefthand ratio=0.6] branchtype:="broken"; draw stree[1][1](3cm,3cm)("$A$","$B$"); @@ -1049,6 +1047,445 @@ draw stree[5][9]()("'u'|1","'o'|1"); endtree; \end{exemple} +\part{Graphs} +\section{Overview} +This package can also be used to draw graphs. In this case, you need to define the nodes by their coordinates and indicate the edges to be drawn. Various commands allow you to draw graphs quickly, but it is also possible to finely control the drawing of each node and edge. + +\section{Nodes} +\subsection{Definition} + +\begin{rpdeclaration}{defnodes(,,...)} +The easiest way to define the nodes : just put a list of pairs. This command does not draw anything, it just defines an array of pairs corresponding to the coordinates. By default the array name is \verb|A[]|. +\end{rpdeclaration} + +\begin{mptparam}{defnodename}{string}{"A"} +Default node array name. +\end{mptparam} + +\begin{mptparam}{nodename}{string}{"array"} +String indicating how the nodes are stored and labels are drawns: +\begin{itemize}[nosep] +\item with \verb|nodename="array"|, nodes are stored in \verb|A[]| and labelled \verb|A1|, \verb|A2|,... +\item with \verb|nodename="Alph"|, nodes are stored and labelled \verb|A|, \verb|B|,... +\item with \verb|nodename="alph"|, nodes are stored and labelled \verb|a|, \verb|b|,... +\item with \verb|nodename="arabic"|, nodes are stored in \verb|A[]|,... but are labelled $1$, $2$,... +\end{itemize} +\end{mptparam} + +\begin{rpdeclaration}{defnode(,)} +Nodes can be defined one by one. \verb|| is the node's name and \verb|| its coordinates. +\end{rpdeclaration} + +\subsection{Drawing} + +\begin{rplabel}{drawnodes.(,,...)} +Draw all the indicated nodes. These nodes can be designated either by name or by rank. If the list is empty, all the nodes are drawn. \verb|pos| can be empty or \verb|lft|, \verb|rt|, etc. or an angle. +\end{rplabel} + +\begin{exemple}[lefthand ratio = 0.6] +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(1,3); +\end{exemple} + +\begin{exemple}[lefthand ratio = 0.6] +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(A1,A3); +\end{exemple} + +\begin{exemple}[lefthand ratio = 0.6] +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + + +\begin{exemple}[lefthand ratio = 0.6] +defnodename:="N"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + + +\begin{exemple}[lefthand ratio = 0.6] +nodename:="Alph"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + +\begin{exemple}[lefthand ratio = 0.6] +nodename:="alph"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + +\begin{exemple}[lefthand ratio = 0.6] +nodename:="arabic"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + +\begin{mptparam}{printnodename}{boolean}{true} +When set to false, node names are not printed. +\end{mptparam} + +\begin{exemple}[lefthand ratio = 0.6] +printnodename:=false; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + + +\begin{mptparam}{nodeformat}{string}{""} +String that indicates how the nodes are printed (the shape of path around the node). Possible values are (for now) \verb|"bbox"|, \verb|"circle"|, \verb|"superellipse"| and \verb|"square"|. +\end{mptparam} + + +\begin{mptparam}{nodewidth}{numeric}{0.6cm} +Node width... +\end{mptparam} + +\begin{exemple}[lefthand ratio = 0.6] +nodeformat:="square"; +nodewidth:=1cm; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + +\begin{exemple}[lefthand ratio = 0.6] +nodewidth:=0.2cm; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes.bot(); +\end{exemple} + +\begin{mptparam}{naturalwidth}{boolean}{false} +When set to true, the width of the node adapts to the content. +\end{mptparam} + +\begin{exemple}[lefthand ratio = 0.6] +defnodename:="AA"; +naturalwidth:=true; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + +\begin{mptparam}{nodelinewidth}{numeric}{1} +Line width of the path around the node. +\end{mptparam} + +\begin{mptparam}{nodelinecolor}{color}{black} +Color of the path around the node. +\end{mptparam} + +\begin{mptparam}{nodebgcolor}{color}{white} +Color of the background of the region delimited by the previous path. +\end{mptparam} + +\begin{mptparam}{nodefgcolor}{color}{black} +Color of the text. +\end{mptparam} + + +\begin{exemple}[lefthand ratio = 0.6] +nodelinecolor:=(0.8,0,0); +nodebgcolor:=(1,0.5,0.5); +nodefgcolor:=white; +nodeformat:="superellipse"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes(); +\end{exemple} + + +\begin{rpdeclaration}{drawnodes() withbgcolor } +While \verb|withcolor| applies to lines and labels, \verb|withbgcolor| applies to the filling of nodes. +\end{rpdeclaration} + +\begin{exemple}[lefthand ratio = 0.63] +nodelinecolor:=(0.8,0,0); +nodebgcolor:=(1,0.5,0.5); +nodefgcolor:=white; +nodeformat:="superellipse"; +defnodes((0cm,0cm),(2cm,0),(4cm,0)); +drawnodes() withcolor black withbgcolor (0.6,0.6,1); +\end{exemple} + + +\begin{rplabel}{drawnode.(,