Discussion:
[Dvipng] Adding tikz/pgf support to dvipng?
Paul Mantz
2007-12-03 09:36:53 UTC
Permalink
hello everyone,

I'm interested to know if there are any plans to add tikz/pgf support
to dvipng, and complications arise in this situation. In order to
include graphics into my files, I use XFig files rendered as pngs and
include those into my documents (which then get rendered to .png for
web display), but I would much rather use tikz and not have to leave
my editor to create in-depth graphics.

I know other projects would benefit; not only myself, if tikz support
was added. What is the feasability and level of effort necessary?

Thanks,
Paul
Jan-Åke Larsson
2007-12-03 11:43:56 UTC
Permalink
Post by Paul Mantz
I'm interested to know if there are any plans to add tikz/pgf support
to dvipng, and complications arise in this situation.
As far as I understand, tikz/pgf can output PostScript (or code fit for
dvips, at least). In that case, the CVS version of dvipng should be able
to handle it. Please try it out, an report success/failure to me.

(I have unfortunately been unable to make the documentation examples in
pgf-1.18 to even produce a DVI, my error is

ERROR: Undefined control sequence.

--- TeX said ---
l.20 \usepgflibrary
{plothandlers}

this is the first code line in tikz.sty)

/JÅ
--
kernel, n.: A part of an operating system that preserves the medieval
traditions of sorcery and black art.
Paul Mantz
2007-12-03 21:35:56 UTC
Permalink
I'm using TeXLive 2007 on OS X 10.4 and don't have any problems
running pdflatex of latex+dvipdf on a .tex file with the following
contents:

----------

\documentclass[10pt]{article}

\usepackage{tikz}

