0

I used hyperref together with expex before and all was fine. Not sure when and what broke, but I don't get hyperlinks anymore, nor any idea where to look for the source of this grief. I'm compiling with lualatex, but pdflatex gives exactly the same result. Here's a MNWE:

\documentclass{scrartcl}
\usepackage[luatex]{graphicx}
\usepackage{color,expex,hyperref}
\gathertags %for forward refs
\begin{document}
Forward reference: (\getref{test}).\pagebreak

The ex:
\ex<test>Does the expex get a hyperlink?\xe
\pagebreak

Backward reference: (\getref{test}).
\end{document}

Any suggestions are appreciated!

2

I can't see any documented changes that would have affected this but I think you can do something like the following to add a hyperref anchor at \ex and make a link in the reference.

enter image description here

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{color,expex,hyperref}
\makeatletter
\def\ex@c{%
   \ex@setup
   \leavevmode
\ifx\@optionaltag\@empty\else
\hypertarget{expex.\@optionaltag}{}%
\fi
   \setbox\numbox=\hbox{\hskip\lingnumoffset\ep@actualexnoprint}%
   \epd@numright=\wd\numbox
   \ifcase\ep@textanchor                          % numleft
         \ep@settosum\leftskip\lingnumoffset\lingtextoffset
      \or                                         % normal
         \ep@settosum\leftskip\epd@numright\lingtextoffset
      \fi
   \llap{\hbox to\leftskip{\unhbox\numbox \hss}}%
   \lingeveryex
   \latex@tagex
   \ignorespaces
}

\def\getref#1{\def\expexrefname{#1}\getref@a{#1}\getref@aa}

\let\old@printref\@printref
%oops \def\@printref#1{\hyperlink{expex.expecrefname}{\old@printref{#1}}}
\def\@printref#1{\hyperlink{expex.\expexrefname}{\old@printref{#1}}}


\makeatother
\begin{document}


This is a test of hyperref with expex.\footnote{The former should make hyperlinks for the latter's labels.}
\ex<test>
Does the expex get a hyperlink?
\xe

This must be a hyperlink, but it isn't: (\getref{test}).
\end{document}
  • Thank you, that's great! Two 'but's though: I get a warning that " (pdf backend): unreferenced destination with name 'expex.expecrefname'", and the link does not send me to the anchor (checked over a \pagebreak). And it doesn't pick up forward reference at all (prints the tag name instead of label). Do you think this can be helped? – Ivan Kapitonov Jul 8 '16 at 12:08
  • @IvanKapitonov expex doesn't seem to support forward references at all, it does not use the aux file and just seems to use a macro, so even without hyperref if you move the getref before the \ex then it fails as far as I can see, but i don't know the package at all. I just did the link type in your example there are probably more expex links that need to be made hyperref aware, but probably should be done by someone who knows what the package is doing. – David Carlisle Jul 8 '16 at 12:13
  • Oh boy, I'm sorry, I was sure that my \gathertags is "somewhere in the preamble file" -- fixed the code in the question. That's a macro that "turns" forward reference "on" -- you're right, it doesn't use the .aux, but rather creates a -tags.tex file for that. Now I can see that if I have a link on the previous page, and a link on the page that follows the example, the first link sends me to the last one. It could be a hint to the anchor problem -- but unfortunately I've no idea what in your code is the anchor.. – Ivan Kapitonov Jul 8 '16 at 12:25
  • Oh I'm missing a \ !!! expexrefname was supposed to have a backslash in so \hyperlink{expex.expecrefname}{ links to the anchor made here \hypertarget{expex.\@optionaltag}{}%` I'll fix... – David Carlisle Jul 8 '16 at 13:17
  • @IvanKapitonov try now – David Carlisle Jul 8 '16 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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