# Does TikZ use the same internal mechanism as PSTricks to produce vector based pdf outputs?

Currently I am using PSTricks. From this forum, I see many people using TikZ. I have done a little exploration that TikZ can produce vector images in PDF format only in one step using pdftex.

To produce the same vector images in PDF, PSTrick must be compiled in 3 steps, i.e., latex -> dvips -> ps2pdf.

According to The current state of the PSTrick project:

TeX as a typesetting machine cannot make full use of the possibilities of PostScript. There cannot be a direct interaction between TeX and PostScript; it is more of a one way communication from TeX to PostScript. The interface between these two systems is the DVI converter dvips which converts the DVI output of TeX into the PostScript format. Here we use DVI output only as an intermediate format; it is not really of interest. On the TeX side the user has to reserve some space (a box) which is filled on the PostScript side with a graphic or some text. If this space is not reserved the everything will be printed over the text, depending on the current point before the PostScript-related code. This PostScript code must be transferred from TeX via the DVI output with the macro \special. Its contents are ignored by TeX and passed to PostScript where it will be executed by a PostScript interpreter such as GhostScript or Distiller.

From the quote, PSTricks need an intermediate phase,i.e., using DVI output. Shortly speaking, this intermediate output forces PSTrick to be compiled using 3 steps.

If Tikz using the same internal mechanism as PSTrick does, why TikZ can be compiled in 1 step?

-
Btw. why did you delete your TikZ node question? That one could have been answered by "yes" together with an example. – Stefan Kottwitz Dec 7 '10 at 13:47
Because I have got the answer from the TikZ manual. Thank you @Stefan. – xport Dec 7 '10 at 13:49
Generally, if you were able to find the answer by yourself, it would be great if you post that answer. So everybody could learn something and the solution is archived for further use. If a question has just been deleted because it's been solved, nobody else would benefit. – Stefan Kottwitz Dec 7 '10 at 13:54
OK @Stefan, I will follow your suggestion for the next one. – xport Dec 7 '10 at 16:02

Just a short answer: PSTricks only uses PostScript `\special`s, whereas TikZ can use both PostScript and PDF `\special`s, depending on the desired output format (when `latex` together with `dvips` or `dvipdfm` is used). For direct compilation to PDF with `pdflatex`, the pdfTeX primitive `\pdfliteral` is used.

-
Thanks Hendrik. I need pdf output only. So TikZ is more appropriate for me? – xport Dec 7 '10 at 14:03
@xport TikZ is also better supported by authors at the moment and you will find more packages to use. With pdf you can also add interactivity via JavaScript. – Yiannis Lazarides Dec 7 '10 at 15:44
I was under the impression that (a) a different mechanism than `\special` was needed for graphics in PDF mode and (b) that in DVI mode, you would use the same PostScript specials whether your intended final form was PostScript or PDF. Is this not so? – SamB Dec 8 '10 at 6:21
@SamB: see my updated answer. – Hendrik Vogt Dec 8 '10 at 10:45
@Hendrik: Ah, `dvipdfm`, of course. I admit I had begun to wonder about that before I actually posted my previous comment... It looks like you've unbalanced your parentheses now, though, and the language doesn't seem quite ideal... I would suggest: "[...] TikZ can use PostScript (for `dvips` and many previewers) or PDF (for `dvipdfm`) `\special` s when outputting to DVI, and `\pdfliteral` when used under pdfTeX with `\pdfoutput=1`." – SamB Dec 8 '10 at 15:41
• PSTricks generates only PostScript, not PDF.

• TikZ uses PGF which is capable of directly producing PDF output.

So, if your goal is to produce PDF output, you have to do some conversion if you use PSTricks which generates only an intermediate format which isn't required by TikZ.

-
@Thanks Stefan. I am also reading the TikZ manual now for the details. I think Tikz has better structured and syntax than PSTricks. :-) – xport Dec 7 '10 at 13:47
with xelatex PSTricks can be used directly inside the code – Herbert Dec 17 '10 at 18:35
@Herbert: why there is no intermediate step with xelatex and one with pdflatex? – pluton Apr 8 '11 at 15:33
@Pluton: xelatex does it itself in the background, as soon as a `\special` command appears. – Herbert Apr 8 '11 at 15:45
@Herbert: and pdflatex cannot? it would require a new version? – pluton Apr 8 '11 at 15:56