zeno tsang
zeno tsang

Reputation: 745

fail to preview using auctex and emacs

I am using emacs and auctex on linux mint. I fail to preview the math formula in emacs when writing the following simple .tex file

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}

\begin{document}
I am going to write down the formula 
\[
    \sum_{k=1}^\infty x_k=\frac{x}{1-x^2}
\]
\end{document}

When I press C-c C-p, there comes the following error messages:

No appropriate `.dvi' file could be found

It seems that emacs doesn't generate any .dvi file. How to address this problem? Thanks all.

Upvotes: 5

Views: 1422

Answers (2)

Paul
Paul

Reputation: 582

I ran into this issue because I was asking for the dvi file to be displayed before it was done being built. The following elisp is used inside a bind-keys function which assigns control-p to preview the latex.

("C-p" . (lambda ()
  "Preview a latex buffer or selected region."
  (interactive)
  (if (use-region-p)
     (tex-region (region-beginning) (region-end))
   (tex-buffer))
  (run-with-idle-timer 0.3 nil 'tex-view)))

The tex-region and tex-buffer commands begin the conversion from TeX to dvi and opens another window showing the intermediate file names. These files, which include the desired dvi file, will be deleted as soon as the window is closed.

I used the run-with-idle-timer function to wait until emacs has been idle for 0.3 seconds before attempting to display the file.

Note: I am uncertain if this works solely because my tex file is small, or because it actually works.

Upvotes: 0

Krzysztofik
Krzysztofik

Reputation: 55

C-c C-p C-p works for me on Windows 10.

Upvotes: -1

Related Questions