2

Greetings to the distinguished gathering of TeXperts!

My problem is: if a macro is defined with a babel shorthand containing the quote mark (") as an active character, it does not expand when invoked.

MWE (TeXLive 2014 with the latest updates):

\documentclass[11pt]{article}

\usepackage[T2A]{fontenc} 
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

\newcommand{\myname}{А.",С.",Пушкин "--- самый"=самый известный русский поэт.}
\newcommand{\mynamea}{\shorthandon{"}А.",С.",Пушкин "--- самый"=самый известный русский поэт.}

\begin{document}
\myname \par
\expandafter\myname \par
\mynamea \par
\expandafter\mynamea \par
Benchmark: \par
А.",С.",Пушкин "--- самый"=самый известный русский поэт.
\end{document}

For your information, in [russian]{babel}, the following definitions are present:

\declare@shorthand{russian}{",}{\nobreak\hskip.2em\ignorespaces}
\declare@shorthand{russian}{"=}{\nobreak-\hskip\z@skip}

The "--- is a shorthand for Cyrillic text dash, \cdash---. Shorthands not expanded

For some reasons, LaTeX did not expand any of these four (!) commands despite the fact he had been explicitly ordered to. What is the best practice for such occasions?

1 Answers1

0

Quick and dirty solution. There is an option KeepShorthandsActive for babel package that provides the desired result. This is what happens when the respective line in the preamble is changed to \usepackage[russian, KeepShorthandsActive]{babel}: Shorthands expanded as requested

However, such behaviour seems odd. I wonder if such manner of expansion is intentional, or the \myname macro should be rewritten? Can it be done in a cleaner way?

  • It is intentional. Babel delays the activation to the begin of the document to avoid side effects on other packages. If you need a shorthand in the preamble you must activate it, e.g. with \shorthandon. – Ulrike Fischer Jan 30 '15 at 08:02