hyperref 没有为 expex 创建链接

hyperref 没有为 expex 创建链接

我以前hyperref曾一起使用过expex,一切都很好。不知道什么时候和什么坏了,但我再也看不到超链接了,也不知道在哪里可以找到这个麻烦的根源。我正在用 进行编译lualatex,但pdflatex结果完全相同。这是一个 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}

任何建议都值得赞赏!

答案1

我看不到任何会影响这一点的记录更改,但我认为您可以执行以下操作来添加超链接锚点\ex并在引用中创建链接。

在此处输入图片描述

\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}

相关内容