LyXOption Clash Errors

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
aidin_foroughi
Posts: 3
Joined: Mon Apr 08, 2013 11:24 pm

Option Clash Errors

Post by aidin_foroughi »

Hi everyone. This is my first time posting, and I read the guidelines, but sorry if I'm making any mistakes.

I'm using lyx to write my thesis. I'm trying to do some fancy stuff, like setting the chapter title fonts etc. The problem is, whenever I try to use a package with specific options, if the package is already loaded by lyx, I get an option clash error. Usually I just give up. But this time, I decided to ask it here. So, specifically, I add this code in my preamble:

Code: Select all

\usepackage[{sf,bf}]{titlesec}
Obviously, I get:
The package titlesec has already been loaded with options:
[toctitles]
There has now been an attempt to load it with options
[sf,bf]
I tried using PassOptionsToPackage, as in

Code: Select all

\PassOptionsToPackage{titlesec}{sf,bf}
This time I get no errors, but the font stays the same. This has happened to me before, for other packages, like hyperref, and surprisingly, I couldn't find the answer anywhere.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Option Clash Errors

Post by sommerfee »

aidin_foroughi wrote:I tried using PassOptionsToPackage, as in [...] This time I get no errors, but the font stays the same.
You can't simply replace \usepackage by \PassOptionsToPackage, this will not work:

\usepackage loads the given package with given options. \PassOptionsToPackage will store the given options so they will be passed to the given package when the package is actually loaded. If the package is already loaded, nothing will happen instead since LaTeX does not provide a standard way to pass options to packages already loaded. (Some packages, like hyperref offers commands like \hypersetup for this purpose.)

So if you get an option clash with \usepackage, the package is already loaded (otherwise you would not get an option clash). This could be solved by using \PassOptionsToPackage instead, but to make it actually work \PassOptionsToPackage needs to be moved to a place within the document preamble where the package is not loaded yet. (Usually \PassOptionsToPackage will be placed as very first line, before \documentclass.)
aidin_foroughi
Posts: 3
Joined: Mon Apr 08, 2013 11:24 pm

Option Clash Errors

Post by aidin_foroughi »

Thank you for your response.
sommerfee wrote:\PassOptionsToPackage needs to be moved to a place within the document preamble where the package is not loaded yet. (Usually \PassOptionsToPackage will be placed as very first line, before \documentclass.)
This is easy to do in LaTeX, because all you need to do is to move the line before \documentclass, or even better, load the package with proper options.

I might be mistaken, but the problem is that, in LyX there seems to be no clean way to access "before \documentclass"
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Re: Option Clash Errors

Post by scottkosty »

Hi aidin,

It would be a lot easier to help you if you post a minimal example:

http://wiki.lyx.org/FAQ/MinimalExample

Scott
aidin_foroughi
Posts: 3
Joined: Mon Apr 08, 2013 11:24 pm

Re: Option Clash Errors

Post by aidin_foroughi »

Hi Scott,

Thanks a lot for your response. I think I'll just export it to .tex and change the package options and compile manually from there. I think sommerfee's answer pretty much sums it up. So until LyX provides more options in their GUI for things like hyperref and titlesec etc, this seems to be the only solutions.

Thanks,
Aidin
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Option Clash Errors

Post by scottkosty »

aidin_foroughi wrote:Hi Scott,

Thanks a lot for your response. I think I'll just export it to .tex and change the package options and compile manually from there. I think sommerfee's answer pretty much sums it up. So until LyX provides more options in their GUI for things like hyperref and titlesec etc, this seems to be the only solutions.

Thanks,
Aidin
Thanks for the reply, Aidin. It would indeed be nice if there was a way to configure things like that.

You can file an enhancement request here if you want:
http://www.lyx.org/trac

Scott
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Option Clash Errors

Post by sommerfee »

aidin_foroughi wrote:So until LyX provides more options in their GUI for things like hyperref and titlesec etc, this seems to be the only solutions.
Regarding hyperref: You can easily change options here after the package has been loaded with \hypersetup.
Post Reply