2

Although this question is very simple in the substance, I would like to ask it anyway. Visibly if I use the comma within the mathematical environment you can see a small space that I have underlined with a red horizontal line.

%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}
\[a=(3,15 \pm 0,22) \text{ cm}\]
\end{document}

enter image description here

Surely the space, with the use of siunitx package it will disappear as it is a specific package for units and decimal numbers. To remove this space I use the command to have a negative space \!. In fact I obtain this:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}
\[a=(3,\!15 \pm 0,\!22) \text{ cm}\]
\end{document}

Are there any other alternatives without the use of siunitx package? Are there possible contraindications if you do not use this package?

Sebastiano
  • 54,118
  • 2
    Yes: just type $3{,}15$, for instance. – Bernard Feb 07 '20 at 21:52
  • 2
    Related: https://tex.stackexchange.com/questions/303110/avoid-space-after-thousands-separator-in-math-mode – Steven B. Segletes Feb 07 '20 at 21:53
  • @StevenB.Segletes Thank you very much to you and Bernard. I have upvoted all of the link. I'm not very familiar with siunitx package, but with Bernard's suggestion or your link I won't have problems with spaces either with commas or exponential notation? If there are further elements that I don't know, I'm very happy to know them. Otherwise I'll close my question with the closing of it. – Sebastiano Feb 07 '20 at 21:57
  • 2
    Is there a reason why you don’t want to use siunitx? In my eyes it is a great package for everything regarding numbers an units an it’s quite flexible while providing a simple input syntax. I.e. \num{3e-2} instead of 3 \cdot 10^{-3} and with the former it is even possible to combin all exponents of 10 to a single one … and for errors you can use the short syntax 3,15(22) and have it printed as in your example. – Tobi Feb 07 '20 at 22:06
  • 2
    I do not use siunitx myself...however, the problem here, I think, is independent of that package, and is related to the fact that , is of math category \mathpunct. – Steven B. Segletes Feb 07 '20 at 22:06
  • 2
    If most of the math-mode commas in your document are decimal markers, definitely load the icomma package to change the default mode of commas from math-punct to math-ord. To restore the math-punct behavior of commas, just leave a space after them. E.g., change $[0,1]$ to $[0, 1]$ to typeset the interval with an appropriate amount of whitespace after the comma. – Mico Feb 07 '20 at 22:06
  • @Tobi Hi, My question arises because it takes a long time to write the decimal digits and units of measurement when I prepare my tests for my students using siunitx.I should study the manual :-( it's true. Thank you for your comment. – Sebastiano Feb 07 '20 at 22:09
  • 1
    @Sebastiano: Well, for me the input for siunitx seems much shorter, thus faster … in my editor I have a keyboard shortcut for \num and \SI so these are only on “click” away and then I just have to enter the numbers. (I wrote a blog post about this some time ago: https://tobiw.de/tbdm/siunitx but it is in German …) – Tobi Feb 08 '20 at 11:15
  • @Tobi I'll use the translator even if it's in German :-):-) Thank you very much for your cooperation and I really appreciate your work which I think is the same as mine. You are very good user with LaTeX. I'm always in a hurry and I will probably use it in the future. Thank you always. – Sebastiano Feb 08 '20 at 13:27
  • 1
    @Sebastiano Thanks :-) – Tobi Feb 08 '20 at 14:33

0 Answers0