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.

When I try to cross-reference with \ref to gb4e's cross-references with primes (\exp) I fail.

Consider the following example:

\documentclass{article}

\usepackage{gb4e}

\begin{document}

\begin{exe}
  \ex\label{ex:1}Example one.
\end{exe}
Reference \ref{ex:1}.
\begin{exe}
  \exp{ex:1}\label{ex:2}Example two.
\end{exe}
Reference \ref{ex:2}.

\end{document}

Which gives the following output:

Output of the example

Why does not \ref{ex:2} produce a cross-reference? Am I doing something wrong?

share|improve this question
    
Maybe I am better off in trying to come up with something similar with enumitem? –  N.N. May 7 '12 at 14:48
    
As far as I understand the documentation exp is not meant for creating a new item, so there's nothing to reference. The same is valid for \exr btw. So using enumitem might be a good idea. –  Martin May 7 '12 at 15:12
3  
There's a very simple solution: don't use primes for example numbers, they're evil. ;-) –  Alan Munn May 7 '12 at 16:53

2 Answers 2

up vote 6 down vote accepted

The \exp command uses the \exi command underlyingly, and this latter command is designed for arbitrarily specified example numbers, so the regular counter system won't work (except that the argument to \exp is a label.)

Personally I think that primed example numbers are not a good idea, so I would advise against doing this. See below for some discussion. However, if you insist, you could create a \primeref command that would refer to a primed example using the label of the original non-primed example:

\newcommand*{\primeref}[1]{\ref{#1}$'$}

Then in your document you would have a label for the original unprimed example, and use \exp{<label>} and \primeref{<label>} to introduce and refer to the primed examples.

Why primed examples are bad (for linguistics)

Although there may be some justification for primed equation numbers in math, I don't think there are equivalently good justifications for their use in linguistics, and certainly not for linguistic examples (as opposed to e.g. semantic formulas that are being developed piecewise.) The only purpose to use a primed example I would think would be to show an alternative version of something that was essentially the same. But this is not really correct for linguistic examples, which, even if they differ minimally from each other, are not really the same ever.

share|improve this answer
    
Thanks for your answer. Your answer would be even better if you include some argument for why they are bad and some notes on how to do without them. –  N.N. May 7 '12 at 17:21

This should work. But while "primed" equation numbers can be justified in math papers, I'm with Alan Munn in discouraging "primed example numbers".

\documentclass{article}
\usepackage{gb4e,refcount}
\makeatletter
\def\new@exp#1{\exi{{(\ref {#1}$'$)}}\edef\@currentlabel{\getrefnumber{#1}$\noexpand'$}}
\AtBeginDocument{\let\exp\new@exp}
\makeatother

\begin{document}

\begin{exe}
  \ex\label{ex:1}Example one.
\end{exe}
Reference \ref{ex:1}.
\begin{exe}
  \exp{ex:1}\label{ex:2}Example two.
\end{exe}
Reference \ref{ex:2}.

\end{document}

It requires a couple of LaTeX runs to stabilize.

share|improve this answer

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.