# Problem with polyglossia with “babelshorthands” enabled and minted: .out.pyg file is not generated anymore

Since some years I'm working with polyglossia and the minted package in combination with XeLaTeX and English texts without any problems. Now I had to write a document in German with some code, so I wanted to use polyglossia with German as main language and babelshorthands enabled together with minted. When I try to compile this document, the .out.pyg file is not generated and XeLaTeX throws an error.

This issue disappears if I disable babelshorthands.

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{german}

\usepackage{minted}

\begin{document}
\begin{minted}{python}
x = 1
\end{minted}
\end{document}


The code above throws the aforementioned error. Now remove babelshorthands=true as option from the \setmainlanguage command:

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{german}

\usepackage{minted}

\begin{document}
\begin{minted}{python}
x = 1
\end{minted}
\end{document}


The document should now compile without any errors.

Is this a bug in polyglossia/minted or am I doing something wrong?

-
Loading minted before polyglossia seems to help. –  egreg Mar 30 '13 at 19:04
@egreg: Thanks, that solved the issue for me! –  DigNative Mar 30 '13 at 20:59

There is a difference between babel and polyglossia (which might be considered as a bug, probably): while the former makes shorthand characters active at \begin{document}, polyglossia makes them active immediately.

Since the definition of the internal macro \minted@pygmentize contains ", a problem arises.

Solution: load minted before polyglossia.

-