TransWikia.com

Compile a pspicture under Emacs

TeX - LaTeX Asked on September 3, 2021

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?

3 Answers

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.

Correct answer by Tyler on September 3, 2021

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.
<recently read> c@lor@to@ps 

l.13    pstree
               {Tcircle{ }}

which means that you have used pdflatex which doesn't work for pstricks, you need to use latex then dvips then ps2pdf.

This seems to be a duplicate but I'm using answer rather than comment to format the answer, Your example works for me with latex. no need to vote for this.

Answered by David Carlisle on September 3, 2021

Your file compile just fine on my TeXLive2020/Debian box. AUCTeX-12.2.4/Emacs-26-3 I just add usepackage{pstricks} and some file variables

documentclass{article}
usepackage{pstricks}
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}:

 % Local Variables:
 % TeX-PDF-from-DVI: "Dvips"
 % TeX-PDF-mode: 1
 % End:

Answered by gigiair on September 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP