1

I'm using the Sweave toolchain in R to generate tex files from Sweave files as part of an R package. I use the R command:

    $(RSCRIPT) -e "tools::texi2dvi( 'file.tex', pdf = TRUE, clean = FALSE )" 

(part of my a Makefile in inst/doc) to generate the pdf. Non-breaking-space character ~ seems to be appearing as a real tilde in the resulting pdf. How do I avoid this? (I running pdflatex on the .tex file seems to do the trick, but I gather that is more platform dependent than using the R tools to compile the package. (More on R/Sweave makefiles in this question)

  • My best solution is to just compile with the native latex tools rather than the R-included tools in the makefile. See this example: gist.github.com/1591001 – cboettig Feb 2 '12 at 18:56
3

I have run into the same issue. At work right now I have a windows machine and the call to tools::texi2dvi seems work just fine, no unbreakable space in the resulting pdf. However, on my Ubuntu 11.10 machine at home I see the ~ character just as you described if I compile via tools::texi2dvi. My solution has been to use a system call from R to get the pdflatex if on Linux and tools::texi2dvi if on windows. I have the function as part of a build.R file for whatever project I'm working on that day.

compile <- function(){
  if (.Platform$OS != 'windows'){
    system("pdflatex ./tex/MAIN.tex")
  } else {
    tools::texi2dvi(file  = "./tex/MAIN.tex",
                    pdf   = TRUE,
                    clean = FALSE,
                    quiet = FALSE)
  }
}

compile()
  • thanks for confirming the bug. Yes, I've been using system calls (or just a custom Makefile) to get around this too, but it seems unsatisfying that tools::tex2dvi has such a bug on Ubuntu. I guess it's worth posting this to r-devel then? – cboettig Mar 27 '12 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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