# Using unicode to input symbols in math mode with unicode-math

I want to input a lambda with a bar (ƛ) with font STIX Two Math in math mode. I've checked in the unicode table that it had a code U+019B, and I'm sure STIX Two Math contains this character. I've tried

\documentclass{article}
\usepackage{amsmath,unicode-math}
\setmathfont{STIX Two Math}
\begin{document}
$\symbol{"019B}$, $ƛ$
\end{document}


Both of them didn't output anything. My question is how can I type it in math mode?

• It's not clear to me why you're trying to use math mode to typeset the symbol. According to FontForge, the character in question is labelled "Latin small letter lambda with stroke". The following test program -- observe that it also loads STIX Two Text via \setmainfont -- manages to typeset the letter in question just fine: \documentclass{article} \usepackage{amsmath,unicode-math} \setmainfont{STIX Two Text} \setmathfont{STIX Two Math} \begin{document} \symbol{411} $\text{\symbol{411}}$ \end{document}. Please clarify what it is that you're trying to achieve.
– Mico
Feb 10, 2021 at 6:56
• @Mico While there is no explicit mathematical version of the symbol in Unicode, it's standard notation in Physics for some weird quantity. Feb 10, 2021 at 7:10
• @MarcelKrüger - Many thanks for this explanation. I learned something that was completely new to me.
– Mico
Feb 10, 2021 at 7:22

By default unicode-math does not assign a mathematical definition or ƛ, but yu can give it a mathcode yourself:

You have to decide which class, family and codepoint it should have. Since our font is Unicode encoded, the codepoint is 0x019B. Since ƛ behaves like a greek letter, we can treat is similar to other greek letters and assign it class 7 (variable ordinary) in the "operators" family:

\Umathcode ƛ 7 0 "019B


\documentclass{article}
\usepackage{amsmath,unicode-math}
\setmathfont{STIX Two Math}
\Umathcode ƛ 7 \symoperators "019B
\begin{document}
$\symbol{"019B}$, $ƛ$
\end{document}


which works correctly:

You can enter it as a text-mode command within \text or \textnormal. The Unicode character is not defined for math mode by default, but you can set it active yourself with newunicodechar.

\documentclass{article}
\tracinglostchars=2
\usepackage{amsmath,unicode-math}
\usepackage{newunicodechar}

\newfontface\symbolfont{STIX Two Math}
\setmathfont{STIX Two Math}

\newcommand\textlambdabar{{\symbolfont\symbol{"019B}}}
\newunicodechar{^^^^019b}{%
\ifmmode\mathalpha{\textnormal{\textlambdabar}}%
\else\textlambdabar%
\fi}

\begin{document}
$^^^^019b$, $ƛ$
\end{document}