# Uneven spacing around a hyphen in sans-serif?

I am used to writing the names of categories in sans-serif. Thus, for the category of R-modules, I have been using

$R\textrm{-}\textsf{Mod}$


However, the kerning/spacing this produces has never been pleasing (click for larger version):

Playing around a bit, I think maybe I'm not crazy, but perhaps there's something actually wrong with how the hyphen is being spaced in sans-serif. For example, the following code

\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsfonts,graphicx}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
M-M \vspace{-0.45cm}
\rotatebox{180}{M-M}
\end{document}


produces (click for larger version):

I'm not sure how to calculate lengths in LaTeX, but just by putting a ruler on my screen, I'm sure this is uneven.

Now, I wouldn't expect it to be even in the usual serif font, because then M is not a fully symmetric letter, but in the sans-serif font, it seems to me that M is completely symmetric and should be spaced as such.

So, I suppose I have three questions:

1. Is this how it is intended to look, or am I doing something wrong?
2. While it seems like an error to my sensibilities, is there a reason why it might have been intentionally designed this way?
3. How can I get the spacing on each side of the hyphen to be equal in sans-serif, particularly for my original goal of writing the category of R-modules?
-
welcome to tex.sx! I inlined the images to save people following links (as a new user you are not able to do that) –  David Carlisle Mar 19 '13 at 19:49
@David: Thanks for your help! I edited the question so that now people can click for the larger versions. –  Zev Chonoles Mar 19 '13 at 19:52
Typing \setlength{\fboxsep}{0pt}\fbox{-} will show that the hyphen is not centered. You can always write -\kern-0.5pt to close up some space. Hyphens have to serve in many places, and several letters are more open to the right, so this might be a reason for the design decision. –  Andrew Swann Mar 19 '13 at 20:02
–  Stephen Mar 19 '13 at 20:15

Mico's shown a possibility of using one of the unicode TeX engines, but to answer you explict questions, and using pdftex, you are not doing anything wrong, and TeX isn't adding space anywhere (as you can see from the log output generated by the code below. the side bearings on teh M are equal, but the - is not centred. TeX has no knowledge of this, to TeX every character is a rectangular box given by the font metrics, it has no information about which part of that rectangle is white.

A modified version of your example showing the original hyphen and then one shifted (by eye) to be centred, and finally raised a bit if it is being used with capitals.

\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsfonts,graphicx}
\renewcommand{\familydefault}{\sfdefault}
\large
\begin{document}
\showoutput

M-M

\fbox{M}\fbox{-}\fbox{M}

\vspace{-1.5em}

\rotatebox{180}{\fbox{M}}%
\rotatebox{180}{\fbox{-}}%
\rotatebox{180}{\fbox{M}}

\newdimen\fudgehy
\fudgehy=.02em
\fbox{M}\fbox{\kern\fudgehy-\kern-\fudgehy}\fbox{M}

\vspace{-1.5em}

\rotatebox{180}{\fbox{M}}%
\rotatebox{180}{\fbox{\kern\fudgehy-\kern-\fudgehy}}%
\rotatebox{180}{\fbox{M}}

M\kern\fudgehy-\kern-\fudgehy M

M\raisebox{.1ex}{\kern\fudgehy-\kern-\fudgehy}M

\end{document}

-
Thanks for your answer, David! Interesting; so the issue is ultimately that the hyphen is just not centered in its box. Is there a typographical reason for this, or is it poor design? How can I (and would it be advisable to) make all hyphens in my document have the extra bit of kerning on the left, both in math mode (like with R-Mod) and text mode? –  Zev Chonoles Mar 19 '13 at 22:15
@user27638 You can't do anything about the hyphens in automatically hyphenated words so I wouldnt try to do anything too globally it's bound to break something but where you have font changes or it's particularly bad match for other reasons you can define a command that encapsulates whatever fine adjustment you prefer. so perhaps \modcat{R} might make your R-mod with whatever fine tuned spacing you need. –  David Carlisle Mar 19 '13 at 22:20
@user27638 Or of course you could experiment with other fonts that computer modern. This is entirely a feature of the font. –  David Carlisle Mar 19 '13 at 22:22

I would argue that the reason that your "R-Mod" looks so unbalanced is not primarily because the hyphen isn't centered. Rather, it's because the cap-heights of the serif/italic-R and sansserif/upright-M letters are noticeably different.

Consider the following alternative MWE, which uses the fontspec package to equalize the cap-heights of the serif and sans-serif fonts used in the document. I'd say that, as a result, the "R-Mod" string looks a lot more balanced and that the asymmetry in the placement of the hyphen character also appears to be much less pronounced. (Note that the MWE requires XeLaTeX or LuaLaTeX to compile.)

My uptake: If one wishes to mix serif and sans-serif letters in close proximity, it's essential to match their sizes appropriately.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setsansfont[Scale=MatchUppercase]{Latin Modern Sans}
\usepackage{amsmath}
\newcommand*{\Rmod}{\text{\textit{R}-\textsf{Mod}}}
\begin{document}
\Rmod
\end{document}

-