Text Formatting ⇒ number formatting
number formatting
I have been googling this but couldn't find anything.
Is there a way to make LaTeX take care of formatting numbers? For example, if I write 165010621 in my tex file I'd like to see 165,010,621 in my PDF. It's not really a big deal, I can add the commas manually, but I am really curious whether something exists to do it automatically.
I use report class and PDFLaTeX.
Cheers,
Mina
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- Joined: Mon Mar 10, 2008 9:44 pm
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
number formatting
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
number formatting
Thank you guys. I tried the numprint packages. An example:
Code: Select all
\documentclass[a4paper,10pt]{report}
\usepackage[english]{babel}
\usepackage{numprint}
\begin{document}
\numprint[m^2]{48524378} (\numprint{4.8e-7}, or \numprint[mln]{48.5}) and \numprint[\%]{36.19}.
\selectlanguage{english}
\numprint[nt]{48524378} (\numprint{4.8e7}, or \numprint[mln]{48.5}) and \numprint[\%]{36.19}.
\npdecimalsign{\ensuremath{\cdot}}
\npthousandsep{,}
\npproductsign{*}
\numprint[nt]{48524378} (\numprint{4.8e7}, or \numprint[mln]{48.5}) and \numprint[\%]{36.19}.
\end{document}
Cheers,
Mina