我正在使用Rstudio中的Knitr来生成Markdown文件。我使用xtable包显示表格,它在HTML文件中显示得很好。然而,当我通过pandoc将.md转换为.tex时,LaTeX文件并不包含应有的表格,只有表格中的值而没有任何命令。
Markdown - Knitr输入
为了更好地说明问题,以下表格提供了一些数据行的示例:
```{r table, results='asis', echo=FALSE}
r = read.table("C:/aR_files/data.txt",sep=",", header=TRUE,as.is=TRUE)
r$X = NULL;
print(xtable(r), type='html')
```
Latex
In order to give a better idea, the following table provides a sample of
data rows:
Row1
Row2
Val1
Val1
我认为可能缺少了一个LaTeX包,所以我下载了ctable.sty,但是仍然得到相同的输出。有任何想法都会受到赞赏,谢谢!
dput(r)
来展示r
中的内容? - David Robinsonpandoc
转换为LaTeX格式。解决方法是使用ascii
包,该包可用于在pandoc
样式下生成表格输出,这样可以在html和latex中都呈现良好的效果。另一种选择是使用options(xtable.type)
来控制表格样式,并根据您要生成的输出类型将其设置为latex
或html
。 - Ramnath