1

I would like to be able to use a custom TTF (News Gothic) as the main font throughout my document wherever text occurs, and CMU Bright for math. But \text inside math mode should use New Gothic. However, attempting to use News Gothic as the main font unsets CMU as the math font, which you can see in the image below — sin is written in News Gothic, as is the ABC, but x and e^{-x} are in Computer Modern instead of CMU Bright.

Here is a sample document. It was compiled with xelatex, although a luatex-only solution would also be fine; I don't think pdflatex can handle fonts like this, but I'd love to be wrong. Any solution that works is acceptable.

\documentclass{article}

\usepackage{mathtools}
\usepackage{fontspec,unicode-math}

\usepackage{cmbright}
\usepackage[T1]{fontenc}

\setmainfont[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
BoldFont = News Gothic MT Bold,
ItalicFont = News Gothic MT Italic,
BoldItalicFont = News Gothic MT Bold Italic
]
{News Gothic MT}

\setsansfont[
Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
Extension = .ttf,
BoldFont = News Gothic MT Bold,
ItalicFont = News Gothic MT Italic,
BoldItalicFont = News Gothic MT Bold Italic
]
{News Gothic MT}

\begin{document}

\begin{center}
    This is math:
    \begin{align*}
        \int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}
    \end{align*}
\end{center}

\end{document}

Result:

enter image description here

If I remove \setmainfont, then sin becomes Computer Modern as well. If I remove \setsansfont, then the body font and ABC both become CMU Bright (but sin remains News Gothic). But I can't figure out the combination that will result in:

  1. Body font = News Gothic
  2. sin = News Gothic (this is optional; CMU Bright would also be ok)
  3. \text in math mode = News Gothic
  4. Numbers, variables, etc in math mode = CMU Bright
3
  • 3
    don't use \usepackage[T1]{fontenc} with luatex or xetex Feb 1 at 23:29
  • latex warns LaTeX Font Warning: Font shape `TU/cmbr/m/n' undefined (Font) using `TU/lmr/m/n' instead on input line 144. which means there is no Unicode CM Bright so it's going to use Unicode Latin Modern instead. Feb 1 at 23:33
  • 1
    Don't load cmbright if you want to use unicode fonts.
    – cfr
    Feb 2 at 2:34

1 Answer 1

0

You want to use legacy math fonts, so don't load unicode-math. And, of course, don't load fontenc with T1 encoding.

\documentclass{article}

\usepackage{mathtools}
\usepackage{fontspec}
\usepackage{cmbright}

%\usepackage[T1]{fontenc}% <--- don't

\setmainfont{News Gothic MT}[
  Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
  Extension = .ttf,
  ItalicFont = * Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,
]

\setsansfont{News Gothic MT}[
  Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
  Extension = .ttf,
  ItalicFont = * Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,
]

\begin{document}

This is math:
\begin{equation*}
\int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}+123
\end{equation*}

\end{document}

enter image description here

One can get the operator names in News Gothic with a slightly different preamble:

\documentclass{article}

\usepackage{mathtools}
\usepackage{fontspec}
\usepackage{cmbright}

\setmainfont{News Gothic MT}[
  Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
  Extension = .ttf,
  ItalicFont = * Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,
  NFSSFamily = ngmt,
]

\setsansfont{News Gothic MT}[
  Path = /Applications/Microsoft PowerPoint.app/Contents/Resources/DFonts/,
  Extension = .ttf,
  ItalicFont = * Italic,
  BoldFont = * Bold,
  BoldItalicFont = * Bold Italic,
]

\DeclareSymbolFont{operators}{TU}{ngmt}{m}{n}
\SetSymbolFont{operators}{bold}{TU}{ngmt}{b}{n}
\DeclareSymbolFont{cmbroperators}{OT1}{cmbr}{m}{n}

\makeatletter
\AtBeginDocument{\DeclareMathSymbol{\std@equal}{\mathrel}{cmbroperators}{`=}}
\makeatother


\begin{document}

\show\Relbar

This is math:
\begin{equation*}
\int_{-\infty}^\infty \frac{\sin(x)e^{-x}}{x}\quad\textbf{\textit{ABC}}+123
\end{equation*}

$\Longrightarrow\longrightarrow$

\end{document}

enter image description here

4
  • I'll just note that this leads to sin being CMU Bright, but since that was optional, this does appear to be the correct answer. Feb 2 at 15:16
  • @BallpointBen Added support for the operator names in News Gothic.
    – egreg
    Feb 2 at 15:41
  • Thanks. This broke \Longrightarrow for me, since the left side is made up of an equals sign, which changes fonts. Feb 2 at 15:59
  • 1
    @BallpointBen Fixed.
    – egreg
    Feb 2 at 16:35

You must log in to answer this question.

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