2

In plots in my thesis I am indicating the depicted quantity's units in square brackets. In the case of a dimensionless quantity, I want to use [-] to explicitly indicate that.

However, I am struggling to find a visually entirely satisfying typeset representation of [-] with Latex.

Out of the alternatives listed below, I favour 1. and 3. In the case of 2. I don't like the mathmode square brackets and the large spacing around the - operator. Regarding 4., the en-dash has an acceptable line thickness. However, the \textbf makes the whole [-] a bit wider.

Yet, in the case of 1., the hyphen, of which I like the line-thickness, is not centered. Regarding 3., on the other hand, the en-dash is a bit skinny.

Preferrably, I'd like to know an easy way of centering the hyphen in between the brackets in 1. Alternatively, increasing the line-thickness of the en-dash in 3. without also increasing its length would be satisfying as well.

Four different ways to typeset [-]1

MWE:

\documentclass{article}
\usepackage[T1]{fontenc}

\begin{document}
\begin{enumerate}
    \item dimensionless $\alpha$ [-]
    \item dimensionless $\alpha\;[-]$
    \item dimensionless $\alpha$ [--]
    \item dimensionless $\alpha$ [\textbf{--}]
\end{enumerate}

\end{document}
4

It's a bit of an overkill but here's a way

\documentclass{article}

\newcommand*{\units}[1]{%
   \mbox{[\ifx&#1&$\vcenter{\hbox{-\kern-.5pt}}$\else#1\fi]}%
}

\begin{document}
Dimensionless $\alpha$ \units{}

Mass $m$ \units{kg}

Compare [-\kern-.5pt]\units{}
\end{document}

enter image description here

5
  • Now, there's only the issue of left-right kerning, LOL. (not sure why the font does that, but I've noticed that for some time and once you see it, you can't unsee it) \newcommand*{\units}[1]{\mbox{[\ifx&#1&$\vcenter{\hbox{\kern.25pt-\kern-.25pt}}$\else#1\fi]}} – Steven B. Segletes May 4 at 10:54
  • @StevenB.Segletes Uh, I had the feeling something was off but I just thought it was a strange rendering of okular (it does this kind of things a lot). That's weird... – campa May 4 at 11:00
  • It's real. Try \fboxsep -1pt\fbox{-} to see it clearly. I figured if the OP niggled about vertical centering, he would be the type to niggle about horizontal centering, as well. – Steven B. Segletes May 4 at 11:03
  • @StevenB.Segletes Now I see what's wrong. It's not about kerning, the box containing the hyphen is larger on the right than the hyphen itself. Try \fboxsep0pt\fbox{-}. That's very peculiar... – campa May 4 at 11:04
  • All glyphs have "sidebearings", that space around the side of a glyph that serves to separate it from adjacent glyphs. Generally, one might expect that space to be symmetrically distributed left and right, but cleary Dr. Knuth had some typographical reason for not doing so with the CM hyphen. – Steven B. Segletes May 4 at 11:26

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.