1

Code:

% !TeX program = lualatex
\documentclass{article}

\usepackage{lmodern}

\usepackage{fontspec, newunicodechar}
\newfontfamily{\fallbackfont}{DejaVu Sans Mono}[Scale=MatchLowercase]
\DeclareTextFontCommand{\textfallback}{\fallbackfont}
\newunicodechar{✓}{\textfallback{✓}}
\newunicodechar{✗}{\textfallback{✗}}

\usepackage{siunitx}

\begin{document}
\ang{4} ✓ ✗
\end{document}

Output:

Output where the degrees symbol does not work.

Problem:

When I remove \usepackage{lmodern}, all symbols work, but I want the lmodern font. Output where all symbols work.

This part defines fallback characters which are not present in lmodern:

\usepackage{fontspec, newunicodechar}
\newfontfamily{\fallbackfont}{DejaVu Sans Mono}[Scale=MatchLowercase]
\DeclareTextFontCommand{\textfallback}{\fallbackfont}
\newunicodechar{✓}{\textfallback{✓}}
\newunicodechar{✗}{\textfallback{✗}}

When I remove that part, the degree symbol starts working again. Output where only the degree symbol works.

Question:

Why are these two things in conflict? Clearly lmodern is capable of displaying the degree symbol. How can it be fixed?

  • 2
    You do get the Latin Modern font without \usepackage{lmodern} (which should not be loaded with XeLaTeX or LuaLaTeX). – egreg Nov 7 '17 at 18:32
2

Don't load lmodern along with fontspec.

The default font, when fontspec is loaded, is Latin Modern:

\documentclass{article}

\usepackage{fontspec, newunicodechar}

\newfontfamily{\fallbackfont}{DejaVu Sans Mono}[Scale=MatchLowercase]
\DeclareTextFontCommand{\textfallback}{\fallbackfont}

\newunicodechar{✓}{\textfallback{✓}}
\newunicodechar{✗}{\textfallback{✗}}

\usepackage{siunitx}

\begin{document}

\ang{4} ✓ ✗

\fontname\font

\end{document}

enter image description here

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.