是否可以使用 Libertine otf 字体(使用 LuaLaTeX 和例如包 libertine 进行自动设置)来处理除数学模式之外的所有情况,在数学模式下我想使用 newtxmath 及其 libertine 选项(使用 pdfLaTeX 产生可接受的输出)?
两者都不 :
\usepackage[libertine]{newtxmath}
\usepackage[no-math]{fontspec}
\usepackage{libertine}
也不
\usepackage[libertine]{newtxmath}
\usepackage[no-math]{fontspec}
\setmainfont[Ligatures={TeX}]{Linux Libertine O}
成功了。我使用以下命令获取数学的 CM 字体:
%!TEX program = lualatex
\documentclass[]{scrbook}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[libertine]{newtxmath}
\usepackage[no-math]{fontspec}
\usepackage{libertine}
\begin{document}
\begin{equation}
\mathit{TRUC} = \frac{1}{10} \times \sum _{d=0.2}^{12.8} \frac{\pi \times d \times A_{d}}{E_{d}}
\end{equation}
\end{document}
答案1
既然你给出了no-math
选择,你就必须提供帮助fontspec
:
\documentclass[]{scrbook}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[libertine]{newtxmath}
\usepackage[no-math]{fontspec}
\usepackage{libertine}
\DeclareSymbolFont{operators}{\encodingdefault}{\familydefault}{\mddefault}{n}
\DeclareMathAlphabet{\mathit}{\encodingdefault}{\familydefault}{\mddefault}{it}
\DeclareMathAlphabet{\mathbf}{\encodingdefault}{\familydefault}{\bfdefault}{n}
\begin{document}
\begin{equation}
\mathit{TRUC} = \frac{1}{10} \times \sum _{d=0.2}^{12.8} \frac{\pi \times d \times A_{d}}{E_{d}}
\end{equation}
$\mathbf{ABC}$
\end{document}
否则,您需要恢复数字的标准数学代码。
\documentclass[]{scrbook}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[libertine]{newtxmath}
\usepackage{fontspec}
\usepackage{libertine}
\AtBeginDocument{%
\DeclareMathSymbol{0}{\mathalpha}{operators}{`0}%
\DeclareMathSymbol{1}{\mathalpha}{operators}{`1}%
\DeclareMathSymbol{2}{\mathalpha}{operators}{`2}%
\DeclareMathSymbol{3}{\mathalpha}{operators}{`3}%
\DeclareMathSymbol{4}{\mathalpha}{operators}{`4}%
\DeclareMathSymbol{5}{\mathalpha}{operators}{`5}%
\DeclareMathSymbol{6}{\mathalpha}{operators}{`6}%
\DeclareMathSymbol{7}{\mathalpha}{operators}{`7}%
\DeclareMathSymbol{8}{\mathalpha}{operators}{`8}%
\DeclareMathSymbol{9}{\mathalpha}{operators}{`9}%
}
\begin{document}
\showthe\mathcode`1
\begin{equation}
\mathit{TRUC} = \frac{1}{10} \times \sum _{d=0.2}^{12.8} \frac{\pi \times d \times A_{d}}{E_{d}}
\end{equation}
$\mathbf{ABC}$
\end{document}
答案2
另一种方法如下,使用 Linux Libertine 系统字体,例如在 lualatex 下:
\documentclass[]{scrbook}
\usepackage{luacode,luatexbase}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[T1]{fontenc}
\usepackage[scaled=.85]{beramono}% used \mathtt; could use Libertine Mono
\usepackage[type1,scaled=.9]{cabin}% used \mathsf; could use Biolinum
\usepackage[libertine]{newtxmath}%
\usepackage{bm}% access to bold math;
\providecommand\mathbfit[1]{\bm{\mathit #1}}% since unicode-math not loaded here.
\usepackage[no-math]{fontspec}
\setmainfont{Linux Libertine O}
\setmonofont{Linux Libertine Mono O}[Scale=0.89]
\setsansfont{Linux Biolinum O}[Scale=MatchUppercase]
\begin{document}
\begin{equation}
\mathit{TRUC} = \frac{1}{10} \times \sum _{d=0.2}^{12.8} \frac{\pi
\times d \times A_{d}}{E_{d}}
\end{equation}
$\mathbf{ABC}$
$\mathbfit{ABC}$
\end{document}