5
votes

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.

2
You need to look at the output from latex. C-c C-l IIRC.lukstafi
Thanks but when I use C-c C-l, it prompts "No TeX output buffer". Still cannot preview the formulas.zeno tsang

2 Answers

0
votes

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.

-1
votes

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