Generalgb4e | Manual Identifiers with Labels and References

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
fauxpas
Posts: 4
Joined: Thu Apr 05, 2012 5:05 pm

gb4e | Manual Identifiers with Labels and References

Post by fauxpas »

So, I'm wondering if I'm missing the obvious here, but I've got the following problem: I'm writing more or less a summary of a paper and want to take the numbering of the examples from there to make it clearer. But I also want to be able to refer to the examples with \ref commands.

My first example would look a bit like this, then (it's a bit stupid because it's actually 1a/b in the original text, so I could just use \ex, but I can't reprint every single example in my summary):

Code: Select all

\begin{exe} 
   \exi{(1)} \label{one} lorem ipsum
	\begin{xlist}
		\exi{a.}[\#]{dolor sit amet}
		\exi{b.}[]{consetetur...}
	\end{xlist}
\end{exe}
Now, that works fine, and renders correctly, but when I do \ref{one} in the text, it prints "2". I don't know why it's 2, but, well, yeah. Is there a way to get it to work somehow without doing a separate \setcounter{exx}{0} for every example? (which is the least ugly solution I've found so far)

edit: I've come to realize that doing it with the \setcounter method is actually easier than manually doing every single one, so while it would be cool to know a different way, there is no need to try to figure out a different solution :)
Last edited by cgnieder on Fri Oct 19, 2012 8:11 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

gb4e | Manual Identifiers with Labels and References

Post by cgnieder »

Would you please make this a complete Infominimal working example so one can just copy, paste, and compile? exe is not a standard LaTeX environment.

Regards
site moderator & package author
fauxpas
Posts: 4
Joined: Thu Apr 05, 2012 5:05 pm

gb4e | Manual Identifiers with Labels and References

Post by fauxpas »

Woops, forgot about that, sorry :)

Code: Select all

\documentclass[a4paper,12pt]{scrartcl}	
\usepackage[T1]{fontenc}
\usepackage{gb4e}
\begin{document}
\ldots lorem ipsum: \ref{one}, \ref{onea}
\begin{exe} 
   \exi{(1)} \label{one} lorem ipsum
        \begin{xlist}
                \exi{a.}[\#]{dolor sit amet} \label{onea}
                \exi{b.}[]{consetetur...}
        \end{xlist}
\end{exe}
\end{document}
That should do the trick, although in that case the \ref doesn't print anything (\pageref still works). gb4e is the package I mentioned in the post title and it provides the exe-environment. I looked at the documentation and didn't find anything that would cover my example. But luckily the setcounter-method seems to work well, so unless you're bored, there isn't really a need to come up with another solution :)
Last edited by cgnieder on Fri Oct 19, 2012 8:29 pm, edited 2 times in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

gb4e | Manual Identifiers with Labels and References

Post by cgnieder »

From what I understand from looking at the documentation and the definitions of \ex and \exi the latter is not meant for the general use but for exceptions when one needs to specify an identifier manually. And this is why it does not set a referable counter. This could be difficult anyway since the allowed identifiers are arbitrary.

I can only see two ways around:
  • Use \ex and the automatic numbering instead or, if this is not an option for you,
  • introduce an own counter
Regards
site moderator & package author
Post Reply