A diacritics table with Pandoc & Knitr through R

I find it difficult to print a diacritics table through the knitr and pandoc packages. I believe that the Name.md file is created correctly, but gives me an error at the pandoc level. What am I doing wrong? Without diacritics, it works great.

Here is an example and the steps that I follow:

Table replication in R

 SampleTable <- data.frame(Nazov=c("Kratkodobé záväzky (TA)","Dlhodobé záväzky (LA)","Záväzky celkovo (TA)")) 

I run a * .Rmd file to create a Name.md file

 ```{r, echo=FALSE, dpi=600, fig.width=12, fig.height=15, fig.cap="Finančná štruktúra"} print(xtable(SampleTable)) ``` 

Convert .md to .pdf

 knit("Name.rmd") system(paste("pandoc -V geometry:margin=1in -o", "Report", ".pdf ", "Name", ".md", sep="")) 

EDIT: error:

 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 
+4
source share
1 answer

After viewing your file in a text editor such as "geany", which makes it easy to view the file encoding (File> Properties), you will see that the file encoding is ISO-8859-1.

However, as mentioned on the Pandoc man page:

Pandoc uses UTF-8 character encoding for input and output. If your local character encoding is not UTF-8, you must connect the input and output through the icon:

 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8 

Thus, what I did on my terminal was (if you went to the directory where your .md file is stored):

 iconv -f ISO-8859-1 -t UTF-8 md_file.md > new.md pandoc new.md -o test.pdf 

If you want to do this from R, put together the commands, as you did, in your existing question.

Here I got the conclusion:

enter image description here

Note. I should mention that I'm on Ubuntu, and iconv is pretty standard on Unix systems.

+3
source

Source: https://habr.com/ru/post/1502440/


All Articles