# \autoref and linguex

I use the linguex package for linguistics examples, and I'd like to be able to refer to the examples with the \autoref command. This works great for examples with labels:

\ex. \label{example} Hi.


In \autoref{example}, I wrote an example.

In a very long piece of work, I've primarily been referring to examples using \Next and \Last, rather than labels. Is there a simple way to link the \Next and \Last references using linguex and the hyperref package? Thank you!

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Feb 5, 2015 at 22:11

## 1 Answer

The counter is ExNo, then the name for \autoref can be defined the following way:

\newcommand*{\ExNoautorefname}{Example}


\Next and friends call \printExNo to print the example number, thus it can be redefined to add the anchor (assuming default options of hyperref regarding links):

\makeatletter
\renewcommand{\printExNo}{%
\@ifnextchar[{\complexExNo}{%
\hyperlink{ExNo.\thetmpaEx}{%
\if@noftnote\theExLBr\else\theFnExLBr\fi
\thetmpaEx
\if@noftnote\theExRBr\else\theFnExRBr\fi
}%
\xspace
}%
}
\makeatother

• Thank you! That's very helpful. Is there an easy way to modify this so that it will also link \Last[a], etc? Feb 15, 2015 at 0:46
• @Teresa Unhappily this is much more complicate, because also the anchor setting need to be changed to get better anchor names for \autoref. Thus it would be more or less a rewrite of the package linguex. Feb 25, 2015 at 14:46