latex建立参考文献的超链接

在Latex生成的pdf文档中建立超链接(如从正文到参考文献,从目录到相应内容,从页码编号到实际页面等),有利于读者快速定位当前阅读的信息。

如何在生成的pdf文件中包含超链接呢?需要注意一下两点:

1. 使用“hyperref”这个宏包,即在latex文档的导言部分添加“\usepackage{hyperref}”;
2. 使用“PDFLaTeX”对latex源文件进行编译,不要用“LaTeX”编译。

这样能确保生成的pdf文件中包含有可以用鼠标进行点击的超链接。但是这样存在一个问题,就是这些包含超链接的文本周围会出现彩色的方框,这种方框实在有碍观瞻,尤其是当出现在目录中时,大片的方框非常难看。

克服以上问题的方法是,不要使用“hyperref”宏包的默认属性,即使用如下方式引入宏包:

\usepackage[colorlinks,
            linkcolor=red,
            anchorcolor=blue,
            citecolor=green
            ]{hyperref}

colorlinks”的意思是将超链接以颜色来标识,而并非使用默认的方框来标识。
linkcolor, anchorcolor, citecolor分别表示用来标识link, anchor, cite等各种链接的颜色。
若正式的文档中不想使用彩色的标识,但又希望具有超链接的功能,则将上例中的各种颜色换成“black”即可。

如果您的pdf制作中文书签有乱码如下命令,就OK了

\usepackage[dvipdfm,  %pdflatex,pdftex这里决定运行文件的方式不同
            pdfstartview=FitH,
            CJKbookmarks=true,
            bookmarksnumbered=true,
            bookmarksopen=true,
            colorlinks, %注释掉此项则交叉引用为彩色边框(将colorlinks和pdfborder同时注释掉)
            pdfborder=001,   %注释掉此项则交叉引用为彩色边框
            linkcolor=green,
            anchorcolor=green,
            citecolor=green
            ]{hyperref}
  

若正式的文档中不想使用彩色的标识,但又希望具有超链接的功能,则将上例中的各种颜色换成“black”即可。
\href{URL}{text}
\url{URL}
\nolinkurl{URL}
\hyperbaseurl{URL}
\hyperimage{imageURL}{text}
\hyperdef{category}{name}{text}
\hyperref{URL}{category}{name}{text}
\hyperref[label]{text}
\hyperlink{name}{text}
\hypertarget{name}{text}
\phantomsection
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\autoref{label}

  • \url{网址}:生成网址链接,以等宽字体排版;
  • \href{网址}{描述}:生成网址链接,以正常字体显示描述,隐藏网址。

选项中可供设置的常用选项见下表:

extensiontext Set the file extension (e.g. dvi) which will be appended to file links created if you use the xr package.
hyperfiguresboolean  
backrefbooleanFALSEAdds ‘backlink’ text to the end of each item in the bibliography, as a list of section numbers. This can only work properly if there is a blank line after each \bibitem.
pagebackrefbooleanFALSEAdds ‘backlink’ text to the end of each item in the bibliography, as a list of page numbers.
hyperindexbooleanTRUEMakes the page numbers of index entries into hyperlinks. Relays on unique page anchors (pageanchor, ...)
pageanchors and plainpages=false.   
hyperfootnotesbooleanTRUEMakes the footnote marks into hyperlinks to the footnote text. Easily broken ...
encap  Sets encap character for hyperindex
linktocpagebooleanFALSEmake page number, not text, be link on TOC, LOF and LOT
breaklinksbooleanFALSEallow links to break over lines by making links over multiple lines into PDF links to the same target
colorlinksbooleanFALSEColors the text of links and anchors. The colors chosen depend on the the type of link. At present the only types of link distinguished are citations, page references, URLs, local �0�3le references, and other links.
linkcolorcolorredColor for normal internal links.
anchorcolorcolorblackColor for anchor text.
citecolorcolorgreenColor for bibliographical citations in text.
filecolorcolormagentaColor for URLs which open local �0�3les.
menucolorcolorredColor for Acrobat menu items.
runcolorcolorfilecolorColor for run links (launch annotations).
urlcolorcolorcyanColor for linked URLs.
frenchlinksbooleanFALSEuse small caps instead of color for links

参考:

http://www.tug.org/applications/hyperref/manual.html#x1-150005

转载于:https://www.cnblogs.com/ouyxy/p/6743073.html

LaTeX中,可以使用hyperref宏包来创建参考文献超链接。你可以通过设置不同的选项来自定义超链接的样式和颜色。 首先,你需要在导言区加载hyperref宏包,可以使用以下命令: ``` \usepackage{hyperref} ``` 然后,你可以使用hypersetup命令来设置超链接的选项。比如,你可以设置超链接的颜色,可以使用以下命令: ``` \hypersetup{ colorlinks=true, linkcolor=blue, filecolor=magenta, urlcolor=cyan, } ``` 上述代码中,colorlinks=true表示将超链接显示为彩色,默认为红色。linkcolor表示设置内部链接的颜色,filecolor表示设置文件链接的颜色,urlcolor表示设置URL链接的颜色。 除了设置颜色,你还可以设置其他选项,比如设置PDF的标题、默认显示模式等。 在正文中,你可以使用\href命令来创建超链接。比如,你可以使用以下命令创建一个指向网址的超链接: ``` \href{http://www.example.com}{Click here} ``` 上述命令会在文档中创建一个超链接,点击"Click here"时会跳转到"http://www.example.com"。 此外,你还可以使用\url命令来插入纯文本的URL链接,比如: ``` \url{http://www.example.com} ``` 如果你想在文档中创建一个内部链接,可以使用\hyperref命令和\hypertarget命令配合使用。首先,在目标位置使用\hypertarget命令创建一个目标,然后在其他地方使用\hyperref命令创建链接。比如: ``` \hypertarget{target}{The target sentence} ... \hyperref[target]{Link to the target} ``` 上述代码中,第一行创建了一个目标位置,第三行创建了一个指向该目标的链接。 综上所述,可以使用hyperref宏包在LaTeX中创建参考文献超链接,通过设置选项来自定义超链接的样式和颜色,并使用\href命令和\hyperref命令来创建各种类型的链接。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值