summaryrefslogtreecommitdiff
path: root/macros/xetex/latex/langsci/langsci-optional.sty
blob: c70f7e35f7e4591590bf05a3c14697e77fe0b5ad (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%      File: langsci-optional.sty
%%    Author: Language Science Press (http://langsci-press.org)
%%      Date: 2016-01-16 16:47:43 UTC
%%   Purpose: This file contains useful, but not essential,
%%            macros for books using langscibook.cls
%%  Language: LaTeX
%%   Licence:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Heiko Oberdiek
% http://tex.stackexchange.com/questions/136644/vertical-space-in-interaction-with-figure-center-environment
\newcommand{\oneline}[1]{%
  \begingroup
    \sbox0{\ignorespaces#1\unskip}%
    \leavevmode
    \ifdim\wd0>\linewidth
      \hbox to\linewidth{%
        \hss\resizebox{\linewidth}{!}{\copy0 }\hss
      }%
    \else
      \copy0 %
    \fi
  \endgroup
}

\newcommand{\centerfit}[1]{%
  \begingroup
    \sbox0{\ignorespaces#1\unskip}%
    \leavevmode
    \ifdim\wd0>\linewidth
      \hbox to\linewidth{%
        \hss\resizebox{\linewidth}{!}{\copy0 }\hss
      }%
    \else
      \centerline{\copy0 }%
    \fi
  \endgroup
}

% Helps to fit verbatim onto one line:
% http://tex.stackexchange.com/questions/140593/shrinking-verbatim-text/
\usepackage{fancyvrb}
\newenvironment{fitverb}
 {\SaveVerbatim{rlwv}}
 {\endSaveVerbatim
  \sbox0{\BUseVerbatim{rlwv}}
  \begingroup\center % don't add indentation
  \ifdim\wd0>\linewidth
    \resizebox{\linewidth}{!}{\copy0}%
  \else
    \copy0
  \fi
  \endcenter\endgroup}

% \VerbatimFootnotes %breaks roman numbering for examples in footnotes


% http://tex.stackexchange.com/questions/73464/inserting-rtl-text-in-verbatim-environment?rq=1
% verbatim with RTL text

%\DefineVerbatimEnvironment{rtlverbatim}{Verbatim}{commandchars=+\[\]}

%add intonation bars over morphemes or words
\newcommand{\intline}[2]{\settowidth{\LSPTmp}{#2}\raisebox{#1pt}{\parbox{.1mm}{\rule{\LSPTmp}{.5pt}}}#2}

%add rising or falling intonation
\newcommand{\dline}[3]{%
  \parbox{.1mm}{\begin{picture}(0,0)%
        \put(0,#1){\line(#2,-1){#3}}%
        \end{picture}%
  }%
}

%% rotated table headers
% create lengths
\newlength{\rotheight}
\newlength{\rotwidth}

\newcommand{\rotatehead}[2][1cm]{
%width is the width of the parbox
%height is the buffer space used to vertically stretch the headere
\setlength{\rotwidth}{#1}
\setlength{\rotheight}{.85\rotwidth}
  \begin{rotate}{33}~ %nbsp shifts the content away from the line underneath
   \parbox{\rotwidth}{\raggedright #2}
  \end{rotate}%
  \rule{0pt}{\rotheight} %add zero width rule to get the right table height
}

% example metadata

\newcommand{\langinfo}[3]{{\upshape #1\il{#1}~(%
\ifx\\#2\\%
\else%
#2;
\fi%
#3)}\nopagebreak[4]\ignorespaces}

\newcommand{\langinfoverb}[3]{{\upshape #1~(% langinfo without index marker
\ifx\\#2\\%
\else%
#2;
\fi%
#3)}\nopagebreak[4]\ignorespaces}

\newcommand{\fitpagewidth}[1]{
  \resizebox{\textwidth}{!}{#1}
}
\newcommand{\fittable}[1]{\resizebox{\textwidth}{!}{#1}}

\usepackage{tabularx}
\usepackage{array}
\newenvironment{widetabular}[1][1]
  {\tabularx{#1\textwidth}}
  {\endtabularx}


% Vowel chart tikz commands
\newcommand{\aeiou}{%
	\node at (1.5,0) (a) {a};
	\node at (0,3) (i) {i};
	\node at (3,3) (u) {u};
	\node at (0.5,1.5) (e) {e};
	\node at (2.5,1.5) (o) {o};
}
\newcommand{\aeiouEO}{%
	\node at (1.5,0) (a) {a};
	\node at (0,3) (i) {i};
	\node at (3,3) (u) {u};
	\node at (0.25,2) (e) {e};
	\node at (2.75,2) (o) {o};
	\node at (0.75,1) (E) {ε};
	\node at (2.25,1) (O) {ɔ};
}

%no hyphenation left alingned
\newcolumntype{Q}{>{\raggedright\arraybackslash}X}
%no hyphenation right aligned
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
%no hyphenation centered
\newcolumntype{C}{>{\centering\arraybackslash}X}
%no hyphenation fixed width
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
%no hyphenation centered fixed width
\newcolumntype{Z}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
%no hyphenation right aligned fixed width
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\newcolumntype{d}[1]{D{.}{.}{#1}}


% Underlining in gb4e-example Environments. Usual underlining commands that span multiple words do not work, because gb4e would parse it as one word.
% Example: \underline{My example phrase} should become \ulp{My}{~~~~~} \ulp{example}{~~~~~} \ule{phrase}
% Note: The 2nd Argument of the \ulp command is filled in by experience - if you are not familiar with the command, you should experiment a bit. Usually, five tildes are enough, but be sure to check the outcome.
% \ule is meant to be the last word in a phrase that is underlined. Therefore, \ule does not have an extra length.
\usepackage[normalem]{ulem}
\usepackage{calc}
\newlength{\fulllength}
\newcommand{\ulp}[2]{%#1: stuff to underline, #2: extra length to skip the whitespace between to components
  \settowidth{\LSPTmp}{#1}%
  % several boxes are need to assure that words with ascending and descending letters are underlined at the same
  % level, leading to the impression of a continuous stroke
  \parbox[t]{\LSPTmp}{%restrict first box to the length of first argument
      \settowidth{\fulllength}{\parbox{\LSPTmp}{~}\parbox{#2mm}{~}} %inner box is larger than outerbox, so underlining will extend beyond length of outer box
      %             align parbox to bottom
      %              |           mbox to prevent hyphenation
      \uline{\parbox[b]{\fulllength}{\mbox{#1}}}%
    }%
}

\newcommand{\ule}[1]{%#1: stuff to underline, no extra length
  \ulp{#1}{0}%
  }

\newlength{\fullllength}
\newcommand{\soutp}[2]{%#1: stuff to underline, #2: extra length to skip the whitespace between to components
  \settowidth{\LSPTmp}{#1}%
  % several boxes are need to assure that words with ascending and descending letters are underlined at the same
  % level, leading to the impression of a continuous stroke
  \parbox[t]{\LSPTmp}{%restrict first box to the length of first argument
      \settowidth{\fullllength}{\parbox{\LSPTmp}{~}\parbox{#2mm}{~}}%inner box is larger than outerbox, so underlining will extend beyond length of outer box
      %             align parbox to bottom
      %              |           mbox to prevent hyphenation
      \sout{\parbox[b]{\fullllength}{\mbox{#1}}}%
    }%
}

\newcommand{\soute}[1]{%#1: stuff to underline, no extra length
  \soutp{#1}{0}%
  }

\newcommand{\longrule}{\rule{1em}{.3pt}}
\usepackage{colortbl}
\newcommand{\shadecell}{\cellcolor{black!20!white}}

% vertical alignment of  numbered  example
\newcommand{\eabox}[2][-.7\baselineskip]{
  \ea
    \parbox[t]{.8\textwidth}{
      \vspace{#1}
      #2
     }
  \z
}
\newcommand{\exbox}[2][-.7\baselineskip]{
  \ex
    \parbox[t]{.8\textwidth}{
      \vspace{#1}
      #2
     }
}

%fix \verb error in biblatex
% \makeatletter
% \def\blx@maxline{77}
% \makeatother

\newcommand{\rephrase}[2]{{\color{yellow!30!black}#2}\todo{replaced `#1'}}

\newcommand{\missref}[2][]{\todo[#1]{missing reference #2}}

\newenvironment{indentquote}[1]%
  {\list{}{\leftmargin=#1\rightmargin=0pt}\item[]}%
  {\endlist}


\newcommand{\phonrule}[3]{#1 $\to$ #2 / #3}
\newcommand{\featurebox}[1]{$\left[\begin{tabular}{>{\scshape}c}#1\end{tabular}\right]$}



%connect two elements with lines
\newcommand{\connect}[2]{%
  \tikz[overlay,remember picture]{%
    \draw[-,thick] (#1) -- (#2) node   {};  %
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Experimental feature for pointing out moving things. %%%%
%%%% Buggy? Write to: kopeckyf@hu-berlin.de               %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usetikzlibrary{arrows,arrows.meta}
\newcounter{lsConnectTempGroup}
\NewDocumentCommand\ConnectTail{m O{\thelsConnectTempGroup}}{%read: mandatory arg #1, optional argument #2 with the current group counter as its default value.
    \edef\lsConnectTempPosition{#2}%\edef expands the argument, which means reading the current value of the counter.
    {\tikz[remember picture,
           anchor=base, baseline,
           inner xsep=0pt,
           inner ysep=-.5ex]\node (ConnectTempTail\lsConnectTempPosition) {\strut{}#1};}%\strut for baseline
}
\NewDocumentCommand\ConnectHead{s O{1ex} m O{\thelsConnectTempGroup}}{%read: star #1, optional argument (distance of arrow from text= std. one x-height), mand. arg. (node text), optional argument #2, the group specifier
    \edef\lsConnectTempPosition{#4}%
    \stepcounter{lsConnectTempGroup}%We have a match, let's update the group counter
    {\tikz[remember picture,
           anchor=base, baseline,
           inner xsep=0pt,
           inner ysep=-.5ex] \node (ConnectTempHead\lsConnectTempPosition) {\strut{}#3};%
     \tikz[remember picture] \draw[% we have a tail and a head, let's bring them together
                                \IfBooleanTF#1{{Triangle[]}-}{-{Triangle[]}},% Check if the starred version is used. The starred version is right->left, the normal version left->right
                                overlay] (ConnectTempTail\lsConnectTempPosition.south) -- ++(0,-#2) -| (ConnectTempHead\lsConnectTempPosition.south);
    }%
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Extras for use in (some) edited volumes             %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% for chapters without abstract
\newcommand{\noabstract}{\vspace*{-2\baselineskip}}

%%%%%%%%%%%%%%%%%%%%
%%%%           %%%%%
%%%%   PLOTS   %%%%%
%%%%           %%%%%
%%%%%%%%%%%%%%%%%%%%


\newcommand{\LSfrac}[1]{{\addfontfeature{Fractions=On}#1}}% Use the fraction glyphs shipped with Libertine. The argument is n/m, where n and m are integers


% Provide a raised tie bar for diphthongs and affricates with ascenders
\newcommand{\hitie}[2]{%
\mbox{#1}%
\raisebox{.5mm}{%
͡%
}%
\mbox{#2}%
}


\newcommand{\hitier}[3][.7]{%
\mbox{#2}%
\hspace*{#1mm}%
\raisebox{.5mm}{%
͡%
}%
\hspace*{-#1mm}%
\mbox{#3}%
}


\newcommand{\hitiel}[3][.7]{%
\mbox{#2}%
\hspace*{-#1mm}%
\raisebox{.5mm}{%
͡%
}%
\hspace*{#1mm}%
\mbox{#3}%
}


% commands moved here from cgloss
\let\prmbrs=0
\def\primebars{\let\prmbrs=1}
\def\obar#1{\ifmmode#1^{0}\else#1$^{0}$\fi}  %% FIX
\def\mbar#1{\ifmmode#1^{\mathrm{max}}\else#1\textsuperscript{max}\fi}
\def\ibar#1{\ifx\prmbrs0%
                 \ifmmode\overline{\mathrm{#1}}\else$\overline{\mbox{#1}}$\fi%
            \else\ifmmode#1^{'}\else#1$^{'}$\fi\fi}
\def\iibar#1{\ifx\prmbrs0%
                  \ifmmode\overline{\overline{\mathrm{#1}}}%
                  \else$\overline{\overline{\mbox{#1}}}$\fi%
             \else #1P\fi}


\def\spec#1{[Spec,#1]} %Def. of "Specifier of #1"

% Check marks and crosses
\usepackage{pifont}
\newcommand*{\langscicheckmark}{\ding{51}}
\newcommand*{\langscicross}{\ding{55}}