diff options
author | Norbert Preining <norbert@preining.info> | 2020-03-19 03:01:18 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-03-19 03:01:18 +0000 |
commit | c8b8ea37fe9cd71b53223dff23f291b2f158fc0f (patch) | |
tree | 4b91fec7c54c33edfbd023be9ccbdac673504483 /macros/xetex/latex/langsci/langsci-forest-setup.sty | |
parent | 701be49cc7a592cc192c0f28e45a763a4c745282 (diff) |
CTAN sync 202003190301
Diffstat (limited to 'macros/xetex/latex/langsci/langsci-forest-setup.sty')
-rw-r--r-- | macros/xetex/latex/langsci/langsci-forest-setup.sty | 107 |
1 files changed, 82 insertions, 25 deletions
diff --git a/macros/xetex/latex/langsci/langsci-forest-setup.sty b/macros/xetex/latex/langsci/langsci-forest-setup.sty index 49e0a854ca..7a9f3e4ef6 100644 --- a/macros/xetex/latex/langsci/langsci-forest-setup.sty +++ b/macros/xetex/latex/langsci/langsci-forest-setup.sty @@ -33,12 +33,13 @@ % does not work with forest v1.05 did not check later versions -\usepackage[external,linguistics]{forest} -\tikzset{external/up to date check=simple} +\usepackage[linguistics]{forest} +%\usepackage[external,linguistics]{forest} +%\tikzset{external/up to date check=simple} % for texlive: -shell-escape, for miktex -enable-write18 % All externalized graphics go go the \externaldirectory %\tikzexternalize[prefix=external-figures/,shell escape=-shell-escape] -\tikzset{external/system call={xelatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}} +%\tikzset{external/system call={xelatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}} %\usepackage{morewrites} @@ -48,10 +49,12 @@ % The version with apostrophe replaces it. \forestset{default preamble'={ for tree={align=center,parent anchor=south, child anchor=north,anchor=north,base=bottom}, - before drawing tree={ - sort by=y, - for min={tree}{baseline} - } +% This would align trees to the baseline. We do not want this for TAG +% where several trees have to be aligned with respect to their center. +% before drawing tree={ +% sort by=y, +% for min={tree}{baseline} +% } }} @@ -104,19 +107,53 @@ append translation/.style={ if={strequal("#1","")}{}{ append={[#1,no edge,inner xsep=0,inner ysep=0,outer ysep=0, - tier=gloss, + tier=gloss, % does not work for TAG trees since the words are not aligned at the baseline + l=\baselineskip + 0.2ex, + ]} + } + } +} + +\forestset{ + with unaligned translation/.style={ + l sep=0,inner xsep=0, + append unaligned translation/.expanded/.wrap pgfmath arg={\gettranslation{##1}}{content}, + content/.expanded/.wrap pgfmath arg={\gettext{##1}}{content}, + }, + append unaligned translation/.style={ + if={strequal("#1","")}{}{ + append={[#1,no edge,inner xsep=0,inner ysep=0,outer ysep=0, + %tier=gloss, % does not work for TAG trees since the words are not aligned at the baseline l=\baselineskip + 0.2ex, ]} } } } + \def\gettext#1{\gettextA#1;;\endget} \def\gettextA#1;#2;{\removesep#1;} \def\gettranslation#1{\gettranslationA#1;;\endget} \def\gettranslationA#1;#2;{\removesep#2;} \def\removesep#1;#2\endget{#1} +% copy of the above for TAG +\forestset{ + with translation TAG/.style={ + l sep=0,inner xsep=0, + append translation TAG/.expanded/.wrap pgfmath arg={\gettranslation{##1}}{content}, + content/.expanded/.wrap pgfmath arg={\gettext{##1}}{content}, + }, + append translation TAG/.style={ + if={strequal("#1","")}{}{ + append={[#1,no edge,inner xsep=0,inner ysep=0,outer ysep=0, + %tier=gloss, % does not work for TAG trees since the words are not aligned at the baseline + l=\baselineskip + 0.2ex, + ]} + } + } +} + % a specific style that specifies the word tier: all nodes that do not have any children % to do: make this style default and change all other figures explicitely as is described here: @@ -163,42 +200,62 @@ dg junction/.style={no edge, tikz+={\draw (!p.east)--(!.west) (.east)--(!n.west) % % So cool! Thanks Sašo Živanović % - wg/.style={ +% modified to cope with multiple occurances of the same word (the, the1, the2) +% + wg/.style={ for tree={ no edge, draw, outer ysep=1pt, }, - copy label/.style={ - for children={ - if content={}{ - content/.pgfmath={content("!u")}, - calign with current, - edge={draw,{-Triangle[open,reversed]}}, - copy label, - !u.content/.pgfmath={content}, - !u.content+=', - }{ - copy label, - } - } - }, delay={ copy label, - for tree={name/.pgfmath={content}}, + for tree={nameN/.option=content}, }, for tree={content format={\strut\forestoption{content}}}, where n children={0}{ tier=word, }{}, }, + copy label/.style={ + for children={ + if content={}{ + % content/.pgfmath={content("!u")}, + content/.option=!u.content, % faster + calign with current, + edge={draw,{-Triangle[open,reversed]}}, + copy label, + % !u.content/.pgfmath={content}, + !u.content/.option=content, % faster + !u.content+=', + }{ + copy label, + } + } + }, + % 1. This is not effective if there's many clashes. + % 2. Register tempcounta must be free to use. + nameN/.style={ + if nodewalk valid={name=#1}{ + tempcounta=2, + @nameN=#1, + }{ + name=#1, + }, + }, + @nameN/.style={ + while nodewalk valid={name/.process=Rw1{tempcounta}{#1##1}}{ + tempcounta+=1, + }, + name/.process=Rw1{tempcounta}{#1##1}, + }, % % % TAG % http://tex.stackexchange.com/questions/207459/getting-old-school-trees-with-forest % fit -> fit=band causes all nodes to have nothing below them tag/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top,fit=rectangle}, - where n children=0{delay=with translation}{}, + where n children=0{delay=with translation TAG}{}, % the following breaks the alignments in sets begin draw/.code={\begin{tikzpicture}[baseline=(current bounding box.center)]} }, |