4

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.

Iuli
  • 471
  • 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. – Torbjørn T. 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

1 Answers1

4

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.)

Torbjørn T.
  • 206,688
  • 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.) – Torbjørn T. 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} – Bernhard Kleine 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. – Torbjørn T. May 24 '16 at 13:51
  • to be used like this:\begin{document}\SI{1}{\dm}\end{document}‌​. Therefore my suggestion. – Bernhard Kleine 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.) – Torbjørn T. May 24 '16 at 13:59
  • The original question was to provide shortcuts for dm and cm. The solution \DM with the defined macro is obviously one of the shortest to think of and which is even better easy to remember. It is also easy to be extended in order to reflect the possibilities of the \SI macros. Therefore I like it and would use it myself. – Bernhard Kleine May 24 '16 at 14:31
  • But your original answer (which still stands) has no mention of that whatsoever. – Torbjørn T. May 24 '16 at 14:35