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!

M. Logic
  • 4,214
  • 4
    While it is easy to change the font (automatically) in math (see https://tex.stackexchange.com/a/7510/2388) in text it would need a virtual font to do the same in text. – Ulrike Fischer Jan 01 '18 at 15:43
  • Doesn't the numprint package do this? – wendy.krieger Jan 01 '18 at 13:43
  • @Ulrike Fischer Thanks although it's not what I want. – M. Logic Jan 02 '18 at 10:33
  • @wendy.krieger No. – M. Logic Jun 17 '18 at 02: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 '18 at 14:59
  • Do you want @UlrikeFischer to answer, saying that what you want can't be done for text (without creating a set of virtual fonts)? Or do you want an answer using a different engine with fontspec? Or ... what kind of answer do you want here, given that no answer can give you what you want? (So I assume you'll comment on any answer 'This isn't what I want.') – cfr Jun 17 '18 at 15:03
  • @cfr In fact, I expressed clearly about what I want in my "GOAL" and "NOTE". Any solution is ok only if it can achieve my requests. – M. Logic Jun 18 '18 at 01:22
  • Not really. What about the tag? Do you want to create a virtual font? Ask for a solution with XeTeX or LuaTeX? Or what? If you want to create a virtual font, the Font Installation Guide will explain how you can do it. But do not expect this to be an easy or quick process: you will have to learn more than you ever wanted to know about traditional TeX fonts in order to create and install the many files you will need. I expect somebody can do something with Lua if you want that. The fontspec tag suggests you might, but you might not know the implications. Otherwise, the answer is you can't. – cfr Jun 18 '18 at 01:46
  • Also, your question does not make clear that you are not prepared to countenance the use of macros to obtain your desired output. Since that's the obvious solution, you are likely to keep getting solutions which are not what you want. – cfr Jun 18 '18 at 01:48
  • @cfr Roughly speaking, the numbers font is default under every font package. What I want to do is under that package to change the numbers' font only. – M. Logic Jun 18 '18 at 02:08
  • @Kuttens There is no 'numbers font' in text. You don't switch fonts when you type a number. You get the number from the current font Maths is different, but text font configuration is not at all the same as maths font configuration. In text, what you get is determined by the currently active font encoding, font family, font series, font shape and font size. That's it. So 'the numbers font is default under every font package' is nonsense. There is no such thing. It doesn't exist. – cfr Jun 18 '18 at 02:31

1 Answers1

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