我想修改积分的字形,然后有时将其用作 \myint 代替 \int。为此,我需要弄清楚如何从某种字体加载积分字形并赋予它典型的 \int 外观(使用路拉泰克斯)。让我们以拉丁现代字体为例,从下载它的数学部分LM 数学下载.目前我得到这个:
请注意积分后的多余空间和不合适的极限。我的问题是:如何解决这两个问题?
产生上述结果的代码是:
% !TEX program = lualatex
\documentclass[ngerman,10pt]{scrartcl}
\usepackage{fontspec}
%\usepackage{unicode-math}
\setlength{\fboxsep}{0pt}
%\usepackage{newcomputermodern}
% from https://tex.stackexchange.com/a/439983/294323
\newfontface{\mysymbolsfontface}{latinmodern-math.otf}[
%Path = ./, % Adjust the path to where the font is located
Extension = .otf,
NFSSFamily=mysymbolsfontfamily %use some name for the font family
]
\DeclareSymbolFont{mysymbolsfont}{TU}{mysymbolsfontfamily}{m}{n}
\Umathchardef\displaymyint="1 \symmysymbolsfont "222B %"\sym" then symbolsfontname then glyph code. The "1 stands for mathoperator
\Umathchardef\inlinemyint="1 \symmysymbolsfont "222B
\DeclareRobustCommand\myint{\mathchoice
{\displaymyint\nolimits}
{\inlinemyint\nolimits}
{\inlinemyint\nolimits}
{\inlinemyint\nolimits}}
\begin{document}
Inline: \qquad\qquad\qquad \fbox{$\myint$} \quad \fbox{$\myint_\infty^\infty g(x)$}\\
Displaymode: \qquad\qquad\qquad \fbox{$\displaystyle\myint$} \quad \fbox{$\displaystyle\myint_\infty^\infty g(x)$}\\
Supposed Inline: \quad \fbox{$\int$} \quad \fbox{$\int_\infty^\infty g(x)$}\\
Supposed Displaymode: \quad \fbox{$\displaystyle\int$} \quad \fbox{$\displaystyle\int_\infty^\infty g(x)$}\\
\end{document}
答案1
当您使用 Unicode 数学字体(例如latinmodern-math.otf
作为基本字体和texgyrepagella-math.otf
替代字符)时,一切都可以正常工作。我通过 OpTeX 尝试了这个:
\fontfam[lm] % latinmodern-math is loaded here
\addUmathfont \pagella {[texgyrepagella-math]]}{} {}{} {} % load font and register it at math-font family \pagella
\Umathchardef\myintop 1 \pagella `∫ \protected\def\myint{\myintop\nolimits} % \myint declaration
Test: $\int_a^b f(x), \myint_a^b f(x), \displaystyle \myint_a^b f(x) $
\bye
我选择了 Pagella,以便您可以看到积分符号确实在\myint
宏中使用。当然,您可以使用特殊字体代替它。
OpTeX 可与 LuaTeX 一起运行。您提到您正在使用 LuaLaTeX,它也可与 LuaTeX 一起运行。这意味着在 LuaLaTeX 中也应该没有问题,但我不懂 LaTeX,所以不要指望我会提供与 LaTeX 相关的建议