1

Can we define a macro for writing "10^power" using a single command?

like I am using following macros for various units.

\documentclass[a4paper,12pt,oneside,openright]{report}
\usepackage{listings}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{appendix}
\usepackage[T1]{fontenc} 

\usepackage{xspace}
\newcommand*{\eg}{\emph{e.g.}\@\xspace}
\newcommand*{\ie}{\emph{i.e.}\@\xspace}
\newcommand*{\flow}{$m^3/s$\@\xspace}
\newcommand*{\visc}{$Pa.s$\@\xspace}
\newcommand*{\dens}{$kg/m^3$\@\xspace}

so can we do that?

4
  • 2
    In math mode or in text? You may also want to look at the siunitx package for units (which are traditionally set upright and not in math italics).
    – moewe
    Jun 22, 2018 at 8:01
  • Actually in both, because it is really hectic to write anything like "1.489X10^-15" for 15 to 20 times. Jun 22, 2018 at 8:03
  • 3
    Then as mentioned use siunitx, then \num{123.25e-25} is enough plus you can control from the preamble how the e should work. See the siunitx manual for details
    – daleif
    Jun 22, 2018 at 8:18
  • 1
    I'd also rather suggest the siunitx package, and then you might introduce some shortcut suiting you. Note that your present definitions of the units in math mode $...$ are wrong: units must be upright: $\mathrm{kg}/\mathrm{m}^3$ and so on.
    – campa
    Jun 22, 2018 at 8:18

1 Answer 1

4

Something like this?

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "\ensuremath" macro
\newcommand\tenpow[1]{\ensuremath{{\times}10^{#1}}}
\begin{document}
$1.487\tenpow{-15}$  1.23\tenpow{45}
\end{document} 

You're obviously free to come up with another name than \tenpow for the LaTeX macro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .