-1

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....

Can someone please help me make this work ?

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

GS>{<</PermitFileReading[(_region_.prv/tmp10394KqL/preview.ps)]>> 
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 

[(_region_.prv/tmp10394KqL/preview.ps)(r)file]aload exch dup 0 
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)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(add-hook 'bibtex-mode-hook 'turn-on-auto-revert-mode)

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"
'(add-to-list 'preview-default-preamble "\\PreviewEnvironment{tikzpicture}"     t)
)

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.

1

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}

Addition

with pgf-3.0 I can view the file in gsview but the tightpage option didn't work: I see a full page.

11
  • So, I am not sure what and how to use your response. I am a newbie, please keep this in mind.
    – brandon
    Feb 20 '14 at 9:27
  • Well don't fight with the auctex configuration: If the file can't be viewed in ghostscript without error then the preview simply won't work. You could ask on the auctex list if auctex could run pdflatex on tikzpicture environments (and then show the pdf). You could wait until 3.0. is on your system (it should imho appear soon on CTAN). If the preview doesn't work there correctly you could try a bug report in the bug tracker of pgf. Feb 20 '14 at 9:41
  • thank you for that response. this is all very confusing to me .... as it stands , it might as well be that i have not "configured" things correctly ... how on earth would i know whether I am not doing something correctly ? sure thing, if i "latex" the file and the use the "run viewer" within emacs things look fine. but that's not the point of having auctex ?
    – brandon
    Feb 20 '14 at 9:45
  • Did you run your file or mine? With your file there should be not problem. But my file (and auctex) uses preview and preview tries to cut out a portion of a page while tikz is putting material everywhere (there is e.g. the "current page" node) and so something clash. Feb 20 '14 at 9:54
  • i am sorry for my late response. I tried, of course, my file and i just cannot get the rectangle to show up with the auctex. If I run "latex" then "dvi" viewer, of course, I can see the result. But that shouldn't be the point. I just don't know what I am doing wrong. I seem to have the write commands in the .emacs file installed. I realize that on terminal I can access: emacs or emacs23. I tried both, but to no avail.
    – brandon
    Feb 20 '14 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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