Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In contrast to \texttt{typewriter} normal text is "connected". When using a forward slash, I get for y/. this:

y/.

while I would like to get something like that:

y$!$/$!$.

which can be accomplished by y$\!$/$\!$., but this is brute-force. Is there a better way to tell LaTeX to "connect" the forward slash with the adjacent characters?

(For fractions there is \sfrac of the xfrac package, but I do not want to typeset fractions here.)

MWE:

\documentclass{minimal}
\begin{document}
y/.

y$\!$/$\!$.
\end{document}
share|improve this question
    
It seems you want to draw the dot below the slash, so that their boxes will intersect. I'm not a pro typist so I might be wrong, but that seems beyond the scope of kerning. –  T. Verron Nov 10 '12 at 14:22
    
@T.Verron: Yes, and also to draw the slash next to the y, therefore their boxes overlap, too. –  Stephen Nov 10 '12 at 14:32
1  
This should be better addressed by changing the kerning table for the font (but it would be a very hard job). –  egreg Nov 10 '12 at 17:22
1  
What you want is essentially automatic kerning. This is obviously beyond the scope of TeX and it's really the font that should provide the kerning information anyway (otherwise you'd have to do one of the brute force methods described below which is ugly and not the point as you rightfully say). Automatic kerning is obviously not ideal in any case but even good fonts sometimes have crappy kerning tables for slashes and all caps. You can try the open source software FontForge which can do automatic kerning: fontforge.org/lookups.html#Pair and you can of course manually tune afterwards. –  Christian Mar 5 '13 at 13:49
add comment

2 Answers

up vote 7 down vote accepted

use of \! may be brute force, but that is what is recommended in the texbook (examples, in math, on p.169; for plain tex, \! doesn't work outside of math, so a negative \kern would be needed).

if this tight spacing were always wanted, a font designer could provide kerning pairs between "y" and slash and between slash and period, but i suspect this is unlikely to be popular.

share|improve this answer
    
Yes, it is an exceptional case and the opposite to cases where automatic kerning between characters is not wished for and an {} between them is necessary. +1 and accepted. (Usually I would wait for some time before accepting, but when the TeXbook gives the answer...) –  Stephen Nov 10 '12 at 14:47
add comment
\documentclass{minimal}
\makeatletter
\catcode`/\active
\def/{\@ifnextchar.{\@withdot}{\string/}}
\def\@withdot.{\ifmmode\!\string/\!
               \else\kern-1.8pt\string/\kern-1.8pt\fi.}
\makeatother

\begin{document}
y\slash.

y/.

$y/.$

\end{document}

enter image description here

share|improve this answer
    
OK, +1 also for this answer. y and . were just examples. My question should read "Whenever it is possible to overlap the boxes of the character before/after a forward slash without overlapping the character itself with the slash, reduce the space between character and slash as much as possible, leaving only a necessary space between, thus that the character and slash are recognized as separated." Just a little bit complicated... –  Stephen Nov 10 '12 at 15:17
1  
@Herbert -- try this with g/. or q/.; the result is not so good. it really does depend on the shape of the character preceding the slash. –  barbara beeton Nov 10 '12 at 16:53
    
@barbarabeeton: that is obvious ... –  Herbert Nov 10 '12 at 17:07
    
@Herbert -- indeed obvious to you and me, but if someone uses it without thinking of the implications, and doesn't check the output, they might be called on the results by someone else reading it. just a suggestion to "think about it first". –  barbara beeton Nov 10 '12 at 21:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.