For the German language the babel
package defines a set of shorthand commands that I use quite often. They all start with a quotation mark ("
) which is redefined as an active character. In detail, I'm talking about these commands:
-
a visible hyphen that defines a break point and prohibits other break points. (This is the usual (La)TeX hyphen not a special from Babel.)"=
a visible hyphen that defines a break point and still allows other break points. (A very convinient alternative to 1.)"~
a visible hyphen that must not be used as a break point, like inMess"~, Schätz"~ und Testergebnisse
\-
a conditional hyphen that defines a break point and prohibits other break points. (This is the usual conditional (La)TeX hyphen not a special from Babel.)"-
a conditional hyphen that defines a break point and still allows other break points. (A very convinient alternative to 4. and/or the\hyphentation
-command.)""
a zero-width space that defines a break point. Example:(Mess"~)""Ergebnis
As they are very handy, I also like to use them, if the document language is English. To this end I usually define these shorthands myself in the preamble:
\makeatletter
\initiate@active@char{"}
\addto\extrasenglish{\languageshorthands{english}\bbl@activate{"}}
\addto\noextrasenglish{\bbl@deactivate{"}}
\declare@shorthand{english}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{english}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{english}{""}{\hskip\z@skip}
\declare@shorthand{english}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{english}{"=}{\penalty\@M-\hskip\z@skip}
\initiate@active@char{"}
\addto\extrasamerican{\languageshorthands{american}\bbl@activate{"}}
\addto\noextrasamerican{\bbl@deactivate{"}}
\declare@shorthand{american}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{american}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{american}{""}{\hskip\z@skip}
\declare@shorthand{american}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{american}{"=}{\penalty\@M-\hskip\z@skip}
\initiate@active@char{"}
\addto\extrasusenglish{\languageshorthands{usenglish}\bbl@activate{"}}
\addto\noextrasusenglish{\bbl@deactivate{"}}
\declare@shorthand{usenglish}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{usenglish}{"|}{\textormath{\penalty\@M\discretionary{-}}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{usenglish}{""}{\hskip\z@skip}
\declare@shorthand{usenglish}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{usenglish}{"=}{\penalty\@M-\hskip\z@skip}
\makeatother
The code above is essentially a copy of what Babel does for the German language. This works as expected if the document class is article
, report
, book
and so on.
But it does not work with the beamer
class. With beamer
the quotation mark is not recognized as an active character but printed as is. Why?
MWE:
\documentclass[american]{beamer}
\usepackage[TS1,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,USenglish,main=USenglish]{babel}
\makeatletter
\initiate@active@char{"}
\addto\extrasenglish{\languageshorthands{english}\bbl@activate{"}}
\addto\noextrasenglish{\bbl@deactivate{"}}
\declare@shorthand{english}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{english}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{english}{""}{\hskip\z@skip}
\declare@shorthand{english}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{english}{"=}{\penalty\@M-\hskip\z@skip}
\initiate@active@char{"}
\addto\extrasamerican{\languageshorthands{american}\bbl@activate{"}}
\addto\noextrasamerican{\bbl@deactivate{"}}
\declare@shorthand{american}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{american}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{american}{""}{\hskip\z@skip}
\declare@shorthand{american}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{american}{"=}{\penalty\@M-\hskip\z@skip}
\initiate@active@char{"}
\addto\extrasusenglish{\languageshorthands{usenglish}\bbl@activate{"}}
\addto\noextrasusenglish{\bbl@deactivate{"}}
\declare@shorthand{usenglish}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{usenglish}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}\allowhyphens}{}}
\declare@shorthand{usenglish}{""}{\hskip\z@skip}
\declare@shorthand{usenglish}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{usenglish}{"=}{\penalty\@M-\hskip\z@skip}
\makeatother
\begin{document}
\begin{frame}
\begin{itemize}
\item (sub"~)""protocols
\end{itemize}
\end{frame}
\end{document}
\defineshorthand
. See sec. 1.10 in the manual.