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 https://latex.org/forum/viewtopic.php?f=19&t=31294


2 Answers 2


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.

  • Yes, that's right I have that line in my preamble. Thanks for the info. So it means pdftexis just a driver to generate the image for the pdf and will not interfere with the template itself, right?
    – user44756
    Feb 28, 2018 at 11:43
  • 1
    @user44756 Not sure what you mean by "interfere". As I understand it the drivers are what are actually responsible for placing the image into the output, and they are different from engine to engine. When you pass the pdftex option you're specifying that the driver for the pdftex engine should be used, meaning that if you were to use luatex or xetex to generate the output instead, it probably wouldn't work. If the driver is not specified, graphicx will pick the correct driver depending on which engine is used. Feb 28, 2018 at 11:50

My issue was different. I had one master document with multiple children and when I used float graphics in the child, I got this error. The solution was to go to Document -> Document Settings -> Document Class -> Graphics Driver to default in all child documents (I accidentally had it different in my master and child).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.