Skip to content

Commit

Permalink
v2.1
Browse files Browse the repository at this point in the history
Changes:

1. Performance:
- Substantially enhance the argument processor.
- `<forestmath>` expressions: accept an argument processor expression whereever
  a `<pgfmath>` expression is allowed, simply by prefixing it with `>`.
- Internally, avoid using pgfmath whereever possible.
- Implement a fast set of macros to determine if a `<pgfmath>` expression is
  just a count or dimen expression.
- Optimize keys `split option` and `split register`.

2. Minor improvements:
- Allow <relative node name>s in handler `.option`.
- Make aggregate functions nestable and implement their `pgfmath` versions.
- Implement `if option/register</>` for dimen and count options and registers.
- Implement `if current nodewalk empty`.
- Implement nodewalk steps `leaves, `-level` and `-level'`.
- Implement nodewalk operation `unique`.
- Implement nodewalk key `on invalid` values `error if real` and `last valid`;
  remove value `step` (no `compat` key, as it was broken and useless).
- Implement growth direction based anchors with the `-` prefix: `-parent`,
  `-parent first` etc.
- Implement key `save and restore register`.
- Implement handler `.nodewalk style`.
- Implement `pgfmath` function `forestloopcount`.
- Allow multiple occurrences of package option `compat`.

Bugfixes:
- Fix a bug in externalization: `\forest@file@copy` set `\endlinechar` to `-1`,
  which caused problems for several packages, e.g. `biblatex`.
- Fix a bug in `delay n`: the number of cycles was reevaluated at each cycle
  (with `compat=2.0-delayn` key).
- Fix a bug in `fixed edge angles`.
- Fix `compat=silent`, `compat=1.0-forstep` and `compat=1.0-stages`.
- Fix invocations of spatial propagators `for nodewalk`, `for Nodewalk` and `Nodewalk`.
- Fix invocations of nodewalk steps `for group`, `for next on tier` and `for
  previous on tier`.
- Fix behaviour of `for next on tier`, `for previous on tier` and `for to tier`
  on arrival to the invalid node.
- Fix problems with interaction between `folder` and `forked edges`.
  • Loading branch information
sasozivanovic committed Dec 8, 2016
1 parent 3c3952f commit 5f91c8c
Show file tree
Hide file tree
Showing 9 changed files with 4,706 additions and 1,295 deletions.
53 changes: 45 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ INTERACTION = batchmode
SINGLEPASS = no
EXTERNALIZE = yes

ins = forest.ins forest-doc.ins
package-ins = forest.ins
doc-ins = forest-doc.ins
ins = ${package-ins} ${doc-ins}

dtx = $(shell grep -Poh '\\from{(.*?)}' $(ins) | sed 's/\\from{\(.*\)}/\1/;' | sort | uniq)

package-nonderived-sty = forest-compat.sty
package-tex =
package-nonderived-sty = forest-compat.sty
package-derived-sty = $(shell grep -Poh '\\file{(.*?)}' $(package-ins) | sed 's/\\file{\(.*\)}/\1/;')
package-sty = $(package-nonderived-sty) $(package-derived-sty)
package-other =
package-pdf = forest.pdf
package-derived-sty = $(shell grep -Poh '\\file{(.*?)}' $(ins) | sed 's/\\file{\(.*\)}/\1/;')
package-sty = $(package-nonderived-sty) $(package-derived-sty)

doc-tex = forest-doc.tex
doc-sty = forest-doc.sty forest-index.sty
doc-nonderived-sty = forest-doc.sty
doc-derived-sty = $(shell grep -Poh '\\file{(.*?)}' $(doc-ins) | sed 's/\\file{\(.*\)}/\1/;')
doc-sty = $(doc-nonderived-sty) $(doc-derived-sty)
doc-other = forest-doc.ist ~/texmf/bibtex/bib/local/tex.bib
doc-pdf = forest-doc.pdf

Expand All @@ -36,6 +41,9 @@ ifneq ($(SINGLEPASS),yes)
@echo
@echo Pass 3 ...
$(call compile, $(<:.success=))
@echo
@echo Pass 4 ...
$(call compile, $(<:.success=))
endif
@echo Compilation successful!
@touch -r $< $<.success
Expand All @@ -59,7 +67,7 @@ externalize = if [[ "$(EXTERNALIZE)" == 'yes' ]] ; then \
echo Externalization is ON. ; echo "\\tikzexternalize" > $1-externalize.tex ; else \
echo Externalization is OFF. ; echo "" > $1-externalize.tex ; fi

