upgreek
works fine both with XeLaTeX and LuaLaTeX. Apparently it isn't clear from chemmacros
' documentation though that setting the option greek=upgreek
does not load upgreek
and greek=textgreek
does not load textgreek
! The option exists to prevent chemmacros
from choosing between upgreek
or textgreek
automatically if either of them or both are loaded by the user. Using either option without loading the appropriate package usually throws an error like
! Undefined control sequence.
<argument> \textbeta
l.9 \iupac{\b-carotene}
However, when fontspec
is loaded, too, the code silently fails with Latin Modern. (I should probably add some checking whether the needed packages are loaded.)
\documentclass{article}
\usepackage{fontspec}
\usepackage{upgreek}% needs no be loaded
\usepackage{chemmacros}[2014/01/24]
\usepackage{newunicodechar}
\newunicodechar{β}{\chembeta}
\begin{document}
\iupac{\b-carotene} % works
\iupac{β-carotene} % works
β % works
\chembeta % works
$\beta$ % works fine
\end{document}
In normal text, phi
is only one glyph, and the font makes it upright, bold, italic, bold-italic. In math text, there are a dozen phi
glyphs, and the boldness, italic is part of the glyph itself:
To have upright lower case Greek, use \setmathfont{Asana Math}[math-style=french]
, for example, and use \mitphi
for italic phi.
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[math-style=french,Colour=blue]
\setmathfont{Asana Math}[range={\mitphi},Colour=red]
\setmainfont{Noto Serif}
\begin{document}
abc xyz
$𝛗𝜙𝝋𝞍𝞿
\mupphi
\mupvarphi
\mbfphi
\mbfvarphi
\mitvarphi
\mitphi
\mbfitvarphi
\mbfitphi
\mbfsansvarphi
\mbfsansphi
\mbfitsansvarphi
\mbfitsansphi
$
$\phi \mu \lambda$
\end{document}
Use \AtBeginDocument{\renewcommand\mupphi{\mitphi}}
to redefine upright phi as italic phi.
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[math-style=french,Colour=blue]
\setmathfont{Asana Math}[range={\mitphi},Colour=red]
\setmainfont{Noto Serif}
\AtBeginDocument{\renewcommand\mupphi{\mitphi}}
\begin{document}
phi $\phi$, upright phi (now italic) $ \mupphi$, and the rest $ \mu \lambda$
\end{document}
To do the converse, italic lower case Greek with italic phi redefined as upright phi:
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana Math}[Colour=blue]
\setmathfont{Asana Math}[range={\mupphi},Colour=red]
\setmainfont{Noto Serif}
\AtBeginDocument{\renewcommand\mitphi{\mupphi}}
\begin{document}
phi $\phi$, italic phi (now upright) $ \mitphi$, and the rest $ \mu \lambda$
\end{document}
Or maybe even just use \mupphi
wherever needed.
Best Answer
Don't try this at home...
Mixing fonts in this way is not recommended and is likely to produce results which are significantly suboptimal.
However, if you really must:
Complete code:
Based on egreg's answer to your earlier question. I can't find the code you are using for Times so I've guessed but it shouldn't matter.
[EDITED to simplify thanks to egreg's comment.]