I wrote the following commands in R to generate a picture. However, the y-axis label is missing as the picture below shows. There seems to be some error in ylab="$\\ln \\mathbb V \\widehat\\sigma_{MOP, \\alpha}$". However, I could not figure out why. Could anyone help me, please? Thank you!

Error: TeX was unable to calculate metrics for the following string or character: $\ln \mathbb{V} \widehat{\sigma}_{MOP, \alpha}$

var.asym <- function(shape, alpha){

tikz("MOPasyvar.tex", width=4, height=3)
par(mar=c(4, 4, 0.5, 0.2))
theta0 <- c(-0.4, 1)
plot(seq(0.001, 0.999, by=0.001), log(var.asym(theta0[1], seq(0.001, 0.999, by=0.001))), type="l", lwd=2, ylim=c(-8, 0),
     xlab="$\\alpha$", ylab="$\\ln \\mathbb V \\widehat\\sigma_{MOP, \\alpha}$")
theta0 <- c(0.4, 1)
lines(seq(0.001, 0.999, by=0.001), log(var.asym(theta0[1], seq(0.001, 0.999, by=0.001))), lty=2, lwd=2)
legend("top", legend=c("$\\xi_0=-0.4$", "$\\xi_0=+0.4$"), lty=c(1, 2), lwd=2, bty="n")

enter image description here

  • Er... what did you write them in exactly? This is not from a .tex file, is it? Also, any error in particular or just some error in general? Please remember that we only know what you tell us right now as our crystal balls are all out for repair in the summer season. – cfr Aug 17 '15 at 2:27
  • Er... Sorry. I do not know what you meant. I wrote the above codes in R. – LaTeXFan Aug 17 '15 at 2:30
  • @cfr Yes, I wrote them in a .tex file as in tikz("MOPasyvar.tex", width=4, height=3). – LaTeXFan Aug 17 '15 at 2:38
  • That is rather important information. I'm glad to see you've edited your question accordingly. (So you presumably did know what I meant.) – cfr Aug 17 '15 at 2:39
  • Probably you are missing packages required for one or more of the symbols you're using. – cfr Aug 17 '15 at 2:40

The problem comes from the fact that you are using \mathbb in your y label, and the mathbb fonts require some math font to be loaded. In this case, amsfonts will do the trick, so you have to tell TikZdevice to load that package. To do that use:

   =c(getOption( "tikzLatexPackages" ),"\\usepackage{amsfonts}"))

You can add as many packages as needed separated by commas (since this is simply a c() function.)

  • What if I need more than one package? Can I simply add their names like "\\usepackage{amsfonts}", "\usepackage{whatever}"? – LaTeXFan Aug 17 '15 at 3:02
  • @LaTeXfan Yes. I've updated the answer. – Alan Munn Aug 17 '15 at 3:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.