# AUCTeX and TikZ does not work in emacs for me : HELP T

This is no duplicate. I am unsure how things work here. But I wasn't able to save my last username as it was a temporary username and cannot access my previous post which was marked as duplicate. However, rest assured it was no duplicate.

so, whenever I click on my previous post it automatically redirects me to Preview TikZ figure in AUCTeX? which is not the problem.

HELLO WHOEVER CLOSED THAT AND MARKED IT AS DUPLICATE. PLEASE REFRAIN FROM DOING SO, since this is a different problem.

As I advised on my previous post, I already followed all the instructions provided in the this tex forum that are related to resolving how tikz and auctex work for the preview....

The minimum working example that does not work for the C-c C-p C-s command for previewing is :

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

\section{test}

\begin{tikzpicture}
\draw (1,1) rectangle (2,2);
\end{tikzpicture}
\end{document}


What I get when I attempt to preview is an [stop symbol] icon before

[icon appears here]\begin{tikzpicture}


When I click on the icon I can select two options:

[View Error]
[View Source]


The error is as follows.

gs -dOutputFile\=$$_region_.prv/tmp10394KqL/pr1-1.png$$ -q -dDELAYSAFER
-dNOPAUSE -DNOPLATFONTS -dPrinted -dTextAlphaBits\=4-dGraphicsAlphaBits\=4

-sDEVICE\=png16m -r127.763x127.523

setuserparams .locksafe} stopped pop {DELAYSAFER{.setsafe}if}stopped
pop/.preview-BP currentpagedevice/BeginPage get dup null eq{pop{pop}bind}if

def<</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1
ne or{.preview-BP }{pop}ifelse}bind/PageSize[1 1]>>setpagedevice/preview-
do{[count 3 roll save]3 1 roll dup length 0 eq{pop}{setpagedevice}{ifelse

.runandhide}stopped{handleerror quit}if aload pop restore}bind def

setfileposition 25160()/SubFileDecode filter cvx .runandhide aload pop dup
dup 25271 setfileposition 387()/SubFileDecode filter cvx<<>>preview-do

Error: /undefined in pgfo

Operand stack:

Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--

--nostringval--   2   %stopped_push   --nostringval--   --nostringval--

%loop_continue   --nostringval--   --nostringval--   false   1

%stopped_push   .runexec2   --nostringval--   --nostringval--

--nostringval--   2   %stopped_push   --nostringval--   --nostringval--

false   1   %stopped_push   1148   --nostringval--   %end_runandhide

--nostringval--

Dictionary stack:
--dict:1169/1684(ro)(G)--   --dict:0/20(G)--   --dict:83/200(L)--

--dict:106/300(L)--

Current allocation mode is local

Last OS error: 2

Preview-Ghostscript finished


What I did

Pre-included in my .emacs file is:

;; To integrate RefTeX with AUCTeX, use
(setq reftex-plug-into-AUCTeX t)


and

;; Automatic Parsing of TeX Files
(setq TeX-parse-self t ; Enable parse on load.
TeX-auto-save t ; Enable parse on save.
LaTeX-math-mode t ;  will read a character from the keyboard,
; and insert the symbol as specified...
TeX-electric-sub-and-superscript t ; If non-nil, insert braces
; after typing  and  in
; math mode.
preview-scale-function 1.33 ; determines by what factor images
; and formulas should be scaled when
; appearing on the screen
)


1) Yes, I included the following into my .emacs file:

(eval-after-load "preview"
)


2) I also included the following command in my .emacs file right after the one above

(setq auto-mode-alist
(append
'(("\\.tikz\\'" . latex-mode))
auto-mode-alist))


At last, someone suggested to include something like \PreviewEnvironment{tikzpicture} I tried that but this does not seem to have made any changes to the error.

It's been nagging and bugging me a lot over the last 20 hours to get this silly preview working. I am no complete retard but I am a newbie. Can someone please help me ?

thanks.

It is imho not a auctex problem. The following document fails with ghostscript errors if I compile through latex-dvips and then try to view in gsview. It works fine with pdflatex.

\documentclass{article}

\usepackage{tikz}

\usepackage[tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}

\section{test}

\begin{tikzpicture}
\draw (1,1) rectangle (2,2);
\end{tikzpicture}

\end{document}
`