立方根显示不准确

立方根显示不准确

跟进此事回答,我添加了这段代码:

\documentclass{memoir}

\usepackage{babel}
\babelprovide[import, onchar = fonts ids]{bengali}
\babelfont[bengali]{rm}[Renderer=Harfbuzz,AutoFakeBold,AutoFakeSlant=0.3]{Kalpurush}
\babelcharproperty{`।}{locale}{bengali}

\babelprovide[maparabic,alph=alphabetic]{bengali}

%\usepackage{amsmath}
\usepackage{unicode-math}

%--------------- Problematic code starts
\setmathfont{latinmodern-math.otf}
\setmathfont{fontkalpurush.ttf}[range={"0980-"09FF}]
\newcount\tmpcount
% re-do range No idea why this is needed
\AtBeginDocument{
\tmpcount="0980
\loop
\Umathcode\tmpcount 0 4 \tmpcount
\ifnum\tmpcount<"09FF
\advance\tmpcount 1
\repeat
}
%--------------- Problematic code ends

\begin{document} 
text
    ৩৪২

math
    $৩৪^২$ %34^2
\begin{align*}
    ৩৪২ &= (৩৪+৪)(৩৪-৪) + ৪২\\
    &= ৩৮৩০ + ৪২
\end{align*}
    \[ \sqrt[৩]{\frac{১}{২}} \] 
\end{document}

它对这个问题很有效,但当我写出立方根方程时,它并没有显示实际的形状。有问题的代码此处使用注释区域显示%--------------- Problematic code。如何才能获得正确的立方根形状并保持其他设置正常?

输出:

在此处输入图片描述

答案1

你需要

\setmathfont{latinmodern-math.otf}
\setmathfont{fontkalpurush.ttf}[range={"0980-"09FF}]
\setmathfont{latinmodern-math.otf}[range=]

这是和范围的一个已知问题unicode-math

然而,这并不是“魔法”代码不是保证工作,因为它依赖于一些未预先确定的数字,我会指定一个数学符号字体​​,而忘记其余的。

\documentclass{memoir}

\usepackage{babel}
\babelprovide[import, onchar = fonts ids]{bengali}
\babelfont[bengali]{rm}[
  Renderer=Harfbuzz,
  AutoFakeBold,
  AutoFakeSlant=0.3,
  NFSSFamily=kalpurush,
]{fontkalpurush.ttf}
\babelcharproperty{`।}{locale}{bengali}

\babelprovide[maparabic,alph=alphabetic]{bengali}

\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}

\DeclareSymbolFont{bangla}{\encodingdefault}{kalpurush}{m}{n}
\Umathcode"09E6 = "0 \symbangla "09E6 % 0
\Umathcode"09E7 = "0 \symbangla "09E7 % 1
\Umathcode"09E8 = "0 \symbangla "09E8 % 2
\Umathcode"09E9 = "0 \symbangla "09E9 % 3
\Umathcode"09EA = "0 \symbangla "09EA % 4
\Umathcode"09EB = "0 \symbangla "09EB % 5
\Umathcode"09EC = "0 \symbangla "09EC % 6
\Umathcode"09ED = "0 \symbangla "09ED % 7
\Umathcode"09EE = "0 \symbangla "09EE % 8
\Umathcode"09EF = "0 \symbangla "09EF % 9

\begin{document} 

text
    ৩৪২

math
    $৩৪^২$ %34^2
\begin{align*}
    ৩৪২ &= (৩৪+৪)(৩৪-৪) + ৪২\\
    &= ৩৮৩০ + ৪২
\end{align*}
    \[ \sqrt[৩]{\frac{১}{২}} \] 
\end{document}

在此处输入图片描述

如果你不想重复这十个声明,下面的代码就足够了。

\DeclareSymbolFont{bangla}{\encodingdefault}{kalpurush}{m}{n}
\ExplSyntaxOn
\int_step_inline:nnn { "09E6 } { "09EF } { \Umathcode #1 = "0 \symbangla #1 }
\ExplSyntaxOff

相关内容