[R] a question about "latex" in Hmisc and .dvi file

Erik Iverson eriki at ccbr.umn.edu
Thu May 13 16:58:28 CEST 2010



Felipe Carrillo wrote:
> HI:
> If you don't mind me asking this question about latex:
> Based on Duncan's comment:
> "The print method for "latex" objects tries to run latex and then display the resulting .dvi file.  (Or maybe it runs pdflatex and displays the .pdf file)."
> Where in MikTex can I change to pdflatex? everytime I use latex it displays the dvi file which is a problem because tables that I want to see landscaped don't work. Thanks

I don't work in a Windows environment, but I think the process is the 
same here.

You have to know what the print.latex function in Hmisc is doing.  It 
simply calls show.latex.  If you look at the source for show.latex, it 
looks at the latex object passed to it, and inspects the file argument. 
  If the file argument is the empty string ( "" ), it does not attempt 
to show the resulting output in a dvi.  If the file argument is a file 
name, show.latex will call dvi.latex on the object, which will wrap the 
latex code in some basic latex, and call optionsCmds("latex") on the file.

This is by default set to

 > optionsCmds("latex")
[1] "/usr/bin/latex"

This will of course create a dvi and attempt to display it with 
show.dvi, which will in turn use

 > optionsCmds("xdvi")
[1] "xdvi"

to display the resulting file.

I'm guessing MikTex comes with pdflatex, just like it comes with a 
binary called latex.  You'd just have to find it and make sure it's in 
your path.

Then, by setting the relevant options I just described above to pdflatex 
and a suitable pdf viewer, you might get what you want.  But there might 
be other things I haven't thought of that will prohibit this from 
working.  In fact, it looks like dvi.latex naturally assumes the 
extension .dvi from its output, and so this may not work.  You/I might 
have to write separate functions to carry this out it appears.  Of 
course, someone else may have already, and I just don't know about it.

--Erik



More information about the R-help mailing list