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.

Some pairs of glyphs look more visually appealing when a kern is inserted between the glyphs. For instance, if the word Calabi–Yau is typeset with a font that does not include kerning information for the pair (–,Y), the space between the end of the en-dash and the stem of the letter Y is too large. Compare the results of Calabi--Yau without or with a kern:

Calabi–Yau with differenti kernings

\documentclass{article}
\begin{document}
Calabi--Yau
Calabi--\kern-.15em Yau
\end{document}

Is there a way to automatically insert such a kern, preferably by inserting some code in the preamble, and no extra markup in the document?

share|improve this question
    
microtype has a similar option but I'm even scared to open the manual considering my font related skills.. –  percusse Dec 21 '12 at 2:47
add comment

1 Answer 1

up vote 12 down vote accepted

That probably will break all sort of things …

… for example \kern--.15em and \csname --Y\endcsname.

Related: Easily assign undefined ligatures with pdfLaTeX?

Code

\documentclass{article}
\usepackage[english]{babel}
\makeatletter
    \languageshorthands{english}
    \initiate@active@char{-}
    \defineshorthand{--}{%
        \char`-\char`-%
        \@ifnextchar Y{\ifmmode\else\kern-.15em\fi}{}%
    }
\newcommand*{\activateendashYligature}{\bbl@activate{-}}
\newcommand*{\deactivateendashYligature}{\bbl@deactivate{-}}
\makeatother
\activateendashYligature
\begin{document}
Calabi--Yau (\verb|Calabi--Yau|) \par
Calabi--\kern-.15emYau (\verb|Calabi--\kern-.15emYau|) \par
Calabi--{}Yau (\verb|Calabi--{}Yau|)\par
Calabi-Test (\verb|Calabi-Test|)

$ --Y = -{}-Y $ (\verb|$ --Y = -{}-Y $|) \par
--Y $\to$ \deactivateendashYligature --Y \par% turning it off
$ --Y = -{}-Y $ (\verb|$ --Y = -{}-Y $|)\par
\end{document}

Output

enter image description here

share|improve this answer
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.