4

I am writing a book in the following codes:

\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}

After compiling, they are the following way,

enter image description here

My GOAL is to change the numbers' in both texts and math modes to times but not to change to the font of the other texts and math modes. The following is the effect that I want to get. enter image description here NOTE: 1. I don't want to change the font of other non-number texts or non-number math mode. 2. The numbers I talked about here consist of page numbers, enumerating numbers, mathematical numbers and so on.

How can I get these? Any help would be appreciated and welcome!

11
  • Doesn't the numprint package do this? Jan 1, 2018 at 13:43
  • 4
    While it is easy to change the font (automatically) in math (see tex.stackexchange.com/a/7510/2388) in text it would need a virtual font to do the same in text. Jan 1, 2018 at 15:43
  • @Ulrike Fischer Thanks although it's not what I want.
    – M. Logic
    Jan 2, 2018 at 10:33
  • @wendy.krieger No.
    – M. Logic
    Jun 17, 2018 at 2:16
  • You're tagged this 'fontspec', but aren't using it. Are you saying this is an option? You would need to compile with Xe/LuaTeX in that case, rather than (pdf)TeX. If not, the tag is erroneous and just confuses things, as you'll likely get answers you don't want.
    – cfr
    Jun 17, 2018 at 14:59

1 Answer 1

2

The SIUNITX package is the way to go.

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}

Resulting in this:

enter image description here

3
  • Could you give a direct way? Thanks very much!
    – M. Logic
    Jan 1, 2018 at 14:19
  • I've changed my answer. Jan 1, 2018 at 19:20
  • This isn't what I want...
    – M. Logic
    Jan 2, 2018 at 10:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .