Take the 2-minute tour ×
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.

I'm using MiKTeX 2.9 on a Windows 7 Home Premium 64-bit computer.

I have been experimenting with using attachfile2 to make a link to an embedded LaTeX file. When I compile the following document, named test.tex,

\documentclass{article}
\usepackage{xcolor}
\definecolor{myred}{rgb}{0.9,0.2,0.2}
\usepackage{attachfile2}
\attachfilesetup{color = myred}
\begin{document}
\jobname.tex \textattachfile{test.tex}{view source code}
\end{document}

it works as expected, producing the name of the file and a link:

enter image description here

But when I replace test.tex with \jobname.tex in the \textattachfile command, I get the following error (I am using TeXstudio 2.6.2):

enter image description here

Even putting \expandafter right before \textattachfile, which as far as I understand should ensure that \textattachfile never even sees the command \jobname, doesn't help.

What's going on?


Further observations (not sure if relevant):

  • When I use attachfile instead of attachfile2, it works fine with the \jobname input (of course, the only difference being that I can't use my custom color, which is the reason I wanted to use attachfile2 in the first place).

  • As I mentioned, I'm using TeXstudio. This editor has a convenient feature where it (at least attempts to) detect the commands that are defined by any included packages, and then highlights any commands it doesn't recognize. When I use the attachfile package, the commands \attachfilesetup and \textattachfile are recognized; when I use the attachfile2 package, they are not recognized. Perhaps my copy of the attachfile2 package is broken somehow? MiKTeX tells me that I have the oberdiek bundle installed, which is apparently where attachfile2 lives.

  • I also tried using the currfile package, which provides a macro \currfilename. Nothing different happens when I replace \jobname.tex with \currfilename; it works and doesn't work in the same cases.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Package attachfile had read the backslash in the argument of \textattachfile with verbatim catcode before version 2011/03/27 v1.5b. Package attachfile2 was written in that time before and has followed attachfile in this.

Now (2011/03/27 v1.5b) package attachfile reads the backslash with the usual catcode in \textattachfile to support \jobname (and other macros).

I have updated attachfile2 accordingly: 2013/07/29 v2.10. The package is available here until I release my updated bundle to CTAN later (this year hopefully). The source file attachfile2.dtx is embedded as file attachment. The package file attachfile2.sty with the driver files are unpacked by running plain TeX (or iniTeX) on attachfile2.dtx.

share|improve this answer
    
Awesome, thanks so much for your help! –  Zev Chonoles Jul 28 '13 at 23:33
add comment

Your Answer

 
discard

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.