Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I updated MacTeX recently with TeX Live Manager and I installed the last tikz/pgf CVS (02/12/2011) and I got a problem with the standalone class. The size of the picture seems fine but nothing is drawn. I don't know if it's possible to find a workaround. I compiled the next code with latex no problem with pdflatex.

\documentclass{article}
\usepackage{tikz} 
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}  

\begin{document}
\begin{tikzpicture}
    \draw[fill] (0,0)rectangle(5,5); 
\end{tikzpicture}
\end{document}  

or with

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
 \begin{tikzpicture}
\draw[fill] (0,0)rectangle(5,5); 
 \end{tikzpicture} 
  % or  \tikz \draw[fill] (0,0) rectangle (5,5);
  % or  \tikz{\draw[fill] (0,0) rectangle (5,5)} % with pgf 2.10 cvs
\end{document}

The log file gives :

This is dvips(k) 5.991 Copyright 2011 Radical Eye Software (www.radicaleye.com) ' TeX output 2011.12.12:0630' -> standalone.ps . 1 Error: /undefined in pgfo Operand stack: Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1894 1 3 %oparray_pop 1893 1 3 %oparray_pop 1877 1 3 %oparray_pop 1771 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- Dictionary stack: --dict:1154/1684(ro)(G)-- --dict:0/20(G)-- --dict:81/200(L)-- --dict:100/300(L)-- Current allocation mode is local Last OS error: 2 Current file position is 9241 GPL Ghostscript 9.02: Unrecoverable error, exit code 1

If you want the tikz/pgf CVS package with pgfmanual_cvs.pdf, you can find it here.

share|improve this question
    
I can compile \tikz \draw[fill] (0,0) rectangle (5,5); but not \tikz{\draw[fill] (0,0) rectangle (5,5)}. –  cyanide-based food Dec 12 '11 at 6:52
    
\tikz{\draw[fill] (0,0) rectangle (5,5)} compiles with article class and I've the same problem with \tikz \draw[fill] (0,0) rectangle (5,5);. Do you make a try with the last pgf cvs ? Perhaps my problem comes from the last version of MacTeX ! –  Alain Matthes Dec 12 '11 at 7:00
1  
I used old pgf/tikz. Please try using preview package and article class to diagnose whether the error is caused by preview encapsulated in standalone class. –  cyanide-based food Dec 12 '11 at 7:04
    
FWIW, Miktex compiles with \tikz \draw[fill] (0,0) rectangle (5,5); and also with (notice the semicolon location!) \tikz {\draw[fill] (0,0) rectangle (5,5);} and shows two black squares as intended. –  percusse Dec 12 '11 at 7:12
1  
@Altermundus: The upcoming v1.0 of standalone provides an alternative to preview which will be enabled by default. You can test the beta version, see chat.stackexchange.com/transcript/41?m=2621195#2621195. –  Martin Scharrer Dec 12 '11 at 11:27

2 Answers 2

up vote 4 down vote accepted

The PostScript prologue is missing in fact of the special handling of \AtBeginDocument and \special{ps::} by tikz. If you reload it by "hand" it will work:

\documentclass{standalone}
\usepackage{ifpdf}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}  

\begin{document}
\ifpdf
\else
  \special{ps::
    /pgfsc{}bind def% stroke color is empty by default
    /pgffc{}bind def% fill color is empty by default
    /pgfstr{stroke}bind def%
    /pgffill{fill}bind def%
    /pgfeofill{eofill}bind def%
    /pgfe{a dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath}bind def% rectangle
    /pgfw{setlinewidth}bind def% setlinewidth
    /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}bind def% save
    /pgfr{pgfsd restore}bind def %restore
    userdict begin%
    /pgfo{pgfsd /pgfx currentpoint /pgfy exch def def @beginspecial}bind def %open
    /pgfc{newpath @endspecial pgfpd}bind def %close
    /pgfsd{globaldict /pgfdelta /delta where {pop delta} {0} ifelse put}bind def% save delta
    /pgfpd{/delta globaldict /pgfdelta get def}bind def % put delta
    /.setopacityalpha where {pop} {/.setopacityalpha{pop}def} ifelse % install .setopacityalpha 
    /.pgfsetfillopacityalpha{/pgffoa exch def
      /pgffill{gsave pgffoa .setopacityalpha fill 1 .setopacityalpha newpath fill grestore newpath}bind def
      /pgfeofill{gsave pgffoa .setopacityalpha eofill 1 .setopacityalpha newpath eofill grestore newpath}bind def}bind def
    /.pgfsetstrokeopacityalpha{/pgfsoa exch def /pgfstr{gsave pgfsoa .setopacityalpha stroke grestore newpath}bind def}bind def
    /pgffoa 1 def
    /pgfsoa 1 def
    end
  }
\fi
\begin{tikzpicture}
    \draw[fill] (0,0)rectangle(5,5); 
\end{tikzpicture}
\end{document} 
share|improve this answer
    
I could make standalone add this code automatically if preview is used in PS mode. What do you think? –  Martin Scharrer May 27 '12 at 15:01
    
@MartinScharrer: It is a good idea if you add the code that is extracted from relevant PGF prologue file (rather than hard coding it) so any future changes in the prologue file can be available automatically in standalone. –  cyanide-based food Apr 17 '13 at 13:23

An alternative is now to use the crop option of standalone which does not use the preview package but crops the content using custom code. This works for DVI/PS and PDF output. Note that this option is available since v1.0 of standalone and is now the default (!), while before the preview option was the default.

Your original MWE therefore works fine with standalone v1.0 (as long the preview option is not re-enabled):

\documentclass{standalone}% works fine with v1.0
\usepackage{tikz}
\begin{document}
 \begin{tikzpicture}
\draw[fill] (0,0)rectangle(5,5); 
 \end{tikzpicture} 
  % or  \tikz \draw[fill] (0,0) rectangle (5,5);
  % or  \tikz{\draw[fill] (0,0) rectangle (5,5)} % with pgf 2.10 cvs
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.