General question: how do I change the mapping of a single character?
Details: I want all instances of ``, '', and --- to output a left single quote, a right single quote, and an en dash respectively. I need to do this for one of two copies of a document I'm making. The other will retain the default mapping.
Thanks
Fonts & Character Sets ⇒ Changing mapping of single characters
Changing mapping of single characters
Generally, you should find a higher-level solution. The resolving of `` into “ is hard-coded in the font as a ligature. This cannot be easily changed. Consider defining semantic macros like \quote and \dash whose definition you can change easily.
Nevertheless, a crude hack makes it possible to change the meaning of characters. But this will most certainly fail if your document contains anything else than simple text. Sometimes hacks like this are fun to play with, but generally I strongly advise against them because they alter the most basic parts of LaTeX fundamentally and are highly fragile.
Nevertheless, a crude hack makes it possible to change the meaning of characters. But this will most certainly fail if your document contains anything else than simple text. Sometimes hacks like this are fun to play with, but generally I strongly advise against them because they alter the most basic parts of LaTeX fundamentally and are highly fragile.
Code: Select all
\documentclass{article}
\makeatletter
\let\normal@asciigrave`
\let\normal@asciiapos'
\let\normal@asciihyphen-
\catcode96 13
\catcode39 13
\catcode45 13
\def`{\normal@asciigrave\@ifnextchar`\@gobble\@empty}
\def'{\normal@asciiapos\@ifnextchar'\@gobble\@empty}
\def-{\@ifnextchar-\check@emdash\normal@asciihyphen}
\def\check@emdash-{\textendash\@ifnextchar-\@gobble\@empty}
\makeatother
\begin{document}
``aa''---bb
\end{document}