交叉发布http://latex-community.org/forum/viewtopic.php?f=48&t=24483但由于我没有得到答案,我希望这里有人可以提供帮助。
目标:
我想使用自定义字体(Exljbris 的 Calluna 和 Calluna Sans)作为我的文档的主字体fontspec
,并使用eulervm
和数学字体。此外,Calluna 提供 OldStyle 和 Lining 两种字体,我更喜欢在正文中使用前者,在数学模式中使用后者。此外,我非常喜欢用siunitx
单位来格式化数字。最后,我还用它biblatex
来排版我的参考资料。
问题:
eulervm
带有一组数字,它们与 Calluna 一起看起来不太好看,尤其是在文本中内联格式化数字时。此外,默认设置是eulervm
不使用欧拉数字,而是使用默认的罗马数字。显然,这些不是由设置的,fontspec
因为在“普通”数学模式下,使用的是 Computer Modern 数字,这看起来更糟。更糟糕的是,无论有没有euler-digits
选项eulervm
,siunitx
总是在数学模式下使用欧拉数字,并且根据detect-all
选项在文本模式下也使用。
为了解决这些问题,我使用该mathspec
包将数学模式中的数字也设置为 Calluna,同时保留普通文本。此解决方案在整个正文(包括逐字环境)中都运行良好。
但是,接下来,输入参考文献。我的大多数参考文献都包含 URL 或 DOI(数字对象标识符),这些都由 以逐字格式处理biblatex
。但是,只要我使用该\setmathfont
命令,-verbatim 字段内的数字(并且只有数字)biblatex
也会更改为 Calluna。但是,逐字字体(Latin Modern Mono)和 Calluna 非常不同,并且不能很好地融合。不幸的是,该\setmonofont
命令确实会更改字母,但不会更改数字。
问题
使整个文档中的数字保持一致的最佳方法是什么?我更喜欢文本和数学模式下的 Calluna 数字,但在逐字模式下使用默认的单色字体。如果可以在不使用 的情况下在数学模式下设置数字mathspec
,而只使用fontspec
,那么我更喜欢这样做,因为mathspec
限制我只能使用XeTeX
,而我想使用LuaTeX
。
代码
请注意,为了兼容性,我将代码中对 Calluna 的所有引用更改为大多数计算机上默认可用的字体。
\begin{filecontents}{test.bib}
@Article{Hay2011,
Title = {Can humans force a return to a `Cretaceous' climate?},
Author = {William W. Hay},
Journaltitle = {Sedimentary Geology},
Year = {2011},
Doi = {10.1016/j.sedgeo.2010.04.015},
ISSN = {0037-0738},
Language = {english},
Note = {Causes of oxic - anoxic changes in Cretaceous marine environments and their implications for Earth systems },
Number = {1-2},
Pages = {5--26},
Volume = {235},
Journal = {Sedimentary Geology },
Keywords = {Cretaceous},
}
\end{filecontents}
\documentclass{scrartcl}
\usepackage{amsfonts}
\usepackage[
euler-digits
]{eulervm}
\usepackage{siunitx}
\sisetup{
detect-all,
}
\usepackage{mathspec}
\setmainfont[Ligatures={Common,TeX},Numbers={OldStyle,Proportional}]{Times New Roman}
\setsansfont[Ligatures={Common,TeX},Numbers={Lining,Proportional}]{Arial}
\setmathfont(Digits,Latin,Greek)[Arabic=Regular,Uppercase=Plain,Lowercase=Plain,Numbers={Lining,Monospaced}]{Times New Roman}% According to the manual this sets the digits to the regular arabics, while leaving the latin and greek letters untouched, which is intented, I want eulervm for maths letters.
\setmonofont[Ligatures={NoRequired,NoCommon,NoContextual},Numbers={Lining,Monospaced}]{Courier New}
\usepackage[
style=authoryear-comp,
doi=true,
url=true,
sorting=nyvt,
backend=biber,
]{biblatex}
\usepackage[hidelinks]{hyperref}
\addglobalbib{test.bib}
\begin{document}
\section{Verify sans font}
The following line shows the normal verb command is unaffected:
{\scshape DOI:}\ \verb|10.1016/j.sedgeo.2010.04.015|
This is a sentence to test the various fonts for digits with or without \verb|\sisetup{detect-all}| or \verb|\setmathfont|. 1234567890, \(1234567890\), \SI{1234567890}{\metre}, \(\SI{1234567890}{\metre}\),\\ \num{1234567890}, \(\num{1234567890}\).
\begin{verbatim}
This is a test of numerals in the verbatim environment: 1234567890
\end{verbatim}
\textcite{Hay2011} shows the problem with the DOI, I included this one because it has an ugly mixture of letters and digits, showing the problem to its full extent.
\printbibliography
\end{document}
答案1
这里有一个解决方法fontspec
。诀窍是为内衬数字定义一种新的数学符号字体。
我不会使用detect-all
:数字\SI
或\num
应始终在数学模式下排版(因此带有衬线数字)。
\begin{filecontents}{test.bib}
@Article{Hay2011,
Title = {Can humans force a return to a `Cretaceous' climate?},
Author = {William W. Hay},
Journaltitle = {Sedimentary Geology},
Year = {2011},
Doi = {10.1016/j.sedgeo.2010.04.015},
ISSN = {0037-0738},
Language = {english},
Note = {Causes of oxic - anoxic changes in Cretaceous marine environments and their implications for Earth systems },
Number = {1-2},
Pages = {5--26},
Volume = {235},
Journal = {Sedimentary Geology },
Keywords = {Cretaceous},
}
\end{filecontents}
\documentclass{scrartcl}
\usepackage{amsfonts}
\usepackage{eulervm}
\usepackage{siunitx}
\sisetup{
% detect-all,
math-rm=\mathlining,
}
\usepackage[no-math]{fontspec}
\setmainfont[Ligatures={Common,TeX},Numbers={OldStyle,Proportional}]{TeX Gyre Termes}
\newfontfamily{\liningmain}[Ligatures={Common,TeX},Numbers=Lining]{TeX Gyre Termes}
\setsansfont[Ligatures={Common,TeX},Numbers={Lining,Proportional}]{TeX Gyre Heros}
\setmonofont[Ligatures={NoRequired,NoCommon,NoContextual},Numbers={Lining,Monospaced}]{TeX Gyre Cursor}
% A trick for extracting the family information
% which works independently of the chosen font
\begingroup
\def\getfamily#1#2#3#4#5{#4}
\edef\x{\endgroup
\def\noexpand\liningdefault{\expandafter\expandafter\expandafter
\getfamily\csname liningmain \endcsname}}\x
\DeclareSymbolFont{liningmath}{\encodingdefault}{\liningdefault}{m}{n}
\DeclareSymbolFontAlphabet{\mathlining}{liningmath}
\Umathcode`0="7 \symliningmath `0
\Umathcode`1="7 \symliningmath `1
\Umathcode`2="7 \symliningmath `2
\Umathcode`3="7 \symliningmath `3
\Umathcode`4="7 \symliningmath `4
\Umathcode`5="7 \symliningmath `5
\Umathcode`6="7 \symliningmath `6
\Umathcode`7="7 \symliningmath `7
\Umathcode`8="7 \symliningmath `8
\Umathcode`9="7 \symliningmath `9
\usepackage[
style=authoryear-comp,
doi=true,
url=true,
sorting=nyvt,
backend=biber,
]{biblatex}
\usepackage[hidelinks]{hyperref}
\addglobalbib{test.bib}
\begin{document}
\section{Verify sans font}
The following line shows the normal verb command is unaffected:
DOI: \verb|10.1016/j.sedgeo.2010.04.015|
URL: \url{10.1016/j.sedgeo.2010.04.015}
This is a sentence to test the various fonts for digits with or without
\verb|\sisetup{detect-all}| or \verb|\setmathfont|.\\
No math: 1234567890,\\
Math: \(1234567890\),\\
\verb|\SI| in text: \SI{1234567890}{\metre},\\
\verb|\SI| in math: \(\SI{1234567890}{\metre}\),\\
\verb|\num| in text: \num{1234567890},\\
\verb|\num| in math: \(\num{1234567890}\).
A test of math: $X=12$.
\begin{verbatim}
This is a test of numerals in the verbatim environment: 1234567890
\end{verbatim}
\textcite{Hay2011} shows the problem with the DOI, I included this one because it has an ugly mixture of letters and digits, showing the problem to its full extent.
\printbibliography
\end{document}