2

I have to write a math book and I'm using often the following measurement units: centimeter (cm), decimeter (dm). Can you provide me the shortcut which will output cm and dm. For meter(m) I've found the following shortcut \meter -> m.

3
  • 4
    Use siunitx. If you need to write numerical values, it produces a correct unbreakable thin space between number and unit.
    – Bernard
    May 17 '16 at 19:06
  • \meter is not a standard macro, so you must have included some package that defines it. siunitx, as @Bernard mentions is one such package. May 17 '16 at 19:26
  • OT, but the unit is called 'metre' (I know it's common in the US to spell it 'meter' but in technical writing the international standard applies).
    – Joseph Wright
    May 17 '16 at 20:32
3

When you use siunitx the shortcuts are already there. \dm and \cm are already provided: see page 36 of siunitx manual (version from 2016/03/01). Shorter shortcuts you will not find. (There are two packages siunits and siunitx, I prefer the latter.)

7
  • By default those will only work inside \si or \SI of course, though you can make them available outside these as well, with the free-standing-units class option. (And by the way, there are other packages for units as well, e.g. units.) May 17 '16 at 20:28
  • You could with siunitx define your own shortcuts: \newcommand{\DM}[1]{\SI{#1}{\dm}} and use it as \DM{2.5} May 24 '16 at 13:43
  • Was that addressed to me? I'm not sure what you were trying to say, the point I was trying to make is that \documentclass{article}\usepackage{siunitx}\begin{document}1\,\dm\end{document} will throw an error. May 24 '16 at 13:51
  • to be used like this:\begin{document}\SI{1}{\dm}\end{document}‌​. Therefore my suggestion. May 24 '16 at 13:55
  • Yes, I'm obviously aware of \SI, but your answer says nothing about that (or \si or the free-standing-units option), which I think it should. Looking at the answer alone, a user might think that the code I posted above should work. (Sorry if I'm unclear or nitpicking.) May 24 '16 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.