2

I'm trying to print the ✔ symbol using XeLaTeX and directly from the code (i.e. putting the symbol into the source code directly and not using some \macro). I have the following MWE:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Lato}

\begin{document}
This is a test: ✔
\end{document}

But it doesnt work:

xelatex test.tex

enter image description here

However, using Libertine font (with \usepackage{libertine}) works OK.

Is there a way to do it?

Thank you very much in advance.

2
  • 1
    looks as if your font doesn't contain the symbol, so you will have to switch to another font for it. Commented Apr 22, 2019 at 10:26
  • 2
    The log file says Missing character: There is no ✔ in font Lato Regular/OT, so you'll have to find a font which contains that glyph. Commented Apr 22, 2019 at 10:26

1 Answer 1

7

The font has no glyph for that character (you can see it from the “missing symbol” glyph or from the message in the log file).

Use a font that provides it. Here I use Libertinus Serif.

\documentclass{article}

\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Lato}
\newfontfamily{\libertinus}{Libertinus Serif} % a font that has ✔
\newfontfamily{\iosevka}{Iosevka}

\newunicodechar{✔}{%
  \begingroup
  \iffontchar\font`✔ \else \libertinus\fi ✔%
  \endgroup
}

\begin{document}

This is a test: ✔

\iosevka

This is a test: ✔

\end{document}

enter image description here

You might want to have the symbol not to change based on the current conditions. Then use

\documentclass{article}

\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Lato}
\newfontface{\libertinus}{Libertinus Serif} % a font that has ✔
\newfontfamily{\iosevka}{Iosevka}

\newunicodechar{✔}{%
  \begingroup
  \normalfont\libertinus ✔%
  \endgroup
}

\begin{document}

This is a test: ✔

\iosevka

This is a test: ✔

\end{document}

enter image description here

I use the Iosevka font just to see the difference in the two situations.

2
  • I would like to use Iosevka just for verbatim with small font size, could you show me how to do that? Thanks in advance! Commented Dec 13, 2020 at 14:37
  • 1
    @SergioAraujo The simplest is to do \setmonofont{Iosevka}[Scale=0.8] (adjust the factor).
    – egreg
    Commented Dec 13, 2020 at 14:44

You must log in to answer this question.

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