summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/expex-glossonly/expex-glossonly.sty
blob: 95547ec2e0cb1207faf09a4aebec3dd82fff273d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
\def\EPGL@version{0.9}
\def\EPGL@date{2024/2/5}
% 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