[Tex/LaTex] How to use Scandinavian characters in LaTeX math mode

accentsmath-modescandinavian-lettersunicode

Here's a MWE/MNWE:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{icomma}
\begin{document}
Regular text with Scandinavian characters (å, ä, ö, ø, æ) works fine. 
Using Å as unit (ångström) fails in math mode: $ 3,0\,\mathrm{Å} $ -- 
there isn't even a regular ''add a circle above'' diacritic macro afaik 
-- and also using å as a variable fails for example in $ (å-1)^2 $ and 
$ \dfrac{\mathrm{d}å(t)}{\mathrm{d}t} $ , but I \emph{really} need it 
to work. \end{document}

how Scandinavian characters fail to render

Without the T1 option, I get the "Please use \mathaccent" error. With these settings, it compiles and renders although I do get a mention of ''Command \r invalid in math mode'' in the log. In the result, the characters simply aren't drawn.

I am not looking for specific macros to draw diacritics. I am not meant to type all those characters in \text mode as they are not text in this case but actual variables which can therefore still be differentiated and whatnot. \mathit does not work (still no render) nor is it acceptable.

Is this a font-specific problem and the corresponding characters just don't exist in the font's math version? If that is the case, which fonts include math versions of the Scandics? I've tried at least kpfonts and fourier.

Is the only way out to move on from LaTeX? (This would be fine if it was just for me but my coworkers have to be able to work with these files as well.)

Best Answer

There is a regular command for a circle above a letter: \mathring.

For the angstrom unit, use siunitx, which avoids the need for icomma.

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{siunitx}

\sisetup{output-decimal-marker={,}}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\begin{document}

Regular text with Scandinavian characters (å, ä, ö, ø, æ) works fine. 
Using Å as unit (ångström) fails in math mode: $\SI{3,0}{\angstrom}$ -- 
there isn't even a regular ``add a circle above'' diacritic macro afaik 
-- and also using å as a variable fails for example in $ (\mathring{a}-1)^2 $ and 
$ \dfrac{\diff\mathring{a}(t)}{\diff t}$, but I \emph{really} need it 
to work.

\end{document}

enter image description here

You may input å in math mode for \mathring{a}, but I can't recommend it; you don't type ü for the second derivative, do you?

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{newunicodechar}

\sisetup{output-decimal-marker={,}}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\newunicodechar{å}{\ifmmode\mathring{a}\else\r{a}\fi}

\begin{document}

Regular text with Scandinavian characters (å, ä, ö, ø, æ) works fine. 
Using Å as unit (ångström) fails in math mode: $\SI{3,0}{\angstrom}$ -- 
there isn't even a regular ``add a circle above'' diacritic macro afaik 
-- and also using å as a variable fails for example in $ (å-1)^2 $ and 
$ \dfrac{\diff å(t)}{\diff t}$, but I \emph{really} need it 
to work.

\end{document}
Related Question