我想知道如何在数学表达式中交替使用无衬线希腊字体和衬线希腊字体。sansmathfonts 包会将字体更改为整个文档,而我并不想这样做。我读过相关文章,我认为必须定义一个特殊的数学字母表,比如\mathsfgreek
,在某种意义上类似于
\SetSymbolFont{letters}{sans}{OML}{cmbrm}{m}{it}.
我尝试使用\usefont
类似参数的类似方法,但没有成功。我希望在 sans normal (upright)、sans italic、sans bold normal 和 sans bold italic 之间进行选择,这些都应该在 cmss 中可用。我想写类似
\[ \alpha\mathsfgreek{\alpha} \]
左边\alpha
是正常,\alpha
右边是无(直立)。你能给我一些提示吗?
谢谢你!
答案1
声明一个新的符号字体:
\documentclass{article}
\usepackage{amsmath}
\DeclareSymbolFont{sfletters}{OML}{cmbrm}{m}{it}
\DeclareMathSymbol{\salpha}{\mathord}{sfletters}{"0B}
\DeclareMathSymbol{\sbeta}{\mathord}{sfletters}{"0C}
\DeclareMathSymbol{\sgamma}{\mathord}{sfletters}{"0D}
\DeclareMathSymbol{\sdelta}{\mathord}{sfletters}{"0E}
\DeclareMathSymbol{\sepsilon}{\mathord}{sfletters}{"0F}
\DeclareMathSymbol{\szeta}{\mathord}{sfletters}{"10}
\DeclareMathSymbol{\seta}{\mathord}{sfletters}{"11}
\DeclareMathSymbol{\stheta}{\mathord}{sfletters}{"12}
\DeclareMathSymbol{\siota}{\mathord}{sfletters}{"13}
\DeclareMathSymbol{\skappa}{\mathord}{sfletters}{"14}
\DeclareMathSymbol{\slambda}{\mathord}{sfletters}{"15}
\DeclareMathSymbol{\smu}{\mathord}{sfletters}{"16}
\DeclareMathSymbol{\snu}{\mathord}{sfletters}{"17}
\DeclareMathSymbol{\sxi}{\mathord}{sfletters}{"18}
\DeclareMathSymbol{\spi}{\mathord}{sfletters}{"19}
\DeclareMathSymbol{\srho}{\mathord}{sfletters}{"1A}
\DeclareMathSymbol{\ssigma}{\mathord}{sfletters}{"1B}
\DeclareMathSymbol{\stau}{\mathord}{sfletters}{"1C}
\DeclareMathSymbol{\supsilon}{\mathord}{sfletters}{"1D}
\DeclareMathSymbol{\sphi}{\mathord}{sfletters}{"1E}
\DeclareMathSymbol{\schi}{\mathord}{sfletters}{"1F}
\DeclareMathSymbol{\spsi}{\mathord}{sfletters}{"20}
\DeclareMathSymbol{\somega}{\mathord}{sfletters}{"21}
\DeclareMathSymbol{\svarepsilon}{\mathord}{sfletters}{"22}
\DeclareMathSymbol{\svartheta}{\mathord}{sfletters}{"23}
\DeclareMathSymbol{\svarpi}{\mathord}{sfletters}{"24}
\DeclareMathSymbol{\svarrho}{\mathord}{sfletters}{"25}
\DeclareMathSymbol{\svarsigma}{\mathord}{sfletters}{"26}
\DeclareMathSymbol{\svarphi}{\mathord}{sfletters}{"27}
\begin{document}
$\alpha\salpha\beta\sbeta\gamma\sgamma$
\end{document}
您可以定义一个\msf
命令:
\documentclass{article}
\usepackage{amsmath}
\DeclareRobustCommand{\msf}[1]{%
\ifcat\noexpand#1\relax\msfgreek{#1}\else\mathsf{#1}\fi
}
\makeatletter
\newcommand{\msfgreek}[1]{\csname s\expandafter\@gobble\string#1\endcsname}
\makeatother
\DeclareSymbolFont{sfletters}{OML}{cmbrm}{m}{it}
\DeclareMathSymbol{\salpha}{\mathord}{sfletters}{"0B}
\DeclareMathSymbol{\sbeta}{\mathord}{sfletters}{"0C}
\DeclareMathSymbol{\sgamma}{\mathord}{sfletters}{"0D}
\DeclareMathSymbol{\sdelta}{\mathord}{sfletters}{"0E}
\DeclareMathSymbol{\sepsilon}{\mathord}{sfletters}{"0F}
\DeclareMathSymbol{\szeta}{\mathord}{sfletters}{"10}
\DeclareMathSymbol{\seta}{\mathord}{sfletters}{"11}
\DeclareMathSymbol{\stheta}{\mathord}{sfletters}{"12}
\DeclareMathSymbol{\siota}{\mathord}{sfletters}{"13}
\DeclareMathSymbol{\skappa}{\mathord}{sfletters}{"14}
\DeclareMathSymbol{\slambda}{\mathord}{sfletters}{"15}
\DeclareMathSymbol{\smu}{\mathord}{sfletters}{"16}
\DeclareMathSymbol{\snu}{\mathord}{sfletters}{"17}
\DeclareMathSymbol{\sxi}{\mathord}{sfletters}{"18}
\DeclareMathSymbol{\spi}{\mathord}{sfletters}{"19}
\DeclareMathSymbol{\srho}{\mathord}{sfletters}{"1A}
\DeclareMathSymbol{\ssigma}{\mathord}{sfletters}{"1B}
\DeclareMathSymbol{\stau}{\mathord}{sfletters}{"1C}
\DeclareMathSymbol{\supsilon}{\mathord}{sfletters}{"1D}
\DeclareMathSymbol{\sphi}{\mathord}{sfletters}{"1E}
\DeclareMathSymbol{\schi}{\mathord}{sfletters}{"1F}
\DeclareMathSymbol{\spsi}{\mathord}{sfletters}{"20}
\DeclareMathSymbol{\somega}{\mathord}{sfletters}{"21}
\DeclareMathSymbol{\svarepsilon}{\mathord}{sfletters}{"22}
\DeclareMathSymbol{\svartheta}{\mathord}{sfletters}{"23}
\DeclareMathSymbol{\svarpi}{\mathord}{sfletters}{"24}
\DeclareMathSymbol{\svarrho}{\mathord}{sfletters}{"25}
\DeclareMathSymbol{\svarsigma}{\mathord}{sfletters}{"26}
\DeclareMathSymbol{\svarphi}{\mathord}{sfletters}{"27}
\begin{document}
$\alpha\salpha\beta\sbeta\gamma\sgamma$
$\alpha\msf{\alpha}x\msf{x}$
\end{document}
这里不涉及大写希腊文。留给读者练习。;-)