# Compile a pspicture under Emacs

I copied the solution from this link to a file try.tex under Emacs:

\documentclass{article}

\usepackage{pst-tree}

\begin{document}
Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem
ipsum.

\begin{figure}
\centering
\begin{pspicture}(5,-5)
\psgrid
\pstree{\Tcircle{ }}
{
\pstree{\Tr{ }}{\Tfan}
\pstree{\Tr{ }}{\Tfan}
}
\end{pspicture}
\caption{}
\end{figure}

Lorem ipsum. Lorem ipsum. Lorem ipsum.

\end{document}


Then I try to compile it with C-c C-c which is LaTeX, but it returns to me ERROR: Undefined control sequence. at the place of \pstree. Could anyone tell me how to compile and preview this picture from Emacs?

-
That doesn't look like an Emacs problem, I think the problem is in the pst-tree macros. – Tyler Feb 28 '13 at 22:04
This appears to be a duplicate of the question in the related list that come up automatically: tex.stackexchange.com/questions/10549/… – David Carlisle Feb 28 '13 at 22:07

This is only sort-of an Emacs issue. As David Carlisle points out, you can't compile your example with pdflatex, you need regular latex. The fact that you don't get regular latex by default with Emacs suggests that you've enabled TeX-PDF-mode. You can turn that off again with M-x TeX-PDF-mode, and then compile as usual with C-c C-c.

-
+1 for bringing it back to the question:-) – David Carlisle Feb 28 '13 at 22:33
You can also add a local variables line to your .tex file. Add the following at the top: %-*- mode: latex; TeX-master: t; TeX-engine: latex -*-. Here's the relevant section of the GNU Emacs manual: gnu.org/software/emacs/manual/html_node/emacs/… – kahen Feb 28 '13 at 22:42
@kahen: I think TeX-PDF-mode will override the TeX-engine local variable, but I'm not certain. – Tyler Feb 28 '13 at 22:51
@Tyler: Well. Nothing's stopping you from putting TeX-PDF-mode: nil in the variables line as well – kahen Feb 28 '13 at 22:52
@kahen: good point! – Tyler Mar 1 '13 at 1:57

This is clearly unrelated to the editor you use. You don't show the exact error you got but I would guess it is

! Undefined control sequence.