3

This is a follow-up post to Polymode installation on Windows machine. Accordingly I installed polymode using this code in the init.el file after ESS code:

(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))  

This seems to work as polymode (PM-Rnw) does appear in the minibuffer:

enter image description here

Now I want to weave this file using M-n w and knitr option, it prompts me then whether this is the master file:

enter image description here

When I hit RET to accept the default (same file is master file), I get this message:

enter image description here

This indicates that a mwe_demo[weaved].tex buffer has already been created and transferred to a project cache in projectile. But this buffer is empty and no such file was ever found in that path. So what am I missing here?

Update
the following message appears in the *polymode weave* buffer:

weaving latex with command:
     Rscript -e "library(knitr); knit('mwe_demo.Rnw', output='mwe_demo[weaved].tex')"
'Rscript' is not recognized as an internal or external command,
operable program or batch file.

So it seems that knitr could not be loaded because of no recognized Rscript.exe shell command. This means that it won't use the Rterm.exe that I have this line of ESS installation in init.el:

(setq-default inferior-R-program-name "C:/Program Files/R/R-3.1.2/bin/i386/Rterm.exe")

but how to make Rscript recognized which I have it on this path C:/Program Files/R/R-3.1.2/bin/Rscript.exe? I hope that was more explained in the documentation.

I ended up adding the above path to PATH variables Win + break. It worked now and weaved into .tex file. Now when I press M-x e/E I get two candidates pdflatex|latexmk how to extend that to include xelatex, which is more useful in my case?

Updated Question

How to make polymode opt for xelatex?

A similar case with Noweb mode could be solved by M-x customize-group as in this post: https://stackoverflow.com/a/28515366/1288722

Note

  • The same file could be weaved successfully using the Noweb mode in ESS using knitr
  • Pandoc is already installed and in the PATH variable M-x getenv RET PATH RET
  • Windows 7 32 bit

1 Answer 1

3

After some trials on Windows machine, I found this workflow works very well:

Installation for Windows users

Step 1
Put this in your init.el or .emacs.el file - after ESS code:

(require 'poly-R)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
;;; MARKDOWN
; (add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))

;;; R modes
; (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
; (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
; (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))

Step 2
Put C:/Program Files/R/R-3.1.2/bin into PATH variable of your Windows; Win + break shortcut is useful. This step to make sure that Rscript.exe will be accessible by shell command of polymode to load knitr package.

Step 3
Once you have polymode file say .Rnw or alike ready and you have already fired up your ESS R session, you can issue M-x w to weave it (I use Knitr).

Step 4
Instead of issuing M-x e or M-x E directly from .Rnw file (which has only latexmk | pdfaltex options), I tend to open the newly generated weaved .tex file (if not already opened for you in other window) and hit the usual C-c C-c command to compile it using my favorite default engine xetex, if you don't have it as default, this line in your init.el will let you do so:

(setq-default TeX-engine 'xetex)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.