我想修改積分的字形,然後有時將其用作 \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 Math 字體(例如latinmodern-math.otf
作為基本字體和texgyrepagella-math.otf
替代字元)時,一切都可以正常工作。
\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相關的建議