1

I'm using LuaTeX via LyX with OpenType fonts and have some trouble setting the Ångström unit in math mode.

Using this order works, but composes the character instead of using the font's glyph:

$\mathring{\mathrm{A}}$

Using this order, which is effectively what is generated by using the units package, fails:

$\mathrm{\mathring{A}}$

The error message is:

Missing character: There is no (U+0017) in font DejaVuSerif:mode=node;...

This isn't technically wrong, but we've already left the TeX math font and should produce glyphs from the main font. "Latin Capital Letter A with Ring Above" is U+00C5, which the font contains and renders just fine in text mode.

What can I do to achieve this? LyX always decomposes the character Å into \mathring{A} in math blocks, so I can't just input that (which would work, I've tested it). I don't need a general solution, this is the only character where it needs to work. It's also the only use of \mathring, so I'd have no qualms redefing the accent to something else...

Thanks!

5
  • Why not directly use U+00C5?
    – egreg
    Commented Aug 31, 2021 at 14:31
  • Because LyX doesn't let one enter it in math boxes, it always gets decomposed. There is probably a good reason for it...
    – Martok
    Commented Aug 31, 2021 at 14:33
  • 1
    Why would you want to use math mode to begin with? And LyX, but that's another question.
    – egreg
    Commented Aug 31, 2021 at 14:35
  • @egreg Ah, well it's clearly a unit ;)
    – Joseph Wright
    Commented Aug 31, 2021 at 14:38
  • @JosephWright Excactly. Things like $a=\unit[4.1]{\mathring{A}}$, which expands to the narrowed down problem here.
    – Martok
    Commented Aug 31, 2021 at 14:46

2 Answers 2

2

Use \textnormal{Å}.

\documentclass{article}
\usepackage{amsmath}
\usepackage{units}
\usepackage{unicode-math}

\setmainfont{DejaVu Serif}
\setmathfont{TeX Gyre DejaVu Math}

\newcommand{\angstrom}{\textnormal{Å}}

\begin{document}

$a=\unit[1.4]{\angstrom}$

\end{document}

Of course, nowadays siunitx should be preferred to a package that hasn't been maintained for several years.

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{unicode-math}

\setmainfont{DejaVu Serif}
\setmathfont{TeX Gyre DejaVu Math}

\DeclareSIUnit\angstrom{\text{Å}} % angstrom is deprecated

\begin{document}

$a=\qty{1.4}{\angstrom}$

\end{document}

enter image description here

1

Answering my own question. I've been thinking down this line since before asking, but missed that fontspec does its magic AtBeginDocument...

Simply hard-wire \mathring{A} to the character.

\AtBeginDocument{
 \let\@oldmathring\mathring
 \renewcommand{\mathring}[1]{%
  \if\detokenize{A}\detokenize{#1} Å \else \@oldmathring{#1} \fi%
 }
}

Comparision of outputs

This breaks when it isn't used in operator font (cmmi doesn't have nor need the glyph), but that is not a situation I will ever have. U+C5 is always the unit and should never be printed in variable font anyway.

You must log in to answer this question.

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