[Tex/LaTex] utf8 inputenc vs. babel

babelhungarianinput-encodingsunicode

I'm using TeXLive 2014 on FreeBSD. Every LaTeX-files produce the following warning:

LaTeX Warning: Please use \usepackage[latin2]{inputenc} with
           \usepackage[magyar]{babel}.

"Magyar" is the name of the hungarian in hungarian language 🙂

The relevant part of my documents:

\documentclass[a4paper]{article}
\usepackage[magyar]{babel}
\usepackage[utf8]{inputenc}
\usepackage{t1enc}
\begin{document}
Árvíztűrő tükörfúrógép.
\end{document}

Can I skip this warning or should do something to fix it? Or maybe it's a bug?

Before TeXLive 2014 this warning didn't appear.

Best Answer

As Psyconaut points out an updated version of magyar.ldf is now available on CTAN fixing the problem.

There is some mistake in the tests for input encodings in magyar.ldf. You get the same error message if you choose latin2 as the encoding. The relevant part of magyar.ldf is:

\def\magyar@sugg@ie@lowb#1{\@latex@warning@no@line{Please use \string\usepackage[latin2]{inputenc} with\MessageBreak \string\usepackage[#1]{babel}}}%
  %** @param #1 \@inpenc@undefined@
  %** @param #2 input encoding name
  \def\magyar@sugg@ie@low#1#2#3\vfuzz#4{%
    \def\reserved@b{#2}%
    \def\reserved@a{latin2}%
    \ifx\reserved@a\reserved@b\else
      \def\reserved@a{utf8}%
      \ifx\reserved@a\reserved@b\else
        \def\reserved@a{utf8x}%
        \ifx\reserved@a\reserved@b\else
          \def\reserved@a{cp1250}%
          \ifx\reserved@a\reserved@b\else
            \magyar@sugg@ie@lowb{#4}%
          \fi
        \fi
      \fi
    \fi
  }

It is clear that what is intended is that latin2, utf8, utf8x or cp1250 encodings should not give an error. It looks like this file needs some updating.

Update: more analysis shows that what this command is expecting to receive is

 \@inpenc@undefined@ {latin2}....\vfuzz{#1}

with latin2 replaced by whatever encoding has actually been selected, but what it actually receives is

 \protect \@inpenc@undefined@ {latin2}....\vfuzz{#1}

Thus a simple work around is to change the first line of the definition to

 \def\magyar@sugg@ie@low\protect #1#2#3\vfuzz#4{%

so the pattern matching gobbles the \protect. At this stage, I suggest you copy magyar.ldf to your working directory or local texmf tree and make this change in that copy.

Update pts points out that the above does not work in old versions of babel. I can't test that, but his suggestion to change the definition to

\def\magyar@sugg@ie@low#1\@inpenc@undefined@#2#3\vfuzz#4{%

which apparently works in all versions. This has now been included in the version of magyar.ldf on CTAN, so the recommended action now is to update to that version.

Related Question