10

I got the problem, that links in \url only break in LyX when there is a \ character in it. I found the solution to add \usepackage[hyphens]{url} to my preamble.

But the problem is, LyX loads the package url with no options, and I get an error. How can I solve this?

yo'
  • 51,322
uloco
  • 223
  • Welcome to TeX.SX! I believe you can somehow modify the document preamble in LyX (I've never used it so I don't know the details). You can add the line \PassOptionsToPackage{hyphens}{url} before \documentclass and you should be fine :) – yo' Oct 30 '13 at 13:40
  • I tried, doesn't seem to work... Perhaps my solution isn't right. – uloco Oct 30 '13 at 13:45
  • 1
    @tohecz I don't think you can add anything before \documentclass in LyX. You can add options to the document class however, which will also pass it to all packages (right?). – Torbjørn T. Oct 30 '13 at 13:49
  • @TorbjørnT. Jees, all options to class are passed to all packages as well, as long as the packages are loaded after the class. – yo' Oct 30 '13 at 13:51
  • THANKS! I just inserted hyphens in the options and it worked! – uloco Oct 30 '13 at 13:52
  • But now i got the problem, that Links are just clickable in the first line, and the browser opens the wrong page -.- – uloco Oct 30 '13 at 13:53
  • 1
    Can you illustrate your problem via an example? Adding a screenshot of your LyX editor interface (or a link to the screenshot) would help. Also, when I add \usepackage[hyphens]{url} in the LaTeX Preamble in LyX, the option is loaded correctly. – Herr K. Oct 30 '13 at 16:37
  • Solved! I forgot using \usepackage{hyperref} and I loaded the old package subfigure instead of subfig. Now everything works fine. – uloco Oct 31 '13 at 06:49

2 Answers2

4

A workaround for this problem would be to add hyphens to the document class options, in Document --> Settings --> Document class. Any options added to the document class will also be applied to all packages loaded later.

Torbjørn T.
  • 206,688
3

According to this answer, LyX 2.2 now supports putting into Document > Settings > Local Layout:

PackageOptions url hyphens

I have successfully used this with todonotes, but haven't tried it with your specific problem.