# Aquamacs + AUCTeX inline preview

I tried to search for the solution, but I couldn't even find references to this problem. I'm trying to use Aquamacs+AUCTeX as my LaTeX editor. One of the major features available in this setting is the inline preview. For me it doesn't work. I'll try to provide the relevant information.

I'm using:

GNU Emacs 23.2.50.1 (i386-apple-darwin9.8.0, NS apple-appkit-949.54) of 2010-08-18 on braeburn.aquamacs.org - Aquamacs Distribution 2.1

with

Mac OS 10.6.6

And this is my .emacs file:

Assigns org-mode to .org files
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) (define-key global-map "\C-cl" 'org-store-link) (define-key global-map "\C-ca" 'org-agenda) (setq org-log-done t) ;; Make use of refTeX in org-mode (defun org-mode-reftex-setup () (load-library "reftex") (and (buffer-file-name) (file-exists-p (buffer-file-name)) (reftex-parse-all)) (define-key org-mode-map (kbd "C-c )") 'reftex-citation) ) (add-hook 'org-mode-hook 'org-mode-reftex-setup) ;; Set LaTeXmk the default LaTeX compiler ;;(setq org-latex-to-pdf-process (list "latexmk -f -pdf %s")) ;;(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "LaTeXmk"))) ;; Enable LaTeX-math-mode by default (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)  I tried to use it with a simple example like: \documentclass{article} \begin{document} Well what do you say? Here's the first formula$x^2=1\$.
It seems not to be working...

\end{document}


Then C-c C-p C-d produced nothing but a no-entrance sign beside the formula. In this zip file I included all the related files I gathered.

Did any of you encountered this issue? Hints tips and fixing methods are welcomed!

-

## 3 Answers

Perhaps try exiting from pdf mode (C-C C-t C-p) and then generating previews (C-c C-p C-d). I believe that this results in the previews (which are png images by default) being generated from dvi rather from pdf.

(It still seems to me like the underlying issue with generating previews in pdf-mode is something related to ghostscript. However, your original zip file did not appear to contain any errors to help track the issue down.)

-
Thnx! I tend to agree with your assumption although I have no clue how to handle it. – Dror Mar 19 '11 at 7:59

That is my settings:

(setq TeX-PDF-mode nil)
(setq preview-image-type (quote dvipng))


In this case you don't even need Ghostscript or Gsview.

But, as it says, PDF mode is disabled. However, there is a more convenient way to get .pdf. Add this string in .emacs:

(add-hook 'LaTeX-mode-hook '(lambda () (setq compile-command "latexmk -pdf")))


Now, while you're in the LaTeX mode enter M-x compile RET and confirm the line by default (it will be latexmk -pdf). You'll see the compilation process in a separate window and *.pdf will appear in the tex file's directory. Actually, latexmk is a powerful tool that produces any kind of output depending on options (see manual). Note that latexmk will run on all tex-files in the current directory. If it's not a part of intentions, compile command should be provided with a filename to process. For example, latexmk -pdf introduction (without the extension)

compile in other major modes will still be make -k (or whatever you've assigned to them).

-

I'm not an expert on preview-latex, but this works fine on my Aquamacs 2.1 installation. Some thoughts:

1. I believe it is preferable to load the preview package when using preview-latex

\usepackage{preview}

Check the docs for options applicable to your situation, though not loading it does not appear to prevent previews being generated.

2. I believe preview-latex uses ghostscript to generate the preview images that are rendered in emacs. Assume that you have ghostscript installed and it's in your emacs exec-path?

3. I recently had an issue with displaying previews that I found to be related to using recent versions of ghostscript. Applying the patch found here to the preview.el packaged with Aquamacs fixed the issue I was having. However, I do not see any errors in your archive that are similar to those that led me to this fix, so possibly this is not your issue.

-
@shimeike: Adding the preview package changed nothing. I think I have ghostscript installed. For example I can invoke gs from the terminal. Finally, I'm trying to struggle with the patch you referred to. This might work. So far no success. I'll update. – Dror Mar 16 '11 at 15:30
@Dror: Perhaps try explicitly requesting that inline math previews are generated, since this is all you have in your sample: \usepackage[textmath]{preview}. Also, where is your gs installed? I have mine installed via macports, so the gs executable is located in /opt/local/bin . In my .emacs, I then include – shimeike Mar 17 '11 at 3:57
@Dror: Sorry, meant to say: Where is your gs installed? I have mine installed via macports, so the gs executable is located in /opt/local/bin. In my .emacs, I then include (add-to-list 'exec-path "/opt/local/bin"). – shimeike Mar 17 '11 at 4:05
another thought: have you tried exiting from pdf mode (C-C C-t C-p) and then generating previews? – shimeike Mar 17 '11 at 9:11
@shimeike: your last comment was the thing I was missing. Now inline previewing works! Thnx! However, I'm not sure what's the effect of disabling this pdf mode. Finally, I'd suggest that you post another answer, with the solution in your last comment, and I'll be happy to vote it up. – Dror Mar 17 '11 at 12:14