[ESS] configuring ess-pdf-view-pref for forward and inverse search.

Martin Maechler maechler at stat.math.ethz.ch
Fri Oct 17 15:39:03 CEST 2014


>>>>> Raghu Naik <naik.raghu at gmail.com>
>>>>>     on Thu, 16 Oct 2014 20:56:14 +0000 writes:

    > Guys, I am new to emacs/auctex/ess and ubuntu as well.

    > Based on some online search, I have been able to configure
    > my .tex documents for forward and inverse search with
    > Okular.

    > I am having difficulty doing that when I use a .Rnw
    > file. My relevant .emacs code is below. I would appreciate
    > any help.

Not really looking at  your .emacs  {lack of time ..}, but I see
you are using the 'synctex' option -- though  quite a bit
differently than we did (below).

But: Yes, it is possible, I have done this -- with prompting and
help from Marius Hofert (in CC) who I think uses this much more
regularly than I do.

It is important to use "synctex" when building the final PDF.
Also important is to use R package "patchDVI" to collaborate with synctex.

We've used ESS for editing and running R etc, but used a
Makefile for final Sweaving and pdf production, also because the
final pdf was made from several *.tex, *.Rnw, *.R  *.sty ... files.

Here are relevant parts of the Makefile
where you should note the Rscript call to  patchDVI::patchSynctex() :
----------------------------------------------------------------------

PDFLATEX0 = pdflatex
PDFLATEX = $(PDFLATEX0) --shell-escape -synctex=1 -file-line-error
#TEXI = PDFLATEX='${PDFLATEX}' ${R_PROG} CMD texi2dvi -p
TEXI = PDFLATEX='${PDFLATEX}' texi2dvi -p
SWEAVE  = $(R) CMD Sweave --encoding=utf-8
STANGLE = $(R) CMD Stangle --encoding=utf-8
ifneq ($(strip $(RNW)),)
 PATCHSYNCTEX = `$R RHOME`/bin/Rscript -e "patchDVI::patchSynctex('$*.synctex')"
endif

pdfDeps = $(RNW:=.tex) $(TEX:=.tex)  Sweave-JSS-prelim.R *.bib


[...............]

%.pdf: %.tex $(pdfDeps)
	$(TEXI) $<
	$(PATCHSYNCTEX)

%.tex: %.Rnw $(R_AUX)
	@echo; echo; echo '--- Sweaving '$<': ------------------------------------'; echo;
	$(SWEAVE) $<

----------------------------------------------------------------------

I hope this will help


    > I am using the latest versions of emacs, ess, auctex, and R.

    > Regards.
    > Raghu

    


    > ________.emacs code_______________________________________

    > (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-command "latex -synctex=1")
    > '(TeX-PDF-mode t)
    > '(TeX-source-correlate-method (quote synctex))
    > '(TeX-source-correlate-mode t)
    > '(TeX-source-correlate-start-server t)
    > '(TeX-view-program-list (quote (("Okular" "okular -unique %o#src:%n%b"))))
    > '(TeX-view-program-selection (quote ((output-pdf "Okular") ((output-dvi
    > style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "Evince")
    > (output-html "xdg-open"))))
    > '(ess-pdf-viewer-pref (quote ("okular"))) ;; "-reuse-instance" "unique"
    > '(cua-mode t nil (cua-base))
    > '(ess-swv-processor (quote knitr))
    > '(reftex-plug-into-AUCTeX t)
    > '(show-paren-mode t))
    > (custom-set-faces
    > ;; custom-set-faces 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.
    > )

    > ;; this is taken from
    > http://www.kevindemarco.com/2013/04/24/emacs-auctex-synctex-okular-on-ubuntu-12-04/
    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    > ;; Latex for Emacs
    > ;; 
    > ;; Dependencies: okular, texlive-full, auctex
    > ;;
    > ;; Okular setup: 
    > ;; 1.) Open Okular and go to...
    > ;; 2.) Settings -> Configure Okular -> Editor
    > ;; 3.) Set Editor to "Emacs client"
    > ;; 4.) Command should automatically set to: 
    > ;; emacsclient -a emacs --no-wait +%l %f
    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    > ;; only start server for okular comms when in latex mode
    > (add-hook 'LaTeX-mode-hook 'server-start)
    > (setq TeX-PDF-mode t) ;; use pdflatex instead of latex

    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    > ;; Standard emacs/latex config
    > ;; http://emacswiki.org/emacs/AUCTeX
    > (setq TeX-auto-save t)
    > (setq TeX-parse-self t)
    > (setq-default TeX-master nil)


    > (add-hook 'LaTeX-mode-hook 'visual-line-mode)
    > (add-hook 'LaTeX-mode-hook 'flyspell-mode)
    > (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

    > ; enable auto-fill mode, nice for text
    > (add-hook 'LaTeX-mode-hook 'auto-fill-mode)
    > (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
    > (setq reftex-plug-into-AUCTeX t)
    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    > ;; Enable synctex correlation
    > (setq TeX-source-correlate-method 'synctex)
    > ;; Enable synctex generation. Even though the command shows
    > ;; as "latex" pdflatex is actually called

    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    > ;; Use Okular as the pdf viewer. Build okular 
    > ;; command, so that Okular jumps to the current line 
    > ;; in the viewer.
    > (setq TeX-view-program-selection
    > '((output-pdf "PDF Viewer")))
    > (setq TeX-view-program-list
    > '(("PDF Viewer" "okular --unique %o#src:%n%b")))
    > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    > ______________________________________________
    > ESS-help at r-project.org mailing list
    > https://stat.ethz.ch/mailman/listinfo/ess-help



More information about the ESS-help mailing list