texlive[41777] Master/texmf-dist: binarytree (26jul16)

commits+karl at tug.org commits+karl at tug.org
Sun Jul 31 01:12:58 CEST 2016


Revision: 41777
          http://tug.org/svn/texlive?view=revision&revision=41777
Author:   karl
Date:     2016-07-31 01:12:58 +0200 (Sun, 31 Jul 2016)
Log Message:
-----------
binarytree (26jul16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/binarytree/README
    trunk/Master/texmf-dist/doc/latex/binarytree/binarytree.pdf
    trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex1.pdf
    trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex2.pdf
    trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex3.pdf
    trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex4.pdf
    trunk/Master/texmf-dist/source/latex/binarytree/binarytree.dtx
    trunk/Master/texmf-dist/tex/latex/binarytree/binarytree.sty

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/binarytree/README	2016-07-30 23:12:46 UTC (rev 41776)
+++ trunk/Master/texmf-dist/doc/latex/binarytree/README	2016-07-30 23:12:58 UTC (rev 41777)
@@ -13,18 +13,39 @@
 LaTeX version 2005/12/01 or later.
 
 =========================== ABOUT ==========================
-The 'binarytree' package provides an easy but flexible way to draw binary trees using TikZ. It provides a macro \BinaryTree which takes two arguments: a path specification and a number indicating the maximum depth of the tree. The path specification and the setting of various options determine the style for each edge of the tree. The options can be set either by passing them as an optional argument to \BinaryTree, or by calling \btreeset.
+The 'binarytree' package provides an easy but flexible way
+to draw binary trees using TikZ. It provides a macro
+\BinaryTree which takes two arguments: a path specification
+and a number indicating the maximum depth of the tree. The
+path specification and the setting of various options
+determine the style for each edge of the tree. The options
+can be set either by passing them as an optional argument to
+\BinaryTree, or by calling \btreeset.
 
-There is support for the external library of TikZ which does not affect externalization of the rest of the TikZ figures in the document (externalization is enabled locally for each \BinaryTree). There is an option to use automatic file naming: this is useful if the trees are often moved around or new ones are added in between, in which case using the default naming will cause all of them to be rebuilt. Instead, giving a unique name to each tree will have TikZ use the already compiled image no matter where in the document it is or how many times it has been used. This feature is still in its very infancy and more control over how the file name is generated is planned for the future.
+There is support for the external library of TikZ which does
+not affect externalization of the rest of the TikZ figures
+in the document (externalization is enabled locally for each
+\BinaryTree). There is an option to use automatic file
+naming: this is useful if the trees are often moved around
+or new ones are added in between, in which case using the
+default naming will cause all of them to be rebuilt.
+Instead, giving a unique name to each tree will have TikZ
+use the already compiled image no matter where in the
+document it is or how many times it has been used. This
+feature is still in its very infancy and more control over
+how the file name is generated is planned for the future.
 
 ======================= INSTALLATION =======================
 Extract all of the files and run latex on binarytree.ins:
   latex binarytree.ins
 
-Move the generated binarytree.sty into a TeX searchable directory, for example on Linux:
+Move the generated binarytree.sty into a TeX searchable
+directory, for example on Linux:
   mkdir -p <TeX folder>/tex/latex/binarytree
   mv binarytree.sty <TeX folder>/tex/latex/binarytree
-for example the local user TeX directory is in 'C:\Documents and Settings\<user name>\texmf' on Windows, '~/texmf' on Linux or '~/Library/texmf' on OS X.
+The local user TeX directory is in
+'C:\Documents and Settings\<user name>\texmf' on Windows,
+'~/texmf' on Linux or '~/Library/texmf' on OS X.
 
 If you wish to (re)create the documentation:
   pdflatex binarytree.dtx
@@ -35,14 +56,25 @@
   pdflatex binarytree.dtx
 
 ========================== TESTING =========================
-Provided are four files to test the package (also included as examples in the documentation:
-* 'examples/binarytree-ex1.tex' draws two trees, names them as nodes and uses them in a simple graph. To recompile it, simply run:
+Provided are four files to test the package (also included
+as examples in the documentation:
+* 'examples/binarytree-ex1.tex' draws two trees, names them
+  as nodes and uses them in a simple graph. To recompile it,
+  simply run:
     pdflatex examples/binarytree-ex1.tex
-* 'examples/binarytree-ex2.tex' draws 4 identically structured trees using different level and sibling distance scalings. To recompile it, simply run:
+* 'examples/binarytree-ex2.tex' draws 4 identically
+  structured trees using different level and sibling
+  distance scalings. To recompile it, simply run:
     pdflatex examples/binarytree-ex2.tex
-* 'examples/binarytree-ex3.tex' draws a square with arrows on each side! To recompile it, simply run:
+* 'examples/binarytree-ex3.tex' draws a square with arrows
+  on each side! To recompile it, simply run:
     pdflatex examples/binarytree-ex3.tex
-* 'examples/binarytree-ex4.tex' draws a similar square twice and exports them using the external library. It uses the 'list and make' mode, so it generates 'examples/binarytree-ex4.figlist' and 'examples/binarytree-ex4.makefile', requiring manual compilation of the exported figure:
+* 'examples/binarytree-ex4.tex' draws a similar square twice
+  and exports them using the external library. It uses the
+  'list and make' mode, so it generates
+  'examples/binarytree-ex4.figlist' and
+  'examples/binarytree-ex4.makefile', requiring manual
+  compilation of the exported figure:
     pdflatex examples/binarytree-ex4.tex
     make -f examples/binarytree-ex4.makefile
     pdflatex examples/binarytree-ex4.tex

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/binarytree.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex2.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex3.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/binarytree/examples/binarytree-ex4.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/binarytree/binarytree.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/binarytree/binarytree.dtx	2016-07-30 23:12:46 UTC (rev 41776)
+++ trunk/Master/texmf-dist/source/latex/binarytree/binarytree.dtx	2016-07-30 23:12:58 UTC (rev 41777)
@@ -20,7 +20,7 @@
 %<*package>
 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
 \ProvidesPackage{binarytree}
-  [2016/07/01 v1.0 Binary trees using TikZ]
+  [2016/07/25 v1.01 Binary trees using TikZ]
 \RequirePackage{tikz}
 %</package>
 %<*driver>
@@ -234,6 +234,8 @@
 % \section{Introduction}
 % The \BT package provides a macro, |\BinaryTree|, which accepts a path specification and a number signifying the maximum tree depth. The path specification determines the style for each edge of the tree. The behaviour can be customized by calling |\btreeset| or |\btreesetexternal| with a list of \meta{key=value} pairs. These will have effect until the end of the current group. Additionally, one can pass these keys as an optional argument to |\BinaryTree| to have them affect only that single tree.
 %
+% Each node is named, so you can refer to it later. The root is named |btree-root| while each of its children is named according to its ancestors, for example |btree-l-r| is the name of the right child of the root's left child.
+%
 % The package supports the \TikZ |external| library. To use this feature however one needs to load this library and execute |\tikzexternalize| in the preamble. All of the externalization options passed to, for example, |\btreesetexternal| are only executed once inside the local group of each tree so there is no conflict between them and any global configuration of the library. One may therefore disable externalization globally by calling |\tikzexternaldisable|; externalization will still be enabled for all the trees of \BT for which the \BTkey{external} option is |true|.
 %
 % \section{Usage}
@@ -359,7 +361,7 @@
 % \section{Examples}
 % 
 % \begin{itemize}[leftmargin=0pt]
-% \item You can name each tree using \TikZ's |local bounding box key| and refer to it for example in a graph.\par
+% \item Each node has a unique name, but you can name the entire tree using \TikZ's |local bounding box key| and refer to it for example in a graph.\par
 % \vskip 10pt\import{examples/}{binarytree-ex1.tex}
 % \vskip 10pt\hrule
 % \verbatiminput{examples/binarytree-ex1.tex}
@@ -407,7 +409,7 @@
 % \clearpage
 % \section{Implementation}
 %
-% The tree is drawn in a simple recursive way, which creates exactly two child nodes for each previous node, up to a maximum depth of |\BT at max@depth|. The entire appearance is controlled by a global style \BTkey{/tikz/binary tree} (which is determined by the setting of various pgf keys) as well as individual styles for each edge, which are created on the fly as the path specification is processed. Each style lives under the \BTkey{/tikz/binary tree} directory and is named according to the unique place of the child in the tree, by appending |l@| or |r@| to the name of its parent. The root is called |@| and has a depth of 0, its immediate children are |@r@| and |@l@| on level 1, and so on.\par
+% The tree is drawn in a simple recursive way, which creates exactly two child nodes for each previous node, up to a maximum depth of |\BT at max@depth|. The entire appearance is controlled by a global style \BTkey{/tikz/binary tree} (which is determined by the setting of various pgf keys) as well as individual styles for each edge, which are created on the fly as the path specification is processed. Each style lives under the \BTkey{/tikz/binary tree} directory and is named according to the unique place of the child in the tree, by appending |l@| or |r@| to the name of its parent. The root is called |@| and has a depth of 0, its immediate children are |@r@| and |@l@| on level 1, and so on. Each node is also named similarly, for example |btree-l-l-r| or |btree-root|.\par
 % We create template styles for each type of node: root, intermediate labelled, final labelled, unlabelled, or unvisited. When setting a style for a particular edge, the relevant template is used and a macro with the name |\|\meta{child name}| styled| is defined (let to |\relax|). This is so we don't override a previously set style unless one of \meta{label}, \meta{color} or \meta{anchor} is given explicitly. It is also used when drawing the tree to check if such a style exists, otherwise the style is set to \BTkey{/tikz/binary tree/default}.\par
 % \TikZ would put unnecessary white space around the tree (especially if there are missing outer children), so we need to calculate the actual size of the tree and clip the bounding box accordingly: we need the left and right width, height and depth, since these will be coordinates for the clipping rectangle. It is mostly calculated on the fly, starting with 0pt for each 4 coordinates. If \BTkey{draw missing} is |true|, we set the bounding box size to the maximum for this depth (and don't change it further). Otherwise we proceed in the following way: the height is easy to deal with---we add a level distance to the height each time a new level is created (we keep track by defining a macro |\level |\meta{depth}| exists|). The width is trickier---consider for example the case where there are no children on the right, but there are right children to one of the left nodes; they may extend to the right side of the box. What is done is we keep track of a current x coordinate (which is relative to root, being negative on the left) and each time any left (right) edge is created, we compare the (magnitude of the) coordinate to the current left (right) width of the box, and if greater---set the box width to it.\par
 % Additionally, we save the height (width) of the root's label since this will (may) add to the depth (width) of the box, but we do not add it to the size of the box just yet (since the root label may change several times). Furthermore, we keep track of the maximum height (width) of any of the final children's labels since these will increase the ``height''\footnote{Here ``height'' means height if the tree is growing up, depth if it's growing down, left/right width if it's growing left/right; and similarly for ``width''} of the box when the tree is growing vertically (sideways). We also save the width (height) of the left- and rightmost final children, as these will increase the ``width'' of the box when growing vertically (sideways). At the end all of these are used to increase the box (still assuming the tree is growing upwards). Finally, the four sides are cycled according to the actual growing direction.
@@ -1220,6 +1222,16 @@
 % \subsection{Macros for setting the styles}
 % \subsubsection{Helper macros}
 %
+% \begin{macro}{\BT at at@to at dash}
+% \begin{macro}{\BT at at@to at dash@i}
+%   Convert |@| to |-| (except trailing |@|, which is removed) for root children. For example |@r at l@| \(\to\) |-r-l|. Used in naming the child nodes. For root, |@|, it expands to empty.
+%    \begin{macrocode}
+\def\BT at at@to at dash#1{\BT at at@to at dash@i#1\@nil}
+\def\BT at at@to at dash@i @#1{\ifx\@nil#1\else-#1\expandafter\BT at at@to at dash@i\fi}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \begin{macro}{\BT at anchor@or at default}
 %   Use the given anchor, or if empty---the default one.\par
 %   \nsig{anchor,\ttup{root\vbar left\vbar right\vbar final}}
@@ -1252,7 +1264,7 @@
 %    \begin{macrocode}
   \else\expandafter\BT at if@child at is@outer at ii\expandafter#2\fi}
 \def\BT at if@child at is@outer at ii#1{%
-  \ifx#1\@nil\expandafter\@firstoftwo%
+  \ifx\@nil#1\expandafter\@firstoftwo%
   \else\expandafter\expandafter\expandafter\@secondoftwo%
     \expandafter\BT at gobble@till at nil\fi}
 %    \end{macrocode}
@@ -1699,10 +1711,10 @@
 \def\BT at draw@tree at children#1#2{%
   \ifnum\numexpr#2\relax = \numexpr\BT at max@depth\relax\else%
     child[\ifcsname#1r@ styled\endcsname binary tree/#1r@\else%
-      binary tree/default\fi] {node {}% right
+      binary tree/default\fi] {node (btree\BT at at@to at dash{#1r@}) {}% right
         \BT at draw@tree at children{#1r@}{#2+1} }%
     child[\ifcsname#1l@ styled\endcsname binary tree/#1l@\else%
-      binary tree/default\fi] {node {}% left
+      binary tree/default\fi] {node (btree\BT at at@to at dash{#1l@}) {}% left
         \BT at draw@tree at children{#1l@}{#2+1} }\fi}
 %    \end{macrocode}
 % \end{macro}
@@ -1714,7 +1726,7 @@
     \advance\BT at bbox@height\BT at level@distance\relax%
     \BT at adjust@bbox at sides%
     \edef\BT at tree{%
-      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] {}%
+      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] (btree-root) {}%
       child[\ifcsname @ styled\endcsname binary tree/@\fi] {%
         node {} \BT at draw@tree at children{@}{\BT at root@depth}}}%
     \clip (-\BT at bbox@l at width,-\BT at bbox@depth)%
@@ -1724,7 +1736,7 @@
     \BT at tree;%
   \else\BT at adjust@bbox at sides%
     \edef\BT at tree{%
-      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] {}%
+      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] (btree-root) {}%
       \BT at draw@tree at children{@}{\BT at root@depth}}%
     \clip (-\BT at bbox@l at width,-\BT at bbox@depth)%
       rectangle (\BT at bbox@r at width,\BT at bbox@height);%
@@ -1737,6 +1749,7 @@
 %
 % \hrule
 % \begin{macro}{\BinaryTree}
+% \changes{1.01}{2016/07/25}{Each node is now uniquely named.}
 % \begin{macro}{\@BinaryTree}
 % \begin{macro}{\BT at max@depth}
 % \begin{macro}{\BT at root@depth}

Modified: trunk/Master/texmf-dist/tex/latex/binarytree/binarytree.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/binarytree/binarytree.sty	2016-07-30 23:12:46 UTC (rev 41776)
+++ trunk/Master/texmf-dist/tex/latex/binarytree/binarytree.sty	2016-07-30 23:12:58 UTC (rev 41777)
@@ -23,7 +23,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
 \ProvidesPackage{binarytree}
-  [2016/07/01 v1.0 Binary trees using TikZ]
+  [2016/07/25 v1.01 Binary trees using TikZ]
 \RequirePackage{tikz}
 \newdimen\BT at bbox@r at width
 \newdimen\BT at bbox@l at width
@@ -384,6 +384,8 @@
   \extractcolorspecs{#1}{\tmp at mod}{\tmp at col}%
   \convertcolorspec{\tmp at mod}{\tmp at col}{rgb}{\tmp at col}%
   \BT at endgroup@let#2\tmp at col}
+\def\BT at at@to at dash#1{\BT at at@to at dash@i#1\@nil}
+\def\BT at at@to at dash@i @#1{\ifx\@nil#1\else-#1\expandafter\BT at at@to at dash@i\fi}
 \def\BT at anchor@or at default#1#2{%
   \BT at if@blank{#1}{\pgfkeysvalueof{/BT/#2 label anchor}}{#1}}
 \def\BT at color@or at default#1{\BT at if@blank{#1}{BT at default}{#1}}
@@ -392,7 +394,7 @@
   \ifx#1#2\expandafter\BT at if@child at is@outer at i\expandafter @\expandafter#2%
   \else\expandafter\BT at if@child at is@outer at ii\expandafter#2\fi}
 \def\BT at if@child at is@outer at ii#1{%
-  \ifx#1\@nil\expandafter\@firstoftwo%
+  \ifx\@nil#1\expandafter\@firstoftwo%
   \else\expandafter\expandafter\expandafter\@secondoftwo%
     \expandafter\BT at gobble@till at nil\fi}
 \def\BT at check@if at new@level#1{%
@@ -598,10 +600,10 @@
 \def\BT at draw@tree at children#1#2{%
   \ifnum\numexpr#2\relax = \numexpr\BT at max@depth\relax\else%
     child[\ifcsname#1r@ styled\endcsname binary tree/#1r@\else%
-      binary tree/default\fi] {node {}% right
+      binary tree/default\fi] {node (btree\BT at at@to at dash{#1r@}) {}% right
         \BT at draw@tree at children{#1r@}{#2+1} }%
     child[\ifcsname#1l@ styled\endcsname binary tree/#1l@\else%
-      binary tree/default\fi] {node {}% left
+      binary tree/default\fi] {node (btree\BT at at@to at dash{#1l@}) {}% left
         \BT at draw@tree at children{#1l@}{#2+1} }\fi}
 \def\BT at draw@tree{%
   \ifBT at root@edge%
@@ -608,7 +610,7 @@
     \advance\BT at bbox@height\BT at level@distance\relax%
     \BT at adjust@bbox at sides%
     \edef\BT at tree{%
-      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] {}%
+      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] (btree-root) {}%
       child[\ifcsname @ styled\endcsname binary tree/@\fi] {%
         node {} \BT at draw@tree at children{@}{\BT at root@depth}}}%
     \clip (-\BT at bbox@l at width,-\BT at bbox@depth)%
@@ -618,7 +620,7 @@
     \BT at tree;%
   \else\BT at adjust@bbox at sides%
     \edef\BT at tree{%
-      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] {}%
+      \noexpand\node[\ifcsname @ styled\endcsname binary tree/@\fi] (btree-root) {}%
       \BT at draw@tree at children{@}{\BT at root@depth}}%
     \clip (-\BT at bbox@l at width,-\BT at bbox@depth)%
       rectangle (\BT at bbox@r at width,\BT at bbox@height);%



More information about the tex-live-commits mailing list