Linguistic gloss for dialogue with expex and marking the speakers

I am looking to create something that will look like this:

(1) A: word word word?

gloss gloss gloss?

translation translation translation?

B: word word word!

gloss gloss gloss!

translation translation translation!

For ordinary examples I am using expex like this:

\pex
\begingl
\gla ...
\glb ...
\glft ...
\endgl...
\xe


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{expex}
\begin{document}
\pex<withparts>
\a<first>
\begingl
\gla Meri - mal'čik.//
\glb Mary - boy.//
\glft Mary is a boy.'//
\endgl
\a<second>
\begingl
\gla Net, Mèri - devočka.//
\glb No, Mary - girl//
\glft Mary is a boy.'//
\endgl
\xe\end
{document}


but it does not really work because I may need to do the gloss of a dialogue where it is speaker A - speaker B - speaker A again, but with this method I will be getting a-b-c-d...

Next I also tried this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{expex}
\begin{document}
\pex<withparts>
\a<first>
\begingl
\gla A: Meri - mal'čik.//
\glb A: Mary - boy.//
\glc ...//
\glft ...//
\endgl
\xe\end
{document}


I thought I would be able to replicate the example in (1) by adding \glc, \gld, \gle, but evidently a b in \gla \glb do not stand for a,b,c ...

• Welcome to TeX.SX! Please show us a compilable code example of what you have tried (MWE). Oct 27 '17 at 16:00
• TeXnician thank you! I have edited the question. Oct 27 '17 at 16:23
• Would it be possible to remove all those backticks and use the {} button? That would make it easier for people to help you as they can copy and paste your code better (and it looks more like a code block). Oct 27 '17 at 16:31
• I hope I got it right this time) Oct 27 '17 at 16:39
• Related although maybe more than you need. tex.stackexchange.com/q/299264/2693 Oct 27 '17 at 17:33

If all you need to do is supply speaker labels, you can simply use the label= key for the example, and add your speaker labels there. All that is needed is to adjust the width of the label accordingly. To do this, I've created a command that takes your longest envisioned speaker name and adjusts the label width based on its length.

Here's a complete example:

\documentclass{article}
\usepackage{expex}
\usepackage{calc}
\newlength{\largestspkr}
\newcommand*\largestlabel[1]{\settowidth{\largestspkr}{#1~}}
\largestlabel{Speaker A}
\begin{document}
\pex[labelwidth=\largestspkr]
\a[label=Speaker A]
\begingl
\gla Meri - mal'čik.//
\glb Mary - boy.//
\glft Mary is a boy.'//
\endgl
\a[label=Speaker B]
\begingl
\gla Net, Mèri - devočka.//
\glb No, Mary - girl//
\glft Mary is a girl.'//
\endgl
\xe\end
{document}