[Tex/LaTex] Using “German” quotation marks inside \newcommand

babelexpansionmacrospunctuation

Possible Duplicate:
babel shorthand "| doesn’t work in macros

I know there is a deeper non-understanding of LaTeX mechanics at work here, but I have no idea how to phrase my question to cover the general case, sorry.

\documentclass{scrbook}
\usepackage[ngerman]{babel}

% Trivial case, the "real" macro is a *bit* more involved
\newcommand{\mymacro}[1]{"`#1"'}

\begin{document}

"`Foo"'
\mymacro{Bar}

\end{document}

"Foo" gets typeset as expected, with the correct "German" quotation marks. But "Bar" gets typeset verbatim:

"`Bar"'

Apparently, the quotation marks "transformation" doesn't work inside \newcommand.

Since I never really understood what the more "magic" LaTeX commands (like \relax, \detokenize or \makeatletter) really were about, or how the underlying TeX really works, I'm stuck and cannot figure out what I need to make the quotation marks inside the macro work properly

Best Answer

The solution here is easier than in the "duplicate" question, because you do want quotation marks, instead of other effects of the " character.

For this you can use the alternate commands \glqq and \grqq defined by babel[ngerman] for the quotation marks.

\documentclass{scrbook}
\usepackage[ngerman]{babel}

% Trivial case, the "real" macro is a *bit* more involved
\newcommand{\mymacro}[1]{\glqq #1\grqq}

\begin{document}

"`Foo"'
\mymacro{Bar}

\end{document}