[XeTeX] linguistics trees using qtree: no go

Jonathan Kew jonathan_kew at sil.org
Wed Jan 31 11:50:11 CET 2007


On 31 Jan 2007, at 1:26 am, Cyril wrote:

> Hi everybody,
> I'm pretty sure that some of you are used to making trees. I'm just
> only trying, and I found a few packages here:
> <http://www.essex.ac.uk/linguistics/clmt/latex4ling/trees/>.
> I'm just dabbling since yesterday, so I tried my hand at parsetree,
> xyling and qtree. It's with the last one I managed to get exactly the
> trees I wanted, and easily at that.
>
> Thing is, it does not work with XeLaTeX.
>
> %%%
> \documentclass[12pt]{article}
> \usepackage{geometry}
> \geometry{a4paper}
> \usepackage{qtree}
> \begin{document}
>
> \Tree [.{ai mang\'e} J' [ .pomme une jolie ] ]
>
> \end{document}
>
>
> %%%
>
> dies with:
>
> This is XeTeX, Version 3.141592-2.2-0.995 (Web2C 7.5.5)
> entering extended mode
> (./Untitled4.tex
[snip]
> (/usr/local/teTeX/share/texmf.tetex/tex/latex/graphics/pdftex.def)
> (/usr/local/teTeX/share/texmf.tetex/tex/latex/pict2e/p2e-pdftex.def)

NOTE that the graphics package is loading pdftex-specific driver  
definitions...

> ! Undefined control sequence.
> \set at color ->\pdfliteral
>                           {\current at color }\aftergroup \reset at color
> l.7 \Tree [.{ai mang\'e} J'
>                              [ .pomme une jolie ] ]
> ?

...leading to this error, when the code tries to use pdfTeX-only  
commands.

This is happening because the configuration file for the geometry  
package "pretends" to be pdfTeX, in order to trick the package into  
setting up the page size correctly.

In the TeXLive2007 release, we have a better version of geometry.cfg  
that no longer deceives other packages in this way. With the older  
setup, it's possible that loading the pict2e package (which qtree  
uses) *before* geometry would avoid the issue.

However, that would only get you back to a situation similar to this:

> Only this
> \documentclass[12pt]{article}
> \usepackage{qtree}
> \begin{document}
> \Tree [.{ai mang\'e} J' [ .pomme une jolie ] ]
> \end{document}
>
> compiles but there are no lines.

There are no lines because this uses the dvips graphics driver by  
default (check the log and you'll see that it loads dvips.def, etc).  
This draws the lines using literal PostScript instructions using  
\special commands, but xetex/xdv2pdf does not have any support for  
direct PostScript.

The solution is to switch to the xdvipdfmx output driver, which you  
can do by creating a new engine for TeXShop (or equivalent for other  
environments). This has some (limited) support for dvips-style  
\special commands, and may be able to draw your trees; or you can say  
\usepackage[dvipdfm]{pict2e} in order to use a driver based on PDF  
\special commands.

To set up a TeXShop engine, go to ~/Library/TeXShop/Engines and  
duplicate the existing XeLaTeX.engine file. Name the new copy  
something like "XeLaTeX-x.engine". Then edit it, and change the  
xelatex command line to read

   xelatex -output-driver="xdvipdfmx -E -q" "$1"

Save the file, and then you should be able to use this alternative  
xelatex engine to process documents that need the xdvipdfmx back-end.  
A modified version of your example works nicely for me; I added  
fontspec and used a Mac OS X font here, otherwise the result is no  
different than you could get from standard (pdf)tex:

%!TEX TS-program = xelatex-x
%!TEX encoding = UTF-8 Unicode
\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{fontspec,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{Hoefler Text}
\usepackage[dvipdfm]{pict2e}
\usepackage{qtree}
\begin{document}

\Tree [.{ai mang\'e} J' [ .pomme une jolie ] ]

\end{document}

generates:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: texshop_image.pdf
Type: application/pdf
Size: 19917 bytes
Desc: not available
Url : http://tug.org/pipermail/xetex/attachments/20070131/993febf2/attachment-0002.pdf 
-------------- next part --------------

And for a more "fun" example (please excuse the Hindi, which is  
probably incorrect), try:

\newfontfamily\dev[Scale=1.2]{Devanagari MT}
\Tree [ .{Sentence}
   [ .NP {\dev ???} ]
   [ .VP [ .NP [ .Adj {\dev ?????} ]
     [ .NP [ .N {\dev ?????} ] [ .Suffix {\dev ??} ] ] ]
     [ .Verb {\dev ????} ] ] ]

which xelatex+xdvipdfmx renders as:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: texshop_image.pdf
Type: application/pdf
Size: 19962 bytes
Desc: not available
Url : http://tug.org/pipermail/xetex/attachments/20070131/993febf2/attachment-0003.pdf 
-------------- next part --------------

HTH .... JK



More information about the XeTeX mailing list