What is the proper way of solving this problem with respect to AUCTeX's design - I mean, how to do that in a way that it will still recognize the errors, display log on demand, make "View" command default on successful compilation, etc. Or, what is a way to define my own command with the same functionality and make it default?
With the current AUCTeX management of compilers I think the cleanest solution would be to add a new command for dvips
and another one for ps2pdf
and every time issue C-c C-c three times, but this isn't definitely comfortable.
Here there is the following solution (slightly improved): add this code to your .emacs
file
(eval-after-load "tex"
'(progn
(add-to-list
'TeX-command-list
'("LaTeX + dvips + ps2pdf"
"latex%(mode) %t && dvips %d -o %f && ps2pdf14 %f"
TeX-run-TeX nil t))))
This isn't the best solution, but at least is able to catch error reports.
-
Note that it may be necesary to include this inside a
(eval-after-load "tex-mode" ...)
– Stone Mason Mar 31 '14 at 22:28 -
Since AucTeX 11.89, this is a built-in feature; simply set the variable TeX-PDF-via-dvips-ps2pdf
to non-nil. The relevant documentation is found here:
User Option: TeX-PDF-via-dvips-ps2pdf
With TeX-PDF-mode set to non-nil, if TeX-PDF-via-dvips-ps2pdf is non-nil too, the document is compiled with tex (or latex) instead of pdftex (or pdflatex). When the document is ready, C-c C-c will suggest to run dvips and then ps2pdf in order to convert the DVI file to PDF. When the PDF file is finally ready, the next suggested command will be to open the viewer.
This option can also be set as a file local variable, in order to use the sequence tex–dvips–ps2pdf on a per-document basis.
So you could just put (setq TeX-PDF-via-dvips-ps2pdf t)
in your .emacs
to make every file be compiled this way.
-
1there is also a menu interface to check that option:
Command->TeXing Options->PDF via dvips + ps2pdf
(but no shortcut of three or fourC-something
is provided) – user4686 Nov 23 '15 at 21:35 -
Uh, I forgot to mention this new feature, thank you! And I'd add that with the new
C-c C-a
key binding you can compile the whole document at once. – giordano Nov 23 '15 at 22:38 -
I am finding this discussion useful but difficult to follow since I guess I do not know the exact lisp commands and their effects in auctex. But,ok, I am a frequent user of psfrag, I would also like to follow the latex->dvips->ps2pdf as default and view the resulting pdf with the view command in auctex. But no success so far, so I added the (setq TeX-PDF-via-dvips-ps2pdf t) but I can still not see the pdf output.(B) Do I need other options also in my init file? – Umut Tabak Mar 4 '18 at 13:16
I am a just plain latex user, but I got results, which was my best. I don't know LISP at all, and I was using just aquamacs and its GUI-like AUCtex customize menus. Anyway, for now I use psfrag, inverse search for pdf in Skim viewer both from pdflatex and from dvips + ps2pdf.
This was all my best. First, I separated (latex) and (dvips + ps2pdf). The reason is that if I don't, C-c C-v try to show dvi, which was not a good idea in my mac.
In the AUCtex customize menu -> TeX-command-list, the LaTex is bound to the PdfLatex as a default. So I added two more command-lists, the PdfLatex and the dvips + ps2pdf, and I just copied the original command in the LaTex list to PdfLatex list, which was
%`%l%(mode)%' %t
In the LaTex list, I replaced by
%(latex) --synctex=1 %s
In the dvips + ps2pdf list, I put
dvips %s.dvi && ps2pdf %s.ps %s.pdf
Then, the LaTex icon in the aquamacs operates as only latex compilation. After C-c C-c to run dvips + ps2dvi, I can see the pdf file using C-c C-v.
Also, I was able to use inverse search generated by dvips + ps2pdf in Skim viewer after I changed the value to synctex for DVI in the Tex Source Correlate Method menu.
Overall changes resulted in the following LISP, which I don't understand, but I put them here.
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(LaTeX-clean-intermediate-suffixes nil)
'(LaTeX-clean-output-suffixes nil)
'(LaTeX-command "latex")
'(LaTeX-mode-hook
(quote
(preview-mode-setup smart-dnd-latex
(lambda nil
(TeX-fold-mode t))
turn-on-bib-cite turn-on-reftex flyspell-mode abbrev-mode)))
'(TeX-clean-confirm nil)
'(TeX-command-list
(quote
(("TeX" "%(PDF)%(tex) %(extraopts) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil
(plain-tex-mode texinfo-mode ams-tex-mode)
:help "Run plain TeX")
("LaTeX" "%(latex) --synctex=1 %s" TeX-run-TeX nil
(latex-mode doctex-mode)
:help "Run LaTeX")
("PdfLaTex" "%`%l%(mode)%' %t" TeX-run-command nil t)
("dvips + ps2pdf" "dvips %s.dvi && ps2pdf %s.ps %s.pdf " TeX-run-TeX nil t)
'(TeX-view-program-selection
(quote
((output-dvi "Skim")
(output-pdf "Skim")
(output-html "open"))))
'(TeX-source-correlate-method (quote ((dvi . synctex) (pdf . synctex))))
.tex
file you edit or only for certain projects? – Paul Gessler Mar 4 '14 at 16:48.tex
file, even in the future. – Andrew Zabavnikov Mar 4 '14 at 17:03.eps
graphics with thepdflatex
? Here, 'proper' means that I can use them in scalable manner (after conversion to some other format for example). – Andrew Zabavnikov Mar 4 '14 at 17:47