0

I'm using the Hmisc latex command to print a summary table generated by summary() in an Rmd document in Rstudio. It works fine with the results='asis' option specified, however there is a spurious line that appears in my PDF file:

%latex.default(summary(cars), file = “”)%

I think knitr must be somehow escaping this comment such that it gets transferred verbatim to the output. Anyone know how I can suppress this behavior?

This is the contents of my .Rmd file:

---
title: "Untitled"
author: "John Smith"
date: "August 22, 2015"
output: pdf_document
---

```{r, results='asis', echo=FALSE, message=FALSE}
library(Hmisc)
latex(summary(cars), file="")

```

When I render it, I get a PDF that includes the phrase "%latex.default(summary(cars), file=`')%"

I'm using R version 3.2.1 (2015-06-18) on Mac OS X Darwin 12.6.0 and Knitr 1.11

ideas?

Peter

Peter Young
  • 131
  • 3
  • Possible duplicate: [knitr sanitises the % marker for LaTex comments and they show up in the final document](http://tex.stackexchange.com/questions/201820/knitr-sanitises-the-marker-for-latex-comments-and-they-show-up-in-the-final-do). As you finally generate a PDF you could write a Rnw instad of a Rmd file and directly compile Rnw to PDF. – CL. Aug 22 '15 at 22:59
  • `cat(capture.output(latex(summary(cars), file=''))[-1], sep='\n')`worked for me. Source: http://stackoverflow.com/questions/31443409/hmisc-latex-fuction-need-to-remove-the-first-line – A Toll Jul 01 '16 at 19:53

0 Answers0