[XeTeX] Using MetaPost together with XeTeX

Mojca Miklavec mojca.miklavec.lists at gmail.com
Sat Jul 7 20:02:50 CEST 2007

On 7/4/07, Evgenie Medvedev wrote:
> I'm trying to typeset an old thesis of mine with XeLaTeX. It includes
> lots of charts and I wish to generate those anew using MetaPost and
> include them as PDFs. (I'd rather XeLaTeX did this automatically for me,
> but I guess I can't have everything...)
> And yet, somehow it is possible, as demonstrated by an example I found
> on the MetaPost mailing list, which I'm including here. It does indeed
> generate the legend just like I would want it, with xdvipdfmx written
> prominently as the generator in file properties. Unfortunately, that
> example is generated through ConTeXt somehow, and I can't make heads or
> tails of how the MetaPost commands work in it, and no further
> instructions came with it -- so while I can see it can be done, I can't
> actually do it like this.

What exactly would you like to know? ConTeXt uses quite some scripts
behind the scenes, whereas the same kind of support is not available
for LaTeX. What ConTeXt currently does is:
- extract metapost code
- write that code to a temporay file
- run metapost on that file
- include the generated metapost output (with some internal conversion
from PS to PDF - also done in ConTeXt, but works in LaTeX as well)

Unicode labels with special fonts (provided by XeTeX) are result from
some rather complicated code (which I doubt that anyone would care to
port to LaTeX).

But you can create metapost images with ConTeXt (the final result
would be no different as if you created them with LaTeX), or typeset
the whole document with ConTeXt.

> > PGF/Tikz? It has support for (x)dvipdfm(x), pdfTeX, dvips, TeX4HT.
>         Does it really support xdvipdfmx? In the distribution that comes with
> TexLive 2007? (While I am using Linux for my typesetting, compiling from
> source within the Gentoo environment turned out to be exceptionally
> tricky, so I am using the binary distribution...) I was under the
> impression it didn't, at least, I couldn't find anything on that in the
> docs.

It supports dvipdfm, and that one is OK for xdvipdfmx. I don't know
since when choosing the proper backend works by default, but in recent
versions it surely does. (But you answered your own question later.)

> Assuming it does, I don't fancy generating a histogram or a pie
> chart by manually writing every single line, and as far as I can see,
> gnuplot doesn't have a PGF output driver as of version 4.2. What could I
> do this with?

Again, there are two possibilities:
- you could use the ConTeXt terminal, generate PDFs with it, and
include the resulting PDFs into your LaTeX document (not the most
convenient way to go)
- I have written preliminary support for TikZ terminal in Gnuplot. If
you have enough nerves and time to compile gnuplot by yourself, to
test it and help to improve it, I'll be glad to implement new feature

Neither terminal is part of Gnuplot yet. The ConTeXt terminal is
pretty complete, and TikZ is still in its pre-alpha state (I only took
one afternoon to rewrite the ConTeXt terminal into TikZ), but
developers are more interested in including that one, since it should
work with LaTeX as well (they don't care about testing it with

But there's another problem: gnuplot doesn't support pie charts (there
is some experimental code - they argue that the problem is that
gnuplot doesn't support drawing arcs, but that's a bad argument, and
gnuplot development is so slow that one would write the whole doctor
thesis before seing any major improvement in feature requests).

> > ConTeXt with or without XeTeX is *TeX*, not LaTeX, XeTeX is used as
> > some font chooser ... (and I think micro-typography does not work)
>         I just need to make sure the chart legend is done through Xe(La)TeX, so
> that it can take any symbol I throw at it in bare utf-8, print it in the
> same font I use throughout the rest of the document, and result in a pdf
> which will include properly in the output. I don't anticipate needing
> more than that, and I don't think micro-typography is involved in one or
> two words you'd see as legend in charts.
>         But how?

What exactly is wrong with the example that you posted to the list?
What prevents you from using ConTeXt for generating PDFs and include
the resulting images into LaTeX document?

>         That was quite a bit more hoops to jump than I was hoping for. I wish
> there was a reasonable package to draw diagrams for TikZ, or a TikZ
> driver for R, but alas, so far there isn't, and looks like there won't
> be for a while...

PicTeX "driver" has only 800 lines of C code, and PS "driver" 7100
lines. Starting from PicTeX driver doesn't sound undoable, if anyone
who needs it decides to do it.


More information about the XeTeX mailing list