• Home   /
• Archive by category "1"

## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ JABREF and HYPERLINKS

Information and discussion about graphics, figures & tables in LaTeX documents.

sw3quant
Posts:76
Joined: Tue Nov 02, 2010 11:40 pm

Postby sw3quant » Sun Nov 07, 2010 4:43 pm

Hello.

I am very new to Latex. I am using MikTex 2.8, WinEdt 6, JABREF 2.6 and Windows Vista. I am creating PDFs.

In JABREF there is a URL field, which you can use to link straight to the reference document of interest on the web.

When I generate the PDF I would like teh final PDF to include this hyperlink, so all the reader has to do is click on it and get taken there, rather than have to copy and paste the reference into google and search for it.

I have had a look and cant see how this can be done.

Would anyone be kind enough to help me on this? Please remember if it can't be done with JABREF and requires some complex hyperlink package, I would be greatful if you included a step by step example.

many thanks!!!
frabjous
Posts:2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Sun Nov 07, 2010 6:31 pm

I don't think the question can be answered without knowing what bibliography style you're using and what fields it supports for which types of bibliography entries.

You'll get quicker help if you create a minimal sample document showing your usage, and perhaps a single item bib file exported from JabRef.
sw3quant
Posts:76
Joined: Tue Nov 02, 2010 11:40 pm

Postby sw3quant » Sun Nov 07, 2010 10:53 pm

Hi,

Unclear what is meant by "bibliography style" but guess it refers to the type of entry that I wish to see inserted into the final PDF? If that is what it means I am just using all the default settings on JABREF. I have not changed anything. On entering data into JABREF i just specify which data source (journal, book etc) and then fill in as much information as possible. One field I always fill in is the "url" field.

The document showing usage is at:
http://www-h.eng.cam.ac.uk/help/tpl/tex ... PSnPDF.zip

You see this includes a JABREF *.bib file. However in this case the url field is left blank.

many thanks
frabjous
Posts:2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Sun Nov 07, 2010 11:10 pm

No, a minimal document. As in, just a few lines. And one-entry bib file. These are just supposed to be examples. No one has time to go through your entire thesis.

Do you really want to post your thesis on some random website? I'd delete that if I were you.

The bibliography style is a .bst file. Somewhere in one of those documents, you must be using a \bibliographystyle command to set your bibliography style. I'm far too lazy to go looking for it in some huge set of files.

Board Rules
The Post on Avoidable Mistakes
Instructions on creating a minimal working example
This FAQ on "How to Ask Questions the Smart Way"

Anyway, you can load the hyperref package and see if that helps.
sw3quant
Posts:76
Joined: Tue Nov 02, 2010 11:40 pm

Postby sw3quant » Thu Nov 11, 2010 2:57 pm

The link is to a thesis template that uses JABREF. It is not my thesis or indeed anything to do with me. In fact there is no writing in at all and only 2 references in the .bib file.

I thought this was what you asked for?

Would very much appreciate knowing how to include the url field of the bib file as a hyperlink in the final PDF.

many thanks for your kind time
frabjous
Posts:2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Thu Nov 11, 2010 6:20 pm

Wow. Sorry, I downloaded that, opened it up and saw it had 80 files and folders in it, and just assumed it was your full dissertation. Cambridge is a crazy place if they're giving you 80-file templates.

There are two bibliography style files in there: jmb.bib and CUEDbiblio.bst. I don't know what the difference is, but it seems that it defaults to CUEDbiblio.bst, so I'm going to assume you're using that unless you tell me otherwise.

That .bst file does not support the URL field which some bibliography files do. However, it appears that the template does load the hyperref package. You could try putting, e.g.:

