Producing hyperlinks in SVG with hyperref

Asked by Andrew Belt

I am confused about the manual regarding rendering hyperlinks to SVG.
Under the "html" special, the manual says that "The hyperref specials allow the definition of hyperlinks inside DVI files in various flavors."
Do I have to enable this special somehow? I am using dvisvgm 1.5.1 with the html special listed under --list-specials, but the SVG files do not produce href links.
Here is my full process.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{http://en.wikipedia.org/}{Wikipedia}
\end{document}

$ latex test.tex
$ latex test.tex
$ dvisvgm test.dvi

Question information

Language:
English Edit question
Status:
Solved
For:
dvisvgm Edit question
Assignee:
Martin Gieseking Edit question
Solved by:
Martin Gieseking
Solved:
Last query:
Last reply:
Revision history for this message
Best Martin Gieseking (martin-gieseking) said :
#1

dvisvgm expects the hyperref specials to be in HyperTeX format. By default, the hyperref package creates PostScript links which are not supported. So just load the hyperref package with option "hypertex":

  \usepackage[hypertex]{hyperref}

dvisvgm should now recognize the link statements.

Revision history for this message
Andrew Belt (andrewpbelt) said :
#2

Thanks! This works for me.
I hope others might find this feature useful.

Revision history for this message
Andrew Belt (andrewpbelt) said :
#4

I have one further question. This might not be within the scope of dvisvgm, but is it possible to specify the target attribute (and perhaps title attribute) of the 'a' element in the SVG file?

For example the above produces
<a xlink:href='http://en.wikipedia.org/' xlink:title='http://en.wikipedia.org/'>
but I would like
<a xlink:href='http://en.wikipedia.org/' xlink:title='Wikipedia' target='_parent'>

I suspect this data could be specified in the LaTeX file and preserved by hypertex, but ultimately the SVG converter must know to write this data to the SVG file on output.

Reference:
http://www.w3.org/TR/SVG/linking.html#AElementTargetAttribute

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#5

dvisvgm uses the HyperTeX special statements [1] to extract hyperlink information from the dvi file. Unfortunately, they don't support additional parameters for titles and targets. Therefore, there is no common way to add these information to the dvi file using the basic set of commands. If the hyperref package added title and target data to the generated special commands, a future version of dvisvgm would possibly be able to process them. At the moment, I think, you have to postprocess the svg files in order to adapt the links as desired.

[1] http://www.tug.org/applications/hyperref/manual.html#x1-20001

Revision history for this message
Rdtennent (rdtennent) said :
#6

The dvisvgm in TeXLive-2013 (1.5.1) doesn't support html specials. Why?

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#7

Please provide a small working TeX file showing the issue. I'm currently unable to reproduce it.

BTW, as far as I know, TeX Live 2013 comes with dvisvgm 1.2.2, not 1.5.1.

Revision history for this message
Rdtennent (rdtennent) said :
#8

Sorry. That was the version number for a local build. But the TeXLive issue can be seen without a TeX file:

$ /usr/local/texlive/2013/bin/i386-linux/dvisvgm --list-specials
bgcolor background color special
color complete support of color specials
dvisvgm special set for embedding raw SVG snippets
em line drawing statements of the emTeX special set
pdf pdfTeX font map specials
ps dvips PostScript specials
tpic TPIC specials

$ /usr/local/texlive/2013/bin/i386-linux/dvisvgm | head -n1
dvisvgm 1.2.2

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#9

OK, thanks for the additional info which makes it easy to answer your question: hyperref support was added with version 1.3. It isn't present in previous versions.

Revision history for this message
Rdtennent (rdtennent) said :
#10

So I now have version 1.5.2 working. If I use the hypertex driver with hyperref and dvisvgm, the text of URL links is underlined. If I use pdflatex, the links are in rectangular boxes. The latter would be my preference. Is there some way to suppress underlining of URL link text? More generally, where do I find documentation for "hypertex"?

Bob T.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#11

The hypertex option selects a html-like format of the hyperref specials being written to the dvi file. For more details regarding the format, see https://www.tug.org/applications/hyperref/ftp/doc/manual.html#x1-20001

In order to change the way hyperlinks are marked by dvisvgm, you can use option --linkmark followed by a parameter. The available parameters are documented in the dvisvgm manpage (see http://dvisvgm.sourceforge.net/Manpage for example).

Revision history for this message
Rdtennent (rdtennent) said :
#12

Thanks. I just needed to install the man page for 1.5.2 :+)

Revision history for this message
Rdtennent (rdtennent) said :
#13

I have documents with tikz nodes whose text is typically a tabular environment within the text argument of an \href command. Pdflatex and latex with dvipdfm or dvips produce links for the whole tabular environment. Latex with dvisvgm produces links for the separate text fragments; presumably, this is a result of using the hypertex option. Different -L options to dvisvgm affect the appearance of the links but don't change what is linked. Is there any way to force hyperref to link the whole environment? I realize that this question might better be asked of hyperref support but it's worth a try.

Revision history for this message
Martin Gieseking (martin-gieseking) said :
#14

Bob, could you send me a sample .tex file that shows the problem? I have to look into the dvi file to see what's happening there. You can contact me by email.