this is my first post to tex stack exchange so I apologise if the post is missing required information.
I'm using gb4e to produce linguistic examples for my dissertation, and I'm trying to find the most convenient way to include speaker labels as a part of example numbering. Some of the questions I've seen (eg. Interlinear glosses with overlaps, line numbers, and speaker labels) suggest that it might be easier to do this using a different package, but as I've already written a few hundred examples in gb4e it would save me time to stick with gb4e, given that only a minority that require speaker labels.
These are the basic considerations:
- there are a maximum of three speakers to be distinguished for each example
- speaker labels are simply A/B/C (or similar) identifiers, as I don't need to refer to full names of speakers
- all sub-examples require full interlinear glosses
The current method is to put each utterance in an \xlist, and for each sub-example include the speaker label on the same line as the example number, removing some whitespace before the \gll:
\newcommand{\speakerlabel}[1]{Speaker #1\vspace*{-.5\baselineskip}}
\begin{exe}
\ex \begin{xlist}
\ex \label{ex:my example} \speakerlabel{A}
\gll my example\\
my example\\
\trans `My example'
\end{xlist}
\end{exe}
\ref{ex:my example}
This is a reasonably tidy solution, but it wastes space for single character speaker identifiers, and speaker identifiers aren't preserved in example numbering for cross referencing (note text reference Example 171a, not 171a-A). It would be a useful to me if the identity of the speaker was clear from the example number, so as to avoid prose such as `Speaker A responds with 171a'.
Ideally what I'd like is something like a custom \xlist environment that adds the speaker identifier to the example number (171a-A, 171b-A, 171c-B). \exi{speaker label} does not work for this because (from what I've read so far) custom identifiers are not intended for use in cross-referencing due to the problems with including arbitrary characters in counters. But as mentioned, there are at most 3 unique speakers at a time, so perhaps a finite set of speaker characters might not be considered arbitrary.
I'm to suggestions for other ways to refer to speakers, and I really appreciate all responses. Thanks in advance!
The code below gives an idea of how I would like this to work. Is it possible to define myxlist and \exa, \exb, etc, so that this code snipped produces a formatted example that retains speaker identifiers in cross-references similar to the screenshot below?
(note that I would also change speaker identifiers to something other than A/B/C so as not to confuse with sub-example numbering, but this is sufficient for explanation)
\begin{exe}
\ex \label{ex:some dialogue} \begin{myxlist}
\exa \gll first utterance\\
first utterance\\
\trans `First utterance'
\exb \label{ex:B's reply} \gll second utterance\\
second utterance\\
\trans `Second utterance'
\exb \gll third utterance\\
third utterance\\
\trans `Third utterance'
\end{myxlist} \end{exe}
Reference to \ref{ex:B's reply}.