在我目前的工作中,我似乎无法获得这些包裹harvard
并hyperref
正确地协同工作。
一个小例子:
\documentclass[12pt,a4paper]{scrreprt}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage{times}
\usepackage[hyphens]{url}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{listings}
\usepackage{fancyhdr}
\usepackage{cite}
\usepackage{harvard}
\citationmode{abbr}
\bibliographystyle{dcu}
\usepackage{setspace}
\onehalfspacing
\usepackage[pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}]{hyperref}
\hypersetup{colorlinks=false}
\begin{document}
test
\end{document}
我收到的错误信息是:
! LaTeX Error: Missing \begin{document}.
紧接着 的那行\usepackage[...]{hyperref}
。
只要我删除harvard
包,文档就可以完美编译。删除hyperref
包时也会发生同样的情况。
令我烦恼的是:当我从中删除选项时\usepackage[...]{hyperref}
,它也能正常工作。
有人知道我面临什么问题吗?
编辑:
有时,更详细地阅读错误日志会有所帮助。似乎缺少 \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.43
The package hyperref has already been loaded with options:
[pdftex]
There has now been an attempt to load it with options
[pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}]
Adding the global options:
pdftex,pdfborder={0 0 0},pdftitle={the document title},pdfauthor={the author}
to your \documentclass declaration may fix this.
我不知道为什么,但当我使用 pdflatex 编译文档时,该包似乎会自动加载。我最终使用了
\usepackage{hyperref}
\hypersetup{colorlinks=false}
\hypersetup{pdfborder={0 0 0}}
\hypersetup{pdftitle={\thetitle}}
\hypersetup{pdfauthor={\theauthor}}
编辑2
根据 Marco Daniel 的要求:
*File List*
scrreprt.cls 2009/07/24 v3.04a KOMA-Script document class (report)
scrkbase.sty 2009/07/24 v3.04a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
scrbase.sty 2009/07/24 v3.04a KOMA-Script package (KOMA-Script-independent
basics and keyval usage)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty 2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty 2009/06/08 v3.03b KOMA-Script package (handling toc-files)
scrsize12pt.clo 2009/07/24 v3.04a KOMA-Script font size class option (12pt)
typearea.sty 2009/07/24 v3.04a KOMA-Script package (type area)
inputenc.sty 2008/03/30 v1.1d Input encoding file
utf8x.def 2004/10/17 UCS: Input encoding UTF-8
ucs.sty 2004/10/17 UCS: Unicode input support
uni-global.def 2004/10/17 UCS: Unicode global data
times.sty 2005/04/12 PSNFSS-v9.2a (SPQR)
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
dvips.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
dvipsnam.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
graphicx.sty 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2009/08/28 v1.8 graphics configuration of TeX Live
rotating.sty 2009/03/28 v2.16a rotated objects in LaTeX
ifthen.sty 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
fancyhdr.sty
cite.sty 2009/08/29 v 5.2
harvard.sty
html.sty 1999/07/19 v1.38 hypertext commands for latex2html (nd, hws, rr
m)
setspace.sty 2000/12/01 6.7 Contributed and Supported LaTeX2e package
hyperref.sty 2009/10/09 v6.79a Hypertext links for LaTeX
ifpdf.sty 2009/04/10 v2.0 Provides the ifpdf switch (HO)
ifvtex.sty 2008/11/04 v1.4 Switches for detecting VTeX and its modes (HO)
ifxetex.sty 2009/01/23 v0.5 Provides ifxetex conditional
hycolor.sty 2009/10/02 v1.5 Code for color options of hyperref/bookmark (HO
)
xcolor-patch.sty 2009/10/02 xcolor patch
pd1enc.def 2009/10/09 v6.79a Hyperref: PDFDocEncoding definition (HO)
etexcmds.sty 2007/12/12 v1.2 Prefix for e-TeX command names (HO)
infwarerr.sty 2007/09/09 v1.2 Providing info/warning/message (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty 2009/08/13 v3.4 Keyval support for LaTeX options (HO)
kvsetkeys.sty 2009/07/30 v1.5 Key value parser with default handler support
(HO)
bitset.sty 2007/09/28 v1.0 Data type bit set (HO)
intcalc.sty 2007/09/27 v1.1 Expandable integer calculations (HO)
bigintcalc.sty 2007/11/11 v1.1 Expandable big integer calculations (HO)
pdftexcmds.sty 2009/09/23 v0.6 LuaTeX support for pdfTeX utility functions (
HO)
ifluatex.sty 2009/04/17 v1.2 Provides the ifluatex switch (HO)
ltxcmds.sty 2009/08/05 v1.0 Some LaTeX kernel commands for general use (HO)
atbegshi.sty 2008/07/31 v1.9 At begin shipout hook (HO)
hdvips.def 2009/10/09 v6.79a Hyperref driver for dvips
pdfmark.def 2009/10/09 v6.79a Hyperref definitions for pdfmark specials
ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
ucsencs.def 2003/11/29 Fixes to fontencodings LGR, T3
nameref.sty 2007/05/29 v2.31 Cross-referencing by name of section
refcount.sty 2008/08/11 v3.1 Data extraction from references (HO)
minimalbeispiel.out
minimalbeispiel.out
答案1
我无法直接回答您的问题,但我可以建议一种几乎万无一失的解决方法:不要加载harvard
参考书目引文管理器,而是同时加载natbib
和har2nat
包。Natbib
众所周知,它可以很好地与配合使用hyperref
,并且该har2nat
包将所有 -type 引文命令“翻译”harvard
为等效的natbib
-type 引文命令。这样,您可以继续使用所有-style 引文命令,但从现在开始harvard
它们将由处理。:-)natbib
在您的 latex 文件上(重新)运行 latex 和 bibtex 之前,您可能应该删除各种辅助文件,因为它们包含“harvard”样式而不是“natbib”样式指令的信息。
几年前,我遇到了与 交互导致的问题,在软件包的帮助下,我进行了此切换(从harvard
到) 。这些问题与您在帖子中描述的问题大致相同。从那时起,我再也没有遇到过这些问题。:-)natbib
har2nat
hyperref
一些额外的评论关于您文档的序言,与 harvard-hyperref 交互问题无关:
- 该
times
包已过时;请考虑加载mathptmx
。 cite
如果您加载了harvard
或包,则无需加载该包natbib
。(两个包都重新定义了 LaTeX 的\cite
命令,禁用了包提供的所有功能cite
。)\hypersetup{colorlinks=false}
由于您已经pdfborder=...
在加载包时指定了该选项,因此该命令是不必要的hyperref
。
答案2
编辑:楼主使用的是由 synaptic 安装的 TeX Live 2009。在Ubuntu 社区 wiki您可以阅读以下说明:
自 2011 年 10 月起,Ubuntu(TeX Live 2009)附带的 texlive 软件包是比当前的 TeX Live 版本落后两年多(TeX Live 2011)。如果你没有很大的空间限制,并且想要最新版本的 TeX Live,你可以直接从 TeX Live 网站(这不会干扰 Ubuntu 中的软件包)。
您的示例没有错误。以下是一些提示:
- 请看一下这个答案:避免使用 utf8x
- 不要使用默认
ucs
加载的包utf8x
- 您不需要加载包
url
。hyperref
做这项工作。
这里是我的文件列表以供比较:
*File List*
scrreprt.cls 2011/06/16 v3.09a KOMA-Script document class (report)
scrkbase.sty 2011/06/16 v3.09a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
scrbase.sty 2011/06/16 v3.09a KOMA-Script package (KOMA-Script-independent
basics and keyval usage)
keyval.sty 1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty 2011/03/09 v3.09 KOMA-Script package (loading files)
tocbasic.sty 2011/05/30 v3.09a KOMA-Script package (handling toc-files)
scrsize12pt.clo 2011/06/16 v3.09a KOMA-Script font size class option (12pt)
typearea.sty 2011/06/16 v3.09a KOMA-Script package (type area)
inputenc.sty 2008/03/30 v1.1d Input encoding file
utf8.def 2008/04/05 v1.1m UTF-8 support for inputenc
t1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc
ot1enc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc
omsenc.dfu 2008/04/05 v1.1m UTF-8 support for inputenc
times.sty 2005/04/12 PSNFSS-v9.2a (SPQR)
xcolor.sty 2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/message (HO)
ltxcmds.sty 2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
dvipsnam.def 1999/02/16 v3.0i Driver-dependant file (DPC,SPQR)
graphicx.sty 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
rotating.sty 2009/03/28 v2.16a rotated objects in LaTeX
ifthen.sty 2001/05/26 v1.1c Standard LaTeX ifthen package (DPC)
listings.sty 2007/02/22 1.4 (Carsten Heinz)
lstmisc.sty 2007/02/22 1.4 (Carsten Heinz)
listings.cfg 2007/02/22 1.4 listings configuration
fancyhdr.sty
cite.sty 2010/09/10 v 5.3
harvard.sty
setspace.sty 2000/12/01 6.7 Contributed and Supported LaTeX2e package
hyperref.sty 2011/10/01 v6.82j Hypertext links for LaTeX
hobsub-hyperref.sty 2011/04/23 v1.4 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty 2011/04/23 v1.4 Bundle oberdiek, subset generic (HO)
hobsub.sty 2011/04/23 v1.4 Subsetting bundle oberdiek (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifvtex.sty 2010/03/01 v1.5 Switches for detecting VTeX and its modes (HO)
intcalc.sty 2007/09/27 v1.1 Expandable integer calculations (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
etexcmds.sty 2011/02/16 v1.5 Prefix for e-TeX command names (HO)
kvsetkeys.sty 2011/04/07 v1.13 Key value parser (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Defining keys (HO)
pdftexcmds.sty 2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
pdfescape.sty 2011/04/04 v1.12 Provides string conversions (HO)
bigintcalc.sty 2011/01/30 v1.2 Expandable big integer calculations (HO)
bitset.sty 2011/01/30 v1.1 Data type bit set (HO)
uniquecounter.sty 2011/01/30 v1.2 Provides unlimited unique counter (HO)
letltxmacro.sty 2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
hopatch.sty 2011/01/30 v1.0 Wrapper for package hooks (HO)
xcolor-patch.sty 2011/01/30 xcolor patch
atveryend.sty 2011/04/23 v1.7 Hooks at very end of document (HO)
atbegshi.sty 2011/01/30 v1.15 At begin shipout hook (HO)
refcount.sty 2010/12/01 v3.2 Data extraction from references (HO)
hycolor.sty 2011/01/30 v1.7 Color options of hyperref/bookmark (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
kvoptions.sty 2010/12/23 v3.10 Keyval support for LaTeX options (HO)
pd1enc.def 2011/10/01 v6.82j Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc.
hpdftex.def 2011/10/01 v6.82j Hyperref driver for pdfTeX
rerunfilecheck.sty 2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
supp-pdf.mkii
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Managing graphics extensions (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
nameref.sty 2010/04/30 v2.40 Cross-referencing by name of section
gettitlestring.sty 2010/12/03 v1.4 Cleanup title references (HO)
test.out
test.out
***********
答案3
包harvard
加载包html
,如果存在,则加载hyperref
。来自harvard.sty
:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{harvard}
\RequirePackage{ifthen}
\IfFileExists{html.sty}{\RequirePackage{html}
...
可能的解决方案:
- 您可以使用 ,而不必
hyperref
自己加载选项\hypersetup
。建议这样做。 - 在这种及类似情况下,可以使用
\PassOptionsToPackage{...}{packagename}
。 - 另一个选项是将 hyperref 选项指定给文档类,这些选项将被继承。我一般不希望这样做,因为其他包可能会受到影响。
- 卸载
html.sty
并停用自动包安装 - 将虚拟文件
html.sty
放入您的文件夹可以解决这个问题,但是拥有同名的不同样式文件是不好的 - 只是提一下并建议不要这样做。
注意,hyperref
应在序言末尾加载,有一些例外,因此请harvard
按照与hyperref
序言末尾相同的方式加载以避免出现问题。