TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm embedding an external file in my pdf with \usepackage{attachfile2} and\textattachfile[color=1 1 1]{description}{file.pdf}. How can I make the text look the same as it would if I had used the hyperref package and done something like \hyperref{file.pdf}{description}? (By look the same, I mean black text, cyan border that disappears on printing, hand icon on mouse over, name of file in a box on hover (at least in acrobat/reader).)

share|improve this question
up vote 13 down vote accepted

I'd replace attachfile2 with a combination of embedfile and hypgotoe:

Instead of \textattachfile[color=0 0 0]{file.pdf}{description}, you'll have to use \embedfile{file.pdf}. This command does not create any visible entry, it just adds the file to the resulting PDF file (and Adobe Reader's attachment tab), so you can use the macro anywhere in your document.

In order to produce the clickable link, use the extended functionality of hypgotoe's \href command: To make "description" a link to the embedded file.pdf, the correct syntax is


(More information can be found in the hypgotoe manual.) The appearance of the links can be controlled with \hypersetup using the keys gotoecolor and gotoebordercolor.

A minimal example:


Note that this solution only works with pdf(la)tex and only for embedded PDF files.

share|improve this answer
The problem with this solution is that it requires you to provide the file names you are embedding in two locations. – vy32 Sep 3 '11 at 15:11
@vy32 You can avoid specifying the file name twice by creating a new macro for this purpose: \newcommand*{\embedfileandcreatelink}[2]{\embedfile{#1}\href{gotoe:embedded=#1}‌​{#2}} Use it like \embedfileandcreatelink{file.pdf}{description} – diabonas Sep 6 '11 at 16:17
I thought that \embedfile{} had to go in the preamble. Does it not? – vy32 Sep 7 '11 at 1:08
@vy32 You can safely use \embedfile anywhere in your document. The list of embedded files the PDF file contains is written at the very end of the document. – diabonas Sep 7 '11 at 9:57
Ah, okay. Thanks! – vy32 Sep 9 '11 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.