7

I'm using the package gb4e to gloss my linguistic examples. It nicely aligns the words in the original language with its glosses. But this alignment does not extend beyond the first line of glosses. If I want to gloss the words in more than one language, there will be no alignment beyond the first line of glosses. How can I enforce such alignment?

\documentclass{article}
\usepackage{gb4e}
\begin{document}
\begin{exe}
    \ex
    \gll gef hundinum matinn\\
    gje hunden maten\\
    give {the dog} {the food}\\
    gib {dem Hunde} {das Essen}\\
\end{exe}
\end{document}

enter image description here

  • Manually should be no problem, but I guess you want it automated (with cookies on the side). – Werner Jan 26 '14 at 19:30
  • @Werner Manual solutions will also be appreciated! :) – Sverre Jan 26 '14 at 19:35
11

The cgloss4e package, which is loaded by gb4e is able to account for an example with two lines of glosses automatically, using the \glll (note the extra l) macro:

\documentclass{article}
\usepackage{gb4e}
\begin{document}
\begin{exe}
    \ex
    \glll gef hundinum matinn\\
    give {the dog} {the food}\\
    gib {dem Hunde} {das Essen}\\
\end{exe}
\end{document}

However, for your example, you require yet one more line of gloss, for which the package is not actually designed. But it's not to hard to add the relevant code. Here I've created a \gliv command to introduce an example with 3 extra gloss lines.

\documentclass{article}
\usepackage{gb4e}
\makeatletter
\newbox\linefour
\newbox\wordfour
\def\gliv%                 % Introduces 4-line text-and-gloss.
   {\begin{flushleft}
     \ifx\@gsingle1% 
        \vskip\baselineskip\def\baselinestretch{1}%
        \@selfnt\vskip-\baselineskip\fi%
    \bgroup
    \foursent
   }
\@ifundefined{eachwordfour}{\let\eachwordfour=\rmfamily}{\relax}   
\gdef\foursent#1\\ #2\\ #3\\ #4\\{% #1 = first line, #2 = second line, #3 = third, #4 = fourth
    \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}
\makeatother

\begin{document}
\begin{exe}
    \ex
    \gliv gef hundinum matinn\\
    gje hunden maten\\
    give {the dog} {the food}\\
    gib {dem Hunde} {das Essen}\\
\end{exe}
\end{document}

output of code

5

A manual way of achieving this is possible via tabbing:

enter image description here

\documentclass{article}
\usepackage{gb4e}
\begin{document}
\begin{exe}
    \ex \begin{tabbing}
      give \= dem Hunde \= das Essen \kill
      gef \> hundinum \> matinn \\
      gje \> hunden \> maten\\
      give \> the dog \> the food \\
      gib \> dem Hunde \> das Essen
    \end{tabbing}
\end{exe}
\end{document}

The \kill line contains the longest word across each language translation to mark the tabbing points with \=.

  • This solution is really only practical for very short lines. One of the things that the glossing macros do is automatically line up each word independent of the length of the example, so that the glossed lines will wrap as needed. – Alan Munn Jan 27 '14 at 2:51
  • @AlanMunn: True. You've done a great job at extending this. – Werner Jan 27 '14 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.