35

The main font I use for my LuaLaTeX document lacks bold and italic variants. I'd like to specify a different font for those variants using the fontspec package.

Initially what I had in my preamble was this:

\usepackage{fontspec}
\setmainfont{GFS Elpis}
\setmonofont{Courier}

and in order to use a different font for italics and bold, say Minion Pro, I tried putting the following line in the preamble just after the above shown lines:

\fontspec[BoldFont={Minion Pro}, ItalicFont={Minion Pro}]{GFS Elpis}

Unfortunately it doesn't seem to have any effect. Italics and bold passages in the document remain in upright font.

Could someone please help me with this issue?

2
  • Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you.
    – doncherry
    Commented Oct 16, 2011 at 17:53
  • Thank you for welcoming me to TeX.sx and for the tip. I'll keep it in mind next time.
    – christosc
    Commented Oct 16, 2011 at 19:00

3 Answers 3

46

You need to be specific if you declare the bold/italic/bold italic shapes, because fontspec does not automatically expand the font name:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[
 BoldFont={Minion Pro Bold}, 
 ItalicFont={Minion Pro Italic},
 BoldItalicFont={Minion Pro Bold Italic}
 ]{Linux Libertine O}

\begin{document}
normal \emph{italic}, \textbf{bold} and \textbf{\emph{bold italic}}.
\end{document}

Works fine with Minion/Linux Libertine O.

Sample image with Linux Libertine O and minion

Edit: changed to \setmainfont instead of \fontspec so that there is a correct and good example. Thanks Ulrike for pointing this out.

4
  • Thank you very much for the quick reply! Actually a few moments before I check if anyone had answered my question, I reached the same answer myself by trials. However I'm having another problem now with the text I had put in the header and footer of the pages (with \lhead{...} and \cfoot{...} commands of the fancyhdr package), that happens to be in Greek, and most of the letters there have now gone missing. That seems a different issue, though. Thanks very much again.
    – christosc
    Commented Oct 16, 2011 at 18:49
  • @christosc you're welcome, glad I could help you. Just post another question here and we can look into it.
    – topskip
    Commented Oct 16, 2011 at 19:01
  • how using \textsc ? Commented Mar 3, 2016 at 10:30
  • This allowed me to fix a "font not found" error for TeX Gyre Heros after migrating to MacOS using TeXLive 2022 and XeLaTeX. For reasons I don't understand, I now need to specify otf filenames instead of font names. \setmainfont[ BoldFont={texgyreheros-bold.otf}, ItalicFont={texgyreheros-italic.otf}, BoldItalicFont={texgyreheros-bolditalic.otf} ]{texgyreheros-regular.otf} \setmathfont(Digits,Latin,Greek)[ BoldFont={texgyreheros-bold.otf}, ItalicFont={texgyreheros-italic.otf}, BoldItalicFont={texgyreheros-bolditalic.otf} ]{texgyreheros-regular.otf} Commented Feb 2, 2023 at 16:20
22

Don't use \fontspec. It is a command to change locally to another font and its settings will be lost if you switch fonts. If you want to setup the overall document font you should use the optional argument of \setmainfont.

\documentclass{article}
\usepackage{fontspec}
\setmainfont[ItalicFont=Arial]{Linux Libertine O}
\begin{document}

abc {\itshape abc}
\end{document}
1
  • Thanks very much for the clarification. I think that was the culprit for which I kept having problems with some parts of my document (running headers and footers). Leaving just the \setmainfont[...]{...} as you pointed out, corrected this issue too. Thank you.
    – christosc
    Commented Oct 17, 2011 at 10:51
-1

For me this worked best on Overleaf with XeLaTex compiler and Minion Pro fonts uploaded as .otf files:

\usepackage{fontspec}
\setmainfont{MinionPro-Regular.otf}[
   BoldFont       = MinionPro-Bold.otf,
   ItalicFont     = MinionPro-It.otf,
   BoldItalicFont = MinionPro-BoldIt.otf
]

Note: I have the 4 specified fonts on the top level (so not inside a folder) of my overleaf project.

Source: https://texdoc.org/serve/fontspec/0

You must log in to answer this question.

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