42

When producing pdf directly, PostScript code cannot be used, which means that pstricks macros do not work. Now, it is still possible to include pstricks code using external tools (running LaTeX on files built from the document's preamble and the figure's contents), but not as seamlessly as we could want.

My aim is to fix this, by implementing a PostScript interpreter in TeX. Before starting such a large project (the part of the PostScript standard that deals only with the programming structures is ~150 pages long), I would like to make sure that this will not be in vain.

If I understand correctly, pstricks macros eventually insert the PostScript code as \special with a certain structure, so in principle I should be able to redefine that primitive to send PostScript special to my interpreter.

The step that is not clear to me is how to go from there to actually producing graphics: presumably I would be using pgf. This leads me to a few related questions:

  • Is it enough to simply hook into \special, or should I also change the pstricks macros that inserts spacing around figures, for instance?

  • Is pgf powerful enough to express all elementary graphical operations of PostScript?

  • Will I need a general purpose (e)ps to pdf converter?

  • Suppose we have Herbert's this answer given which computes an integral(!?) 3d-plotting-sine-integral-pstricks. Skipping the other z buffering etc., shortcomings, PGF and PGFPLOTS combined might not be enough for the scary pst-func alone. There are other ODE solving possibilities etc. too. Do you plan to replicate the PSTricks overhead in the interpreter? Though I don't get how that would work, sounds just amazing. I'll wait for Herbert's response but still great initiative. – percusse Apr 23 '13 at 00:43
  • 6
    From my point of view you should go the LuaTeX way of MetaPost, using a library which is then imported into the LuaTeX source. That is not a TeX solution but much more powerful. –  Apr 23 '13 at 07:13
  • 6
    You should have a look at Escrito. It's a PostScript interpreter written in Lua to be used from within LuaTeX. It's still in a very early stage. You may consider contributing instead of starting a project from scratch. – Marco Jun 10 '13 at 08:41
  • 1
    You could also look at eps2pgf which is a postscript interpreter for converting eps to pgf. – Martin Heller Jun 15 '13 at 19:12
  • 2
    Why not use TikZ directly? – Martin Ueding Jun 17 '13 at 11:21
  • @queueoverflow There is a bigger project is going on behind the scenes. Bruno is an active member of the LaTeX3 team and they are considering the inclusion of Postscript interpreter in. So it's kind of a big deal but not related to the usage of the graphics packages. – percusse Jun 18 '13 at 20:02
  • @percusse This is not quite accurate. The project of writing a PostScript interpreter is a personal one, independent of my involvement in the LaTeX3 team. I'd be writing a package for that, and it will not be included in the core LaTeX3, as it is most likely not so useful. – Bruno Le Floch Jun 19 '13 at 08:20
  • @BrunoLeFloch My bad. That's why i was trying to soften the sentence with consider but apparently not enough. – percusse Jun 19 '13 at 08:37

1 Answers1

2

Even without consulting the PostScript specification, I can see that pgf's system interfaces do not seem to provide any facilities explicitly for dealing with raster images, much less the full generality of raster image representations supported in PostScript/PDF.

At minimum, this would require the ability render an arbitrary raster image.

Ideally, JPEG-compressed images (as output by sam2p) would be preserved as such (without recompression or the attendent loss of quality). (Though, last I heard, Ghostscript couldn't manage that trick yet, so it might be pretty difficult.)

SamB
  • 2,837