summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/expex-glossonly/expex-glossonly.sty
blob: b33b6b41c068e521522d6cf66c9fa3b86966ea88 (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
\def\EPGL@version{0.6}
\def\EPGL@date{2023/08/15}
% expex-glossonly is a package which allows gb4e and linguex 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 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 two test files: gb4e-expex.tex and linguex-expex.tex
%
% This package is currently experimental. Use at your own risk.
%
\ProvidesPackage{expex-glossonly}[\EPGL@date\ Compatibility package for using ExPex glosses with gb4e and linguex v. \EPGL@version ]
\DeclareOption*{\PackageWarning{expex-glossonly}{Unknown option `\CurrentOption`}}
\ProcessOptions
\RequirePackage{calc}
\RequirePackage{expex}
% First define a command to patch the ExPex main gloss command
% Need to find out if other gloss commands need to be patched.
\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
}}
% First check to see whether we are loaded first
% Since there is some overlap in commands, gb4e and linguex must be loaded second
\@ifpackageloaded{linguex}{\PackageError{expex-glossonly}{Please load expex-glossonly BEFORE linguex}{Please load expex-glossonly BEFORE linguex}}{}
\@ifpackageloaded{gb4e}{\PackageError{expex-glossonly}{Please load expex-glossonly BEFORE gb4e}{Please load expex-glossonly BEFORE gb4e}}{}
% Now only patch the command if the packages have been loaded
% This means that the package will do no harm if loaded by itself
\AtBeginDocument{%
\@ifpackageloaded{linguex}{
  \def\EPGL@setglossmargin{%
	\ifnum\theExDepth=1%
         \setlength{\leftskip}{\Exindent+\Exlabelsep+\Exlabelwidth+.5em}
     \else
         \setlength{\leftskip}{\Exindent+\Exlabelsep+\Exlabelwidth+\SubExleftmargin+.5em}
     \fi}
  \EPGL@patchexpexgloss
  \PackageInfo{expex-glossonly}{Patching ExPex for use with linguex}
  \typeout{Patching ExPex for use with linguex}  
}
{\@ifpackageloaded{gb4e}{
  \def\EPGL@setglossmargin{%
   \ifnum\@xnumdepth=1%
      \setlength{\leftskip}{\leftmargin+\widthof{\@exwidth}+1em}
   \else
      \setlength{\leftskip}{\leftmargin+\labelwidth+\labelsep+1.5em}
    \fi}
  \EPGL@patchexpexgloss
  \PackageInfo{expex-glossonly}{Patching ExPex for use with gb4e}
  \typeout{Patching ExPex for use with gb4e}
}{}}
}
\endinput