summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-04 23:46:18 +0000
committerKarl Berry <karl@freefriends.org>2017-06-04 23:46:18 +0000
commita3b4fdac70b493a7f09ffa14c4e0e1a581c0c213 (patch)
tree173846a645fa67bf1dd0b8cfdbf6592ac1f4cb74 /Master/texmf-dist/doc/metapost
parentb0f56d42fd0a34fb4afdac35f6b58625e2b67057 (diff)
mptrees (2jun17)
git-svn-id: svn://tug.org/texlive/trunk@44453 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost')
-rw-r--r--Master/texmf-dist/doc/metapost/mptrees/README.md2
-rw-r--r--Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdfbin388957 -> 429600 bytes
-rw-r--r--Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex246
3 files changed, 211 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/metapost/mptrees/README.md b/Master/texmf-dist/doc/metapost/mptrees/README.md
index c038dca046a..ee9e901ceab 100644
--- a/Master/texmf-dist/doc/metapost/mptrees/README.md
+++ b/Master/texmf-dist/doc/metapost/mptrees/README.md
@@ -1,4 +1,4 @@
-Package mptrees - Version 17.05 - May 10, 2017
+Package mptrees - Version 17.06 - June 1, 2017
This package provides MetaPost tools for drawing simple probability trees.
One command and several parameters to control the output are provided.
diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf
index f86d52150ce..816b302304c 100644
--- a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf
+++ b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex
index 78fb19f8b14..e1a2387913a 100644
--- a/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex
+++ b/Master/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex
@@ -208,9 +208,9 @@
\setcounter{tocdepth}{2}
-%\setlength{\columnsep}{25pt}
-%\tableofcontents
-%\setlength{\columnsep}{10pt}
+\setlength{\columnsep}{25pt}
+\tableofcontents
+\setlength{\columnsep}{10pt}
\newcommand{\ijc}{[i][j]}
@@ -228,15 +228,15 @@ dirtree:=0;
\section{Overview}
-This package is intended to simplify the drawing of probability trees with \MP. It provides one command and several parameters to control the output.
+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.
It can be used in standalone files with two compilations (\verb|latexmp| package is loaded) but it can also be used with Lua\LaTeX{} and \verb|luamplib| package.
\begin{description}
-\item[tree\ijc (dim1,dim2,...)(ev1,prob1,ev2,prob2,...)] 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|... are strings and will be printed (using \verb|latexmp|) at the end of the edge (the event) and above the edge (the probability).
+\item[tree\ijc (dim1,dim2,...)(ev1,prob1,ev2,prob2,...)] 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).
-\item[shiftev, scaleprob, posprob, typeprob, proboffset, dirtree] numerics controlling the scale and position of the probability label, the direction of the tree...
+%\item[shiftev, scaleprob, posprob, typeprob, proboffset, dirtree] numerics controlling the scale and position of the probability label, the direction of the tree...
\end{description}
@@ -266,7 +266,8 @@ endfig;
\end{center}
-\section{Different kinds of trees}
+\section{Trees}
+\subsection{Different kinds of trees}
\begin{description}
\item[tree\ijc (width,vspace)(ev1,prob1,ev2,prob2,...)] regular tree where \verb|width| is the horizontal width of the tree and \verb|vspace| the vertical space between two consecutive nodes.
@@ -275,7 +276,7 @@ endfig;
string dim[];
dim[4]:="4 cm";dim[3]:="3 cm";dim[2]:="2 cm";dim[1]:="1 cm";
dim[15]:="1.5 cm";dim[25]:="2.5 cm";dim[11]:="-1 cm";
-dim[22]:="-2 cm";
+dim[22]:="-2 cm";dim[7]:="7cm";
\end{codecache}
@@ -339,29 +340,118 @@ draw tree[2][1]((3cm,2cm),(4cm,-1cm))("$B$","$q$","$C$","$r$");
\begin{codecache}
extra_endfig:="";
\end{codecache}
+\end{description}
+
+\subsection{Start and end labels}
+\begin{description}
+\item[startlabel(s)] Print \verb|s| (can be a string or a picture) at the origin of the tree.
+
+\begin{exemple}[0.65]
+ draw startlabel("$S$");
+ draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$");
+\end{exemple}
+
+\item[endlabel\ijc(s)] Print \verb|s| at the end of a branch. The space between the previous label ans \verb|s| is controlled by the numeric \verb|endlabelspace| which defaults to \verb|1cm|.
+
+\begin{exemplev}{1}
+ draw startlabel("$S$");
+ draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$");
+ draw tree[2][2](2cm,1cm)("$A$","$p$","$B$","$q$");
+ draw endlabel[2][1]("$SA$");
+ draw endlabel[3][1]("$SBA$");
+ draw endlabel[3][2]("$SBB$");
+\end{exemplev}
\end{description}
-\section{Parameters}
+\section{Direction}
\begin{description}
-\item[shiftev] The origin of each tree is located where the bounding box of the previous event's name ends. Thus subtrees may begin at different places. The numeric \verb|shiftev| indicates the horizontal space between the end of the edges and the beginning of following trees. It should be used inside the first set of parameters of the tree (see example below).
+\item[dirtree] All trees are construct horizontally by default. \verb|ditree| indicates the angle in degrees between the horizontal and the main direction of the tree. Default is $0$.
+
+
\begin{exemplev}{1}
- draw arbre[1][1](80,120)("$A$","$0.5$","$\overline{A}$","$0.5$");
- draw arbre[2][1](70,40)("Yes","$p$","No","$q$","Maybe","$r$");
- draw arbre[2][2](70,40,"shiftev:=1.5cm")("Yes","$p$","No","$q$","Maybe","$r$");
- draw arbre[3][1](50,20)("$B$","$b$","$C$","$c$");
- draw arbre[3][2](50,20)("$B$","$b$","$C$","$c$");
- draw arbre[3][3](50,20)("$B$","$b$","$C$","$c$");
- draw arbre[3][4](50,20)("$B$","$b$","$C$","$c$");
- draw arbre[3][5](50,20)("$B$","$b$","$C$","$c$");
- draw arbre[3][6](50,20)("$B$","$b$","$C$","$c$");
+dirtree:=135;
+draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$");
+draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$");
+draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$");
\end{exemplev}
-\item[scaleprob] numeric controlling the scale of the label above the edge (the probability). Default is $0.85$.
+\begin{exemplev}{1}
+dirtree:=-60;
+draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$");
+draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$");
+draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$");
+\end{exemplev}
-\item[posprob] numeric controlling the position of the label above the edge. Default is $0.6$.
+\begin{codecache}
+dirtree:=0;dirlabel:=0;
+\end{codecache}
+
+\item[dirlabel] With dirtree, the whole tree is rotated. With \verb|dirlabel|, only the position of the labels is changed so the given coordinates are the real ones. May be useful for vertical trees.
+
+\begin{exemplev}{1}
+dirlabel:=90;
+draw tree[1][1]((-1cm,2cm),(1cm,2cm))("$A$","$p$","$B$","$q$");
+draw tree[2][1]((-0.5cm,2cm),(0.5cm,2cm))("$C$","$c$","$D$","$d$");
+draw tree[2][2]((-0.5cm,2cm),(0.5cm,2cm))("$E$","$e$","$F$","$f$");
+\end{exemplev}
+
+\begin{codecache}
+dirlabel:=0;
+\end{codecache}
+
+\end{description}
+
+\section{Dealing with alignment}
+\begin{description}
+\item[shiftev] The origin of each tree is located where the bounding box of the previous event's name ends. Thus subtrees may begin at different places. The numeric \verb|shiftev| indicates the horizontal space between the end of the edges and the beginning of following trees.
+
+It can be used inside the first set of parameters of the tree (see example below) or as a global variable.
+
+
+\begin{exemplev}{1}
+ draw tree[1][1](80,120)("$A$","$0.5$","$\overline{A}$","$0.5$");
+ draw tree[2][1](70,40)("Yes","$p$","No","$q$","Maybe","$r$");
+ draw tree[2][2](70,40,"shiftev:=1.5cm")("Yes","$p$","No","$q$","Maybe","$r$");
+ draw tree[3][1](50,20)("$B$","$b$","$C$","$c$");
+ draw tree[3][2](50,20)("$B$","$b$","$C$","$c$");
+ draw tree[3][3](50,20)("$B$","$b$","$C$","$c$");
+ draw tree[3][4](50,20)("$B$","$b$","$C$","$c$");
+ draw tree[3][5](50,20)("$B$","$b$","$C$","$c$");
+ draw tree[3][6](50,20)("$B$","$b$","$C$","$c$");
+\end{exemplev}
+
+
+\item[abscoord] With the boolean \verb|abscoord| set to \verb|true|, all the coordinates are given from the origin of the \emph{first} tree instead of the origin of the subtree, which make easier the alignment of all the subtrees.
+\end{description}
+
+
+\begin{codecache}
+extra_endfig:="drawoptions(withcolor red);";
+extra_endfig:=extra_endfig & "drawdblarrow ((0,0)--(7cm,0)) shifted (0,2.25cm);label.top(textext(dim[7]),(3.5cm,2.25cm));";
+extra_endfig:=extra_endfig & "drawdblarrow ((0,0)--(0,2cm)) shifted (-0.5cm,0);label.lft(textext(dim[2]),(-0.5cm,1cm));";
+\end{codecache}
+
+\begin{exemplev}{1}
+abscoord:=true;
+draw tree[1][1](3cm,2cm)("$A$","$p$","Blabla","$q$");
+draw tree[2][1]((7cm,2cm),(7cm,0.5cm))("$A$","$p$","$B$","$q$");
+draw tree[2][2]((7cm,-0.5cm),(7cm,-2cm))("$A$","$p$","$B$","$q$");
+\end{exemplev}
+
+\begin{codecache}
+extra_endfig:="";
+abscoord:=false;
+\end{codecache}
+
+
+\section{Parameters}
+\begin{description}
+
+
+\item[scaleprob] numeric controlling the scale of the label above the edge (the probability). Default is $0.85$.
\begin{exemple}[0.65]
scaleprob:=1.5;
@@ -372,6 +462,22 @@ extra_endfig:="";
scaleprob:=0.85;
\end{codecache}
+
+\item[scaleev] numeric controlling the scale of the label at the end of the edge (the event). Default is $1$.
+
+\begin{exemple}[0.65]
+ scaleev:=2;
+ draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$");
+\end{exemple}
+
+\begin{codecache}
+scaleev:=1;
+\end{codecache}
+
+
+\item[posprob] numeric controlling the position of the label above the edge. Default is $0.6$.
+
+
\begin{exemple}[0.65]
posprob:=0.8;
draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$");
@@ -416,29 +522,40 @@ typeprob:=1;
draw tree[1][1](3cm,3cm)("$A$","$p+q+r$","$B$","$s$");
\end{exemple}
+\begin{codecache}
+proboffset:=3bp;
+\end{codecache}
+\item[edgearrow] When the boolean \verb|edgearrow| is set to true, edges end with an arrow. Default is \verb|false|.
-\item[dirtree] All trees are construct horizontally by default. \verb|ditree| indicates the angle in degrees between the horizontal and the main direction of the tree. Default is $0$.
-\end{description}
+\begin{exemple}[0.65]
+ edgearrow:=true;
+ draw tree[1][1](3cm,2cm)("$A$","$p$","$B$","$q$");
+\end{exemple}
\begin{codecache}
-proboffset:=3bp;
+edgearrow:=false;
\end{codecache}
-\begin{exemplev}{1}
-dirtree:=135;
-draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$");
-draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$");
-draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$");
-\end{exemplev}
+\item[endedgeshift] vertical space added at the end of the edge. Default is $0$. Useful when various edges end at the same point
+\begin{exemple}[0.65]
+ draw startlabel("$S$");
+ draw tree[1][1]((3cm,-1cm))("$A$","$p$");
+\end{exemple}
-\begin{exemplev}{1}
-dirtree:=-60;
-draw tree[1][1](3cm,2cm)("$A_1$","$a_1$","$A_2$","$a_2$");
-draw tree[2][1](3cm,1cm)("$B$","$b$","$C$","$c$");
-draw tree[2][2](3cm,1cm)("$D$","$p$","$E$","$q$");
-\end{exemplev}
+
+\begin{exemple}[0.65]
+ endedgeshift:=10;
+ draw startlabel("$S$");
+ draw tree[1][1]((3cm,-1cm))("$A$","$p$");
+\end{exemple}
+
+\begin{codecache}
+endedgeshift:=0;
+\end{codecache}
+
+\end{description}
\section{Embedded code in \LaTeX{} files}
@@ -528,9 +645,66 @@ endfig;
\end{minipage}
\end{center}
+\section{Examples}
+
+\begin{exemplev}[0.9]{1}
+u:=0.4cm;
+dirlabel:=90;
+abscoord:=true;
+endlabelspace:=0.5cm;
+draw startlabel("S");
+draw tree[1][1]((-5.5u,4u),(5.5u,8u))("NP","","VP","");
+draw tree[2][1]((-8.5u,12u),(-2.5u,8u))("A","","NP","");
+draw tree[2][2]((3.5u,12u),(7.5u,12u))("V","","Adv","");
+draw tree[3][2]((-4.5u,12u),(-0.5u,12u))("A","","N","");
+draw endlabel[3][1]("Colorless");
+draw endlabel[4][1]("green");
+draw endlabel[4][2]("ideas");
+draw endlabel[3][3]("sleep");
+draw endlabel[3][4]("furiously");
+\end{exemplev}
+\begin{codecache}
+endlabelspace:=1cm;
+\end{codecache}
+\begin{exemplev}[0.9]{1}
+u:=1cm;
+dirlabel:=-90;
+abscoord:=true;
+scaleev:=2;
+label.top(textext("\Large Tree diagram of $(2x+1)(x-1)$"),(0,1cm));
+draw startlabel("$\times$");
+draw tree[1][1]((-2u,-1.5u),(2u,-1.5u))("$+$","","$-$","");
+draw tree[2][1]((-3u,-3.5u),(-1u,-3.5u))("$\times$","","$1$","");
+draw tree[2][2]((1u,-3.5u),(3u,-3.5u))("$x$","","$2$","");
+draw tree[3][1]((-4u,-5.5u),(-2u,-5.5u))("$2$","","$x$","");
+\end{exemplev}
+
+\begin{codecache}
+dirlabel:=0;
+abscoord:=false;
+scaleev:=1;
+\end{codecache}
+\begin{exemplev}{1}
+posprob:=0.5;
+typeprob:=3;
+shiftev:=1.5cm;
+edgearrow:=true;
+u:=0.2cm;
+vardef paral = ((2,-2)--(6,2)--(0,2)--(-4,-2)--cycle) scaled u enddef;
+vardef rhombus = ((3,0)--(0,6)--(-3,0)--(0,-6)--cycle) scaled u enddef;
+vardef rectangle = ((3,5)--(-3,5)--(-3,-5)--(3,-5)--cycle) scaled u enddef;
+vardef square = ((3,3)--(-3,3)--(-3,-3)--(3,-3)--cycle) scaled u enddef;
+draw startlabel(paral);
+draw tree[1][1](5cm,4cm)(rhombus,"Diagonals perpendicular",%
+ rectangle,"Diagonals of equal length");
+endedgeshift:=5;
+draw tree[2][1]((5cm,-2cm))("","Diagonals of equal length");
+draw tree[2][2]((5cm,2cm))(square,"Diagonals perpendicular");
+\end{exemplev}
+
\begin{codecache}
end
\end{codecache}