6

I like the mathdesign package, but would like to use Myriad Pro section headings in LuaLaTeX. Is this possible, or do I have to convert an OTF font to T1? (My ignorance of font issues in *TeX is boundless.) The \setsansfont command and mathdesign packages seem not to work together, though there is no mention of fontspec within mathdesign. Here's a MWE that shows what doesn't work when running through LuaLaTeX.

 \documentclass{article}
 \usepackage [english] {babel}
 \usepackage {blindtext}
 \usepackage {titlesec}
 \usepackage {etoolbox}
 \usepackage {ifluatex}
 \titleformat{\section}{\Large\sffamily\bfseries}{\thesection}{1em}{}

 \ifbool{luatex} { 
   \usepackage {fontspec}
   \setsansfont [Ligatures=TeX,Scale=MatchLowercase] {Myriad Pro}
   \usepackage [charter] {mathdesign}
 }{\usepackage [T1] {fontenc}
   \usepackage [charter] {mathdesign}
   \renewcommand*{\sfdefault}{phv} % Adobe Helvetica 
 }

 \begin{document}
 \section {A section}
 \blindmathpaper
 \end{document}

The beginning of that document looks as follows (note the lack of sans serif section heading) fontspec first

If I load the mathdesign package before fontspec I get the correct section heading font, but the rmdefault font switches to CM.

Interestingly, the math font remains Charter in all cases.

enter image description here

12
  • It's not something fontspec can do. You need to redefine the heading commands and letting the redefined commands set the headings in sans serif with fontspec. To redefine the headers you can use a package but it may depend on which headers you want to redefine.
    – user10274
    Commented Dec 11, 2012 at 8:20
  • How about loading \usepackage [charter] {mathdesign} before fontspec in your preamble? I don't have myriad pro but it should work in other otf fonts.
    – hpesoj626
    Commented Dec 11, 2012 at 8:24
  • @MarcvanDongen, I am redefining the section heading with the \titleformat command (from the titlesec package) to set them in sans serif. At least that's what the intent is, and it works right up until (and unless) I use fontspec and mathdesign together.
    – GTK
    Commented Dec 11, 2012 at 8:29
  • 1
    you can get the Charter ITC as TrueType from font-zone.com/download.php?fid=953. Then you can define the font with \setmainfont as usual
    – user2478
    Commented Dec 11, 2012 at 8:39
  • 2
    @GTK It's another example that shows that using different LaTeX engines may cause problems. This is exactly the reason why I always recommend to my students they should use one and only one engine. I always recommend they should use pdflatex (no offence to implementors of other engines).
    – user10274
    Commented Dec 11, 2012 at 8:48

1 Answer 1

4

You have to set also the correct font encoding in order to choose the correct font (for the LuaLaTeX version):

\titleformat{\section}
  {\fontencoding{EU2}\Large\sffamily\bfseries}
  {\thesection}
  {1em}
  {}

enter image description here

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage{ifluatex}

\ifluatex
  \usepackage {fontspec}
  \setsansfont [Ligatures=TeX,Scale=MatchLowercase] {Myriad Pro}
  \usepackage[T1]{fontenc}
  \usepackage[charter]{mathdesign}
  \titleformat{\section}
    {\fontencoding{EU2}\Large\sffamily\bfseries}
    {\thesection}
    {1em}
    {}
\else
  \usepackage[T1]{fontenc}
  \usepackage[charter]{mathdesign}
  \renewcommand*{\sfdefault}{phv} % Adobe Helvetica
  \titleformat{\section}
    {\Large\sffamily\bfseries}
    {\thesection}
    {1em}
    {}
\fi

\begin{document}

\section {A section}
\blindmathpaper
\end{document}

Just for completeness, here is a LuaTeX only version with the fonts Herbert pointed at in a comment:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{titlesec}

\usepackage[charter]{mathdesign}
\usepackage[no-math]{fontspec}
\setmainfont[Ligatures=TeX,
             BoldFont={CharterITC Bold BT},
             BoldItalicFont={CharterITC Bold Italic BT},
            ]{CharterITC BT}
\setsansfont[Ligatures=TeX,Scale=MatchLowercase]{Myriad Pro}

\titleformat{\section}{\Large\sffamily\bfseries}{\thesection}{1em}{}

\begin{document}

\textbf{Abc}

\section {A section}
\blindmathpaper
\end{document}

Your way to specify the fonts may need to be different (here I put the fonts in the system fonts). Notice that one has to specify by hand the bold and bold italic versions, because the defaults are "Black", which fontspec doesn't understand. I added a boldface word just as an example.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .