\def\EPGL@version{0.9b}
\def\EPGL@date{2024-02-14}
% expex-glossonly is a package which allows gb4e and linguex and covington users to use
% the glossing macros  of the ExPex package, while still using the standard example and
% subexample numbering macros of those respective packages.
%
% Copyright 2016-2024 by Alan Munn
%
% This package may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This package has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this package is Alan Munn.
%
% This package consists of the file expex-glossonly.sty and documentation files
% expex-glossonly.tex and expex-glossonly.pdf plus three test files:
% gb4e-expex.tex, linguex-expex.tex, and covington-expex.tex
%
% This package is currently experimental. Use at your own risk.
%
\ProvidesPackage{expex-glossonly}[\EPGL@date\ Compatibility package for using ExPex glosses with other example packages v. \EPGL@version ]
\RequirePackage{calc}
\RequirePackage{expex}
\newif\ifEPGL@examplesloaded
\@ifpackageloaded{linguex}{\PackageError{expex-glossonly}{Please load linguex using the package option!}{Please load linguex using the package option!}}{}
\@ifpackageloaded{gb4e}{\PackageError{expex-glossonly}{Please load gb4e using the package option!}{Please load gb4e using the package option!}}{}
\@ifpackageloaded{covington}{\PackageError{expex-glossonly}{Please load covington using the package option!}{Please load covington using the package option!}}{}
% This is a separate macro because it needs to be changed per package.
\newcommand\EPGL@setglossmargin{\setlength{\leftskip}{\@totalleftmargin}}
\def\EPGL@patchexpexgloss{%
  \let\xe\relax
  \let\pex\relax
\def\gl@wrap@below@begin@a{%
   \bgroup
   \parindent0pt
   \ep@setglstrut
   \ifdim\ling@glwidth=0pt
      \ifling@glbreaking
         \bgroup
       \else
         \vtop\bgroup
            \advance\hsize by -\leftskip
            \advance\hsize by -\rightskip
            %\leftskip=0pt
            \EPGL@setglossmargin % this is the changed line
       \fi
   \else
      \vtop\bgroup
         \hsize=\ling@glwidth
         \leftskip=0pt
   \fi
   \leavevmode
   \bgroup
   \parindent=0pt
   \@glpreamblefalse
   \@glftfalse
   \let\mainlist=\empty
   \let\itemtypelist=\empty
   \let\aboveskiplist=\empty
   \let\strutlist=\empty
   \let\everylist=\empty
   \let\colorlist=\empty
}}
\DeclareKeys[expex-glossonly]
{
gb4e.code = {
	\RequirePackage{gb4e}
	\EPGL@examplesloadedtrue
	\EPGL@patchexpexgloss
	\lingset{belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex,everygla=\eachwordone}
	\PackageInfo{expex-glossonly}{Patching ExPex for use with gb4e}
	\typeout{Patching ExPex for use with gb4e}
  },
gb4e-emulate.code = {
	\RequirePackage{gb4e-emulate}
	\EPGL@examplesloadedtrue
    \EPGL@patchexpexgloss
    \lingset{belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex,everygla=\eachwordone}
    \PackageInfo{expex-glossonly}{Patching ExPex for use with gb4e}
    \typeout{Patching ExPex for use with gb4e}
},
linguex.code = {
	\RequirePackage{linguex}
	\EPGL@examplesloadedtrue
    \EPGL@patchexpexgloss
    \def\printGramm{\makebox[0pt][r]{\normalfont\the\CollectTokens}\renewcommand\EPGL@setglossmargin{\setlength{\leftskip}{0pt}}\ignorespaces}
    \def\newb.{\renewcommand\EPGL@setglossmargin{\setlength{\leftskip}{\@totalleftmargin}}\ifindex\firstwordtrue\fi
        \my@ifnextchar[{\newExitem}{\item\testforgramm}}
    \lingset{belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex,everygla=\eachwordone}
    \PackageInfo{expex-glossonly}{Patching ExPex for use with linguex}
    \typeout{Patching ExPex for use with linguex}
},
covington.code = {
	\PassOptionsToPackage{covington}{#1}
	\let\ex\relax
	\RequirePackage{covington}
	\EPGL@examplesloadedtrue
	\EPGL@patchexpexgloss
	\newcommand*{\EPGL@glosslineone}{%
       \@ifundefined{glosslineone@global}{\glosslineone}{\glosslineone@global}}
	\lingset{belowglpreambleskip=-0.5ex, aboveglftskip=-0.5ex,everygla=\EPGL@glosslineone}
	\PackageInfo{expex-glossonly}{Patching ExPex for use with covington}
    \typeout{Patching ExPex for use with covington}
}
}
\DeclareUnknownKeyHandler[expex-glossonly]{\PackageError{expex-glossonly}{Please specify which example package you are using as a package option!}{Please specify which example package you are using as a package option!}}

\ProcessKeyOptions[expex-glossonly]
\ifEPGL@examplesloaded\else\PackageWarning{expex-glossonly}{No example package specified! Assuming ExPex}\fi

\endinput