0

I have a document that contains many syntax trees that I've typeset using the pst-jtree package. I would greatly prefer to not convert all of them to another tree-making package's format (i.e., I do not want to use qtree, tikz-qtree, forest, etc., as that would involve redoing all of these trees).

However, I am running into an issue when I compile this document: so far, every time I have compiled it, there has always been some weird error in rendering the trees. For instance:

a tree with a misplaced line

This tree was made with the following code:

\newcommand{\abar}[1]{\ensuremath{\overline{\text{#1}}}}

\jtree[scaleby=0.75 1] ! = {AP} :{DP}(<vert>{\abar{D}}(<vert>{D}(<vert>{him)) {\abar{A}}(<vert>{A}(<vert>{honest})). \endjtree

When I compile this tree on its own, it looks as expected (using a MWE with a different font):

\documentclass{article}

\usepackage{pstricks} \usepackage{pst-jtree}

\newcommand{\abar}[1]{\ensuremath{\overline{\text{#1}}}}

\begin{document} \jtree[scaleby=0.75 1] ! = {AP} :{DP}(<vert>{\abar{D}}(<vert>{D}(<vert>{him)) {\abar{A}}(<vert>{A}(<vert>{honest})). \endjtree \end{document}

a good-looking tree

Something odd about this error is that it is not consistent when compiling the document with many trees. For instance, the tree above just happened to have the particular error shown above when I grabbed the screenshot. But if I try recompiling the document, it may well end up fine, while one of the other trees will have a similar sort of issue. Or it might have a different error. So far as I can tell, these random errors only seem to occur when the document contains a large number of trees (mine has 38).

Is there any way to solve this error? What is especially confusing is the random nature of it—different errors occur each time I try compiling, and it seems to be a matter of luck whether everything looks right. I've tried compiling using xelatex directly, as well as xelatex -no-pdf and then xdvipdfmx, but it doesn't seem to make a difference.

Another thing I've tried is saving each tree in a standalone document and compiling them separately, then including the PDFs. A problem with this, though, is that the bounding box doesn't seem to be calculated in the same way as it is when the tree is created directly in the actual document, and so the included images end up misaligned with example numbers, or movement arrows get cut off, etc.

The topic seems related to something posted about here, which suggests it may be a pstricks issue (though I couldn't replicate the error discussed there). Unfortunately, there wasn't any reliable solution offered at that link, and I share that poster's confusion about why a deterministic algorithm would display different random errors every time it is run.

Here's an attempt at a MWE, that just repeats drawing the same tree, using some code from here. Though, of course, the random nature of the error means that it may end up working as intended sometimes.

\documentclass{article}

\usepackage{pstricks} \usepackage{pst-jtree} \usepackage{amsmath}

\newcommand{\abar}[1]{\ensuremath{\overline{\text{#1}}}}

\usepackage{expl3}

\ExplSyntaxOn \cs_new_eq:NN \Repeat \prg_replicate:nn \ExplSyntaxOff

\begin{document} \Repeat{38}{% \jtree[scaleby=1.5 1] ! = {IP} :{DP}(<vartri>{this tree}) {\abar{I}} :{I}(<vert>{might}) {VP} "{\psset{scaleby=1}} :{AdvP}(<vartri>{not}) {\abar{V}} :{\abar{V}}(<vert>{V}(<vert>{work})) {AdvP}(<vartri>{correctly}). \endjtree\ } \end{document}

Edit: I've just confirmed that the MWE can indeed produce similar errors. For me, the following happened on page 10 (replications 31–33 of the tree):

two good trees, followed by a bad tree, all generated by the same exact code

Jigsaw
  • 935
  • Unfortunately I can't replicate this (TeXLive 2023) using either latex+dvips or lualatex. Increasing the number of trees to 150 doesn't change things either. Is your distribution up to date? – Alan Munn Feb 11 '24 at 03:25
  • Unrelated syntax observation: having a line between a terminal node label and its word is syntactically incorrect. – Alan Munn Feb 11 '24 at 03:27
  • Don't know if it makes a difference, but I'm using MikTeX 4.9. Looks like there was an update earlier this year, so I'll see if updating fixes it (though I've had this issue before some years ago, and just kept recompiling until I got lucky enough that everything worked). – Jigsaw Feb 11 '24 at 03:34
  • Update: I've gotten my document (mostly) working on Overleaf, and it not only compiles with no rendering issues, but compiles much, much faster as well. Still trying to get things done locally (since I have several personal packages I don't want to have to upload to every new project), but I'm hopeful that means this is just a problem with MikTeX (since Overleaf uses TeXLive). Installing TeXLive now to see if that helps, or if it's a Windows issue rather than a MikTeX issue. I guess WSL might also be an option if that fails. – Jigsaw Feb 11 '24 at 05:12
  • TeXLive and MikTeX use the same package database. It can only be a problem if yiu have different updates ... – user187802 Feb 11 '24 at 08:32

1 Answers1

0

What happens if you use it this way:

    \Repeat{38}{%
        \begingroup
        \jtree[scaleby=1.5 1]
        \! = {IP}
        :{DP}(<vartri>{this tree}) {\abar{I}}
        :{I}(<vert>{might}) {VP} "{\psset{scaleby=1}}
        :{AdvP}(<vartri>{not}) {\abar{V}}
        :{\abar{V}}(<vert>{V}(<vert>{work})) {AdvP}(<vartri>{correctly}).
        \endjtree
        \endgroup
        \par
    }
user187802
  • 16,850