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

I want to typeset my bar plots with a sans serif font (using LuaTeX). I tried many options that I found searching the manual and the internet. None of them solved my problem---using different fonts than CM; with CM it works!

The same MWE shows different results in the PDF depending on the engine (PDFTeX vs. LuaTeX).

MWE MinionPro, MyriadPro, pdflatex:

\documentclass{scrartcl}
\usepackage{%
  sansmath%
  ,MinionPro%
  ,MyriadPro%
} 
\usepackage{pgfplots}
\pgfplotsset{%
  /tikz/font=\sansmath\sffamily
}
\usepackage{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  xbar,
  xlabel={a--d},
  symbolic y coords={a,b,c,d},
  ytick=data,
  nodes near coords, nodes near coords align={horizontal},
  ]
  \addplot coordinates {
    (45,a)
    (20,b)
    (1,c)
    (5,d)
    };
\end{axis}
\end{tikzpicture}
\end{document}

Plot: Bar plot, MinionPro, MyriadPro, pdflatex

MWE MinionPro, MyriadPro, lualatex

\documentclass{scrartcl}
\usepackage{%
  sansmath%
} 
\usepackage{fontspec}
\setmainfont[%
  BoldFont={MinionPro-Bold}%
  ,ItalicFont={MinionPro-It}%
  ,BoldItalicFont={MinionPro-BoldIt}%
  ,Numbers=OldStyle%
]{MinionPro-Regular}

\setsansfont[%
  Scale=MatchLowercase%
  ,BoldFont={MyriadPro-Bold}%
  ,ItalicFont={MyriadPro-It}%
  ,BoldItalicFont={MyriadPro-BoldIt}%
  ,Numbers=OldStyle%
]{MyriadPro-Regular}
\setmathsf{MyriadPro-Regular}
\usepackage{pgfplots}
\pgfplotsset{%
  /tikz/font=\sansmath\sffamily
}
\usepackage{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  xbar,
  xlabel={a--d},
  symbolic y coords={a,b,c,d},
  ytick=data,
  nodes near coords, nodes near coords align={horizontal},
  ]
  \addplot coordinates {
    (45,a)
    (20,b)
    (1,c)
    (5,d)
    };
\end{axis}
\end{tikzpicture}
\end{document}

Plot: Bar plot, MinionPro, MyriadPro, lualatex

Here are some of the pgfplotsset options I already tried (and noted down):

\pgfplotsset{%
%  ,tick label style = {font=\sansmath\sffamily}%
%  ,tick style = {font=\sansmath\sffamily}
%  ,every axis label = {font=\sansmath\sffamily}%
%  ,every axis/.style={font=\sansmath\sffamily}%
%  ,xticklabel={$\pgfmathprintnumber{\sansmath\tick}$}%
  ,/tikz/font=\sansmath\sffamily
%  ,legend style = {font=\sansmath\sffamily}%
%  ,label style = {font=\sansmath\sffamily}%
}

Best regards Christoph

share|improve this question
    
Not an answer, but if a deadline is looming could you generate the image in a standalone document, and then include the image for the LuaTeX run? –  cmhughes Nov 25 '12 at 22:14
    
@cmhughes Good idea! But I did not have a working solution for PDFTeX (numerics were printed italic) since sebschub posted his solution. –  typokurz Nov 27 '12 at 15:18
add comment

2 Answers 2

Do you use the MinionPro and MyriadPro versions from FontPro with pdflatex? With these packages, you do not need sansmath, it is already incorporated in MdSymbol which is needed by MyriadPro. The following set-up works with pdflatex:

\documentclass{scrartcl}
\usepackage{MinionPro}
\usepackage[sansmath]{MyriadPro}
\usepackage{pgfplots}
\pgfplotsset{%
  /tikz/font=\mathversion{sans}\sffamily
}
\usepackage{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
  xbar,
  xlabel={a--d},
  symbolic y coords={a,b,c,d},
  ytick=data,
  nodes near coords, nodes near coords align={horizontal},
  ]
  \addplot coordinates {
    (45,a)
    (20,b)
    (1,c)
    (5,d)
    };
\end{axis}
\end{tikzpicture}
\end{document}

This produces

sans serif figure

share|improve this answer
    
No, I use the fonts provided with Adobe Reader with LaTeX support from developer.berlios.de/projects/minionpro. MyriadPro.sty provided by this project does not know the sansmath option. Do your files support the fonts from Adobe Reader? –  typokurz Nov 27 '12 at 15:32
1  
@typokurz My scripts are based on the project you mentioned and work well with any version of the fonts. I don't provide prepared metrics, though, so one has to use the bash scripts to create them. My MinionPro.sty is very similar to the original one, only small bug fixes and extensions. I'm sure, however, that the original MinionPro project doesn't provide any support for Myriad Pro. My MyriadPro support offers features similar to the ones of MinionPro including proper maths support and the functionality to use two different maths fonts in one document (with the setup above). –  sebschub Nov 27 '12 at 16:33
    
Thanks for your answer! But maybe there's somebody else with a solution for LuaTeX? –  typokurz Nov 28 '12 at 18:09
add comment

My problem was solved by Herbert here using the unicode-math package and \setmathfont. Another approach was offered by egreg here by changing the mathcode of the digits.

share|improve this answer
add 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.