- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我注意到,在数学模式下(即四开本、$$...$$
或 $...
),正在设置字母和数字使用默认字体,无论 mainfont
或 mathfont
。因此,变量名称和数字以不同的字体排版。
mathfont
确实对数学运算符有影响,例如\log
将使用mathfont
进行排版。然而,字母和数字则不然。这是预期的行为吗?
我知道一个解决方法。即对整个方程使用\mathit{}
,然后对需要直立的数字使用\mathrm{}
。然后它看起来是正确的,但它使编码变得更加繁重(比它已经可能的)。
编译以下文档来查看问题:
---
documentclass: article
mainfont: Lato
mathfont: Lato
---
$$ y = 123\cdot\log{x} $$
$$ \mathit{y = \mathrm{123}\cdot\log{x}} $$
(最终替换为您自己的字体)。第二个方程看起来应该是这样的。在第一个方程中,只有运算符 (log
) 使用 mathfont
。其他项目使用默认的“latex”字体(与未指定 mainfont
时的字体相同)。
最佳答案
并非每种字体都包含必要的数学符号,Lato 不包含它们。您将在 .log 文件中看到如下警告:
Package fontspec Warning: Font "Lato" does not contain requested Script
(fontspec) "Math".
特别是对于无衬线字体,没有太多可供选择的字体,而且现有的少数字体通常不完整。
Fira Math 是一种提供相当好的覆盖范围的无衬线字体(...但它的设计可能有点两极分化)
---
documentclass: article
mainfont: Lato
mathfont: Fira Math
format:
pdf
---
$$ y = 123\cdot\log{x} $$
$$ \mathit{y = \mathrm{123}\cdot\log{x}} $$
如果您想在数学模式下使用文本字体中的字母和数字,您可以使用 mathastext
包:
% !TeX TS-program = lualatex
\documentclass{article}
\usepackage[no-math]{fontspec}
\setmainfont{Lato}
\usepackage{mathastext}
\begin{document}
\[ y = 123\cdot\log{x} \]
\end{document}
关于latex - 数学中的字母和数字不使用 "mainfont"也不使用 "mathfont",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75288350/
我注意到,在数学模式下(即四开本、$$...$$ 或 $...),正在设置字母和数字使用默认字体,无论 mainfont 或 mathfont。因此,变量名称和数字以不同的字体排版。 mathfont
我是一名优秀的程序员,十分优秀!