Один из способов сделать это в UNIX-подобных системах - открыть канал для процесса, перенаправляющего stdout
и stderr
на 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] ""
К сожалению, fifo
не поддерживается в Windows.