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.

Please consider the following MWE, in a form of a batch file, which creates two tex files (one of them gets \includepdfd in the other):

cat > insert.tex <<'EOF'
\documentclass{article}
\usepackage[a4paper]{geometry}

\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, citecolor=blue, filecolor=blue, urlcolor=blue} %


\begin{document}

A test of url: \href{http://www.example.com}{http://www.example.com}

A test of cite: \cite{mytest}




\begin{thebibliography}{9}

\bibitem{mytest} Just Testing, \emph{Just Testing}, 2012.

\end{thebibliography}


\end{document}
EOF

pdflatex insert.tex
pdflatex insert.tex

pdfannotextractor insert.pdf


cat > includer.tex <<'EOF'
\documentclass{article}
\usepackage[a4paper]{geometry}

\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=red, citecolor=red, filecolor=red, urlcolor=red} %

\usepackage{pdfpages}
\usepackage{pax}


\begin{document}

\def\excerpt{\section{A test of inclusion}

Turns out we cannot just use includepdf in between section and
text, even if it is scaled down - must define the whole section
and use it as a pagecommand, see \url{http://tex.stackexchange.com/questions/5911/}.

}

\includepdf[pages=1,scale=0.6,frame,pagecommand={\excerpt},link]{insert.pdf}


\end{document}
EOF

# pdflatex includer.tex
# pdflatex includer.tex

xelatex includer.tex
xelatex includer.tex

If I compile the second file, includer.tex, with pdflatex - then all the links work fine in the includer.pdf.

However, if I try to compile includer.tex with xelatex (as in the example), I get:

! Package pax Error: Missing pdfTeX in PDF mode.

See the pax package documentation for explanation.

... after which, the process can continue - but no links in the included pdf work.

The error message is actually quite clear, in that pax doesn't as of yet support xelatex - but I was wandering if anyone, maybe, knows a hack/workaround, so the links would work also with xelatex?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

pax uses the following pdftex primitives:

\pdfstartlink
\pdfendlink
\pdfescapename
\pdfdest
\pdfstrcmp

Only the last one has a counterpart in xetex. You may have better luck with luatex, but \pdfstrcmp and \pdfescapename are only available as \pdf@strcmp and \pdf@escapename by loading pdftexcmds, so possibly

\usepackage{pdftexcmds}
\makeatletter
\let\pdfescapename=\pdf@escapename
\let\pdfstrcmp=\pdf@strcmp
\makeatother
\usepackage{pax}

can work. There's nothing similar with xetex, that uses a completely different model for inserting hyperlinks.

share|improve this answer
    
Many thanks for that, @egreg - wasn't even aware that there are different pdftex primitives supported between engines (pdftex, xetex, luatex) - and it's great to see there's some hope with luatex as it also supports (most) of the fontspec stuff... Many thanks again - cheers! –  sdaau Jun 18 '12 at 3:17
1  
@sdaau Unfortunately, my experiment failed, because my Perl doesn't have a module required by pdfannotextractor. I will retry. –  egreg Jun 18 '12 at 6:54
    
Hi @egreg - strange, because I actually tried your solution (on my actual work, not on the MWE, though), and works damn fine with my .pax files and lualatex so far!? :) Cheers! –  sdaau Jun 18 '12 at 7:00
1  
@sdaau I tried on a machine where Perl has no problem, and it seems to work: differently from xetex, luatex descends from pdftex and shares many of the specific primitives introduced by it. Some of them have been removed, because they can be emulated with Lua functions (what pdftexcmds does). –  egreg Jun 18 '12 at 7:15
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.