
由于某种原因,当我使用时\mathsf{}
,小数点似乎不受影响:
\documentclass{article}
\begin{document}
\textsf{This is an example.} $ \mathsf{\frac{1}{2} = 0.5} $
The rest of the document is in normal serif font.
\end{document}
如果仔细观察,您会注意到“示例”后面的点是一个正方形,但 0 到 5 之间的点是一个圆形。
这在英语中可能不是什么大问题,但在我们使用逗号而不是点的其他语言中,这种情况更加明显:
\documentclass{article}
\usepackage[spanish]{babel}
\begin{document}
\textsf{This is an example,} $ \mathsf{\frac{1}{2} = 0.5} $
The rest of the document is in normal serif font.
\end{document}
答案1
这是预料之中的,因为句点的类型是\mathord
,所以它不会随\mathXY
命令而改变。不过,这个问题很容易解决。
\DeclareMathSymbol{.}{\mathalpha}{operators}{`.}
对于逗号来说,这并不容易,因为我们不能为逗号指定类型\mathalpha
,因为它应该是标点符号。
它更易于使用sansmath
,并且还使许多其他符号变得无衬线。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{sansmath}
\newcommand{\sftextandmath}{\sffamily\sansmath}
\DeclareTextFontCommand{\allsf}{\sftextandmath}
\begin{document}
\allsf{This is an example: $\frac{1}{2} = 0.5$}
This is another example: $\frac{1}{2}=0.5$
\end{document}
答案2
spanish
来自 babel,定义一个特定的宏来改变输出小数点(IE,输入如下总是,一个点.
,然后您可以使用此宏更改输出)。
\usepackage[spanish]{babel}
\spanishdecimal{\textsf{,}}
就我个人而言,我喜欢点本身,所以\spanishdecimal{.}
对我来说就够了(还有其他针对点或逗号的具体宏,但\spanishdecimal
更通用)。