Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I do

ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}], 
 PlotStyle -> PointSize[0.02], 
 Epilog -> 
  Style[Text["b: 5%", Scaled[{0.05, 0.05}], {-1, -1}], 
   FontFamily -> "Helvetica"]]

enter image description here

the percent symbol is shown in the wrong typeface, possibly Times. How can I make it display in the correct face?

share|improve this question
1  
Unfortunately, the only way in which I've ever been able to achieve fully consistent typesetting in Mathematica is to use Times font for everything, or to use external $\LaTeX$ processing. Since the default notebook style has changed to Arial in version 9, many inconsistencies like the one you observe are revealed, and I haven't found a good answer how to fix that while using sans serif fonts. –  Jens Jan 10 '13 at 18:38
add comment

3 Answers 3

up vote 10 down vote accepted

Mathematica automatically replaces many operators found in normal text fonts with operators in a Mathematica font. You can change that behavior as follows:

SetOptions[EvaluationNotebook[], PrivateFontOptions -> {"OperatorSubstitution" -> False}]

Test:

ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}], 
   PlotStyle -> PointSize[0.02], 
   Epilog -> Style[Text["b: 5%", Scaled[{0.05, 0.05}], {-1, -1}], 
                    FontFamily -> "GiddyupStd", 20]
]

Mathematica graphics

share|improve this answer
    
+1 Sjoerd! Mooi. –  Rolf Mertig Jan 10 '13 at 20:37
    
In the notebook, this works indeed (+1), but when you export it to PDF the problem re-appears. Also, it re-appears of course when you copy the graphic to another notebook. So the substitution doesn't appear to get turned off for good, unfortunately. –  Jens Jan 10 '13 at 20:48
1  
@Jens The OP says nothing about EPS. The question is: "How can I make it display in the correct face?". Other Notebooks can be served by replacing EvaluationNotebook[] with $FrontEnd. –  Sjoerd C. de Vries Jan 10 '13 at 20:50
    
@Jens, you can set this globally using SetOptions[Graphics,BaseStyle -> {PrivateFontOptions -> {"OperatorSubstitution" -> False}} ] or SetOptions[$FrontEnd, PrivateFontOptions -> {"OperatorSubstitution" -> False}] –  Verbeia Jan 10 '13 at 22:08
    
@verbeia Uhm... The latter part is already in my previous comment –  Sjoerd C. de Vries Jan 10 '13 at 22:11
show 4 more comments

It will take some finger-painting to cobble together a combination of different fonts that look right together and have a percent sign that looks like sans-serif . Not a real solution, but maybe this will look more consistent to you:

Style["label text: 5 %", FontFamily -> "Monaco"]

enter image description here

Or you could do this:

Row[{Style["label text: 5", FontFamily -> "Helvetica"], 
  Style["%", FontFamily -> "Monaco"]}]

enter image description here

Edit

Looking at the exported PDF file containing Style[5 %, FontFamily -> "Helvetica"] in a text editor, there is in fact a font descriptor for the Mathematica1 font embedded where the percent sign should be rendered. One can manually delete the descriptors containing Mathematica1 to get a PDF that displays the % correctly in an external PDF viewer. However, I'm not sure if this can be done automatically in a sufficiently robust way. And the problem remains that such modified PDF files can't be directly re-imported into Mathematica unless you first outline the fonts as described here.

share|improve this answer
add comment

An addition to Sjoerd's answer.

Style can be used for setting global FrontEnd or Notebook preferences locally. So it is better to move the PrivateFontOptions -> {"OperatorSubstitution" -> False} option directly in the Style expression rather than changing global preferences. It also solves the problems with Export and copying the graphics between notebooks:

ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}], 
 PlotStyle -> PointSize[0.02], 
 Epilog -> 
  Style[Text["b: 5%", Scaled[{0.05, 0.05}], {-1, -1}], 
   FontFamily -> "Helvetica", 20, 
   PrivateFontOptions -> {"OperatorSubstitution" -> False}]]

Export["test.pdf", %]

screenshot

share|improve this answer
    
I think I knew this, but I had forgotten. Thanks for the reminder. +1 –  Mr.Wizard Jan 11 '13 at 9:19
    
+1 I like this much better than the global $FrontEnd setting because the latter severely messes up the display of things like MatrixForm[...] where custom parentheses "operators" are needed. –  Jens Jan 11 '13 at 19:57
    
Unfortunately, even with your method the formatting is wrong if your plot also includes a matrix with expanded parentheses. The ( and ) surrounding a matrix will simply become fixed height symbols because turning off the operator substitution prevents Mathematica from building them out of extensible parts. –  Jens Jan 11 '13 at 20:25
    
@Jens You can always set local Style for single elements and combine them with Row or use low-level constructs like StyleBox and RowBox. For example, MatrixForm[{{Row[{1,Style["%",PrivateFontOptions->{"OperatorSubstitution"->Fals‌​e}]},BaseStyle->FontFamily->"Helvetica"],2},{3,4}}]. –  Alexey Popkov Jan 11 '13 at 20:35
    
@AlexeyPopkov Sure - but then you're back to what I called "finger painting" in my answer... but at least you're getting nice looking output with your approach. –  Jens Jan 11 '13 at 20:47
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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