\newcommand{\tikzaxes}[2]{
\draw[<->] (-#1, 0) -- (0, #1);
\draw[<->] (-#2, 0) -- (0, #2);
}

\begin{document}

This is a test of the pgf package,and to see if it's even default in
{\TeX}Live.

\begin{center}
\begin{tikzpicture}
\draw (-1.5,0) -- (1.5,0);
\draw (0,-1.5) -- (0,1.5);
\end{tikzpicture}
\end{center}

This is another test.

\begin{center}
\begin{tikzpicture}
\draw[<->, very thick] (-3,0) -- (3,0);
\draw[<->, very thick] (0,-3) -- (0,3);
\draw[thick] (0,0) circle (2);

\draw (0,0) -- (30:2);
\draw (0,0) -- (0:0.75) arc (0:30:0.75);
\draw (15:1) node {$\theta$};
\end{tikzpicture}
\end{center}

\end{document}

-----------

However, I get the following on stderr when I run dvipdf on a .dvi
made with the previous code (sorry for the linebreak soup):

----------

dvipng warning: at (0,0) ignored header \special{! /pgfH{/pgfheight
exch def 0.75 setlinewidth [] 0 setdash /pgfshade {pgfA} def /pgfdir {
dup 0 moveto dup 5 index lineto } bind def} bind def}

dvipng warning: at (0,0) ignored header \special{! /pgfV{/pgfheight
exch def 0.75 setlinewidth [] 0 setdash /pgfshade {pgfA} def /pgfdir {
dup 0 exch moveto dup 5 index exch lineto } bind def} bind def}

dvipng warning: at (0,0) ignored header \special{! /pgfA{ /pgfdiff 8
index round cvi 8 index round cvi sub 2 mul 1 add def 2 index 6 index
sub pgfdiff div 2 index 6 index sub pgfdiff div 2 index 6 index sub p\
gfdiff div pgfheight 9 index 9 index 9 index 14 index pgfdiff { 3
index 3 index 3 index setrgbcolor pgfdir stroke 4 -1 roll 7 index add
4 -1 roll 6 index add 4 -1 roll 5 index add 4 -1 roll .5 sub } repeat
ma\
rk 15 1 roll cleartomark exch pop }bind def }

dvipng warning: at (0,0) ignored header \special{! /pgfR1{ newpath dup
dup dup 0 360 arc clip newpath dup /pgfendx exch def /pgfendy exch def
0.875 setlinewidth [] 0 setdash /pgfshade {pgfR} def /pgfstartx ex\
ch def /pgfstarty exch def /pgfdiffx pgfendx pgfstartx sub def
/pgfdiffy pgfendy pgfstarty sub def dup /pgfdomb exch def }bind def }

dvipng warning: at (0,0) ignored header \special{! /pgfR2{ newpath 0.5
add pgfcircx pgfcircy 3 2 roll 0 360 arc setrgbcolor fill pop}bind def
}

dvipng warning: at (0,0) ignored header \special{! /pgfR{ /pgfdiff 8
index round cvi 8 index round cvi sub 4 mul 1 add def /pgfcircx
pgfstartx 9 index pgfdiffx pgfdomb div mul add def /pgfcircy pgfstarty
9 in\
dex pgfdiffy pgfdomb div mul add def /pgfcircxe pgfstartx 8 index
pgfdiffx pgfdomb div mul add def /pgfcircye pgfstarty 8 index pgfdiffy
pgfdomb div mul add def /pgfxstep pgfcircxe pgfcircx sub pgfdiff div
de\
f /pgfystep pgfcircye pgfcircy sub pgfdiff div def 2 index 6 index sub
pgfdiff div 2 index 6 index sub pgfdiff div 2 index 6 index sub
pgfdiff div 8 index 8 index 8 index 13 index pgfdiff { 3 index 3 index
3 \
index setrgbcolor pgfcircx pgfcircy 2 index 0 360 arc closepath stroke
4 -1 roll 6 index add 4 -1 roll 5 index add 4 -1 roll 4 index add 4 -1
roll .25 sub /pgfcircx pgfcircx pgfxstep add def /pgfcircy pgfcirc\y
pgfystep add def } repeat mark 14 1 roll cleartomark exch pop }bind
def}

dvipng warning: at (0,0) ignored header \special{!
/pgfsc{}B/pgffc{}B/pgfstr{stroke}B/pgffill{fill}B/pgfeofill{eofill}B/pgfe{a
dup 0 rlineto exch 0 exch rlineto neg 0 rlineto
closepath}B/pgfw{setlinewidth}B/\pgfs{save pgfpd 72 Resolution div 72
VResolution div neg scale magscale{1 DVImag div dup scale}if pgfx neg
pgfy neg translate pgffoa .setopacityalpha}B/pgfr{pgfsd restore}B
userdict begin/pgfo{pgfsd /pgfx cur\
rentpoint /pgfy exch def def @beginspecial}B /pgfc{newpath @endspecial
pgfpd}B /pgfsd{globaldict /pgfdelta /delta where {pop delta} {0}
ifelse put}B/pgfpd{/delta globaldict /pgfdelta get def}B
/.setopacityalp\ha where {pop} {/.setopacityalpha{pop}def} ifelse
/.pgfsetfillopacityalpha{/pgffoa exch def /pgffill{gsave pgffoa
.setopacityalpha fill 1 .setopacityalpha newpath fill grestore}B
/pgfeofill{gsave pgffoa .seto\
pacityalpha eofill1 .setopacityalpha newpath eofill grestore}B}B
/.pgfsetstrokeopacityalpha{/pgfsoa exch def /pgfstr{gsave pgfsoa
.setopacityalpha stroke grestore}B}B /pgffoa 1 def /pgfsoa 1 def end }

dvipng warning: at (86,73) ignored header \special{! /pgf1{gsave exec
1.0 pgfw 2.00002 0.0 moveto -6.00006 4.00005 lineto -3.00003 0.0
lineto -6.00006 -4.00005 lineto pgffill grestore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf2{gsave exec
1.0 pgfw 0.8 pgfw [ ] 0.0 setdash 1 setlinecap 1 setlinejoin -3.00003
4.00005 moveto -2.75002 2.50002 0.0 0.24998 0.75 0.0 curveto 0.0
-0.\24998 -2.75002 -2.50002 -3.00003 -4.00005 curveto pgfstr
grestore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf3{gsave exec
1.0 pgfw [ ] 0.0 setdash 0.0 -5.00005 moveto 0.0 5.00005 lineto pgfstr
grestore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf4{gsave exec
1.0 pgfw [ ] 0.0 setdash -3.00003 -5.00005 moveto 0.0 -5.00005 lineto
0.0 5.00005 lineto -3.00003 5.00005 lineto pgfstr grestore} bind
de\f}

dvipng warning: at (86,73) ignored header \special{! /pgf5{gsave exec
1.0 pgfw [ ] 0.0 setdash -2.00002 -5.00005 moveto 1.0 -3.00003 1.0
3.00003 -2.00002 5.00005 curveto pgfstr grestore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf6{gsave exec
1.0 pgfw [ ] 0.0 setdash -4.50003 -5.00005 moveto 0.49998 0.0 lineto
-4.50003 5.00005 lineto pgfstr grestore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf7{gsave exec
1.0 pgfw -2.50002 0.0 translate [ ] 0.0 setdash 3.00003 0.0 moveto
3.00003 1.665 1.665 3.00003 0.0 3.00003 curveto -1.665 3.00003
-3.00003\
1.665 -3.00003 0.0 curveto -3.00003 -1.665 -1.665 -3.00003 0.0
-3.00003 curveto 1.665 -3.00003 3.00003 -1.665 3.00003 0.0 curveto
closepath gsave pgffc pgffill grestore gsave pgfsc pgfstr grestore
newpath g\
restore} bind def}

dvipng warning: at (86,73) ignored header \special{! /pgf8{gsave exec
1.0 pgfw [ ] 0.0 setdash 1.0 0.0 moveto -5.00005 3.00003 lineto
-11.00012 0.0 lineto -5.00005 -3.00003 lineto closepath gsave pgffc
pgffil\
l grestore gsave pgfsc pgfstr grestore newpath grestore} bind def}

dvipng warning: at (324,165) unimplemented \special{ps: }

dvipng warning: at (324,389) unimplemented \special{ps: }

----------

Basically, dvipng completes, and creates none of the pgf elements,
except for the node (which is just a grid-specified string of LaTeX
code.) I'm not much of a TeXnician as I should be, so I'm not
familiar with the .dvi file spec to know what's going on. Any idea on
what these codes mean?

--Paul
Post by Jan-Åke Larsson
Post by Paul Mantz
I'm interested to know if there are any plans to add tikz/pgf support
to dvipng, and complications arise in this situation.
As far as I understand, tikz/pgf can output PostScript (or code fit for
dvips, at least). In that case, the CVS version of dvipng should be able
to handle it. Please try it out, an report success/failure to me.
(I have unfortunately been unable to make the documentation examples in
pgf-1.18 to even produce a DVI, my error is
ERROR: Undefined control sequence.
--- TeX said ---
l.20 \usepgflibrary
{plothandlers}
this is the first code line in tikz.sty)
/JÅ
--
kernel, n.: A part of an operating system that preserves the medieval
traditions of sorcery and black art.
_______________________________________________
Dvipng mailing list
http://lists.nongnu.org/mailman/listinfo/dvipng
Jan-Åke Larsson
2007-12-04 07:59:54 UTC
Permalink
Post by Paul Mantz
Basically, dvipng completes, and creates none of the pgf elements,
except for the node (which is just a grid-specified string of LaTeX
code.) I'm not much of a TeXnician as I should be, so I'm not
familiar with the .dvi file spec to know what's going on. Any idea on
what these codes mean?
Yes. They are PostScript specials that the CVS version of dvipng can
handle. You are probably using dvipng 1.9 (the latest release) which
cannot handle these specials.

I'd suggest you try to compile the CVS version and see if that works,
alternatively send the DVI to me, so that I can try it.

/JÅ
--
Quantum particles: The dreams that stuff is made of.
Loading...