Search code examples
rlatexhmisc

Hmisc latex() saves file but R keeps running


Take this sample data frame

df <- "A B C
1  1 2 3
2  4 5 6
3  7 8 9"
df1 <- read.table(textConnection(df), header=TRUE)

I want to save it as a table on a .tex file. The function

require(Hmisc)
latex(df1,title="TeX/df1prova")

saves the file, but R does not stop running. The output I get is

> latex(df1,title="TeX/df1prova")
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9)
entering extended mode
(C:/Users/Simone/AppData/Local/Temp/Rtmpw116kM/file1bd01a163c06.tex
LaTeX2e <2016/03/31> patch level 3
Babel <3.9r> and hyphenation patterns for 75 language(s) loaded.
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\report.cls"
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\graphics\keyval.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\oberdiek\ifvtex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\generic\ifxetex\ifxetex.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\geometry\geometry.cfg"))
No file file1bd01a163c06.aux.
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
[1] (file1bd01a163c06.aux) )
Output written on file1bd01a163c06.dvi (1 page, 444 bytes).
Transcript written on file1bd01a163c06.log.

Any clue? thanks!


Solution

  • Sorry this answer comes 6 month late. This is explained in the latex help files (look at the examples). When you run the latex command, it creates an object of class "latex" which is automatically printed by the latex print method. To avoid this, pass it to a variable

    mytex <- latex(df1,title="TeX/df1prova")
    

    This will not invoke the print method, but will write the result in the file.