Tikz with positioning does not work with DVI

I have the following Tikz picture:

\begin{tikzpicture}
\node (a) {A};
\node [below=2cm of a] (b) {B};
\end{tikzpicture}


When I compile this code with PDF-LaTeX, I get the expected result: "B" appears 2 cm below "A".

When I compile the exact same code with plain LaTeX, in the DVI file, "A" and "B" are in the same position, mashed together. In the PS file, after another re-compilation, they appear correctly again.

Is there some way or workaround to work with PGF/Tikz with positioning straight with the DVI preview?

-

1 Answer

I take it you mean that after dvips the PostScript file looks okay. In that case, you are seeing the expected behaviour. When working in DVI mode, PostScript specials are used for effects that TeX does not support directly. This includes absolute positioning, rotation, scaling and so on. However, DVI viewers do not interpret these specials (unless they do some PostScript breaking out), and so show only the unmodified results. So you will not see these effects until you convert to PostScript.

-
Is there a way to trick the DVI previewer nevertheless? – Little Bobby Tables Nov 23 '10 at 11:55
There is some variation between DVI viewers in how they handle these cases, but in general the answer is 'no'. The way that these effects are handles is outside of the DVI format, hence the use of specials. In this case, they are PostScript specials which therefore need a PostScript interpreter. – Joseph Wright Nov 23 '10 at 13:27
xdvi does interpret Postscript specials. – Charles Stewart Nov 23 '10 at 14:11
@Charles, as I aid there is some variation between DVI viewers. For example, Yap can include images by calling GhostScript for the appropriate parts of a document. – Joseph Wright Nov 23 '10 at 16:08