Text Formattingnumber formatting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
mina
Posts: 12
Joined: Sun Jul 12, 2009 4:48 pm

number formatting

Post by mina »

Hi all,

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
Last edited by mina on Mon Jul 26, 2010 10:07 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10360
Joined: Mon Mar 10, 2008 9:44 pm

number formatting

Post by Stefan Kottwitz »

Hi Mina,

you could use the numprint package.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

number formatting

Post by localghost »

The siunitx package is also a candidate.


Thorsten
mina
Posts: 12
Joined: Sun Jul 12, 2009 4:48 pm

number formatting

Post by mina »

Hi,

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}
Note that the numbers are in German by default, unless you specify another language using the Babel package and the \selectlanguage command (supports English, German, Portuguese, Dutch and French) or use the autolanguage option. See manual.

Cheers,
Mina
Post Reply