Why are my characters overlapping?

As a test of what's going wrong with a longer LaTeX file I've written, here is what I tried:

\documentclass{article}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
\draw (0,0) node[left] {A} -- (1,1) node[right] {B};
\end{tikzpicture}

\end{document}


I then run this with latex test.tex and dvipng test.dvi -o output.png and I'm ending up with the TikZ part all overlapping:

What is going wrong?

• Hello, welcome to TeX.SE. Presumably, dvipng isn't able to interpret all the \special instructions produced by TikZ (the DVI format can't handle advanced graphics stuff natively, only rules and character boxes). It gives a bunch of warnings here. If you compile with pdflatex, you should see a better result. :-) – frougon Mar 22 at 18:23
• dvipng doesn't understand the \special commands used by TikZ. If you try to view the dvi file with xdvi you will see the same overlapping. – egreg Mar 22 at 18:27
• Intersting. OK, thanks guys! – user184074 Mar 22 at 18:47
• If you want to create images from such LaTeX documents, I recommend using pdflatex/xelatex for compilation and converting the resulting PDF file with ImageMagick to PNG format – siracusa Mar 23 at 5:20