软件包 [square]{natbib} 的选项冲突

软件包 [square]{natbib} 的选项冲突

如果我调用natbib,LaTeX 运行起来没有问题。但是,如果我有以下内容

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

它没有运行,并且出现以下错误:

Latex Error: Option clash for package 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}  

\begin{document}  

答案1

natbib无需使用各种选项重新加载包,只需执行

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

顺便说一下,选项numberssuper相互排斥:选择其中一个,但并非两者兼而有之

答案2

我不知道这是否会产生预期的结果,但以下内容可以在没有选项冲突的情况下进行编译:

\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}

答案3

revtex4本身已经加载。你应该在natbib之前传递选项的原因documentclassnatbib

\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}

相关内容