Getting the Unicode character in a fragment of a fragment of an R-figure

I am currently doing my figs using the “unprincipled” (opportunistic) way of getting Unicode characters. For instance:

<<ClassFig>>=
pdf('figs/figA.pdf', h=6, w=6, encoding='CP1250')
plot(x, y, xlab='rečenica')
dev.off()
@

Now I am wondering how to correctly specify snippet (or global settings, for example, with opts_chunk $ set ()) to see the Uncode characters that I need. For instance:

<<ParadigmFig, fig.height=7, fig.width=15, out.width='1\\textwidth'>>=
plot(x, y, xlab='rečenica')
@

Currently, if I use the second, correct option, I get points instead of spec. character.

+4
source share
1 answer

Try creating this drawing with cairo_pdf().

cairo_pdf('test.pdf', family="Helvetica")
plot(1:10, (1:10)^2, xlab=enc2utf8("ąśćźół"))
dev.off()

, family, ( ). OS X .

knitr, . :

library("knitr")
library("tikzDevice")
opts_chunk$set(
   dev='cairo_pdf',
   dev.args=list(family='DejaVu Sans')
   #out.width='5in', 
   #fig.width=5,
   #fig.height=5/sqrt(2),
   #fig.path='figures-knitr/',
   #fig.align='center',
)

( , , - ). chunk .

.Rnw, ( , Linux) :

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[T1,plmath]{polski}
\usepackage[polish]{babel}

\begin{document}

<<cache=FALSE,echo=FALSE,message=FALSE>>=
options(Encoding="UTF-8")
library("knitr")
library("tikzDevice")
opts_chunk$set(
   dev='cairo_pdf',
   dev.args=list(family='Helvetica')
   #out.width='5in', 
   #fig.width=5,
   #fig.height=5/sqrt(2),
   #fig.path='figures-knitr/',
   #fig.align='center',
)
@

<<>>=
plot(1:10, (1:10)^2, xlab="ąśćźół")
@

\end{document}
+2

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


All Articles