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?
2 Answers
You can use siunitx, which supports both SI and binary prefixes (the latter, via the package option binary-units).
You can even define your own units via \DeclareSIUnit (though that is not necessary here since binary units are already defined in the library). Its main macro, \SI, works in math mode as well as in text:
\documentclass{article}
\usepackage[binary-units]{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.
- 1,939
- 6,713
- 2
- 29
- 27
From documentation: "In version 3, the document commands have been revised to be more descriptive. As such, the commands \SI, \SIlist, \SIrange and \si remain available but are not recommended for use in new documents. Use the new \qty... commands instead"
\documentclass{article}
\usepackage{siunitx}
\begin{document}
For example, \qty{1}{\giga\byte}.
For example, \qty{50}{\mega\byte}.
\end{document}
siunitxoptionbinary-units... can you explain why? – Zarko Jul 23 '22 at 04:41