在 Linux Libertine 的数学模式下使用 unicode-math (XeLaTeX)

在 Linux Libertine 的数学模式下使用 unicode-math (XeLaTeX)

我正在尝试使用 Linux Libertine 字体来完成我的论文。Libertine 确实有数学符号,但我无法在 unicode-math 中正确使用它们。以下示例总结了我逐步从字体中添加符号的尝试,并突出显示了失败之处。我知道有些问题无法解决,因为 OTF 字体不完全支持数学,但也许有些问题可以使用高级 TeX 技巧来解决。两个主要问题是重音符号和括号;我可以容忍从其他字体中获取其他符号。

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\usepackage{fontspec}
\usepackage[partial=upright,nabla=upright]{unicode-math}

\newcommand{\sample}{\[ \underbrace{\frac{\partial y}{\partial x}R(x)^2}_{\text{Foo}} = \left[ \sum_{i=0}^\infty \tilde{f}_i \arcsin\left( \alpha_i^3 x \right) \right]^{-1} \sqrt[6]{\int \nabla y\times\mathbf{\theta}(y) \mathrm{d}\phi} \geq \mathring{\Omega}_\ell [d]\]}

\begin{document}
\sample
This is a correct rendering using Latin Modern. Let's try to add some Libertine\ldots

\setmainfont[Mapping=tex-text]{Linux Libertine O}
\setmathfont[range=\mathit/{latin,Latin,num,Greek,greek}]{Linux Libertine O Italic}
\setmathfont[range=\mathup/{latin,Latin,num,Greek,greek}]{Linux Libertine O}
\setmathfont[range=\mathbfup/{latin,Latin,num,Greek,greek}]{Linux Libertine O Bold}
\setmathfont[range=\mathbfit/{latin,Latin,num,Greek,greek}]{Linux Libertine O Bold Italic}
\setmathfont[range={"0300-"036F}]{Linux Libertine O}% Accents - won't compile correctly without this line
\setmathfont[range={"003D,"00D7,"2202,"2207,"2212,"221E,"2265}]{Linux Libertine O} % some more symbols, they work properly
% U+003D    Equal sign
% U+00D7    Cross
% U+2202    Partial
% U+2207    Nabla
% U+2212    Minus
% U+221E    Infinity
% U+2265    Greater or equal

\sample

\textcolor{red}{Problem 1:} accents are off (ugly hack: use \texttt{\backslash skew})\\
\textcolor{red}{Problem 2:} brackets are still in LM; at least the normal sized brackets must match the text, so let's add parentheses \& square brackets:

\setmathfont[range={"0028,"0029,"005B,"005D}]{Linux Libertine O}

\sample

\textcolor{red}{Problem 3:} only the right parenthesis extends\\
\textcolor{red}{Problem 4:} the underbrace became gibberish\\
Possible fix to 3 \& 4: include the extending brackets from  `Miscellaneous Technical' unicode block (\texttt{U+239B}--\texttt{U+23AA}); unfortunately it doesn't change anything.
\medskip

Libertine has a summation and integral symbol, let's try to use them:

\setmathfont[range={"2211,"222B}]{Linux Libertine O}

\sample

\textcolor{red}{Problem 5:} the summation symbol is too small; Note that the integral symbol was broken to an top and bottom parts (both exist in the font), but there are no top and bottom parts of the summation symbol in this font.
\end{document}

尝试使用 Linux Libertine 渲染复杂的数学公式

答案1

除了字母数字符号外,不要使用非 OpenType 数学字体(如 Linux Libertine)中的任何符号。括号、大运算符(求和、积分等)、宽重音符号、根等都需要特殊考虑,这只有在完整的 OpenType 数学字体中才值得羡慕。

一般来说,如果您想要最高质量的数学排版,请仅使用完整的数学字体,正如您所看到的,即使在第一个 Libertine 示例中,重音和根音度也是偏离的。

XITS Math 可能比较浅的 Latin Modern 字体更匹配。

答案2

自从提出这个问题以来,事情可能已经发生了变化,我相信它只解决了其中的一部分,但我也处于类似的情况(想在论文中使用 Linux Libertine),当我找到这个包时,我感到非常欣慰newtx,它为在大量字体中设置数学提供了许多增强功能,尤其侧重于 Linux Libertine。

我使用 XeLaTeX,简而言之(此时真实文档中的前言超过 100 行……)在前言中放入以下内容:

\usepackage[libertine]{newtxmath}
\usepackage[no-math]{fontspec}
\setmainfont{Linux Libertine O}

突然之间,所有字距调整问题以及数学模式中的更多问题都或多或少地得到了默认解决。

我甚至可以说,如果不付出努力,Linux Libertine 几乎无法用于包括数学在内的文档newtx。人们可以花费数小时手动添加跳过、空格和字距,或者加载newtxmath

我不知道在数学模式下定义字体度量的内部原理,因此我可能在技术上犯了错误,但我确实相信,如果 Linux Libertine 能够将此外部包中的字距调整功能包含在主线字体中,那么它将是 Linux Libertine 的一大增强。如果没有它,数学模式下的几乎所有字符集都会有问题。

我希望那些发现这个问题的人能够彻底探索这个包。

答案3

尝试新的 TeX Gyre Pagella Math,它是 TL 2012 的一部分:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\usepackage[partial=upright,nabla=upright]{unicode-math}
\setmainfont{Linux Libertine O}
\setmonofont{LinMonoO} 
\setmathfont{TG Pagella Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}

\def\Macro#1{\texttt{\textbackslash#1}}
\begin{document}

\[ \underbrace{\frac{\partial y}{\partial x}R(x)^2}_{\text{Foo}} = \left[ \sum_{i=0}^\infty \tilde{f}_i \arcsin\left( \alpha_i^3 x \right) \right]^{-1} \sqrt[6]{\int \nabla y\times\mathbf{\theta}(y) \mathrm{d}\phi} \geq \mathring{\Omega}_\ell [d]
\]

\Macro{mathscr}: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\Macro{mathscr}: $\mathscr{abcdefghijklmnopqrstuvwxyz}$\\
\Macro{mathbfscr}: $\mathbfscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\Macro{mathbfscr}: $\mathbfscr{abcdefghijklmnopqrstuvwxyz}$

\bigskip
\Macro{mathcal} and \Macro{mathbfcal}

\texttt{StylisticSet=1}: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\texttt{StylisticSet=1}: $\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=2]{XITS Math}
\texttt{StylisticSet=2}: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\texttt{StylisticSet=2}: $\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

\end{document}

在此处输入图片描述

答案4

CTAN 软件包的维护者libertine,也是事实上Libertine 字体的维护者,建议使用

\usepackage{unicode-math}
\setmathfont[Scale=MatchUppercase]{libertinusmath-regular.otf}

用于 XeTeX 或 LuaTeX 中的“兼容数学”。字体 libertinusmath-regular.otf 属于libertinus 字体CTAN 包。如果我可以完全控制文档中的字体选择(我现在正在修改),我可能会完全改用这些字体;Libertinus 是 Libertine 家族的一个分支,它“修复了许多错误”,并且具有更多风格化功能。

相关内容