Closed jr1234567 closed 5 years ago
Hey my friend :)
You are not alone with this problem. I just issued a bug report regarding the same issue. On my side german umlauts are responsible for the problem.
However there is a workaround. You can use the indirect latex notation for accented characters like
tikz(standAlone = TRUE)
ggplot(df, aes(x=x, y=y))+geom_point() +xlab("\\'{e}")
dev.off()
This is not a permanent solution but it may help as long as the bug isn't wiped out.
It would be nice if it could be fixed as it precludes using ggplot2 with tikzDevice
Thanks. Can you please share the output of tikzTest()
?
Active compiler: /usr/local/bin/pdflatex pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017) kpathsea version 6.2.3
Measuring dimensions of: A Running command: '/usr/local/bin/pdflatex' -interaction=batchmode -halt-on-error -output-directory '/tmp/Rtmp3xtfKd/tikzDevice7ca7644114a1' '/tmp/Rtmp3xtfKd/tikzDevice7ca7644114a1/tikzStringWidthCalc.tex' This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode [1] 7.49817
I have the same problem with polish accented characters. Output of tikzTest('ą')
Active compiler:
/usr/bin/xelatex
XeTeX 3.14159265-2.6-0.99998 (TeX Live 2017/Arch Linux)
kpathsea version 6.2.3
Measuring dimensions of: ą
Running command: '/usr/bin/xelatex' -interaction=batchmode -halt-on-error -output-director
y '/tmp/RtmpUnF6PW/tikzDevice6ed2109d154d' '/tmp/RtmpUnF6PW/tikzDevice6ed2109d154d/tikzStr
ingWidthCalc.tex'
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/Arch Linux) (preloaded format
=xelatex)
restricted \write18 enabled.
entering extended mode
NULL
Warning message:
In getMetricsFromLatex(TeXMetrics, verbose = TRUE, diagnose = diagnose) :
XeLaTeX was unable to calculate metrics for some characters:
Missing character: There is no ą in font ec-lmr12!
@Ashymad: "Missing character: There is no ą in font ec-lmr12!" is the crucial message, are you sure this particular character can be rendered in a .tex document?
@jr1234567: Measurement looks ok, I really have no idea what's going on.
After some digging i found out that, as per this answer on SE, fontenc
package should not be used with unicode-capable engines, however by default tikzUnicodeMetricPackages
does include it. If I remove it tikzTest('ą') works:
Active compiler:
/usr/bin/xelatex
XeTeX 3.14159265-2.6-0.99998 (TeX Live 2017/Arch Linux)
kpathsea version 6.2.3
Measuring dimensions of: ą
Running command: '/usr/bin/xelatex' -interaction=batchmode -halt-on-error -output-directory '/
tmp/Rtmpde1LkS/tikzDevice176a43a9a6d5' '/tmp/Rtmpde1LkS/tikzDevice176a43a9a6d5/tikzStringWidth
Calc.tex'
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/Arch Linux) (preloaded format=xel
atex)
restricted \write18 enabled.
entering extended mode
[1] 6.75598
So, I suppose this should be changed. Sadly this does not help with the issue and compiling plots still hangs indefinitely :(
Would you suggest changing the default set of packages for XeTeX?
Some plots do take a very long time to render the first time. Can you share a reproducible example?
library(ggplot2)
library(tikzDevice)
dta = list()
dta$x = 0:200*pi/100
dta$y = sin(dta$x)
tikz()
ggplot(as.data.frame(dta), aes(x,y)) + geom_line() + xlab('ą')
If I change ą
to a
it compiles quickly.
Curiously the problem is specific to using ggplot2, as in the following identical graphs (base, lattice and ggplot2)), only ggplot2 graphs hangs, whereas base graphics and lattice graphics works fine. ####################### library(tikzDevice) library(lattice) options(tikzDefaultEngine = "luatex")
tikz(standAlone = TRUE) xyplot(mpg ~ disp, mtcars, main="é") ##works fine dev.off()
tikz(standAlone = TRUE) plot(mpg ~ disp, mtcars, main="é") ##works fine dev.off()
tikz(standAlone = TRUE) ggplot2::qplot(disp, mpg, data = mtcars, main="é") ## does not end dev.off()
Although I haven't done extensive testing, it seems that this problem is fixed in ggplot2 3.0.0. I am able to use polish characters in labels and everything works as expected.
I can confirm that following works for me:
dta = list()
dta$x = 0:200*pi/100
dta$y = sin(dta$x)
tikzDevice::tikz(file = "umlaut.tex", standAlone = TRUE, engine = "xetex")
ggplot2::ggplot(as.data.frame(dta), ggplot2::aes(x,y)) +
ggplot2::geom_line() +
ggplot2::xlab("ąćęłńóśźż")
dev.off()
Compiling the resulting umlaut.tex
with XeLaTeX gives me this.
Closing this issue since it appears to be resolved. Please feel free, if this is still an issue, to leave a comment requesting this issue be reopened.
Using an accented "é" in the following ggplot2 graph makes R hangs when using tikzdevice, whereas it works using simple pdf device. (This is on Linux Mint. All packages updated.)
####### library(tikzDevice) library(ggplot2)
options(tikzDefaultEngine = "luatex")
tikzLualatexPackages =c( "\usepackage{tikz}\n", "\usepackage[active,tightpage,psfixbb]{preview}\n", "\usepackage{fontspec,xunicode}\n", "\PreviewEnvironment{pgfpicture}\n", "\setlength\PreviewBorder{0pt}\n" )
x<- rnorm(10) y<- rnorm(10) df <- data.frame(x=x, y=y)
This example works, without accented glyph
tikz(standAlone = TRUE) ggplot(df, aes(x=x, y=y))+geom_point() +xlab("e") dev.off()
This example, with an "é" in a x-axis label, label hangs and never completes
tikz(standAlone = TRUE) ggplot(df, aes(x=x, y=y))+geom_point() +xlab("é") dev.off()
Working OK when using pdf device
pdf() ggplot(df, aes(x=x, y=y))+geom_point() +xlab("é") dev.off()
Jacques