diff options
Diffstat (limited to 'macros/xetex/latex/langsci/langsci-gb4e.sty')
-rw-r--r-- | macros/xetex/latex/langsci/langsci-gb4e.sty | 731 |
1 files changed, 531 insertions, 200 deletions
diff --git a/macros/xetex/latex/langsci/langsci-gb4e.sty b/macros/xetex/latex/langsci/langsci-gb4e.sty index 23d718f9f9..54bceb4db1 100644 --- a/macros/xetex/latex/langsci/langsci-gb4e.sty +++ b/macros/xetex/latex/langsci/langsci-gb4e.sty @@ -1,15 +1,28 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% File: langsci-gb4e.sty %% Author: Language Science Press (http://langsci-press.org) -%% Date: 2016-01-16 16:47:43 UTC +%% Date: 2020-03-17 13:12 UTC %% Purpose: This file contains an adapted version of the gb4e package -%% for typetting linguistic examples. +%% for typetting linguistic examples. It also includes +%% adapted versions of the cgloss and jambox packages %% Language: LaTeX -%% Licence: +%% Licence: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ProvidesPackage{langsci-gb4e}[2000/09/05] -\def\gbVersion{4e} +\ProvidesPackage{langsci-gb4e}[2020/01/01] + +\usepackage{etoolbox} + +\newtoggle{cgloss} +\toggletrue{cgloss} +\newtoggle{jambox} +\toggletrue{jambox} +\DeclareOption{nocgloss}{\togglefalse{cgloss}} +\DeclareOption{nojambox}{\togglefalse{jambox}} +\DeclareOption*{\PackageWarning{examplepackage}{Unknown option ‘\CurrentOption’}} +\ProcessOptions\relax + +% \def\gbVersion{4e} %%%%%%%%%%%%%%%%%%%%%%%% % Format of examples: % @@ -58,25 +71,22 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%CGLOSS META +% Modified version of cgloss4e.sty. Hacked and renamed cgloss.sty +% by Alexis Dimitriadis (alexis@babel.ling.upenn.edu). Integrated into +% langsci-gb4e.sty by Sebastian Nordhoff +% EnD CGLOSS META -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% auxiliary files -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\usepackage{langsci-cgloss} -% \input{jambox.sty} \@ifundefined{new@fontshape}{\def\reset@font{}\let\mathrm\rm\let\mathit\mit}{} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Font Specifications (Detmar) -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% +% Font Specifications %% +% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Define commands for fonts to be used: % @@ -86,7 +96,7 @@ % b. glossing line \newcommand{\glossfont}{\normalsize\upshape} % c. translation font -\newcommand{\transfont}{\normalsize\upshape} % 08.01.2014 changed small to normalsize (Martin Haspelmath) +\newcommand{\transfont}{\normalsize\upshape} % d. example number \newcommand{\exnrfont}{\exfont\upshape} % @@ -100,23 +110,20 @@ % d. example number \newcommand{\fnexnrfont}{\fnexfont\upshape} -% new user command for specifying translations: -%\newcommand{\mytrans}[1]{{\trans`#1'}\vskip.6\baselineskip} - - - -\renewcommand{\eachwordone}{\exfont} -\renewcommand{\eachwordtwo}{\glossfont} -\renewcommand{\eachwordthree}{\glossfont} % same font for both gloss lines +\newcommand{\examplesroman}{ + \let\eachwordone=\upshape + \exfont{\upshape} +} +\newcommand{\examplesitalics}{ + \let\eachwordone=\itshape + \exfont{\itshape} +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% %% Macros for examples, roughly following Linguistic Inquiry style. %% -%% From here on best not to tamper, else all the examples and cross- %% -%% references will come out scrambled! (see also note below) - CT %% -%% Completely rewritten for more robustness and flexibility. (hpk) %% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\qlist{\begin{list}{\Alph{xnum}.}{\usecounter{xnum}% @@ -127,8 +134,6 @@ \newif\if@xrec\@xrecfalse \@definecounter{fnx} - - % set a flag that we are in footnotes now and change the size of example fonts \let\oldFootnotetext\@footnotetext @@ -145,25 +150,22 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% counters % -% +%% %% +%% counters %% +%% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - +% start counters with 1 \newcount\@xnumdepth \@xnumdepth = 0 +% define four levels of indentation \@definecounter{xnumi} \@definecounter{xnumii} \@definecounter{xnumiii} \@definecounter{xnumiv} -%\@definecounter{equation} -%\setcounter{equation}{0} -% book -%\renewcommand\theequation -% {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@equation} -%\def\thexnumi{\@xsi{xnumi}} + +% use (1) on page, but (i) in footnotes \def\thexnumi {\if@noftnote% \@arabic\@xsi{xnumi}% @@ -199,7 +201,6 @@ \setcounter{rxnumiii}{\value{xnumiii}}% \setcounter{rxnumiv}{\value{xnumiv}}}% - \def\reset@counters{% \setcounter{xnumi}{\value{rxnumi}}% \setcounter{xnumii}{\value{rxnumii}}% @@ -207,38 +208,43 @@ \setcounter{xnumiv}{\value{rxnumiv}}}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% widths % -% +%% %% +%% widths %% +%% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Control the width of example identifiers \def\exewidth#1{\def\@exwidth{#1}} -%\exewidth{(234)} -\exewidth{(34)} -%% St. M�. 02.05.2004 +\newcommand{\twodigitexamples}{\exewidth{(23)}} +\newcommand{\threedigitexamples}{\exewidth{(234)}} +\newcommand{\fourdigitexamples}{\exewidth{(2345)}} + \def\gblabelsep#1{\def\@gblabelsep{#1}} \gblabelsep{1em} - - -%% St. M�. 02.05.2004 \def\subexsep#1{\def\@subexsep{#1}} \subexsep{1.5ex} % set initial sizes of example number and judgement sizes \exewidth{\exnrfont (35)} +% how much should examples in footnotes be indented? +\newlength{\footexindent} +\setlength{\footexindent}{0pt} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% example lists % -% +%% %% +%% example lists %% +%% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\exe{% - %\ifnum\value{equation}>9 \exewidth{(23)}\else\fi% inserted by LSP, for large example numbers - \ifnum\value{equation}>98 \exewidth{(235)}\else\fi% inserted by LSP, for large example numbers + %\ifnum\value{equation}>9 \exewidth{(23)}\else\fi% + %inserted by LangSci, for large example numbers + \ifnum\value{equation}>98 \exewidth{(235)}\else\fi% \@ifnextchar [{\@exe}{\@exe[\@exwidth]}} + \def\@exe[#1]{\ifnum \@xnumdepth >0% \if@xrec\@exrecwarn\fi% \if@noftnote\@exrecwarn\fi% @@ -249,22 +255,14 @@ \if@noftnote% \begin{list}{(\thexnumi)}% {\usecounter{xnumi}\@subex{#1}{\@gblabelsep}{0em}% - \setcounter{xnumi}{\value{equation}}}% + \setcounter{xnumi}{\value{equation}} + \nopagebreak}% \else% \begin{list}{(\roman{xnumi})}% - % 1em is the indentation of footnotes in koma-script - % if this does not work for everybody, use parameters ... - {\usecounter{xnumi}\@subex{(iiv)}{\@gblabelsep}{1.5em}% + {\usecounter{xnumi}\@subex{(iiv)}{\@gblabelsep}{\footexindent}% \setcounter{xnumi}{\value{fnx}}}% \fi} -% \begin{list}{(\thexnumi)}% -% {\usecounter{xnumi}\@subex{#1}{1em}% -% \if@noftnote% -% \setcounter{xnumi}{\value{equation}}% -% \else% -% \setcounter{xnumi}{\value{fnx}}% -% \fi}} \def\endexe{\if@noftnote\setcounter{equation}{\value{xnumi}}% \else\setcounter{fnx}{\value{xnumi}}% @@ -315,10 +313,7 @@ %%% the example-items \def\ex{\@ifnextchar [{\@ex}{\item}} \def\@ex[#1]#2{\item\@exj[#1]{#2}} -\def\@exj[#1]#2{\@exjbg{#1} #2 \end{list}} -% without understanding anything: -\def\exs#1{\item\begin{samepage}#1\end{samepage}} -%-- end +\def\@exj[#1]#2{\@exjbg{#1} #2 \end{list}\nopagebreak} \def\exi#1{\item[#1]\@ifnextchar [{\@exj}{}} \def\judgewidth#1{\def\@jwidth{#1}} \judgewidth{??} @@ -327,14 +322,6 @@ \def\exr#1{\exi{{(\ref{#1})}}} \def\exp#1{\exi{{(\ref{#1}$'$)}}} \def\sn{\exi{}} -\def\bu{\item[$\bullet$]} - -%%% Lazy abbrevs (HANDLE WITH CARE!) -%\def\ea{\ifnum\@xnumdepth=0\begin{exe}[(34)]\else\begin{xlist}[iv.]\fi\raggedright\ex} steht unten noch mal -%\def\ea{\ifnum\@xnumdepth=0\begin{exe}[(\theequation)]\else\begin{xlist}[iv.]\fi\raggedright\ex} -\def\easragged{\ifnum\@xnumdepth=0\begin{exe}[(34)]\else\begin{xlist}[iv.]\fi\raggedright\ex\begin{tabular}[t]{@{}b{\linewidth}@{}}} -\def\eas{\ifnum\@xnumdepth=0\begin{exe}[(34)]\else\begin{xlist}[iv.]\fi\ex\begin{tabular}[t]{@{}b{\linewidth}@{}}} -\def\eaa{\ifnum\@xnumdepth=0\begin{exe}[(\theequation)]\else\begin{xlist}[iv.]\fi\raggedright\ex} \def\ex{\@ifnextchar [{\exnrfont\@ex}{\exnrfont\item\exfont}} @@ -345,153 +332,497 @@ \def\ea{\ifnum\@xnumdepth=0\begin{exe}\else\begin{xlist}[iv.]\fi\raggedright\ex} \def\eal{\begin{exe}\exnrfont\ex\begin{xlist}[iv.]\raggedright} -\def\ealnoraggedright{\begin{exe}\exnrfont\ex\begin{xlist}[iv.]} -\def\eanoraggedright{\ifnum\@xnumdepth=0\begin{exe}\else\begin{xlist}[iv.]\fi\ex} -\def\glt{\nopagebreak\vskip.17\baselineskip\transfont\parindent0ex} - - - -% copied from here: -% http://tex.stackexchange.com/questions/23677/command-for-paragraph-indentation-after-equations +\def\eas{\ifnum\@xnumdepth=0\begin{exe}[(34)]\else\begin{xlist}[iv.]\fi\ex\begin{tabular}[t]{@{}p{\linewidth}@{}}} -%% As Barbara Beeton has commented, forcing the first paragraph after an equation environment to -%% indent can be achieved with \aftergroup -- use this command to add a \par after the group -%% established by the environment. - -%% Forcing the first paragraph after an environment not to indent isn't that straightforward. I came -%% up with the following: - -%% I defined a new macro \@doendeq that will redefine \everypar so that it a) removes the -%% indentation from the first paragraph following it b) reverts to its original (empty) -%% definition. (\@doendeq is an abridged version of LaTeX's \@doendpe which is used after -%% paragraph-making environments.) - -%% To change every instance of the equation environment to remove indents after it, one could -%% simply add \aftergroup\@doendeq to the definition of \endequation. As you are looking for a -%% command to modify only some instances of equation, I used \csappto from the etoolbox package -%% to locally add\aftergroup\@doendeq to \end<\@currenvir> (\@currenvir being the name of the -%% current environment). - -%% I suspect that there are more elegant ways to do this. +% allow hyphenation and justification +\def\eanoraggedright{\ifnum\@xnumdepth=0\begin{exe}\else\begin{xlist}[iv.]\fi\ex} +\def\ealnoraggedright{\begin{exe}\exnrfont\ex\begin{xlist}[iv.]} -%% \newcommand*{\@doendeq}{% -%% \everypar{{\setbox\z@\lastbox}\everypar{}}% -%% } -%% \newcommand*{\eqcntd}{% -%% \csappto{end\@currenvir}{% -%% \aftergroup\@doendeq -%% }% -%% } \def\z{\ifnum\@xnumdepth=1\end{exe}\else\end{xlist}\fi} - - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% completely undocumented code -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -% for enforcing samepage we put stuff in a tabular environment -\def\zs{\end{tabular}\ifnum\@xnumdepth=1\end{exe}\else\end{xlist}\fi} -% %\def\zt{\ifnum\@xnumdepth=1\end{exe}\else\end{xlist}\fi\end{tabular}} -% % if an example is final in a footnote -% \def\zlast{\ifnum\@xnumdepth=1\end{exe}\else\end{xlist}\fi\vspace{-\baselineskip}} -\def\zlast{\z\vspace{-\baselineskip}} -\def\eafirst{\vspace{-1.5\baselineskip}\ea} -% -% % St. Mue. 26.02.00 -% \def\eaf#1{\begin{exe}[(iv)]\exi{(#1)}} -% \def\eal{\begin{exe}[(\theequation)]\ex\begin{xlist}[iv.]} -% \def\eal{\begin{exe}\ex\begin{xlist}[iv.]\raggedright} steht unten noch mal -% \def\eafl#1{\begin{exe}[(iv)]\exi{(#1)}\begin{xlist}[iv.]} -% \def\eaal{\begin{exe}[(\theequation)]\ex\begin{xlist}[iv.]} \def\zl{\end{xlist}\end{exe}} -% % if an example is final in a footnote -% Hey, Sebastian, why did you comment this out? Please tell me, if you do such things. 22.07.2014 +\def\zs{\end{tabular}\ifnum\@xnumdepth=1\end{exe}\else\end{xlist}\fi} \def\zllast{\end{xlist}\end{exe}\removelastskip} -% -% -% %%%%%%% \lcomment for breaks in (example-)lists (leaves all counters -% %%%%%%% as they are) (hpk) -% \newlength{\lcommentsep} -% \lcommentsep = 1ex -% -% \long\def\lcomment#1% -% {\vspace{\lcommentsep} -% \item[]\hspace*{-\leftmargin}% -% \@tempskipa=\linewidth% -% \addtolength{\@tempskipa}{\rightmargin}% -% \addtolength{\@tempskipa}{\leftmargin}% -% \parbox{\@tempskipa}{#1}% -% \vspace{\lcommentsep}% -% } - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Picture examples -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Control vertical space for examples in footnotes +\def\zlast{\z\vspace{-\baselineskip}} +\def\eafirst{\vspace{-1.5\baselineskip}\ea} %%%%%% control the alignment of exampleno. and (picture-)example %%%%%% (by Lex Holt <lex@cogsci.ed.ac.uk>). \def\attop#1{\leavevmode\vtop{\strut\vskip-\baselineskip\vbox{#1}}} \def\atcenter#1{$\vcenter{#1}$} %%%%%% - -% \exewidth{\exnrfont (\theequation)}} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% several examples in one line -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% several examples in one line %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\xbox}[2]{\noindent\parbox[t]{#1}{#2}\noindent} +\newcommand{\nobreakbox}[1]{\xbox{\linewidth}{#1}} +\newcommand{\xref}[1]{(\ref{#1})} +\newcommand{\xxref}[2]{(\ref{#1}--\ref{#2})} -%\newcommand{\nobreakbox}[1]{\xbox{\linewidth}{#1}} +\iftoggle{cgloss}{ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% CGLOSS starts here %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\let\@gsingle=1 +\def\singlegloss{\let\@gsingle=1} +\def\nosinglegloss{\let\@gsingle=0} +\@ifundefined{new@fontshape}% + {\def\@selfnt{\ifx\@currsize\normalsize\@normalsize\else\@currsize\fi}} + {\def\@selfnt{\selectfont}} + +\def\gll% % Introduces 2-line text-and-gloss. + {\raggedright% + \bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \twosent +} +\def\glll% % Introduces 3-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \threesent +} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Bars and other superscripts for projections; specifiers -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\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\gllll% % Introduces 4-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \foursent +} + +\def\glllll% % Introduces 5-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \fivesent +} -\def\spec#1{[Spec,#1]} %Def. of "Specifier of #1" - +\def\gllllll% % Introduces 6-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \sixsent +} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% custom markup -% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\def\ct#1{{\em #1\/}} %Citation of linguistic material with alternative style: -%\def\ct#1{`#1'} -\def\tx{\bf} %Introduction of technical terms with alternative style: -%\def\tx{\em} +\def\glllllll% % Introduces 7-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \sevensent +} + + +\def\gllllllll% % Introduces 8-line text-and-gloss. + {\bgroup %\begin{flushleft} + \ifx\@gsingle1% + \def\baselinestretch{1}\@selfnt\fi + \bgroup + \eightsent +} - +\newlength{\gltoffset} +\setlength{\gltoffset}{.17\baselineskip} +\newcommand{\nogltOffset}{\setlength{\gltoffset}{0pt}} +\newcommand{\resetgltOffset}{\setlength{\gltoffset}{.17\baselineskip}} +\def\glt{\ifhmode\\*[\gltoffset]\else\nobreak\vskip\gltoffset\nobreak\fi\transfont} + + +% Introduces a translation +\let\trans\glt + +% \def\gln{\relax} +% % Ends the gloss environment. + +% The following TeX code is adapted, with permission, from: +% gloss.tex: Macros for vertically aligning words in consecutive sentences. +% Version: 1.0 release: 26 November 1990 +% Copyright (c) 1991 Marcel R. van der Goot (marcel@cs.caltech.edu). + +\newbox\lineone % boxes with words from first line +\newbox\linetwo +\newbox\linethree +\newbox\linefour +\newbox\linefive +\newbox\linesix +\newbox\lineseven +\newbox\lineeight +\newbox\wordone % a word from the first line (hbox) +\newbox\wordtwo +\newbox\wordthree +\newbox\wordfour +\newbox\wordfive +\newbox\wordsix +\newbox\wordseven +\newbox\wordeight +\newbox\gline % the constructed double line (hbox) +\newskip\glossglue % extra glue between glossed pairs or tuples +\glossglue = 0pt plus 2pt minus 1pt % allow stretch/shrink between words +%\glossglue = 5pt plus 2pt minus 1pt % allow stretch/shrink between words +\newif\ifnotdone + +\@ifundefined{eachwordone}{\let\eachwordone=\upshape}{\relax} +\@ifundefined{eachwordtwo}{\let\eachwordtwo=\upshape}{\relax} +\@ifundefined{eachwordthree}{\let\eachwordthree=\upshape}{\relax} +\@ifundefined{eachwordfour}{\let\eachwordfour=\upshape}{\relax} +\@ifundefined{eachwordfive}{\let\eachwordfive=\upshape}{\relax} +\@ifundefined{eachwordsix}{\let\eachwordsix=\upshape}{\relax} +\@ifundefined{eachwordseven}{\let\eachwordseven=\upshape}{\relax} +\@ifundefined{eachwordeight}{\let\eachwordeight=\upshape}{\relax} + +\def\lastword#1#2#3% #1 = \each, #2 = line box, #3 = word box + {\setbox#2=\vbox{\unvbox#2% + \global\setbox#3=\lastbox + }% + \ifvoid#3\global\setbox#3=\hbox{#1\strut{} }\fi + % extra space following \strut in case #1 needs a space + } + +\def\testdone + {\ifdim\ht\lineone=0pt + \ifdim\ht\linetwo=0pt \notdonefalse % tricky space after pt + \else\notdonetrue + \fi + \else\notdonetrue + \fi + } + +\gdef\getwords(#1,#2)#3 #4\\% #1=linebox, #2=\each, #3=1st word, #4=remainder + {\setbox#1=\vbox{\hbox{#2\strut#3{} }% adds space, the {} is needed for CJK otherwise the space + % would be ignored + \unvbox#1% + }% + \def\more{#4}% + \ifx\more\empty\let\more=\donewords + \else\let\more=\getwords + \fi + \more(#1,#2)#4\\% + } + +\gdef\donewords(#1,#2)\\{}% + +\gdef\twosent#1\\ #2\\{% #1 = first line, #2 = second line + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + +\gdef\threesent#1\\ #2\\ #3\\{% #1 = first line, #2 = second line, #3 = third + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + + + +\gdef\foursent#1\\ #2\\ #3\\ #4\\{% #1 = first line, #2 = second line, #3 = third etc + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \getwords(\linefour,\eachwordfour)#4 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \lastword{\eachwordfour}{\linefour}{\wordfour}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + \nointerlineskip + \box\wordfour + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + + + +\gdef\fivesent#1\\ #2\\ #3\\ #4\\ #5\\{% #1 = first line, #2 = second line, #3 = third etc + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \getwords(\linefour,\eachwordfour)#4 \\% + \getwords(\linefive,\eachwordfive)#5 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \lastword{\eachwordfour}{\linefour}{\wordfour}% + \lastword{\eachwordfive}{\linefive}{\wordfive}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + \nointerlineskip + \box\wordfour + \nointerlineskip + \box\wordfive + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + + + +\gdef\sixsent#1\\ #2\\ #3\\ #4\\ #5\\ #6\\{% #1 = first line, #2 = second line, #3 = third etc + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \getwords(\linefour,\eachwordfour)#4 \\% + \getwords(\linefive,\eachwordfive)#5 \\% + \getwords(\linesix,\eachwordsix)#6 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \lastword{\eachwordfour}{\linefour}{\wordfour}% + \lastword{\eachwordfive}{\linefive}{\wordfive}% + \lastword{\eachwordsix}{\linesix}{\wordsix}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + \nointerlineskip + \box\wordfour + \nointerlineskip + \box\wordfive + \nointerlineskip + \box\wordsix + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + + + +\gdef\sevensent#1\\ #2\\ #3\\ #4\\ #5\\ #6\\ #7\\{% #1 = first line, #2 = second line, #3 = third etc + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \getwords(\linefour,\eachwordfour)#4 \\% + \getwords(\linefive,\eachwordfive)#5 \\% + \getwords(\linesix,\eachwordsix)#6 \\% + \getwords(\lineseven,\eachwordseven)#7 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \lastword{\eachwordfour}{\linefour}{\wordfour}% + \lastword{\eachwordfive}{\linefive}{\wordfive}% + \lastword{\eachwordsix}{\linesix}{\wordsix}% + \lastword{\eachwordseven}{\lineseven}{\wordseven}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + \nointerlineskip + \box\wordfour + \nointerlineskip + \box\wordfive + \nointerlineskip + \box\wordsix + \nointerlineskip + \box\wordseven + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + + + +\gdef\eightsent#1\\ #2\\ #3\\ #4\\ #5\\ #6\\ #7\\ #8\\{% #1 = first line, #2 = second line, #3 = third etc + \getwords(\lineone,\eachwordone)#1 \\% + \getwords(\linetwo,\eachwordtwo)#2 \\% + \getwords(\linethree,\eachwordthree)#3 \\% + \getwords(\linefour,\eachwordfour)#4 \\% + \getwords(\linefive,\eachwordfive)#5 \\% + \getwords(\linesix,\eachwordsix)#6 \\% + \getwords(\lineseven,\eachwordseven)#7 \\% + \getwords(\lineeight,\eachwordeight)#8 \\% + \loop\lastword{\eachwordone}{\lineone}{\wordone}% + \lastword{\eachwordtwo}{\linetwo}{\wordtwo}% + \lastword{\eachwordthree}{\linethree}{\wordthree}% + \lastword{\eachwordfour}{\linefour}{\wordfour}% + \lastword{\eachwordfive}{\linefive}{\wordfive}% + \lastword{\eachwordsix}{\linesix}{\wordsix}% + \lastword{\eachwordseven}{\lineseven}{\wordseven}% + \lastword{\eachwordeight}{\lineeight}{\wordeight}% + \global\setbox\gline=\hbox{\unhbox\gline + \hskip\glossglue + \vtop{\box\wordone % vtop was vbox + \nointerlineskip + \box\wordtwo + \nointerlineskip + \box\wordthree + \nointerlineskip + \box\wordfour + \nointerlineskip + \box\wordfive + \nointerlineskip + \box\wordsix + \nointerlineskip + \box\wordseven + \nointerlineskip + \box\wordeight + }% + }% + \testdone + \ifnotdone + \repeat + \egroup % matches \bgroup in \gloss + \gl@stop} + +%\def\gl@stop{{\hskip -\glossglue}\unhbox\gline\end{flushleft}} + +% \leavevmode puts us back in horizontal mode, so that a \\ will work +\def\gl@stop{{\hskip -\glossglue}\unhbox\gline\leavevmode \egroup} +}{} %end toggle cgloss + +\iftoggle{jambox}{ +%BeGIN Jambox +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Alexis Dimitriadis +% +% This is version 0.3 (informal release, Nov. 2003). +% +% Line up material a fixed distance from the right margin. For annotating +% example sentences, usually with a short note in parentheses. +% May overflow to the left or right, or line up on the next line as necessary. +% +% \jambox[width]{text} Align 'text' starting 'width' distance from the +% right margin (default \the\jamwidth). +% \jam(something) Align a note delimited by parentheses (which are +% retained). No optional argument. +% \jambox*{text} Set \jamwidth to the width of 'text', then align it. +% (\jamwidth stays set for the rest of the environment). +% +% Notes: +% +% Distance from the right margin can be set to an explicit amount, or to the +% width of some piece of text, as follows: +% +% \jamwidth=2in\relax Or +% \settowidth\jamwidth {(``annotation'')} +% +% \jamwidth is locally scoped, so it can be set globally or inside an example +% environment. +% +% BUG: Not compatible with ragged-right mode. +% +% Incompatibilities: Not useful with the vanilla cgloss4e.sty, which ends +% glossed lines prematurely. +% I do have a suitably modified file, cgloss.sty. With it you can do the +% following: +% \gll To kimeno. \\ +% the text \\ \jambox{(Greek)} +% \trans `The text.' + + +\newdimen\jamwidth \jamwidth=2in +\def\jambox{\@ifnextchar[{\@jambox} + {\@ifnextchar*{\@jamsetbox}{\@jambox[\the\jamwidth]}}} + +% Set width AND display the argument. +% The star is read and ignored; the argument #1 is boxed, used to set +% \jamwidth, then passed to \@jambox (which also puts it in \@tempboxa!) +% +\def\@jamsetbox*#1{\setbox\@tempboxa\hbox{#1}\jamwidth=\wd\@tempboxa + \@jambox[\the\jamwidth]{\box\@tempboxa}} + +\def\@jambox[#1]#2{{\setbox\@tempboxa\hbox {#2}% + \ifdim \wd\@tempboxa<#1\relax % if label fits in the alloted space: + \@tempdima=#1\relax \advance\@tempdima by-\wd\@tempboxa % remaining \hspace + \unskip\nobreak\hfill\penalty250 % break line here if necessary + \hskip 1.2em minus 1.2em % used when the line extends past the margin + \hbox{}\nobreak\hfill\box\@tempboxa\nobreak + \hskip\@tempdima minus \@tempdima\hbox{}% + \else % the label is too wide: just right-align it + \hfill\penalty50\hbox{}\nobreak\hfill\box\@tempboxa + \fi + % suppress closing glue: + \parfillskip=0pt \finalhyphendemerits=0 \par}} +% The penalty enables a break, taken only if the line cannot fit. +% The \hbox{} ensures the next line does not begin with \hfill, which would +% be discarded if initial. +% (\vadjust inserts an empty element at the beginning of the next line, so +% that COULD be used instead of \hbox{}). +% Algorithm adapted from The TeXBook. +% +% The closing \par could be a problem if there is a \parskip... +}{} +\endinput |