1

knitr我正在尝试使用 R 中的和包创建一个带有表格的 pdf pander,但似乎我的表格中的某些文本被误解为代码,因为生成的文档在不应该的情况下将文本逐字显示。这是一些示例代码,我可以在其中复制该问题。

---
title: "Untitled"
author: "Me"
date: "10/07/2015"
output: pdf_document
classoption: landscape
---

\footnotesize
```{r,echo=F,message=F}
library(pander)
dat <- data.frame(test_name=c("Short","Really, really long test name","Other","The rest/Other/whatever"),
                  campaigns=c("AAA BBB CCC","AAA","BBB CCC","DDD"),
                  objective=c("We want to test whether or not the changes we made to our proceedure will change the outcome. We will test this from January 2015 to January 2016.","I am not very creative and cannot think of any other objectives especially since I made up the rest of this stuff.","Our objective is to improve the quality of our product.","The objective is to find out if people will like this other product better."),
                  results=c("The test we did resulted in the following results that were counter-intuitive since we expected other results.","None","This other test resulted in everything as we expected, blah, blah, blah.","None"))


myTable <- pander(dat,split.cells=c(20,10,60,60),split.table=Inf,style='grid',emphasize.strong.cols=c(1))
return(myTable)
```

我尝试使用pander_return而不是pander函数,然后将该文本转换为 LaTeX,Pandoc.convert这样我就可以将所有的\begin{verbatim}和替换为\end{verbatim}空,但这不起作用。现在这是有道理的,因为我试图在我的 Rmd 文件中这样做。

在此处输入图像描述

就在发布这个问题之前,我确实注意到,如果我/从列中删除所有 's test_name,我不再有该列的逐字记录问题,但问题仍然存在于campaignsandresults列中。

在此处输入图像描述

我如何让它识别出文本是降价而不是逐字代码?任何帮助深表感谢。

编辑:一旦我从第一列中删除“特殊字符”,它似乎只将单元格文本视为单元格中的单个单词时的逐字代码。否则它看起来很好。

4

1 回答 1

0

根据@rawr 的评论,添加justify= 'left'pander函数中解决了问题。

于 2016-11-16T21:40:59.560 回答