[Tex/LaTex] Lyx: LaTeX Option clash error


I am new to Lyx and Latex.
I want to write my thesis in Lyx but the template provided by the university is for for LaTeX.

So, here is what I did:

  1. Created a new layout file called mithesis.layout
  2. Created a class document called mitheis.cls in MikTex containing the same code as the cls file provided by the university.
  3. Copied the tex file preamble options into lyx documents's preamble.

Everything is working fine, except for figure floats because I get an error saying There's an option clash for package graphicx

The package graphicx has already been loaded with options:
There has now been an attempt to load it with options
Adding the global options:
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.

I have checked the sty and cls files being used and I cannot find anywhere any reference to the package graphicx. The only place where I found the package is being loaded is in the LaTeX preamble of my Lyx document.

Any idea where else can the package be loaded from? Or any idea on how to solve this kind of issue?


Question also posted in

Best Answer

If I understand correctly, you have added, among other things,


in Document --> Settings --> LaTeX preamble.


When you insert an image in LyX, LyX will add \usepackage{graphicx} to the preamble of the generated .tex file, before the stuff found in Document --> Settings --> LaTeX preamble. Hence, the result is that the complete preamble will have


causing the option clash error. If a package is loaded twice, the options passed to it a second time must be a subset of the options passed the first time, otherwise an error is thrown.

Note also that you shouldn't add the pdftex option to the package, as it's better to let graphicx figure out which driver to use.

Related Question