2

I installed forest 2016/03/04 v2.0.2. I adapted How do I typeset this parsing tree for propositional logic formula with forest or something else? to my needs to get the following code. The following code introduces two global options, wff and connective.

\documentclass[convert={size=640}]{standalone}
\usepackage{microtype}
\usepackage[T1]{fontenc}
% forest
\usepackage{forest}
% parsing tree
\forestset{
  declare toks={wff}{},
  declare toks={connective}{},
  parsing tree/.style={
    declare dimen register={parsing tree sep},
    parsing tree sep=5pt,
    % Append the current root to a new phantom root.
    for root'={
      replace by={[,phantom,append=!last dynamic node]}
    },
    % `for tree` applies only to the subtree of the new phantom root.
    for tree={
      math content,
      parent anchor=children,
      child anchor=parent,
      inner sep=0pt,
      if n children=1{!first.calign with current edge}{},
      delay={
        content=\circ,
        insert before/.wrap pgfmath arg={
          [##1,no edge,math content,anchor=base east,
          before computing xy={
            s/.pgfmath={s("!n")-\forestregister{parsing tree sep}}
          }]
        }{wff},
        if connective={}{connective/.option=wff}{},
        insert after/.wrap pgfmath arg={
          [##1,no edge,math content,anchor=base west,
          before computing xy={
            s/.pgfmath={s("!p")+\forestregister{parsing tree sep}}
          }]
        }{connective},
      }
    }
  }
}
\begin{document}
\begin{forest}
  parsing tree
  [,wff=p_0\wedge q_0,connective=\wedge
  [,wff=p_0] [,wff=q_0 []]]
\end{forest}
\end{document}

I don't like the fact that declare toks={option}{} messes with the global namespace. I want to define options for only parsing tree style. How can I put an option inside a safe namespace without making clutters in forest trees?

  • 2
    I also dislike that. That's why I plan to introduce namespaces, see footnote 14 in the manual. – Sašo Živanović May 4 '16 at 12:44
  • You know that it is usual to attribute code and link to the source? Apart from an issue of courtesy, it helps to keep track of things. – cfr May 4 '16 at 22:39
  • @SašoŽivanović Note that if you email anything, I probably won't actually receive it. That is, I might. But I might not. The system seems entirely arbitrary as I'm discovering to my cost. – cfr May 4 '16 at 22:41
  • @SašoŽivanović Isn't this unanswerable for the present? That's not to say it is not a reasonable question. But the only answer at the moment is, basically, 'you can't', unless I'm mistaken. – cfr May 4 '16 at 22:42
  • @cfr I don't have academic background, and I haven't written anything serious beyond short blog articles so far, so I am not familiar with references. Reference definitely helps keep track of things. Since this question was primarily about forest options but wasn't trying to claim any originality of the source code, reference didn't occur to my mind. If you want reference to your source code, I can provide. I just updated my question to include the reference. – crocket May 4 '16 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.