# How to use Scandinavian characters in LaTeX math mode?

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}


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.)

• Yes, it's font-specific. Try \usepackage{lmodern}. That works. – TeXnician Nov 17 '17 at 16:07
• Off-topic but ''...'' will give bad results, as you can see, you need to be using ...'' – Au101 Nov 17 '17 at 16:07
• the standard math fonts do not have these characters but you can use \mathring{a} \ddot{a} ø is tricker I suppose either \text{ø} to get it from the text fonts or \empty – David Carlisle Nov 17 '17 at 16:32
• @Au101 Swedish typographic practice uses the “closing style” both before and after. – svenper Nov 17 '17 at 19:50
• @Au101 It's in English for your sake. I'll be mostly typing in Finnish. :) – JoonasD6 Nov 17 '17 at 21:27

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}


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}

• Thanks for the mathringhint; although I doubt I'll ever use it (but you never know). I'm (mostly for didactic reasons) interested in using ≈*anything* as a variable, so my goal is simply to be able to replace English latin alphabet characters with a more wider set as variables, regardless of accents. The ring is not important, the character as a whole is, and I'm typing it directly from the keyboard. (So I completely agree with the "you don't type ü" thing. Didn't even cross my mind. :P) – JoonasD6 Nov 17 '17 at 21:28
• I've yet to be convinced to use siunitx as its syntax is more cumbersome than simply typing the number myself and defining my own unit macro. After defining \newcommand{\unit}[1]{\ensuremath{\,\mathrm{#1}}} I can simply type $3,0\unit{Å}$ which is alot briefer than $\SI{3,0}{\angstrom}$. I don't get the benefits. I would certainly appreciate if someone could elaborate on this, although this is off-topic. I also regularly have the differential operator defined already. – JoonasD6 Nov 17 '17 at 21:32
• @JoonasD6 Suppose your document is to be submitted to a journal which requires a decimal dot, rather than a comma… – egreg Nov 17 '17 at 21:38
• Alright, future-proofing. :) What I'm usually working on has nothing that would be localised elsewhere, but suppose I could just in case at least load the package for a potential document where it would be uncertain what the specific typographic standards will be. Thank you. – JoonasD6 Nov 18 '17 at 8:54
• @JoonasD6 The package provides \num for numbers alone and \si for units alone. – egreg Nov 18 '17 at 9:10

The math fonts do not have these characters but you can set things up to automatically use italic in mathm mode:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{icomma}
\DeclareUnicodeCharacter{C5}{\relax\ifmmode\textit{\AA}\else\AA\fi}
\DeclareUnicodeCharacter{E5}{\relax\ifmmode\textit{\aa}\else\aa\fi}
\DeclareUnicodeCharacter{E6}{\relax\ifmmode\textit{\ae}\else\ae\fi}
\DeclareUnicodeCharacter{C4}{\relax\ifmmode\textit{\"{a}}\else\"{a}\fi}
\DeclareUnicodeCharacter{D8}{\relax\ifmmode\textit{\o}\else\o\fi}

\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}

• Was that definition supposed to override \mathrm? Because it did and now the unit Å is slanted although it should be upright. – JoonasD6 Nov 18 '17 at 8:52
• @JoonasD6 if you always want Å to be upright just replace \textit by \texrm in its definition, but yes these end up working like greek letters in math where \mathrm{\alpha} doesn't make alpha upright and \mathit{\Gamma} doesn't make Gamma slanted. To do more really requires better font support which is beyond the scope of an answer here, sorry – David Carlisle Nov 18 '17 at 8:57