\url{http://www.somedomain.co.uk/someplace}

including the command, inside the "note" or "howpublished" fields. (I can't remember what these look like exactly in JabRef, and I'm too lazy to install it now, but these are standard BibTeX fields which I'm sure it supports somehow.) I think these should produce clickable hyperlinks.

But to be honest, with a template that complicated, there has to be someone there at Cambridge who is responsible for answering questions about it, and if the above advice doesn't work, I'd ask them.
sw3quant
Posts:76
Joined: Tue Nov 02, 2010 11:40 pm

Postby sw3quant » Mon Nov 15, 2010 12:43 am

Hi.

I am bit unclear on your reply Im afraid. JABREF is essentially a nice GUI front end for I think what used to be called bibtex.

I am using JABREF to do all my references. In the template you see there is a folder called references.bib.

This is a file that opens with JABREF and is where you enter the BIBTEX style data including the URL.

Whenever you want to cite anything in the thesis you just write "\cite{myRefAB123}".

I have never touched either of the *.bst files you mention, but I too assume that it's the CUED file.

You say:

You could try putting \url{http://www.cam.ac.uk}
including the command, inside the "note" or "howpublished" fields. (I can't remember what these look like exactly in JabRef, and I'm too lazy to install it now, but these are standard BibTeX fields which I'm sure it supports somehow.) I think these should produce clickable hyperlinks.

I am afraid I am unclear on what you mean here. Please could you re-explain. I see note and howpublished are mentioned in the CUED.bst file. Are you suggesting I need to modify this file somehow? If so how?

(FYI the whole template was written by someone who did know LATEX but is no longer around to take questions on it). Cambridge seems pretty bad at doing any such support I'm afraid: we are left to fend for ourselves!

Many Thanks!
frabjous
Posts:2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Mon Nov 15, 2010 1:38 am

sw3quant wrote:Hi.

I am bit unclear on your reply Im afraid. JABREF is essentially a nice GUI front end for I think what used to be called bibtex.

BibTeX is still called BibTeX, and of course I know what JabRef is. I've used it before. I mentioned BibTeX in my message, so I can't imagine why you would have thought I wouldn't know these things.

I am using JABREF to do all my references. In the template you see there is a folder called references.bib.

This is a file that opens with JABREF and is where you enter the BIBTEX style data including the URL.

Whenever you want to cite anything in the thesis you just write "\cite{myRefAB123}".

Yes, I knew all that.

I have never touched either of the *.bst files you mention, but I too assume that it's the CUED file.

Don't assume. Look. Near the end of thesis.tex, you'll see:

If you haven't changed this, then you are using CUEDbiblio -- the other bibliographystyle lines are "commented out" by the %, so they aren't active. If you changed it so there was a % in front of the first line but not in front of the others, then you would be using a different style.

You say:

You could try putting \url{http://www.cam.ac.uk}
including the command, inside the "note" or "howpublished" fields. (I can't remember what these look like exactly in JabRef, and I'm too lazy to install it now, but these are standard BibTeX fields which I'm sure it supports somehow.) I think these should produce clickable hyperlinks.

I am afraid I am unclear on what you mean here. Please could you re-explain. I see note and howpublished are mentioned in the CUED.bst file. Are you suggesting I need to modify this file somehow? If so how?

No, you shouldn't need to modify this file. Or at least I really hope you don't. I just needed to see it to see what fields are supported and what fields are not. "Note" and "Howpublished" fields are supported by it. However, "URL" is not. Hence, filling in the URL in BibTeX's URL field won't do any good, but perhaps you can use these fields instead.

So I'm telling you to try putting the URL inside these fields in JabRef, complete with \url{...} which is the code to make them clickable hyperlinks.

Perhaps this picture will help:

jabref.jpg (54.23 KiB) Viewed 21688 times

Note that only certain kinds of Bibliography items have "howpublished" fields. Others won't. But I think you can probably use "note" instead. You might not need to do both. But you'll need to test these out with your actual files and entries.
sw3quant
Posts:76
Joined: Tue Nov 02, 2010 11:40 pm

Postby sw3quant » Mon Nov 15, 2010 3:32 pm

Thank you very much for your kind replies. They are very helpful indeed.

As you mentioned, some entry types in JABREF might not have the "Howpublished" field, indeed none of mine do, but they all have the "Note" field.

When I do as you suggest and copy the url from my url field into the note field and surround by \url{} and compile I see that the output PDF contains a hyperlink to the URL as you said it would. Many Thanks.

However, I am afraid this is not quite what I am aiming for. As many of my URLs point to very long paths on servers (several whole lines of text), I would like the actual URL to be hidden and to just show a "globe/other symbol" type figure (as JABREF does for example, when there is a URL in the JABREF url field). This would then be shown next to the reference and allow a user reading it online to connect to the URL by clicking on it. (of course it is of no use to an offline/hardcopy user).

How could I do this? I know the approach is possible as I have seen it in some scientific papers.

To reply to the second post below:

When I tried adding \url{} around the contents of the url field, nothing happens. I dont mind going through my whole JABREF file and modifiying it with \url{}. I also dont mind modifying the bibtex file everytime I import something. Given this are there any advantages to choosing a Biblatex?

Many Thanks

• LaTeX Community
•    Announcements
•    Community talk
•    New Members
• LaTeX
•    Text Formatting
•    Graphics, Figures & Tables
•    Math & Science
•    Fonts & Character Sets
•    Page Layout
•    Document Classes
•    General
• LaTeX's Friends
•    BibTeX, biblatex and biber
•    MakeIndex, Nomenclature, Glossaries and Acronyms
•    Conversion Tools
•    Viewers for PDF, PS, and DVI
•    XeTeX
•    Others
• LaTeX Distributions
•    Decision Guidance
•    MiKTeX and proTeXt
•    TeX Live and MacTeX
•    Others
• LaTeX Editors
•    Decision Guidance
•    AUCTeX
•    Kile
•    LEd
•    LyX
•    Scientific Word/Workplace
•    Texmaker and TeXstudio
•    TeXnicCenter
•       Announcements
•       General
•       Templates, Wizards & Tools
•       Feature Suggestions
•       Development
•    TeXShop
•    TeXworks
•    WinEdt
•    WinShell
•    Others
• LaTeX Templates
•    Articles, Essays, and Journal Templates
•    Theses, Books, Title pages
•    Letters
•    Presentations and Posters
•    Curricula Vitae / Résumés
•    Assignments, Laboratory books and reports
•    Calendars and Miscellaneous

### Who is online

Users browsing this forum: No registered users and 6 guests

LaTeX enables typesetting of hyperlinks, useful when the resulting format is PDF, and the hyperlinks can be followed. It does so using the package hyperref.

## Hyperref

The package hyperref[1] provides LaTeX the ability to create hyperlinks within the document. It works with pdflatex and also with standard "latex" used with dvips and ghostscript or dvipdfm to build a PDF file. If you load it, you will have the possibility to include interactive external links and all your internal references will be turned to hyperlinks. The compiler pdflatex makes it possible to create PDF files directly from the LaTeX source, and PDF supports more features than DVI. In particular PDF supports hyperlinks. Moreover, PDF can contain other information about a document such as the title, the author, etc., which can be edited using this same package.

## Usage

The basic usage with the standard settings is straightforward. Just load the package in the preamble:

This will automatically turn all your internal references into hyperlinks. It won't affect the way to write your documents: just keep on using the standard - system (discussed in the chapter on Labels and Cross-referencing); with hyperref those "connections" will become links and you will be able to click on them to be redirected to the right page. Moreover the table of contents, list of figures/tables and index will be made of hyperlinks, too. The hyperlinks will not show up if you are working in draft mode.

### Commands

The package provides some useful commands for inserting links pointing outside the document.

#### \hyperref

Usage:

This will have the same effect as but will make the text link text a full link, instead. The two can be combined. If the lemma labelled as mainlemma was number 4.1.1 the following example would result in

 We use \hyperref[mainlemma]{lemma \ref*{mainlemma}}. We use lemma 4.1.1.

with the hyperlink as expected. Note the "*" after for avoiding nested hyperlinks.

#### \url

Usage:

It will show the URL using a mono-spaced font and, if you click on it, your browser will be opened pointing at it.

#### \href

Usage:

 \href{}{}

It will show the string description using standard document font but, if you click on it, your browser will be opened pointing at my_url. Here is an example:

 \url{https://www.wikibooks.org}\href{https://www.wikibooks.org}{Wikibooks home}

Both point at the same page, but in the first case the URL will be shown, while in the second case the URL will be hidden. Note that, if you print your document, the link stored using will not be shown anywhere in the document.

### Other possibilities

Apart from linking to websites discussed above, hyperref can be used to provide mailto links, links to local files, and links to anywhere within the PDF output file.

A possible way to insert email links is by

It just shows your email address (so people can know it even if the document is printed on paper) but, if the reader clicks on it, (s)he can easily send you an email. Or, to incorporate the url package's formatting and line breaking abilities into the displayed text, use[2]

When using this form, note that the command is fragile and if the hyperlink is inside of a moving argument, it must be preceeded by a command.

#### Local file

Files can also be linked using the url or the href commands. You simply have to add the string run: at the beginning of the link string:

 \url{run:/path/to/my/file.ext}\href{run:/path/to/my/file.ext}{text displayed}

Following http://tex.stackexchange.com/questions/46488/link-to-local-pdf-file the version with does not always work, but does.

It is possible to use relative paths to link documents near the location of your current document; in order to do so, use the standard Unix-like notation ( is the current directory, is the previous directory, etc.)

It is also possible to create an anchor anywhere in the document (with or without caption) and to link to it. To create an anchor, use:

 \hypertarget{label}{target caption}

and to link to it, use:

where the target caption and link caption are the text that is displayed at the target location and link location respectively.

Note also that if you put a hypertarget, when clicking a link to that hypertarget, it may actually direct to the line after the hypertarget, which is not desirable. Therefore if this occurs, you can report the bug and refer to here for a solution.

## Customization

The standard settings should be fine for most users, but if you want to change something, that is also possible. There are several variables and two methods to pass those to the package. Options can be passed as an argument of the package when it is loaded (the standard way packages work), or the command can be used as follows:

 \hypersetup{ [, ...]}

you can pass as many options as you want; separate them with a comma. Options have to be in the form:

exactly the same format has to be used if you pass those options to the package while loading it, like this:

 \usepackage[]{hyperref}

Here is a list of the possible variables you can change (for the complete list, see the official documentation). The default values are written in an upright font:

Checkout 3.8 Big list at hyperref-manual at tug.org

variablevaluescomment
show or hide the bookmarks bar when displaying the document
allows to use characters of non-Latin based languages in Acrobat’s bookmarks
set the style of the border around a link. The first two parameters (RadiusH, RadiusV) have no effect in most pdf viewers. Width defines the thickness of the border. Dash-Pattern is a series of numbers separated by space and enclosed by box-brackets. It is an optional parameter to specify the length of each line & gap in the dash pattern. For example, {0 0 0.5 [3 3]} is supposed to draw a square box (no rounded corners) of width 0.5 and a dash pattern with a dash of length 3 followed by a gap of length 3. There is no uniformity in whether/how different pdf viewers render the dash pattern.
show or hide Acrobat’s toolbar
resize document window to fit document size
fit the width of the page to the window
define the title that gets displayed in the "Document Info" window of Acrobat
the name of the PDF’s author, it works like the one above
subject of the document, it works like the one above
creator of the document, it works like the one above
producer of the document, it works like the one above
list of keywords, separated by commas, example below
define if a new PDF window should get opened when a link leads out of the current document. NB: This option is ignored if the link leads to an http/https address.
activate back references inside bibliography. Must be specified as part of the \usepackage{} statement.
surround the links by color frames () or colors the text of the links (). The color of these links can be configured using the following options (default colors are shown):
hide links (removing color and border)
color of internal links (sections, pages, etc.)
color of URL links (mail, web)
color of frame around internal links (if )
color of frame around citations
color of frame around URL links

Please note, that explicit RGB specification is only allowed for the border colors (like linkbordercolor etc.), while the others may only assigned to named colors (which you can define your own, see Colors). In order to speed up your customization process, here is a list with the variables with their default value. Copy it in your document and make the changes you want. Next to the variables, there is a short explanations of their meaning:

If you don't need such a high customization, here are some smaller but useful examples. When creating PDFs destined for printing, colored links are not a good thing as they end up in gray in the final output, making it difficult to read. You can use color frames, which are not printed:

When you just want to provide information for the Document Info section of the PDF file, as well as enabling back references inside bibliography:

 \usepackage[pdfauthor={Author's name},% pdftitle={Document Title},% pagebackref=true,% pdftex]{hyperref}

By default, URLs are printed using mono-spaced fonts. If you don't like it and you want them to be printed with the same style of the rest of the text, you can use this:

## Troubleshooting

### Problems with Links and Equations 1

Messages like the following

! pdfTeX warning (ext4): destination with the same identifier (name{ equation.1.7.7.30}) has been already used, duplicate ignored

appear, when you have made something like

 \begin{eqnarray}a=b\nonumber\end{eqnarray}

The error disappears, if you use instead this form:

 \begin{eqnarray*}a=b\end{eqnarray*}

Beware that the shown line number is often completely different from the erroneous line.

Possible solution: Place the amsmath package before the hyperref package.

### Problems with Links and Equations 2

Messages like the following

! Runaway argument? {\@firstoffive }\fi ), Some text from your document here (\ref {re\ETC. Latex Error: Paragraph ended before \Hy@setref@link was complete.

appear when you use inside an environment.

 \AtBeginDocument{\let\textlabel\label}

Note: The same error appears if you use a colon "" as part of a label, i.e. . Replacing that will help.

### Problems with Links and Pages

Messages like the following:

! pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored

appear when a counter gets reinitialized, for example by using the command provided by the book document class. It resets the page number counter to 1 prior to the first chapter of the book. But as the preface of the book also has a page number 1 all links to "page 1" would not be unique anymore, hence the notice that "duplicate has been ignored." The counter measure consists of putting into the hyperref options. This unfortunately only helps with the page counter. An even more radical solution is to use the option , but this will cause the page links in the index to stop working.

The best solution is to give each page a unique name by using the command:

 \pagenumbering{alph}% a, b, c, ... ... titlepage, other front matter ... \pagenumbering{roman}% i, ii, iii, iv, ... ... table of contents, table of figures, ... \pagenumbering{arabic}% 1, 2, 3, 4, ... ... beginning of the main matter (chapter 1) ...

Another solution is to use before the command , which will give the title page the label page.a. Since the page number is suppressed, it won't make a difference to the output.

By changing the page numbering every time before the counter is reset, each page gets a unique name. In this case, the pages would be numbered a, b, c, i, ii, iii, iv, v, 1, 2, 3, 4, 5, ...

If you don't want the page numbers to be visible (for example, during the front matter part), use . The important point is that although the numbers are not visible, each page will have a unique name.

Another more flexible approach is to set the counter to something negative:

 \setcounter{page}{-100} ... titlepage, other front matter ... \pagenumbering{roman}% i, ii, iii, iv, ... ... table of contents, table of figures, ... \pagenumbering{arabic}% 1, 2, 3, 4, ... ... beginning of the main matter (chapter 1) ...

which will give the first pages a unique negative number.

The problem can also occur with the package: because each algorithm uses the same line-numbering scheme, the line identifiers for the second and follow-on algorithms will be duplicates of the first.

The problem occurs with equation identifiers if you use on every line of an eqnarray environment. In this case, use the *'ed form instead, e.g. (which is an unnumbered equation array), and remove the now unnecessary commands.

If your url's are too long and running off of the page, try using the package to split the url over multiple lines. This is especially important in a multicolumn environment where the line width is greatly shortened.

### Problems with bookmarks

The text displayed by bookmarks does not always look like you expect it to look. Because bookmarks are "just text", much fewer characters are available for bookmarks than for normal LaTeX text. Hyperref will normally notice such problems and put up a warning:

Package hyperref Warning: Token not allowed in a PDFDocEncoded string:

You can now work around this problem by providing a text string for the bookmarks, which replaces the offending text:

 \texorpdfstring{''TEX text''}{''Bookmark Text''}

Math expressions are a prime candidate for this kind of problem:

 \section{\texorpdfstring{$E=mc^2$}{E=mc2}}

which turns to in the bookmark area. Color changes also do not travel well into bookmarks:

 \section{\textcolor{red}{Red !}}

produces the string "redRed!". The command gets ignored but its argument (red) gets printed. If you use:

 \section{\texorpdfstring{\textcolor{red}{Red !}}{Red\ !}}

the result will be much more legible.

If you write your document in unicode and use the unicode option for the hyperref package you can use unicode characters in bookmarks. This will give you a much larger selection of characters to pick from when using .

### Problems with tables and figures

The links created by hyperref point to the label created within the float environment, which, as previously described, must always be set after the caption. Since the caption is usually below a figure or table, the figure or table itself will not be visible upon clicking the link[4]. A workaround exists by using the package hypcap[2] with:

If you use the wrapfig package[5] mentioned in the "Wrapping text around figures" section of the "Floats, Figures and Captions" chapter, or other similar packages that define their own environments, you will need to manually include in those environments, e.g.:

 \begin{wrapfigure}{R}{0.5\textwidth}\capstart\begin{center}\includegraphics[width=0.48\textwidth]{filename}\end{center}\caption{\label{labelname}a figure}\end{wrapfigure}

### Problems with long caption and \listoffigures or long title

There is an issue when using with hyperref for long captions or long titles. This happens when the captions (or the titles) are longer than the page width (about 7-9 words depending on your settings). To fix this, you need to use the option breaklinks when first declaring:

This will then cause the links in the to word wrap properly.

### Problems with already existing .toc, .lof and similar files

The format of some of the auxilliary files generated by latex changes when you include the hyperref package. One can therefore encounter errors like

! Argument of \Hy@setref@link has an extra }.

when the document is typeset with hyperref for the first time and these files already exist. The solution to the problem is to delete all the files that latex uses to get references right and typeset again.

### Problems with footnotes and special characters

See the relevant section.

### Problems with Beamer

Using the command

 \hyperref[some_label]{some text}

is broken when pointed at a label. Instead of sending the user to the desired label, upon clicking the user will be sent to the first frame. A simple work around exists; instead of using

 \phantomsection\label{some_label}

 \hypertarget{some_label}{}

and reference it with