# Loading babel with the 'hungarian' (magyar) option breaks 'pygments' code highlighting

Given the following TeX file everything works as expected: the (Hungarian) text Árvíztűrő Tükörfúrógép typesetted as expected and the code snippet also formatted brilliantly.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{verbments}
\begin{document}
\section{Text}
Árvíztűrő Tükörfúrógép.

\section{Java}
\begin{pyglist}[language=java]
public static void main(String[] args) {
int sum = 0;
for (int i = 0; i < 0; i++)
sum += i;
System.out.format("Sum: %s.\n", sum);
}
\end{pyglist}
\end{document}

However if I specify that I want to use the Hungarian babel package with \usepackage[magyar]{babel}, I receive some cryptic errors (possibly related to the code generated by Pygments). (The log file containing the actual error message can be found here.)

I use verbments in this sample, but the same thing applies to minted.

Edit.: I forgot to mention, that loading any babel package (like English, German, etc.) does not results in errors.

Second edit.: I forgot to phrase a question, so here I go: what could be the problem, and what could be the solution? I'm utterly confused.

-

Ok, I've found the solution.

The Hungarian babel package redefines some active characters (whatever those would be) which characters are used by the Pygments library to generate LaTeX code.

One has to use the magyarOptions (before loading the babel package) and set the active=none option (which means something like: do not use or redefine active characters - the ` [backtick] is used as an active character by the way). shorthandcs=none has to be set along the way, because the package complains otherwise...

\def\magyarOptions{defaults=prettiest,active=none,shorthandcs=none}

I've ruined a whole day with this, I hope someone makes good use of it!

-
You should mark your answer as "accepted" to show that this is the preferred way. –  topskip Sep 17 '11 at 20:19
I've just registered to TeX Exchange, so I've to wait for a couple of hours before I can do that. –  Kohányi Róbert Sep 18 '11 at 6:16
welcome here! I hope you enjoy tex.se as much as I do. –  topskip Sep 18 '11 at 6:38
I have the exact same problem, and your solution does not work for me. I use a fairly old version of TeX Live (2009), can that be the problem? –  KovBal Sep 22 '12 at 12:41
@KovBal After answering my own question a year ago I abandoned Pygments and minted altogether, so I'm not sure. Anyway, I went with listings instead. It is much easier and faster to use than other solutions. –  Kohányi Róbert Sep 22 '12 at 14:07