2

I'd like to use multiple languages in my document (babel), and both ngerman and british should have the nice shorthands active ("` and "'). The british language environment should turn "` into “ and "' into ”. The main language should stay ngerman.

\documentclass{article}
\usepackage[british,ngerman]{babel}
\usepackage[utf8]{inputenc}
% \defineshorthand[british]{"`}{\glqq}
% \defineshorthand[british]{"'}{\grqq}
\addto\extrasbritish{\languageshorthands{ngerman}}

\begin{document}
"`Guten Tag"'

\begin{otherlanguage*}{british}
"`Hello tag"'
\end{otherlanguage*}
\end{document}

Output:

bad quotes

expected output:

enter image description here

I feel totally stupid, this seems to be a pre-beginner's question.

4

The documentation is far from clear, but I don't think there's much more to do than redefining the shorthand to do specific tasks depending on the current language:

\documentclass{article}
\usepackage[british,ngerman]{babel}
\usepackage[utf8]{inputenc}
\addto\extrasbritish{%
  \languageshorthands{ngerman}%
  \useshorthands*{"}%
}

\defineshorthand{"`}{\iflanguage{ngerman}{\glqq}{\lq\lq}}
\defineshorthand{"'}{\iflanguage{ngerman}{\grqq}{\rq\rq}}

\begin{document}
"`Guten Tag"'

\begin{otherlanguage*}{british}
"`Hello tag"'
\end{otherlanguage*}
\end{document}

enter image description here

The problem is in the fact that you're importing the shorthands from ngerman; for instance this would work:

\documentclass{article}
\usepackage[british,ngerman]{babel}
\usepackage[utf8]{inputenc}

\useshorthands*{"}
\addto\extrasbritish{%
  \languageshorthands{british}%
}

\defineshorthand[british]{"`}{\lq\lq}
\defineshorthand[british]{"'}{\rq\rq}

\begin{document}
"`Guten Tag"'

\begin{otherlanguage*}{british}
"`Hello tag"'
\end{otherlanguage*}
\end{document}

Of course, the other German shorthands would be lost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.