2

Often authors provide the language name together with examples. The language name is flushed to the right. This works well with short examples but looks ugly with long examples. The code below produces this:

\documentclass{article}

\usepackage{langsci-gb4e}


\usepackage{hyperref}

\begin{document}


\ea
\gll Das ist ein deutsches Beispiel.\\
     this is a   German    example\\ \hfill(German)
\z

\ea
\gll Das  ist einer dieser sehr langen Sätze, die es im Deutschen gibt.\\
     this is  one   of.these very long sentences that it in.the German gives\\ \hfill(German)
\z

\end{document}

enter image description here

What would be better is having some way to limit the space gb4e is taking and having the language aligned at the top of what gb4e does.

Like this:

enter image description here

Is there a way to do this?

1

The tradeoff here is between automatic line wrapping of the long example versus manual intervention. Your solution involves a lot of markup in order to preserve the automatic wrapping of the example. I would go in the other direction and manually split the example where you want it so that the language name annotation fits without extra markup.

\documentclass{article}

\usepackage{langsci-gb4e}


\begin{document}


\ea
\gll Das ist ein deutsches Beispiel.\\
     this is a   German    example\\ \hfill(German)
\z

\ea
\gll Das  ist einer dieser sehr langen Sätze,\\ 
     this is  one   of.these very long sentences\\ \hfill(German)
\sn \gll die es im Deutschen gibt.\\
    that it in.the German gives\\
\z

\end{document}

output of code

1

I found an answer. Maybe it is too complicated, but it works.

\documentclass{article}

\usepackage{langsci-gb4e}

\usepackage{tabularx}

\usepackage{calc}
\usepackage{lipsum}

\newcommand{\longexampleandlanguage}[2]{
\begin{tabularx}{\linewidth}[t]{@{}X@{}p{\widthof{(#2)}}@{}}
\begin{minipage}[t]{\linewidth-1em}
#1
\end{minipage} & (#2)\\
\end{tabularx}}


\begin{document}


\ea
\gll Das ist ein deutsches Beispiel.\\
     this is a   German    example\\ \hfill(German)
\z

\lipsum[1][1-4]


\ea
\longexampleandlanguage{
    \gll Das  ist einer dieser   sehr langen Sätze,    die  es in der a b deutschen Sprache gibt.\\
         this is  one   of.these very long   sentences that it in the a b German    language gives\\
}{German}
\z

\lipsum[1][1-4]




\end{document}

enter image description here

1
  • 1
    +1 This works much better than your original version.
    – Alan Munn
    Nov 9 '21 at 20:52

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.