One way to do it on UNIX-like systems would be to open a pipe to a process that is redirecting stdout
and stderr
to a fifo:
# Setup
system('mkfifo output.fifo')
p_out <- fifo('output.fifo', 'r')
p_in <- pipe('pdflatex &> output.fifo', 'w')
# See what TeX said on startup
readLines(p_out)
[1] "This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)"
readLines(p_out)
character(0) # TeX has nothing more to say
# Tell TeX to do something
writeLines('\documentclass{article}', p_in)
flush(p_in)
# See what it said in response
readLines(p_out)
[1] "**entering extended mode"
[2] "LaTeX2e <2009/09/24>"
[3] "Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ba"
[4] "sque, danish, dutch, finnish, french, german, ngerman, swissgerman, hungarian, "
[5] "italian, bokmal, nynorsk, polish, portuguese, spanish, swedish, loaded."
[6] ""
Unfortunately, fifo
isn't supported on Windows.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…