如何以全局方式仅更改文本和数学模式的数字字体?

如何以全局方式仅更改文本和数学模式的数字字体?

我正在用以下代码写一本书:

\documentclass[12pt,b5paper]{ctexbook}
\usepackage[english]{babel}
\usepackage{amsfonts}
\usepackage[T1]{fontenc}
\usepackage[garamond]{mathdesign}
\begin{document}
The numbers in texts are
\begin{center}
0123456789,
\end{center}
and in math environment they are also
\[0123456789.\]

\end{document}

编译后,它们如下所示,

enter image description here

我的目标是将文本和数学模式中的数字更改为但不改变其他文本和数学模式的字体。以下是我想要得到的效果。 enter image description here 笔记:1. 我不想更改其他非数字文本或非数字数学模式的字体。2. 我在这里谈到的数字由页码、枚举数字、数学数字等组成

我如何获得这些?任何帮助都将不胜感激和欢迎!

答案1

SIUNITX 包是最佳选择。

https://www.dpg-physik.de/dpg/gliederung/junge/rg/wuerzburg/Archiv/WS%202011-12/LaTeX/siunitx.pdf

\documentclass[11pt]{article}
\usepackage[decimalsymbol=comma,exponent-product = \cdot,per-mode=fraction]{siunitx}
\sisetup{load-configurations = abbreviations}
\sisetup{quotient-mode = fraction} 
\parindent=0pt 
\usepackage[sfdefault]{FiraSans}

\begin{document}
This is a number is in the same font as the default font 12351235\\
this is a number as a number is in another font \num{1235123} \\
\num{2,25e6}
\end{document}

结果是:

enter image description here

相关内容