# Labels strangely rendered in PDF

I'm new to Mathematica so I apologize if this is obvious to answer. Anyway, using the following code (most of it is extraneous, to make the plot look the way I want) I plotted the Morse potential,

V[r_] := Exp[-2 (r - 1)] - 2 Exp[-(r - 1)]
p = Plot[V[r], {r, 0, 5}, Ticks -> {Range[0, 5, .5], Range[-1, 1, .25]},
TicksStyle -> Directive[FontOpacity -> 0, FontSize -> 0],
AxesLabel -> {HoldForm[r], HoldForm[V[r]]},


which yields

Now when I export this as PDF, using

Export["PathToLocation\\morse-potential.pdf", p, "PDF"]


the $V(r)$ label gets scrambled a bit:

I've also tried what would happen if I left out the optional arguments: the ticks are rendered exactly the same way,

What's going on here and how can I avoid it? I'm on Win8 with Mathematica 10.0.1.0 and Adobe Reader 11.0.10.

• what OS? versions? – Nasser Apr 2 '15 at 11:51
• I'm on Win8 with Mathematica 10.0.1.0 and Adobe Reader 11.0.10 – Wouter Apr 2 '15 at 11:54
• did you Export["fig.pdf",%] or save as? If it is the latter, it is a known bug. – chris Apr 2 '15 at 12:01
• It has been a problem in many different ways. If you search for it, it has came up many times. – Chen Stats Yu Apr 2 '15 at 12:01
• On macosX mathematica 10.0.2 it works. – chris Apr 2 '15 at 12:19

This isn't a real solution to the Export As PDF problem but it is a useful workaround in case other workarounds like reverting back to MMA 10.0.1 or using Export instead of Save As don't work for you (as was the case for me since I was already in MMA 10.0.1 and had used Export). You could of course always export as a raster graphics format like JPEG or PNG but you would have to sacrifice quality which I wasn't willing to do.

Instead, you can export as EPS and compile the following TeX-file:

\documentclass{standalone}
\usepackage{graphicx,epstopdf}
\begin{document}
\includegraphics{myGraphics.eps}
\end{document}


This will generate a PDF with your graphics as well as all text (labels, legend) intact. Obviously if the idea is to incorporate the graphics into a TeX-generated PDF file anyway, you can just add the appropriate packages to your preamble and include it directly in your TeX-file.

The reason for the trouble, as I understand it, is that the PDF format will attempt to interpret symbols and work with fonts, while the EPS format will just take your graphics as they are.

• Since you probably need a quick workaround for your project, you can also try generating the labels using LaTeX. I still find it very strange that this happens on your computer and I doubt that this is a general problem that happens with every installation of 10.0.1 on Windows ... – Szabolcs Apr 2 '15 at 13:38
• Thanks for the link! For the project I need this for, I'm quite content to use the workaround in my answer here, since I only need the one figure and I'm not too concerned with font consistency in this case. But I'll definitely have a look at this MaTeX package for future projects! – Wouter Apr 2 '15 at 14:04
• would it not be easier to use epstopdf to convert eps to pdf than having to install Latex and compile a document just to do this conversion? There is also many free online sites that converts eps files to pdf. This is assuming the goal is just to convert eps to pdf. – Nasser Apr 2 '15 at 21:26
• @Nasser Yeah I guess you could just convert eps to pdf without LaTeX as well. :) – Wouter Apr 3 '15 at 11:34

Try to avoid transparent Ticks, or FontSize -> 0, probably this is a problem for PDF. Instead you can define your Ticks directly without Labels, if you want to have them like that.

V[r_] := Exp[-2 (r - 1)] - 2 Exp[-(r - 1)]
p = Plot[V[r], {r, 0, 5},
Ticks -> { {#, ""} & /@ Range[0, 5, .5], {#, ""} & /@
Range[-1, 1, .25]},

AxesLabel -> {"r", "V[r]"},

Export["morse-potential.pdf", p, "PDF", ImageSize -> 500]


Try also to set a fixed ImageSize at least in your Export. I hope this helps, but i could not reproduce this problem on my system.

Hint: Its easier to give the AxesLabels as strings.

EDIT:

maybe this is easier to read and to modify:

Ticks -> {Table[{x,""},{x,0,5,.5}], Table[{y,""},{y,-1,1,.25}]}


EDIT2:

Have you tried changing the FontFamilie?

 SetOptions[Plot, BaseStyle -> {Large, FontFamily -> "Times", Italic}]

• Well the problem persisted if I left out the optional arguments in the Plot command so I don't think the Transparent Ticks or 0 Fontsize are causing problems in this case. Also, giving the labels as strings only made things worse: every symbol is then rendered as one of those "L" looking objects in my examples. This makes me suspect it's a problem with fonts... But thanks for the tip on the Ticks without Labels, that will be most useful :) – Wouter Apr 2 '15 at 13:25
• @Wouter year try to play around with FontFamilies. e.g. SetOptions[Plot, BaseStyle -> {Large, FontFamily -> "Times", Italic}] – sacratus Apr 2 '15 at 13:27
• The Times FontFamily doesn't work either, but I'll keep trying a few others... – Wouter Apr 2 '15 at 13:31
• @Wouter i can only recommend you to contact WRI directly. Make a bugreport on this at: -------service AT wolfram DOT com--------- I recently made a bugreport and got a very nice answer 3 days later. The seem to be happy if users help to improve Mathematica. You should tell them your Mathematica-Version and Operating Sytem, visible by \$Version. You can also attach a notebook to make a clear example. good luck – sacratus Apr 2 '15 at 13:37