3

If I call natbib, LaTeX runs with no problem. However, if I had the following

\usepackage[square, comma, numbers, sort&compress, super]{natbib}                                                   

it does not run and the following error appears:

Latex Error: Option clash for package natbib        

The complete beginning of the document is:

\documentclass[preprint,showpacs,preprintnumbers,showkeys]{revtex4}

\newcommand{\classoption}[1]{\texttt{#1}}   
\newcommand{\macro}[1]{\texttt{\textbackslash#1}}  
\newcommand{\m}[1]{\macro{#1}}  
\newcommand{\env}[1]{\texttt{#1}}  

\usepackage[T1]{fontenc}  
\usepackage{graphicx}  
\usepackage{epstopdf}  
\usepackage{bm}  
\usepackage{color}  
\usepackage{natbib}
\usepackage[square,                                                     
comma,                                                                              
numbers,                                                                            
sort&compress,                                                              
super]{natbib}  
\renewcommand{\thefootnote}{\fnsymbol{footnote}}  
\usepackage{amssymb,amsmath,amsfonts}  
\usepackage[hang,scriptsize,tight]{subfigure}  

\begin{document}  
  • This happens when a package you try to use is required by another package or your class, but with different options. You can try \PassOptionsToPackage{<option>}{<package>}. – Skillmon Apr 29 '17 at 18:33
  • Add the options to those for \documentclass; but I doubt the journal editors will be happy to see such changes. – egreg Apr 29 '17 at 21:01
6

Instead of (re)loading the natbib package with various options, simply execute

\usepackage{natbib}
\setcitestyle{square, comma, numbers,sort&compress, super}

By the way, the options numbers and super and mutually exclusive: choose one or the other, but not both.

  • 1
    Read your comment to my answer :-) – user2478 Apr 30 '17 at 7:18
  • Thank you :). Now it does run with no clash error. Unfortunately it does not do what I thought it would. I want to have superscript citations with square brackets (wikipedia style) but now im a bit lost on how to do it. Maybe you can help me again :) – joao filipe horta belo da silv Apr 30 '17 at 11:29
  • @joaofilipehortabelodasilv - To generate numeric superscript-style call-outs surrounded by square brackets, don't specify the option numbers. – Mico Apr 30 '17 at 21:17
  • Dear @Mico Thank you :) Now, it is almost working good: they already appear as superscripts, however they are not surrounded by square brackets as I need. Im sorry to bother you again but if you can tell me what else could I do, it would be great. At the moment I have something like this: – joao filipe horta belo da silv Apr 30 '17 at 22:09
  • 1
    @Mico to be simpler. Just this below matters I think. \documentclass[preprint,showpacs,preprintnumbers,showkeys{revtex4} \usepackage{natbib} \setcitestyle{super,comma,sort&compress,square} – joao filipe horta belo da silv Apr 30 '17 at 22:21
2

I don't know whether this gives the desired results, but the following will compile without the option-clash:

\PassOptionsToPackage{square,comma,numbers,sort&compress,super}{natbib}
\documentclass[preprint,showpacs,preprintnumbers,showkeys]{revtex4}

\newcommand{\classoption}[1]{\texttt{#1}}   
\newcommand{\macro}[1]{\texttt{\textbackslash#1}}  
\newcommand{\m}[1]{\macro{#1}}  
\newcommand{\env}[1]{\texttt{#1}}  

\usepackage[T1]{fontenc}  
\usepackage{graphicx}  
\usepackage{epstopdf}  
\usepackage{bm}  
\usepackage{color}  
%\usepackage{natbib}
%\usepackage[square,                                                     
%comma,                                                                              
%numbers,                                                                            
%sort&compress,                                                              
%super]{natbib}  
\renewcommand{\thefootnote}{\fnsymbol{footnote}}  
\usepackage{amssymb,amsmath,amsfonts}  
\usepackage[hang,scriptsize,tight]{subfigure}  

\usepackage{blindtext}

\begin{document}  
\Blinddocument
\end{document}
  • Thank you very much! As I said above, unfortunately it does not do what I thought it would. I want to have superscript citations with square brackets (wikipedia style) but now im a bit lost on how to do it. Maybe you guys can help me again – joao filipe horta belo da silv Apr 30 '17 at 11:32
1

revtex4 itself already loads natbib. The reason why you should pass the options before documentclass to natbib

\PassOptionsToPackage{square,comma,numbers,sort&compress,super}{natbib}  
\documentclass[preprint,showpacs,preprintnumbers,showkeys]{revtex4}

\newcommand{\classoption}[1]{\texttt{#1}}   
\newcommand{\macro}[1]{\texttt{\textbackslash#1}}  
\newcommand{\m}[1]{\macro{#1}}  
\newcommand{\env}[1]{\texttt{#1}}  

\usepackage[T1]{fontenc}  
\usepackage{graphicx}  
\usepackage{epstopdf}  
\usepackage{bm}  
\usepackage{color}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}  
\usepackage{amssymb,amsmath,amsfonts}  
\usepackage[hang,scriptsize,tight]{subfigure}  

\begin{document} 
foo
\end{document}
  • For the sake of good housekeeping, should the lone \usepackage{natbib} be deleted (or commented out) as well? Separately, I'd put in a note to exhort the OP not to specify mutually exclusive options, such as numbers and super. He/she should set one or the other option, but not both... – Mico Apr 29 '17 at 21:40
  • Thanks Mico, I deleted the line, it was by mistake there. I do not use natbib, so I leave it to the user to use the right optional arguments – user2478 Apr 30 '17 at 7:17
  • Thank you very much! As I said above, unfortunately it does not do what I thought it would. I want to have superscript citations with square brackets (wikipedia style) but now im a bit lost on how to do it. Maybe you guys can help me again – joao filipe horta belo da silv Apr 30 '17 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.