我很难通过 knitr
用变音符号打印我的表格包和 pandoc。相信Name.md
文件生成正确,但在 pandoc
处给我错误等级。我做错了什么?没有变音符号,它可以完美运行。
这是我遵循的示例和步骤:
在 R 中复制表
SampleTable <- data.frame(Nazov=c("Kratkodobé záväzky (TA)","Dlhodobé záväzky
(LA)","Záväzky celkovo (TA)"))
我运行 *.Rmd 文件来创建 Name.md 文件
```{r, echo=FALSE, dpi=600, fig.width=12, fig.height=15, fig.cap="Finančná štruktúra"}
print(xtable(SampleTable))
```
将 .md 转换为 .pdf
knit("Name.rmd")
system(paste("pandoc -V geometry:margin=1in -o", "Report", ".pdf ", "Name", ".md",
sep=""))
编辑:错误:
pandoc.exe: Cannot decode byte '\x20': Data.Text.Encoding.decodeUtf8: Invalid UTF-8
stream
Warning message:
running command 'pandoc -V geometry:margin=1in -oReport7.pdf ReportNew.md' had status 1
最佳答案
在诸如“geany”之类的文本编辑器中查看文件后,您可以轻松查看文件编码(文件 > 属性),您将看到文件编码为 ISO-8859-1。
但是,如 Pandoc 手册页所述:
Pandoc uses the UTF-8 character encoding for both input and output. If your local character encoding is not UTF-8, you should pipe input and output through iconv:
iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
因此,我在终端上所做的是(假设您已更改到 .md 文件的存储目录):
iconv -f ISO-8859-1 -t UTF-8 md_file.md > new.md
pandoc new.md -o test.pdf
如果您希望从 R 中执行此操作,请像您在现有问题中所做的那样将命令粘贴在一起。
这是我得到的输出:
注意:我应该提到我在 Ubuntu 上并且 iconv 在 Unix 系统中是相当标准的。
关于r - R 中带有 Pandoc Knitr 的带有变音符号的表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18831936/