summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/textglos/textglos.sty
blob: 4a17f97f34822cdadbe143b6f37a26f1b697a247 (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
%%
%% This is file `textglos.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% textglos.dtx  (with options: `package')
%% This is a generated file.
%% 
%% ----------------------------------------------------------------
%% textglos --- A package to typeset inline linguistic examples.
%% E-mail: natalie.a.weber@gmail.com
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
%% 
%% Copyright 2013 by Natalie Weber
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) 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 work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Natalie Weber.
%% 
%% This work consists of the files textglos.dtx and textglos.ins
%% and the derived files textglos.sty and textglos.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}[1996/10/24]%
\ProvidesPackage{textglos}%
    [2012/06/27 v1.0 textglos package for inline linguistic glossing]%
\IfFileExists{graphicx}{\RequirePackage{graphicx}}{}%
\global\long\def\tlist@if@empty@nTF #1{%
\expandafter\ifx\expandafter\\\detokenize{#1}\\%
\expandafter\@firstoftwo%
\else%
\expandafter\@secondoftwo%
\fi%
}%
\@ifpackageloaded{graphicx}{%
  \newcommand{\shorteq}{%
    \settowidth{\@tempdima}{-}% Width of hyphen
    \resizebox{1.5\@tempdima}{\height}{=}%
  }%
}{}%
 \def\nbrhyph{\textup{\hbox{-}}}%
 \ifx\shorteq\relax
   \def\nbreq{\textup{\hbox{=}}}%
 \else
   \def\nbreq{\textup{\hbox{\shorteq}}}%
 \fi
 \def\nbrpunct#1{%
   \bgroup
     \catcode`\-=\active
     \catcode`\==\active
     \scantokens{\let-\nbrhyph
         \let=\nbreq#1\ignorespaces}
   \egroup
 }%
\providecommand*{\gl}[1]{`#1'}%
\def\lingexample#1#2{% #1 = name, #2 = template
  \@lingsub(#1)#2\@nil % \@nil as delimiter
  \expandafter\gdef\csname #1\endcsname{% \def\name
    \@ifnextchar[{\@lingexample(#1)}{\@lingexample(#1)[]}%
  }%
}%

\def\@lingsub(#1)#2X#3\@nil{%
  \expandafter\gdef\csname @@lingsub@#1\endcsname##1{\nbrpunct{#2##1#3}}%
}%
\def\@lingexample(#1)[#2]{\@ifnextchar[%
  {\@@lingexample(#1)[#2]}{\@@lingexample(#1)[][#2]}%
}%
\def\@@lingexample(#1)[#2][#3]#4{%
  \ifmmode
    $\tlist@if@empty@nTF{#2}{}{#2~}%
    {\csname @@lingsub@#1\endcsname{#4}}%
    \tlist@if@empty@nTF{#3}{}{ \gl{#3}}$%
  \else
    \tlist@if@empty@nTF{#2}{}{\lingprestyle{{#2}}}%
    {\csname @@lingsub@#1\endcsname{#4}}%
    \tlist@if@empty@nTF{#3}{}{\lingpoststyle{{#3}}}%
  \fi
}%
\providecommand{\lingprestyle}[1]{#1~}
\providecommand{\lingpoststyle}[1]{ \gl{#1}}
\lingexample{xo}{\ensuremath{<}X\ensuremath{>}}
\lingexample{xt}{[X]} % use \lingexample{xt}{\tipaencoding[X]}
                      % if you want IPA
\lingexample{xm}{/X/}
\lingexample{xv}{\itshape X}
\lingexample{xh}{*X} % use \lingexample{xh}{*\textit\bgroup X\egroup}
                     % if you want italicized