[Tex/LaTex] 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.

Árvíztűrő Tükörfúrógép.

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);

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.

Best Answer

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...


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

Related Question