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.
Asked
Active
Viewed 1.3k times
4
1 Answers
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
Bernhard Kleine
- 861
-
By default those will only work inside
\sior\SIof course, though you can make them available outside these as well, with thefree-standing-unitsclass 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
siunitxdefine 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\sior thefree-standing-unitsoption), 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
siunitx. If you need to write numerical values, it produces a correctunbreakable thin spacebetween number and unit. – Bernard May 17 '16 at 19:06\meteris 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