Export pdf format with utf8 symbol

The utf8 symbol in the label does not appear when I save the chart in pdf format. It does not appear when I use the Export button in RStudio, and it does not appear when I include this code in a Sweave document with pdf output. My problem is getting the correct PDF output using Sweave (not knitr). (If I do not find a solution, I will generate it using tikzDevice )

 ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")")) plot(0,0, ylab=ylab) 
+2
r pdf utf-8 sweave graphics
source share
1 answer

EDIT

Next question: a custom graphics device in sweave shows how to integrate it into a custom graphics device.


This seems to look like using CairoPDF() frm the Cairo package using ubuntu14.04, R3.2.1. Stephane's EDIT in the comments: if CairoPDF() doesn't work, then try cairo_pdf() .

Some sweave code (using Rstudio)

 \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} <<Export_plot, echo=FALSE>>= library(Cairo) CairoPDF("test.pdf") par(mar=c(6,6,6,6)) ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")")) plot(0,0, ylab=ylab, cex.lab=2) invisible(dev.off()) @ %Plot \includegraphics[width=6cm]{test.pdf} \end{document} 

This is the pdf output I get (note that resolution is garbage, as I converted it to png via gimp)

enter image description here

+1
source share

All Articles