compile = pdflatex -synctex=1 -interaction $(INTERACTION) $(1) && \
compile = time pdflatex -synctex=1 -interaction $(INTERACTION) $(1) && \
( bibtex $(basename $1) || ( echo bibtex failed! && true ) ) && \
( if [[ -f $(basename $1).idx ]] ; then makeindex -s forest-doc.ist $(basename $1) ; fi || ( echo makeindex failed! && true ) ) && \
if [[ `pdfinfo $(basename $1).pdf | sed -n '/^Pages:/s/^Pages: *//p'` > 10 ]] ; then cp $(basename $1).pdf $(basename $1).bak.pdf ; fi
Expand Down Expand Up @@ -90,6 +98,7 @@ VERSION: version.tex forest.sty

versiondir: VERSION
@echo Creating version directory ...
mkdir -p versions
mkdir versions/`cat VERSION`
mkdir versions/`cat VERSION`/forest

Expand Down Expand Up @@ -117,15 +126,43 @@ checksums: $(patsubst %.dtx,%.dtx.checksum,$(dtx))
zip: versiondir nocheckexternalization checksums \
README LICENCE $(ins) $(dtx) $(sty) $(tex) $(other) $(pdf)
@echo Copying files to the version `cat VERSION` directory ...
@cp README LICENCE $(ins) $(dtx) $(doc-sty) $(package-nonderived-sty) $(tex) $(pdf) $(other) versions/`cat VERSION`/forest
@cp README LICENCE $(ins) $(dtx) $(doc-nonderived-sty) $(package-nonderived-sty) $(tex) $(pdf) $(other) versions/`cat VERSION`/forest
@echo Zipping files
@cd versions/`cat VERSION` && zip -r forest.zip forest
@cd ../..
@echo ZIP file: versions/`cat VERSION`/forest.zip

zipforce: versiondirremove zip

