Skip to content

patchDVI: how to pass encoding of the .Rnw file?

2 messages · Duncan Murdoch, Marius Hofert

#
On 12-08-19 3:47 PM, Marius Hofert wrote:
Sorry, I'm writing this while offline, so I can't quote your message.
The issue was that if the main .tex file uses \input to include another 
file,
and that file needs to be processed by Sweave, then the usual encoding
detection method (looking for \usepackage[utf8]{inputenc} or similar) won't
work, because you can't put that line in the secondary file.

The solution is the same as when using Sweave:  put a default encoding into
the call to SweavePDF (or the similar functions).  For example, my editor
always executes this command when asked to process a .Rnw file:

patchDVI::SweavePDF('%2', stylepath=FALSE,
     preview="f:/SumatraPDF/SumatraPDF \x25s",
     encoding="utf8")

The %2 is a place holder for the filename to process.  The preview argument
invokes the PDF previewer that knows Synctex; the stylepath and encoding
arguments are passed to Sweave.  Because I chose encoding="utf8", Sweave
will assume that encoding as the default for files.  Another encoding  
can be
explicitly declared.

When I have multi-file projects, I make use of .TexRoot and .SweaveFiles
in each of the files so I can make the whole project each time;
see the patchDVI vignette (section 6) for details of how they work.

I think you also asked how to do this in Emacs; I've got no idea about that.

Duncan Murdoch
2 days later
#
Dear Duncan,

many thanks for helping. It works fine.

Cheers,

Marius

Duncan Murdoch <murdoch.duncan at gmail.com> writes: