【latex学习资料】Latex中的超链接(资料下载)

2012-12-04 11:25 阅读 821 次 评论关闭

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

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

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

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

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

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

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

If you need to make references to URLs, or write explicit links, the following low-level user macros are provided:

\href{URL}{text}

The text is made a hyperlink to the URL; this must be a full URL (relative to the base URL, if that is defined). The special characters # and ~ do not need to be escaped in any way.

\url{URL}

Similar to \href{URL}{\nolinkurl{URL}}. Depending on the driver \href also tries to detect the link type. Thus the result can be a url link, file link, …

\nolinkurl{URL}

Write URL in the same way as \url, without creating a hyperlink.

\hyperbaseurl{URL}

A base URL is established, which is prepended to other specified URLs, to make it easier to write portable documents.

\hyperimage{imageURL}{text}

The link to the image referenced by the URL is inserted, using text as the anchor.

For drivers that produce HTML, the image itself is inserted by the browser, with the text being ignored completely.

\hyperdef{category}{name}{text}

A target area of the document (the text) is marked, and given the name category.name

\hyperref{URL}{category}{name}{text}

text is made into a link to URL#category.name

\hyperref[label]{text}

text is made into a link to the same place as \ref{label} would be linked.

\hyperlink{name}{text}

\hypertarget{name}{text}

A simple internal link is created with \hypertarget, with two parameters of an anchor name, and anchor text. \hyperlink has two arguments, the name of a hypertext object defined somewhere by \hypertarget, and the text which be used as the link on the page.

Note that in HTML parlance, the \hyperlink command inserts a notional # in front of each link, making it relative to the current testdocument; \href expects a full URL.

\phantomsection

This sets an anchor at this location. It works similar to \hypertarget{}{} with an automatically choosen anchor name. Often it is used in conjunction with \addcontentsline for sectionlike things (index, bibliography, preface). \addcontentsline refers to the latest previous location where an anchor is set. Example:

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\indexname}
\printindex

Now the entry in the table of contents (and bookmarks) for the index points to the start of the index page, not to a location before this page.

\autoref{label}

This is a replacement for the usual \ref command that places a contextual label in front of the reference. This gives your users a bigger target to click for hyperlinks (e.g. ‘section2’instead of merely the number ‘2’).

The label is worked out from the context of the original \label command by hyperref by using the macros listed below (shown with their default values). The macros can be (re)defined in documents using \(re)newcommand; note that some of these macros are already defined in the standard document classes. The mixture of lowercase and uppercase initial letters is deliberate and corresponds to the author’s practice.

下载查看完整版本:

Latex中的超链接.doc

更多下载:

版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:【latex学习资料】Latex中的超链接(资料下载) | 猎微网

评论已关闭!