4

I have a macro to define a text:

\def\Title{Mein Titel und Langes"=Wort"=Beispiel}

The dash "= is defined in babel/German and is used to activate the hyphenation in concatenated words.

In titlepage.tex I use \Title to generate a title page. If I put the \def into titlepage.tex I get correct dashes, but if I put \def into main.tex which \include{titlepage} I see "= instead of -.

Werner
  • 603,163
knut
  • 43
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. Do you define \Title before you load babel? It might not work if used in the preamble because the language is not loaded yet (IIRC) and therefore the "= still has it's old definition. The order is important here because the characters must be set active before they are used. – Martin Scharrer Oct 19 '11 at 14:42
  • my order is: 1. \usepackage[ngerman]{babel} 2. \def\Titel{...} 3. \include{titlepage} – knut Oct 19 '11 at 14:53

1 Answers1

3

The problem here is that babel seems to load the language at-begin-document and not right away. Using normal macros which aren't defined yet in a definition of another macro is OK as long you don't use the macro right away. However, active character like " need to be already active, otherwise their passive form is stored in the macro.

I don't know how to tell babel to load the language immideatly. A \selectlanguage doesn't work in the preamble (You can't use\setlanguage' in vertical mode.`). However, manually setting " to be active works well:

\documentclass{article}

\usepackage[german]{babel}

\catcode`\"=\active
\def\Title{Mein Titel und Langes"=Wort"=Beispiel}

\begin{document}

\Title

\end{document}
Martin Scharrer
  • 262,582
  • @knut: As you are new on this site, please note that the answer which helped you the most should be accepted by clicking the tick mark on the right upper side of the answer. This marks the question as concluded and assigns reputation to the answerer and also to you. However, you might want to wait a little after getting a working answer to give other people the chance to provide an even better answer of their own. – Martin Scharrer Oct 19 '11 at 16:26
  • Hm. \selectlanguage throwing an error might be a regression in babel, I'll have to check that at some point. It used to not-complain in 2008 when I wrote http://absatzen.de/babelauthor.sty (which would solve-by-overkill for the present question). – Ulrich Schwarz Oct 20 '11 at 21:14