runtime: VERSION $(package-sty)
mkdir -p runtime
mkdir runtime/`cat VERSION`
cp $(package-sty) runtime/`cat VERSION`
chmod -w runtime/`cat VERSION`/*
zip runtime/forest-runtime_v`cat VERSION`.zip $(package-sty)

runtimedirremove:
@if [[ -d runtime && -d runtime/`cat VERSION` ]] ; then read -p "Remove runtime files for forest v`cat VERSION` (y/n)? " jane ; if [ "$$jane" = "y" ] ; then rm -r runtime/`cat VERSION` runtime/forest-runtime_v`cat VERSION`.zip ; echo Removed it! ; else echo "Ok, I won't!" ; exit 1; fi ; fi

runtimeforce: runtimedirremove runtime

currentruntime:
@mkdir -p runtime/current
@ln -sfr $(package-sty) runtime/current

v=current
use: currentruntime
echo Trying to switch to forest v$(v) ...
@if ! [[ -d runtime/$(v) && -f runtime/$(v)/forest.sty ]] ; then echo Runtimes files for forest v$(v) don\'t exist! Available versions: `ls runtime | grep -v zip`; false ; fi
@if [[ ! -h $(HOME)/texmf/tex/latex/forest ]] ; then echo Something is wrong with directory $(HOME)/texmf/tex/latex/forest ... it should be a symlink to some version\'s runtime directory. ; false ; fi
ln -sfT $(abspath runtime/$(v)) $(HOME)/texmf/tex/latex/forest
@texhash 2> /dev/null

used:
@ls -l $(HOME)/texmf/tex/latex/forest | sed -e 's/.*\///;'
@echo Available versions: `ls runtime | grep -v zip`

clean-aux:
rm *.{aux,log,auxlock,bbl,blg,synctex.gz,idx,ilg,ind,out,toc,foridx}
rm *.{aux,log,auxlock,bbl,blg,synctex.gz,idx,ilg,ind,out,toc,foridx,memo,memo.tmp}
clean-test:
rm test-*.{aux,log,auxlock,bbl,blg,synctex.gz,idx,ilg,ind,ins,out,toc} test-*~
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LaTeX package: forest [2016/04/09 v2.0.3 Drawing (linguistic) trees]
LaTeX package: forest [2016/12/05 v2.1 Drawing (linguistic) trees]

Copyright (c) 2016 Saso Zivanovic
(Sa\v{s}o \v{Z}ivanovi\'{c})
Expand Down
89 changes: 75 additions & 14 deletions forest-compat.sty
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% forest-index.dtx
%% `forest-compat' defines a compatibility layer of package `forest'.
%%
%% Copyright (c) 2015 Saso Zivanovic
%% Copyright (c) 2016 Saso Zivanovic
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%% [email protected]
%%
Expand All @@ -23,31 +23,43 @@
%% constituting the package see main source file of the package,
%% `forest.dtx', or the derived `forest.sty'.

\ProvidesPackage{forest-compat}
\ProvidesPackage{forest-compat}[2016/12/05]

\def\forest@deprecated#1{%
\PackageWarning{forest}{Compatibility mode for #1}%
}
\forestset{@@deprecated/.code={\forest@deprecated{#1}}}
\def\forestcompat#1{\pgfqkeys{/forest/@compat}{#1}}
\forestcompat{
silent/.style={\def\forest@deprecated##1{}},
silent/.code={\def\forest@deprecated##1{}},
%%% begin listing region: compat_keys
most/.style={1.0-most},
all/.style={1.0-all},
none/.style={},
1.0-most/.style={
1.0-triangle,1.0-linear,1.0-nodewalk,1.0-ancestors,
1.0-fittotree,1.0-for,1.0-forall
1.0-fittotree,1.0-for,1.0-forall,
2.0.2-most,
},
1.0-all/.style={
1.0-most,
1.0-forstep,1.0-rotate,1.0-stages,1.0-name,
2.0.2-all,
},
2.0.2-most/.style={
2.0-most,
},
2.0.2-all/.style={
2.0.2-delayn,2.0.2-wrapnpgfmathargs,
2.0-all,
},
2.0-most/.style={},
2.0-all/.style={
2.0-most,
2.0-delayn,
2.0-edges,
},
2.0-edges/.style={2.0-anchors,2.0-forkededge,2.0-folder},
%%% end listing region: compat_keys
1.0-triangle/.style={
/forest/triangle/.style={
Expand Down Expand Up @@ -106,14 +118,9 @@
},
1.0-forstep/.code={%
\def\forest@forstepwrapper##1##2{%
\def\forest@nodewalk@config@everystep@method{independent}%
\def\forest@nodewalk@config@history@method{independent}%
\edef\forest@marshal{%
\def\noexpand\forest@nodewalk@config@oninvalid{compatfake}%
\unexpanded{\forest@Nodewalk{##1}{##2}}%
\def\noexpand\forest@cn{\forest@cn}%
\def\noexpand\forest@nodewalk@config@oninvalid{\forest@nodewalk@config@oninvalid}%
}\forest@marshal
\forest@forthis{%
\forest@configured@nodewalk{independent}{independent}{compatfake}{##1}{##2}%
}%
}%
\def\forest@relatednode@option@compat@ignoreinvalidsteps##1{%
\forest@saveandrestoremacro\forest@nodewalk@oninvalid{%
Expand Down Expand Up @@ -172,11 +179,12 @@
},
2.0.2-delayn/.style={
/forest/delay@n/.style 2 args={
@@deprecated={propagator "delay n" (it introduces two levels of hash doubling)},
@@deprecated={propagator "delay n" (it introduces two levels of hash doubling reevaluates the first argument (the desired number of cycles) at every cycle)},
if={##1==1}{delay={##2}}{delay={delay@n/.wrap pgfmath arg={{####1}{##2}}{##1-1}}}
},
2.0-delayn/.style={}, % this key would patch the same thing!
},
2.0.2-wrapnpgfmathargs/.code={
2.0.2-wrapnpgfmathargs/.code={%
\def\forest@wrap@pgfmath@args@@@wrapandpasson{%
\forest@deprecated{handler "wrap n pgfmath args" (it introduces two levels of hash doubling)}%
\expandafter\expandafter\expandafter\def
Expand All @@ -186,5 +194,58 @@
\expandafter\pgfkeysalso\expandafter{\expandafter\pgfkeyscurrentpath\expandafter=\expandafter{\forest@wrapped}}%
}%
},
2.0-delayn/.style={
/forest/delay n/.style 2 args={
@@deprecated={propagator "delay n" (it reevaluates the first argument (the desired number of cycles) at every cycle)},
if={##1==0}{##2}{delay@n={##1}{##2}}
},
/forest/delay@n/.style 2 args={
if={##1==1}{delay={##2}}{delay={delay@n/.process={P}{##1-1}{##2}}}
},
},
2.0-anchors/.code={%
\csdef{forest@anchor@@parent'}{%
\forest@anchor@isbordertrue
\edef\forest@temp@anchor{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
}
\csdef{forest@anchor@@parent first'}{%
\forest@anchor@isbordertrue
\edef\forest@temp@anchor@parent{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
\edef\forest@temp@anchor@first{\number\numexpr\forestove{grow}-\forestove{rotate}\ifnum\forestove{reversed}=0 -\else+\fi90}%
\forest@getaverageangle{\forest@temp@anchor@parent}{\forest@temp@anchor@first}\forest@temp@anchor
}
\csdef{forest@anchor@@parent last'}{%
\forest@anchor@isbordertrue
\edef\forest@temp@anchor@parent{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
\edef\forest@temp@anchor@last{\number\numexpr\forestove{grow}-\forestove{rotate}\ifnum\forestove{reversed}=0 +\else-\fi90}%
\forest@getaverageangle{\forest@temp@anchor@parent}{\forest@temp@anchor@last}\forest@temp@anchor
}
},
2.0-forkededge/.code={%
\forest@iflibraryloaded{edges}{%
\forestset{
forked edge/.style={
edge={rotate/.pgfmath=grow()},
edge path'={(!u.parent anchor) -- ++(\forestoption{fork sep},0) |- (.child anchor)},
},
forked edges/.style={
for tree={parent anchor=children},
for descendants={child anchor=parent,forked edge}
},
}%
}{%
\appto\forest@compat@libraries@edges{\forestcompat{2.0-forkededge}}%
}%
},
2.0-folder/.code={%
\forest@iflibraryloaded{edges}{%
\expandafter\patchcmd\csname @pgfk@/forest/folder/.@cmd\endcsname
{parent anchor=-children last}{parent anchor=parent last}{}{}%
\expandafter\patchcmd\csname @pgfk@/forest/folder/.@cmd\endcsname
{edge={rotate/.option=!parent.grow},}{edge={rotate/.pgfmath=grow()}}{}{}%
}{%
\appto\forest@compat@libraries@edges{\forestcompat{2.0-folder}}%
}%
},
}
\expandafter\forestcompat\expandafter{\forest@compat}
8 changes: 5 additions & 3 deletions forest-doc.sty
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% forest-doc.sty
%% `forest-doc.sty` is an auxiliary package needed to compile the documentation of package `forest`.
%%
%% Copyright (c) 2015 Saso Zivanovic
%% Copyright (c) 2016 Saso Zivanovic
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%% [email protected]
%%
Expand Down Expand Up @@ -31,7 +31,7 @@
basicstyle=\small\ttfamily,basewidth=0.51em,boxpos=c,pointstyle=\pstyle,moredelim=[is][\pstyle]{~}{~}}
%\lst@InstallKeywords{p}{point}{pointstyle}\relax{keywordstyle}{}ld
\def\pstyle{\color{darkgreen}}
\def\itemnosep{\vspace{-1.4ex}}
\newcommand\itemnosep[1][0pt]{\vspace{\the\dimexpr-1.4ex+#1}}
\lstset{
rangebeginprefix=\ \ \%\%\%\ begin\ listing\ region:\ ,
rangebeginsuffix=,
Expand Down Expand Up @@ -230,7 +230,9 @@
\@Repeat{#1}{#2}#2%
}
\def\spaces#1{\Repeat{#1}\space}


\RequirePackage{dingbat}


%%% Local Variables:
%%% mode: latex
Expand Down
Loading

0 comments on commit 5f91c8c

Please sign in to comment.