2

I want to replace the letter "f" from a certain font family with "f" from another font family. My current attempt at doing so is the following.

\documentclass{minimal}

\usepackage{graphicx} \usepackage{physics} \usepackage{mathspec} \defaultfontfeatures{Mapping=tex-text,} \setmathsfont(Digits){Old Standard} \setmathsfont(Latin)[Uppercase=Italic,Lowercase=Italic]{Old Standard}

\makeatletter \DeclareSymbolFont{alphabets}{\encodingdefault}{pmn}{m}{it} \SetSymbolFont{alphabets}{normal}{\encodingdefault}{pmn}{m}{it} \SetSymbolFont{alphabets}{bold}{\encodingdefault}{pmn}{b}{it} \DeclareMathSymbol{f}{\mathalpha}{alphabets}{"66} \makeatother

\begin{document} Print $f$.

\begin{align*}
    F(x)
         & = \sum_{d\mid n}f(d)
\end{align*}\\[1cm]

\end{document}

However, it does not produce the math/italic version of "f", only a straight text version. How can I make this italic?

Related questions which do not answer this: How to replace a letter? and XeLaTeX: mathtools, unicode-math and \text spoil \mathtt

enter image description here

Masum
  • 1,009

1 Answers1

3

I assume you want Minion Pro. For this to succeed you need to declare a font family and assign it a NFSS name.

\documentclass{article}
\usepackage{amsmath}
%\usepackage{graphicx}
%\usepackage{physics}
\usepackage{mathspec}
\defaultfontfeatures{Mapping=tex-text,}
\setmathsfont(Digits){Old Standard}
\setmathsfont(Latin)[Uppercase=Italic,Lowercase=Italic]{Old Standard}
\newfontfamily{\minion}{Minion Pro}[NFSSFamily=pmn]

\DeclareSymbolFont{alphabets}{\encodingdefault}{pmn}{m}{it} \SetSymbolFont{alphabets}{bold}{T1}{pmn}{b}{it} \DeclareMathSymbol{f}{\mathalpha}{alphabets}{"66}

\begin{document}

Print $f$. \begin{equation} F(x) = \sum_{d\mid n}"f(d) \end{equation}

\end{document}

enter image description here

Without this approach you got warnings about not existing fonts that are substitute with others.

egreg
  • 1,121,712