[Tex/LaTex] Option clash for package inputenc when using Lyx with LaTeX class that already uses inputenc

document-classesinput-encodingslyx

I use Lyx to edit document whose class declares \usepackage[latin2]{inputenc} in its .cls file. While I only use languages for which Lyx uses the same encoding it only adds the same command (\usepackage[latin2]{inputenc}) to preamble of the document. However when I started to use some more languages the command that is added by Lyx to preamble is changed to something like \usepackage[latin9, latin2]{inputenc}. Then I get following error:

LaTeX Error: Option clash for package inputenc. 
\setcounter
           {secnumdepth}{3}
The package inputenc has already been loaded with options:
  [latin2]
There has now been an attempt to load it with options
  [latin9,latin2]

Lyx does not seem to expect that classes may use inputenc themselves. What is the right solution to this problem? Should I prevent Lyx from adding any inputenc to preamble? Is there some LaTeX command that can override \usepackage? Or is this problem of the class I'm using so I should modify it? Perhaps I should delete that \usepackage[latin2]{inputenc} from that class or replace it by something…

Edit

Important note: I'm not really asking for some quick dirty fix (I could figure out some myself). I'm trying to make that class work with Lyx also for other users (writing Lyx layout file for it etc.). So I want to do this the right way. If the problem is poor design of LaTeX class I should fix that one. If it is poor Lyx design I should try to submit bug report or fix it myself.

Best Answer

In LyX you have to go Document -> Language and change the "Coding" from the "default settings for the chosen language" to "Others:" with the argment "default language settings (without inputenc)"

I'm sorry that the option names are not 100% those you'll see there because I use the German user interface but I guess you'll find the correct options.