LaTeX forum ⇒ LyXOption Clash Errors Topic is solved

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

Option Clash Errors

Postby aidin_foroughi » Mon Apr 08, 2013 11:43 pm

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:

  1. \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
  1. \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.

Tags:

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

Postby sommerfee » Tue Apr 09, 2013 7:55 am

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

Postby aidin_foroughi » Tue Apr 09, 2013 7:39 pm

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: 531
Joined: Sat Sep 01, 2012 6:38 am

Postby scottkosty » Tue Apr 09, 2013 7:46 pm

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

Postby aidin_foroughi » Tue Apr 09, 2013 9:47 pm

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: 531
Joined: Sat Sep 01, 2012 6:38 am

Postby scottkosty » Wed Apr 10, 2013 1:11 am

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: 498
Joined: Mon Apr 09, 2007 4:20 pm

Postby sommerfee » Wed Apr 10, 2013 9:05 am

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.


Return to “LyX”

Who is online

Users browsing this forum: No registered users and 4 guests