1

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!

  • 1
    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}. – Herr K. Feb 5 '15 at 22:11
3

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? – Teresa Feb 15 '15 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. – Heiko Oberdiek Feb 25 '15 at 14:46

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.