如何在 LaTeX 数学模式中使用斯堪的纳维亚字符?

如何在 LaTeX 数学模式中使用斯堪的纳维亚字符?

这是 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}

斯堪的纳维亚字符如何无法呈现

如果没有 T1 选项,我会收到“请使用 \mathaccent”错误。使用这些设置,它会编译和渲染,尽管我在日志中确实提到了“命令 \r 在数学模式下无效”。结果,字符根本就没有被绘制出来。

我是不是正在寻找绘制变音符号的特定宏。我正在不是意味着在模式下输入所有这些字符,\text因为在这种情况下它们不是文本,而是实际变量,因此仍然可以区分等等。\mathit不起作用(仍然没有渲染)也不可接受。

这是字体特有的问题吗?字体的数学版本中不存在相应的字符吗?如果是这样,哪些字体包含 Scandics 的数学版本?我至少尝试过kpfontsfourier

这是摆脱 LaTeX 的唯一出路吗?(如果只是对我来说还好,但我的同事也必须能够使用这些文件。)

答案1

那里在字母上方画圆圈的常规命令:\mathring

对于埃单位,使用siunitx,这样就避免了 的需要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}

在此处输入图片描述

可能å在数学模式中输入\mathring{a},但我不推荐这样做;ü您不会输入二阶导数,对吧?

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

答案2

数学字体没有这些字符,但您可以设置为在数学模式下自动使用斜体:

在此处输入图片描述

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

答案3

你可以在数学模式下使用任何文本模式命令,只需将其包装在 中即可\textnormal。例如:

\usepackage{amsmath}

\newcommand\mathAring{\textnormal{\itshape Å}}

如果您加载fontspec,它还会将您的\mathrm字体设置为默认文本字体及其\mathit斜体形状,因此\mathit{Å}应该可以工作。

相关内容