# How do I typeset units like MB, GB (megabytes, gigabytes)?

Is there a simple way to typeset byte units like MB, GB, TB in latex in math mode? How do you typeset 1GB for example?

You can use siunitx, which supports both SI- and binary prefixes. Its main macro, \SI, works in math mode as well as in text:

\documentclass{article}
\usepackage[binary-units=true]{siunitx}

\begin{document}
For example, $x = \SI{1}{\giga\byte}$ or \SI{1}{\gibi\byte}.
\end{document}


See page 38 of the siunitx manual for further information.

• @doncherry Exactly. I would like to those units in math mode. – Rasto Jan 1 '13 at 18:37
• @drasto: It works on my installation. Are you loading the package with the correct option? Are you redefining \byte somewhere? – You Jan 1 '13 at 19:06
• I was using incorrect options. – Rasto Jan 1 '13 at 20:34
• @You: Currently at page 36 in the manual – arc_lupus Apr 29 '18 at 13:30
• @You \usepackage[binary-units]{siunitx} – Tim Kuipers Nov 27 '18 at 14:42