4

Here is my MWE:

\documentclass[oneside,mtp]{iiitg}

% To add a bookmark in the pdf you can use \pdfbookmark.  You can look up its usage
% in the hyperref package documentation
\usepackage[bookmarksnumbered,pdfpagelabels=true,plainpages=false,colorlinks=true,
linkcolor=black,citecolor=black,urlcolor=black]{hyperref}
\usepackage[hyphens]{url}
\urlstyle{rm}

which gives me the following error on compiling

Option clash for package url. \urlstyle

What is this error and why is it occurring? If you want to see full template and other files you can see it here.

1
  • 4
    For far more line-breaking ability than what's afforded by \usepackage[hyphens]{url}, run \usepackage{xurl}. Oh, and the xurl (and the url) package is best loaded before, not after, hyperref.
    – Mico
    May 17, 2020 at 0:50

2 Answers 2

8

Since the hyperref package loads the url package without the [hyphens] option, you get an option clash. Just move the \usepackage[hyphens]{url} to above where you load hyperref.

(Looking at the url for this answer, I'd say the hyphen option seems vital.)

2

My answer deals with the same error message, but in another context (the one of Beamer presentations). It could be of interest for people like me who had to cross-check several questions/answers to get the things right (like that one, added to the current page).

In that context, the hyperref package is loaded by default, which, in turns, automatically loads the url one. That's why, if you want to use the [hyphens] option on a classic \usepackage[hyphens]{url} declaration, you would get that error message too.

The workaround is to directly pass the option to the \documentclass command, which yields it correctly to the packages that are automatically loaded, like here:

\documentclass[hyphens]{beamer}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .