" with tipa and babel's ngerman / \shorthandoff{"} in a macro
You have to defer gathering the argument:
\newcommand{\myipa}{\begingroup\shorthandoff{"}\myipaI}
\newcommand{\myipaI}[1]{\tipaencoding #1\endgroup}
This will typeset correctly the bit \myipa{"x""x"a"s}
. Of course such a command can't go in the argument of other commands. Should you need it into a section title, say
\shorthandoff{"}
\section{\textipa{"x""x"a"s}}
\shorthandon{"}
Here \myipa
would not work if you need to typeset the table of contents. It's always the same problem: when some characters are gathered as arguments, their category code is fixed.
This however suggests a different approach:
\newcommand{\myipa}[1]{{\shorthandoff{"}\scantokens{\tipaencoding#1\endinput}}}
Or \DeclareRobustCommand
, if you need it frequently in moving arguments; it's always possible to precede \myipa
with \protect
, for one or two cases.