13

I have a document like this, but when I render it by invoking xelatex on it, the π character is displayed as a blank space:

\documentclass[13pt,oneside]{scrbook}
\usepackage{fontspec} % the problem remains, whether I use this or not

\begin{document}
\mainmatter
This is a paragraph with a PI (π) in it.
\end{document}

The relevant error message in the output seems to be:

LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <13> not available
(Font)              size <12> substituted on input line 1368.

I can work around this with the newunicode char package, but this is somewhat kludgy (I have to define every unicode character I want to use), and does not play well with fonts (when such characters appear in monospaced text, they will be typeset with the sans font because they are seen as math).

The problem seems to be that the font I'm using does not define the given character. Is it possible to have LaTeX automatically fall back to another, richer font in such a situation? Which font is known to cover a lot of characters? (I need some Greek letters, math symbols, arrows, and quote characters.) How about monospaced fonts?

  • You need the ucharclasses package. – Jonathan Protzenko Sep 17 '14 at 9:30
  • 1
    The warning has nothing to do with the missing character and is innocuous; the relevant warning is Missing character: There is no π in font [lmroman12-regular]:mapping=tex-text! which explains the problem: the Latin Modern fonts don't support Greek. – egreg Sep 17 '14 at 9:32
8

Edit Here's egreg's (better) solution, for future reference, since this answer was accepted.

\RequirePackage{fix-cm}
\documentclass[fontsize=13pt,oneside]{scrbook}
\usepackage{fontspec}
\usepackage[Latin,Greek]{ucharclasses}

\newfontfamily\substitutefont{CMU Serif}
\setTransitionsForGreek{\begingroup\substitutefont}{\endgroup}

\begin{document}
\mainmatter
This is a paragraph with a PI (π) in it.
\end{document}

Here's the original message that I wrote, which does not use the \newfontfamily command.

Using ucharclasses:

\usepackage{ucharclasses}
  \setTransitionsFor{GreekAndCoptic}{\begingroup\fontspec{DejaVu Sans}[Scale=MatchLowercase]}{\endgroup}

(Of course, change DejaVu Sans to be any font on your system that has the desired characters.)

  • 1
    I wouldn't use \fontspec, but define a font family in the preamble. See github.com/Pomax/ucharclasses/issues/7 – egreg Sep 17 '14 at 9:33
  • If I add this to my test file, xelatex hangs when it tries to compile the file. The last output line is (/usr/share/texmf/tex/latex/tipa/t3cmr.fd), but that doesn't seem to be related the problem. – Marijn Sep 17 '14 at 9:40
  • Right, that's due to the syntax change in fontspec between texlive 2013 and texlive 2014. If you're runnning texlive 2013, you need to swap the arguments or follow egreg's suggestion and define a font family in the preamble. – Jonathan Protzenko Sep 17 '14 at 9:49
  • @JonathanProtzenko I've added a working solution with ucharclasses; if you want to modify your answer with that code, I'll be happy to roll back mine. – egreg Sep 17 '14 at 10:22
  • @egreg done! :) – Jonathan Protzenko Sep 17 '14 at 14:06
11

The warning message you report is irrelevant and innocuous. It would disappear if you had \RequirePackage{fix-cm} before the \documentclass line, but the Greek pi wouldn't appear either. The relevant message is at the end of the .log file:

Missing character: There is no π in font [lmroman12-regular]:mapping=tex-text!

The Latin Modern fonts support only a few Greek letters. You'd be luckier with CMU Serif

\RequirePackage{fix-cm} % remove the spurious warning
\documentclass[fontsize=13pt,oneside]{scrbook}
\usepackage{fontspec}

\setmainfont{CMU Serif}

\begin{document}
\mainmatter
This is a paragraph with a PI (π) in it.
\end{document}

enter image description here

Note: the fact that scrbook allows setting 13pt as base size isn't a sufficient justification for using such a size. It's either too big (for the vast majority) or too small (for visually impaired people).

  • I don't want to change my main font just for a handful of characters, though. So I guess the ucharclasses approach is more appropriate (if I get it to work). – Marijn Sep 17 '14 at 9:59
2

I had same error, but in different envirnonment, caused by this line in Pandoc Markdown with xelatex in background:

$\beta \in (0,1) $

Apperently, Pandoc or xelatex didn't like whitespace as last characted inside equation.

Maybe it will save few hours of anyone coming here, as it is the first link bound to this warning [WARNING] Missing character: There is no 𝛽 in font [lmroman12-regular]:mapping =tex-text!


EDIT (additional testing)

The following code section is not parsable, but I felt it's better to have a direct comparison of pandoc input and tex output (as the middle step between md and pdf) to get an idea of what works and what doesn't.

pandoc                   -->   LaTeX
------                         -----

Some normal text.        -->   Some normal text.

$\beta \in (0,1) $       -->   \$\beta \in (0,1) \$

$\beta \in (0,1)$        -->   \(\beta \in (0,1)\)

$$\beta \in (0,1) $$     -->   \[\beta \in (0,1) \]

$$\beta \in (0,1)$$      -->   \[\beta \in (0,1)\]

$\beta \in (0,1)$$       -->   \(\beta \in (0,1)\)\$

$$\beta \in (0,1)$       -->   \$\(\beta \in (0,1)\)

$ \beta \in (0,1)$       -->   \$ \beta \in (0,1)\$

$$ \beta \in (0,1) $$    -->   \[ \beta \in (0,1) \]

$ \beta \in (0,1)$$      -->   \$ \beta \in (0,1)\$\$

$$ \beta \in (0,1)$      -->   \$\$ \beta \in (0,1)\$

So, essentially, what we see here is that the first line won't work, since pandoc interprets the dollar signs as text dollar signs. In the five other cases, pandoc will bite the bait and pass math mode to TeX. The important part is to snuggle up the dollar signs in inline math. Spaces don't matter in display math, though.

  • TeX doesn't care about whitespace inside math environments and pandoc, afaik, just passes everything inside $...$ to whatever math parser is specified. Also, if you look at the warning message, it's about the greek\beta not being present in latin modern, not about white space. – thymaro Jun 11 '18 at 6:57
  • @thymaro Well, I know that warning was about greek letter. But removing the whitespace has fixed it. My point is that most likely there is some bug in (my version of) Pandoc (or xelatex) which makes it use wrong font when there is whitespace on the end of formula. I couldn't investigate it yet, but I will do later – R2RT Jun 11 '18 at 8:37
  • huh... you're right. pandoc won't accept spaces before closing math with $. I will edit your answer with some tests. – thymaro Jun 11 '18 at 9:23
  • This seems completely unrelated. Since pandoc allows i made $10 and you made $20 and will convert it to i made \$10 and you made \$20 and NOT i made \(10 and you made \)20, it obviously needs to special-case something to guess when you want math mode and when you don't. – Will Robertson Jun 11 '18 at 10:17
  • @WillRobertson It would be "completly unrelated" if warning that brought me here wouldn't be exact same as in original question. And even if it is obvious looking at only this line it is not so clear when you have wall of text with formulas inside and single typo in one of them. Also, this warning does not provide exact line number so pinning it down can take time. It made me try other answers here (which didn't help) before I found out the root cause. – R2RT Jun 11 '18 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.