【问题标题】:LaTeX Error: Option clash for package hyperrefLaTeX 错误:包 hyperref 的选项冲突
【发布时间】:2022-06-23 18:38:34
【问题描述】:
\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{banking} 
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}

\usepackage{graphicx}
\usepackage{float}

\usepackage{import}

% links Symbol
\usepackage{bbding,pifont}

\usepackage[hidelinks]{hyperref}

% Redefinition:
\let\orighref\href
\newcommand{\hrefa}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{...code}{#1}}
\newcommand{\hrefb}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{xxx/}{#1}}
\newcommand{\hrefc}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{ccc}{#1}}
\newcommand{\hrefd}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{vvv/}{#1}}
\newcommand{\hrefe}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{vvv}{#1}}
\newcommand{\hreff}[1]{\raisebox{-0.4ex}{\HandRight}\,\orighref{vvv}{#1}}
% end links symbol

% personal data
\name{...}
\title{}                               
\address{..}{}{}
\phone[mobile]{+...4}
\email{xxx@a.com} 
\extrainfo{\hrefd{xc.com}}    
%\photo[64pt][0.4pt]{photo.jpg} 


%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}

错误:

LaTeX Error: Option clash for package hyperref.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.40 \begin{document}
                     
The package hyperref has already been loaded with options:
  [hidelinks]
There has now been an attempt to load it with options
  [unicode]
Adding the global options:
  hidelinks,unicode
to your \documentclass declaration may fix this.
Try typing  <return>  to proceed.

当我尝试转换为 pdf 时,我得到一个空的 html 文件。

【问题讨论】:

  • 您尝试过建议的解决方案吗?
  • 是的,我将hidelinksunicode 添加到\documentclass[11pt,a4paper,sans,hidelinks,unicode]{moderncv} 它建议我添加There has now been an attempt to load it with options [unicode] Adding the global options: ,unicode to your \documentclass declaration may fix this.
  • 一旦您的网址包含任何脆弱的内容,您对\hrefa 等的定义就会崩溃。试试\hrefd{xc#.com},玩得开心...

标签: latex pdflatex overleaf


【解决方案1】:

moderncv 类自动加载hyperref 包。您可以使用\PassOptionsToPackage{hidelinks}{hyperref} 来确保它加载了您想要的选项。

(尽管您的hidelinks 选项不会产生很大的影响,因为moderncv 将链接框的线宽设置为零,因此它们已经不可见)

\PassOptionsToPackage{hidelinks}{hyperref}

\documentclass[11pt,a4paper,sans]{moderncv} 
\moderncvstyle{banking} 
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}

\usepackage{graphicx}
\usepackage{float}

\usepackage{import}

% links Symbol
\usepackage{bbding,pifont}

% personal data
\name{...}
\title{}                               
\address{..}{}{}
\phone[mobile]{+...4}
\email{xxx@a.com} 
%\extrainfo{\hrefd{xc.com}}    
%\photo[64pt][0.4pt]{photo.jpg} 


%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
test

\url{stackoverflow.com}

\end{document}

【讨论】:

  • 是否有一些可能与\let\orighref\href \newcommand 结合以添加符号链接?
  • @emoleumassi 正如您在问题下方的评论中所说,以这种方式重新定义您的链接非常脆弱。使用它们需要您自担风险。
猜你喜欢
  • 1970-01-01
  • 2020-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多