答案1
您为字母定义新的符号字体并重置其数学代码。
\documentclass{article}
\DeclareSymbolFont{uiletters}{OT1}{cmr}{m}{ui}
\DeclareMathSymbol{a}{\mathalpha}{uiletters}{`a}
\DeclareMathSymbol{b}{\mathalpha}{uiletters}{`b}
\DeclareMathSymbol{c}{\mathalpha}{uiletters}{`c}
\DeclareMathSymbol{d}{\mathalpha}{uiletters}{`d}
\DeclareMathSymbol{e}{\mathalpha}{uiletters}{`e}
\DeclareMathSymbol{f}{\mathalpha}{uiletters}{`f}
\DeclareMathSymbol{g}{\mathalpha}{uiletters}{`g}
\DeclareMathSymbol{h}{\mathalpha}{uiletters}{`h}
\DeclareMathSymbol{i}{\mathalpha}{uiletters}{`i}
\DeclareMathSymbol{j}{\mathalpha}{uiletters}{`j}
\DeclareMathSymbol{k}{\mathalpha}{uiletters}{`k}
\DeclareMathSymbol{l}{\mathalpha}{uiletters}{`l}
\DeclareMathSymbol{m}{\mathalpha}{uiletters}{`m}
\DeclareMathSymbol{n}{\mathalpha}{uiletters}{`n}
\DeclareMathSymbol{o}{\mathalpha}{uiletters}{`o}
\DeclareMathSymbol{p}{\mathalpha}{uiletters}{`p}
\DeclareMathSymbol{q}{\mathalpha}{uiletters}{`q}
\DeclareMathSymbol{r}{\mathalpha}{uiletters}{`r}
\DeclareMathSymbol{s}{\mathalpha}{uiletters}{`s}
\DeclareMathSymbol{t}{\mathalpha}{uiletters}{`t}
\DeclareMathSymbol{u}{\mathalpha}{uiletters}{`u}
\DeclareMathSymbol{v}{\mathalpha}{uiletters}{`v}
\DeclareMathSymbol{w}{\mathalpha}{uiletters}{`w}
\DeclareMathSymbol{x}{\mathalpha}{uiletters}{`x}
\DeclareMathSymbol{y}{\mathalpha}{uiletters}{`y}
\DeclareMathSymbol{z}{\mathalpha}{uiletters}{`z}
\DeclareMathSymbol{A}{\mathalpha}{uiletters}{`A}
\DeclareMathSymbol{B}{\mathalpha}{uiletters}{`B}
\DeclareMathSymbol{C}{\mathalpha}{uiletters}{`C}
\DeclareMathSymbol{D}{\mathalpha}{uiletters}{`D}
\DeclareMathSymbol{E}{\mathalpha}{uiletters}{`E}
\DeclareMathSymbol{F}{\mathalpha}{uiletters}{`F}
\DeclareMathSymbol{G}{\mathalpha}{uiletters}{`G}
\DeclareMathSymbol{H}{\mathalpha}{uiletters}{`H}
\DeclareMathSymbol{I}{\mathalpha}{uiletters}{`I}
\DeclareMathSymbol{J}{\mathalpha}{uiletters}{`J}
\DeclareMathSymbol{K}{\mathalpha}{uiletters}{`K}
\DeclareMathSymbol{L}{\mathalpha}{uiletters}{`L}
\DeclareMathSymbol{M}{\mathalpha}{uiletters}{`M}
\DeclareMathSymbol{N}{\mathalpha}{uiletters}{`N}
\DeclareMathSymbol{O}{\mathalpha}{uiletters}{`O}
\DeclareMathSymbol{P}{\mathalpha}{uiletters}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{uiletters}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{uiletters}{`R}
\DeclareMathSymbol{S}{\mathalpha}{uiletters}{`S}
\DeclareMathSymbol{T}{\mathalpha}{uiletters}{`T}
\DeclareMathSymbol{U}{\mathalpha}{uiletters}{`U}
\DeclareMathSymbol{V}{\mathalpha}{uiletters}{`V}
\DeclareMathSymbol{W}{\mathalpha}{uiletters}{`W}
\DeclareMathSymbol{X}{\mathalpha}{uiletters}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{uiletters}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{uiletters}{`Z}
\begin{document}
New setup: $ax+by=1$ $\hat{a}+\ddot{a}$
Standard setup $\mathnormal{ax+by}=1$ % for a check
\end{document}
标准声明的fontmath.ltx
形式为
\DeclareMathSymbol{a}{\mathalpha}{letters}{`a}
正常的数学斜体字母仍然可用\mathnormal{a}
。
答案2
使用unicode-math
,您可以使用range=
选项\setmathfont
选择直立斜体。这需要 LuaLaTeX 或 XeLaTeX。例如,这里是欧拉恒等式,其中常数以直立斜体排版:
\documentclass{article}
\usepackage{mathtools}
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{Latin Modern Roman}[
Scale=1.0]
\setmathfont{Latin Modern Math}
\setmathfont{CMU Serif Upright Italic}[
range=up]
\newcommand\upi{\symup{i}}
\newcommand\upe{\symup{e}}
\begin{document}
\begin{align*}
\upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
\upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{document}
要使数学字母默认为直立斜体,请传递unicode-math
以下math-style=upright
选项:
\usepackage[math-style=upright]{unicode-math}
\symit{x}
无论哪种方式,您都可以使用等切换回倾斜斜体。
答案3
答案4
在将 Davislor 的回答与 unicode-math 文档进行交叉引用后,我认为他打错了。参考附图,“math-style = ISO”默认使显示的数学为斜体,而不是“...直立”,这无论如何都不符合直觉。对于读者,我总结了下表
- ISO = 拉丁/希腊小写/大写斜体
- TeX = 拉丁小写/大写 + 希腊小写斜体;希腊大写直立
- 法语 = 拉丁/希腊小写斜体;拉丁/希腊大写直立
- 直立 = 拉丁/希腊小写/大写直立
例如当你声明包时:
\RequirePackage[math-style=TeX]{unicode-math}%Should be loaded after any math-related packages
例如,通过使用命令附加前言来声明包之后:
\unimathsetup{math-style=TeX}
或者例如在 \setmathfont 命令中:
\setmathfont[range = math-style=TeX,
SizeFeatures = {
{Size = -6, Font = MinionMath-Tiny, Style = MathScriptScript},
{Size = 6-8.4, Font = MinionMath-Capt, Style = MathScript},
{Size = 8.4-13, Font = MinionMath-Regular},
}]{MinionMath-Regular}
“sans-style”(无衬线)和“bold-style”也有类似的选项;但是,虽然“math-style”会影响所有内容(拉丁文、希腊文 sans),但您也可以设置单独的数学范围以满足您的需求。从 unicode-math-luatex.sty,我们对各种样式及其可用选项进行了完整的划分:
\__um_keys_choices:nn {math-style}
{
{ISO} {
\unimathsetup { nabla=upright, partial=italic,
normal-style=ISO, bold-style=ISO, sans-style=italic }
}
{TeX} {
\unimathsetup { nabla=upright, partial=italic,
normal-style=TeX, bold-style=TeX, sans-style=upright }
}
{french} {
\unimathsetup { nabla=upright, partial=upright,
normal-style=french, bold-style=upright, sans-style=upright }
}
{upright} {
\unimathsetup { nabla=upright, partial=upright,
normal-style=upright, bold-style=upright, sans-style=upright }
}
{literal} {
\unimathsetup { colon=literal, nabla=literal, partial=literal,
normal-style=literal, bold-style=literal, sans-style=literal }
}
}
\__um_keys_choices:nn {bold-style}
{
{ISO} {
\bool_gset_false:N \g__um_bfliteral_bool
\bool_gset_false:N \g__um_bfupGreek_bool
\bool_gset_false:N \g__um_bfupgreek_bool
\bool_gset_false:N \g__um_bfupLatin_bool
\bool_gset_false:N \g__um_bfuplatin_bool
}
{TeX} {
\bool_gset_false:N \g__um_bfliteral_bool
\bool_gset_true:N \g__um_bfupGreek_bool
\bool_gset_false:N \g__um_bfupgreek_bool
\bool_gset_true:N \g__um_bfupLatin_bool
\bool_gset_true:N \g__um_bfuplatin_bool
}
{upright} {
\bool_gset_false:N \g__um_bfliteral_bool
\bool_gset_true:N \g__um_bfupGreek_bool
\bool_gset_true:N \g__um_bfupgreek_bool
\bool_gset_true:N \g__um_bfupLatin_bool
\bool_gset_true:N \g__um_bfuplatin_bool
}
{literal} {
\bool_gset_true:N \g__um_bfliteral_bool
}
}
\__um_keys_choices:nn {sans-style}
{
{italic} { \bool_gset_false:N \g__um_upsans_bool }
{upright} { \bool_gset_true:N \g__um_upsans_bool }
{literal} { \bool_gset_true:N \g__um_sfliteral_bool }
}
\__um_keys_choices:nn {nabla}
{
{upright} {
\bool_gset_false:N \g__um_literal_Nabla_bool
\bool_gset_true:N \g__um_upNabla_bool
}
{italic} {
\bool_gset_false:N \g__um_literal_Nabla_bool
\bool_gset_false:N \g__um_upNabla_bool
}
{literal} {
\bool_gset_true:N \g__um_literal_Nabla_bool
}
}
\__um_keys_choices:nn {partial}
{
{upright} {
\bool_gset_false:N \g__um_literal_partial_bool
\bool_gset_true:N \g__um_uppartial_bool
}
{italic} {
\bool_gset_false:N \g__um_literal_partial_bool
\bool_gset_false:N \g__um_uppartial_bool
}
{literal} {
\bool_gset_true:N \g__um_literal_partial_bool
}
}
简而言之,您可以调整 \partial、\nabla 命令、serif math、upright math、bold-math 等的样式;请参阅上面的代码了解如何操作。