Search code examples
rlatexbookdown

bookdown: LaTeX Error: Option clash for package hyperref


I know that "LaTeX Error: Option clash for package hyperref. " solution is in https://tex.stackexchange.com/questions/279964/option-clash-for-package-hyperref I used another tex template 'sjtuthesis.cls', which has used package hyperref as,

./sjtuthesis.cls:83:\RequirePackage[xetex, bookmarksnumbered, colorlinks, urlcolor=black, linkcolor=black, citecolor=black, plainpages=false, pdfstartview=FitH]{hyperref}

But bookdown will add package hyperref automately, too. In generated bookdown.tex file by https://github.com/rstudio/bookdown/tree/master/inst/examples

./_book/bookdown.tex:25:\usepackage[unicode=true]{hyperref}
./_book/bookdown.tex:26:\PassOptionsToPackage{usenames,dvipsnames}{color} % color is loaded by hyperref

so the two lines hyperref clash. I mean, how to avoid packages clash between custom tex template with bookdown inner-used package? How to modify the rmd file? can anyone help me, thank you.


Solution

  • Unfortunately it happens quite often that a given class does not work well together with the default LaTeX template used by rmarkdown. You have to write your own template, c.f. Rmd to PDF compiling error: Package geometry \paperwidth (0.0pt) too short.