I realize this is an old question, but for posterity's sake, I thought I'd point out that expex
provides several ways to include language name or other example annotations.
Right-aligned, on first gloss line
This is the format suggested in the answer by @Alan Munn:
Explanation
Use \rightcomment{}
between \gla
and the first word. See section 11.2 of the expex
documentation.
Code
\documentclass{article}
\usepackage{expex}
\lingset{everygla=, belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex} % gloss formatting
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\ex
\begingl
\gla\rightcomment{Hungarian (Finno-Ugric, \emph{reference})}J\'anos h\'aza//
\glb John house.his//
\glft `John's house'//
\endgl
\xe
\lipsum[3]
\end{document}
Within example, above gloss lines
This is the format suggested in the answer by @cbowern:
Explanation
Use \glpreamble
to introduce the preamble line above the first gloss line. Formatting of the gloss preamble line can be controlled globally or locally by the parameter everyglpreamble
. The vertical space between the gloss preamble and the first gloss line can be controlled by the parameter belowglpreambleskip
. See section 9 of the expex
documentation.
Code
\documentclass{article}
\usepackage{expex}
\lingset{everygla=, belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex} % gloss formatting
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\ex
\begingl
\glpreamble Hungarian (Finno-Ugric, \emph{reference})//
\gla J\'anos h\'aza //
\glb John house.his//
\glft `John's house' //
\endgl
\xe
\lipsum[3]
\end{document}
Left-aligned, above the example
This is the format suggested in the original question:
Explanation
expex
doesn't provide a special command for this format, but it's still pretty simple to produce. The code below creates a command \langlabel
that removes the paragraph indent and adds the vertical space that normally appears above examples. It then uses \ex~
instead of \ex
so that there is no vertical space between the label and the example.
By default, example numbers produced by expex
are flush with the left margin (unlike in gb4e
, where they are indented). If you want to indent the example numbers in expex
, use the parameter numoffset
. See sections 4 and 5 of the expex
documentation.
Code
\documentclass{article}
\usepackage{expex}
\newlength{\aboveexskip} % creates a length \aboveexskip
\setlength{\aboveexskip}{2.7ex plus .4ex minus .4ex} % sets a value for \aboveexskip (this the default value for vertical space above examples taken from the expex documentation)
\lingset{aboveexskip=\aboveexskip, everygla=, belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex} % gloss formatting, aboveexskip=\aboveexskip sets the expex parameter aboveexskip to the length specified in the line above
\newcommand{\langlabel}[1]{\vspace{\aboveexskip}\noindent{#1}} % \aboveexskip is used here because \ex~ will remove the vertical spacing above the example
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\langlabel{Hungarian (Finno-Ugric, \emph{reference})}
\ex~ % use the ~ version with \langlabel unless you want vertical space between the label and the example
\begingl
\gla J\'anos h\'aza //
\glb John house.his//
\glft `John's house' //
\endgl
\xe
\lipsum[3]
\end{document}
lipsum
package for introducing dummy text for better readability and focus, you can also use egreg'skantlipsum
package for the same purpose. Please rollback if this is not desired.