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

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.

Ulrike Fischer
  • 327,261
  • 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 09: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. – Ulrike Fischer Feb 20 '14 at 09: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 09: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. – Ulrike Fischer Feb 20 '14 at 09: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
  • It won't work. It is not your fault. It is not the fault of emacs or auctex. It is a bug in pgf. The error will go away when pgf 3.0. will reach your system, but I don't know if the preview will look ok, perhaps it will be too small. – Ulrike Fischer Feb 20 '14 at 16:41
  • OK. One final question. I can download pgf3.0 and there is indeed a post in this forum of how to install it ? But I don't understand it. The post says u can simply download link and then just move to home directory and extract ? but i don't think it is this trivial. – brandon Feb 20 '14 at 16:47
  • Yes in a texlive system pgf 3.0. should work out-of-the-box if you extract it correctly (!) in your TEXMFHOME tree. But if you put the files in the wrong places you can create a chaos. So check carefully the folder/file structure, compare it with the folder/file of the pgf in texmf-dist and make sure that you understand what you are doing. – Ulrike Fischer Feb 20 '14 at 17:24
  • oh dear lord please help me here. how would a newbie know how to extract it correctly or what the exact path is to save it too. it happens that i downloaded it on my desktop, then sudo cp it to a folder i already created on my home drive. then realized that there was not need to first create the folder as it would appear as a subfolder. i did it supposedly as instructed, but it still doesnt' work. the only thing that works is the dvi viewer. which is pointless. – brandon Feb 21 '14 at 03:25
  • I guess in order to truly understand what the hell is going on one needs to be an expert in unix systems and how the file systems work. otherwise, one should be instructed to get the hell out of unix and use toy os systems .... which is saddening – brandon Feb 21 '14 at 03:26
  • I can preview that document. It may be a bug of Ghostscript, that breaks everything from time to time. I have Ghostscript 9.07, what are your versions? – giordano Feb 21 '14 at 21:53