8

Is there a way to write the literal μ character using the Latin Modern Roman font or another font with the same font aesthetics/characteristics?

The following gets me this error

{C:/Users/Diaa/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map} Missing character: There is no μ (U+03BC) in font LatinModernRoman:mode=node;sc ript=latn;language=dflt;+tlig;family=rm;-liga;-dlig;!

\documentclass{article}

\tracinglostchars=3

\usepackage[english, bidi = basic, layout = lists]{babel}

\usepackage{fontspec}


% Set the main font
\setmainfont[
Ligatures = {NoCommon, NoRare},
Scale = 1.0,
Language = Default
]{Latin Modern Roman}


\babelfont{rm}
[Ligatures = {NoCommon, NoRare}, Scale = 1.0, Language = Default]
{Latin Modern Roman}

\babelfont{sf}
[Ligatures = {NoCommon, NoRare}, Scale = 1.0, Language = Default]
{Latin Modern Sans}

\begin{document}
    
    This is a text with μ
    
\end{document}
4
  • 5
    You've discovered that Latin Modern doesn't have Greek letters :-). I think the NewComputerModern fonts (package fontsetup) might be better.
    – campa
    Nov 10, 2023 at 16:28
  • If this is a symbol, it might be more appropriate to use maths mode. If it is text i.e. you need to include Greek words etc., you should use babel or polyglossia to ensure the text is typeset correctly.
    – cfr
    Nov 10, 2023 at 16:48
  • @campa I would be grateful if you could show me to edit my question to get what I need.
    – Diaa
    Nov 10, 2023 at 22:17
  • 1
    Sorry, I can't really help, I don't use Unicode engines, that's why I posted only a comment.
    – campa
    Nov 10, 2023 at 22:30

3 Answers 3

12

Latin Modern does not have Greek, but it does have micro (U+00B5) which is the most common use of an isolated mu in latin script.

enter image description here

\documentclass{article}

\tracinglostchars=3

\usepackage[english, bidi = basic, layout = lists]{babel}

\usepackage{fontspec}


% Set the main font
\setmainfont[
Ligatures = {NoCommon, NoRare},
Scale = 1.0,
Language = Default
]{Latin Modern Roman}


\babelfont{rm}
[Ligatures = {NoCommon, NoRare}, Scale = 1.0, Language = Default]
{Latin Modern Roman}

\babelfont{sf}
[Ligatures = {NoCommon, NoRare}, Scale = 1.0, Language = Default]
{Latin Modern Sans}

\begin{document}
    
    This is a text with µ
    
\end{document}
3
  • 1
    I am sorry, but what is the difference between your code and mine? :) Or how did you make it work?
    – Diaa
    Nov 10, 2023 at 22:18
  • 3
    @Diaa You used mu U+03BC I used micro U+00B5 Nov 10, 2023 at 22:22
  • 1
    that makes sense now. thanks :)
    – Diaa
    Nov 10, 2023 at 22:25
9

You can use a substitute font just for \mu

\documentclass{article}
\usepackage[english, bidi = basic, layout = lists]{babel}
\usepackage{fontspec}
\usepackage{newunicodechar}

\babelfont{rm}[
  Ligatures = {NoCommon, NoRare},
  Scale = 1.0,
  Language = Default
]{Latin Modern Roman}

\babelfont{sf}[
  Ligatures = {NoCommon, NoRare},
  Scale = 1.0,
  Language = Default
]{Latin Modern Sans}

\newfontfamily{\substituterm}{CMU Serif}
\newfontfamily{\substitutesf}{CMU Sans Serif}

\AddToHook{cmd/rmfamily/before}{\let\substitutemu\substituterm}
\AddToHook{cmd/sffamily/before}{\let\substitutemu\substitutesf}
\AtBeginDocument{\let\substitutemu\substituterm}
\newunicodechar{μ}{{\substitutemu μ}}


\begin{document}

This is a text with μ

\textit{This is a text with μ}

\textbf{This is a text with μ}

\textsf{This is a text with μ}

\textsf{\textit{This is a text with μ}}

\textsf{\textbf{This is a text with μ}}

\end{document}

enter image description here

Using U+00B5 MICRO doesn't seem appealing as it's difficult to imagine a worse rendering of mu as the one for micro in Latin Modern.

2
  • 1
    yes micro in lmodern is a bit odd but not my fault, it's arguably the correct markup for a micro rather than textual greek mu. the question asked for the lmodern aesthetics so you get what you get... Nov 10, 2023 at 17:45
  • 1
    I didn't know that U+00B5 would be that ugly :) and forgot the other alternative unicode characters I can use. Thanks for the complete answer.
    – Diaa
    Nov 10, 2023 at 22:26
8

Egreg shows how to do a font-family substitution due to one character in LaTeX. Just for comparison, how to solve the analogical task in opTeX:

\fontfam[New CM]        % this family is accessible by \NewCM family selector
\fontfam[Latin Modern]  % current family is last loaded family: Latin Modern   

\adef μ{{\NewCM\fontsel \string μ}}  % substitution of μ by \NewCM μ

This is a text with μ

{\it This is a text with μ}

{\bf This is a text with μ}

{\sans\rm This is a text with μ}

{\sans\it This is a text with μ}

{\sans\bf This is a text with μ}

{\sans\bi This is a text with μ}

\bye

mu

It seems easier to map μ (U+03BC) to (μ U+00B5) by \adef μ{µ} (inspired by David's answer) or most easy is to select a font family where the character is provided. For example \fontfam[NewCM] and no Latin Modern.

You must log in to answer this question.

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