1

I'm trying to use CMU Serif Upright Italic for some upright symbols in a document processed with XeLaTeX but am geting error "The font CMU Serif Upright Italic" can not be found."

Is this font not part of TeXLive? And if not, where does one get it?

\documentclass{article}

\usepackage{fontspec} \usepackage{polyglossia} \usepackage[math-style=ISO]{unicode-math} \setdefaultlanguage[variant=american]{english} \setotherlanguages{french,german,polish,russian} %% Choose Latin Modern... \defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX} \setmainfont{Latin Modern Roman}[Scale=1.0] \setmathfont{Latin Modern Math} \setmathfont{CMU Serif Upright Italic}[range=up]

\newcommand\upi{\symup{i}} \newcommand\upe{\symup{e}} \newcommand{\uppi}{\symup{\pi}}

\begin{document}

$\upe^{\uppi \upi} = - 1$ \end{document}

murray
  • 7,944
  • The fonts shipped with your tex distribution can be found in usr/local/texlive/2021/texmf-dist/fonts on Mac OS. Try to figure out from the filename the font you are willing to type set with. Maybe you have it may be not, so check for it there. – tush Nov 05 '21 at 20:32
  • 1
    https://tex.stackexchange.com/questions/619573/problem-setting-a-main-font/619577#619577 – David Carlisle Nov 05 '21 at 21:31
  • I have the full TeXLive 2021 installed. Where in usr/local/texlive/2021/texmf-dist/fonts should I look: type1, truetype, opentype, ... ?? And still the question remains as how to form the corect Name for the argument to \setmathfont. – murray Nov 05 '21 at 21:32
  • @murray Just use LuaLaTeX and the whole issue magically disappears... (Also LuaLaTeX will print the paths for all used fonts in the end, so there you can see which name you need for XeLaTeX) – Marcel Krüger Nov 05 '21 at 21:34
  • @DavidCarlisle: I'm working in macOS. Does running fc-cache -f interfere with my local texmf tree, which is in /Users/me/Library/texmf, and normal updating of things when I run the gui TeXLive Utility app? – murray Nov 05 '21 at 21:35
  • @murray No, it doesn't. You might want to run fc-cache again after installing TeX Live updates though to pick up new fonts. – Marcel Krüger Nov 05 '21 at 21:40
  • @MarcelKrüger: I need to use XeLaTeX since I'm using a xelatexmk engine in TeXShop app that automatically takes care of multiple runs of latex, biber, makeindex, etc. – murray Nov 05 '21 at 21:41
  • @murray I'm not a Mac user, but I would expect lualatexmk to be available too. (At least under Linux and Windows latexmk has an option to use LuaTeX) – Marcel Krüger Nov 05 '21 at 21:48
  • @DavidCarlisle: please see the comment I added to your answer https://tex.stackexchange.com/a/619577/13492 . – murray Nov 06 '21 at 01:10
  • By the way, it looks like you’ve seen one of my examples. unicode-math already defines \uppi for you, so I only needed to define it in legacy mode. If you want to redefine unic0de-math symbols, you have to do that inside \AtBeginDocument{\DeclareRobustCommand\uppi{...}}, since the package puts its own definitions last. This is so it doesn’t break if a document loads legacy 8-bit math packages too. – Davislor Nov 06 '21 at 04:53
  • Here, though, you should just be able to take out the definition of \uppi. Or not; it should still work as is. – Davislor Nov 06 '21 at 04:55
  • Redundancy of my \newcommand{\uppi} noted! – murray Nov 06 '21 at 15:17

1 Answers1

1

If you’re not sure where a file is installed, start by running fc-match "CMU Serif Upright Italic" to replicate XeLaTeX’s font search, and luaotfload-tool --find="CMU Serif Upright Italic" to replicate LuaLaTeX’s. I suspect the latter will work, but if it doesn’t, the next thing to try is kpsewhich cmunui.otf. If that doesn’t find it, make sure the cm-unicode TeX Live or MikTeX package is installed. In particular, looking for a font with \setmathfont is often not enough to alert MikTeX that it should install a package.

This problem is often caused on Linux by the system font database not knowing to index your custom TeX Live directory for fonts. The file you need to enable this on Debian or Ubuntu is included with the TeX Live distribution, but you have to install it to the right system directory yourself.

kpsewhich texlive-fontconfig.conf

to see if you have the file, and then

sudo cp $(kpsewhich texlive-fontconfig.conf) /etc/fonts/conf.d/09-texlive.conf

to install it in the system configuration directory with a reasonable priority. I’ve additionally created another file on my own box for the fonts in my texmf-local directory with the same format, but you have the option to install OpenType fonts to /usr/local/share/fonts/ or ~/.fonts/ instead of TEXMFLOCAL.

Then run

fc-cache -f -s -v

to update the font caches.

You can instead use LuaLaTeX, which should work out of the box.

Finally, loading the file by its filename should still work even if XeTeX does not have its display name indexed:

\setmathfont{cmunui.otf}[range=up,
                         Scale=MatchLowercase]
Davislor
  • 44,045
  • I am using macOS, not LInux. macOS/MacTeX users inform me that fc-cache won't do what's needed but merely populate the X11 cache for X11 use. – murray Nov 06 '21 at 15:06
  • File cmunui.otf is where it should be (/usr/local/texlive/2021/texmf-dist/fonts/opentype/public/cm-unicode/cmunui.otf). I added the file to Font Book and now it's accessible using XeLaTeX. In any case, loading the font by name cmunui.otf certainly works with XeLaTeX. So I'll gladly accept the answer even though te fc-cache command seems irrelevant for the macOS/MacTeX environment. – murray Nov 06 '21 at 15:16