4

Below are several sets of identical side-by-side parboxes; the right parbox contains an interlinear gloss (expex) and the left contains regular text. The top three sets are before the modified expex code from this answer, and the bottom set is with the modified code implemented. The modified code simply puts the example number on the correct side of the margin in a RTL context (see bottom vs top examples).

Based on the way my parboxes are set up, there should be almost no gap between them, but as you can see, there is a large gap between the gloss and text. Even if I modify the size of the parbox the gap won't shrink. How can I make the distance between the two parboxes function as I want?

My guess as to what's happening is that perhaps the modified expex code in the MWE is leaving an empty gap where the example number normally would go and the parbox isn't allowed to fill it in. But I'm not sure how to fix that.

%XeLaTeX
\documentclass[11pt]{scrartcl}

\usepackage[showframe]{geometry} 
\usepackage{expex}
\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \setotherlanguage{hebrew}
    \newfontfamily\hebrewfont[Script=Hebrew]{Linux Libertine O}
    \newfontfamily\englishfont[Ligatures=NoCommon]{Linux Libertine O}

\begin{document}

\section{Bar of Foo 1}
\textbf{Before \textsf{example number} fix.}

\noindent\makebox[\textwidth]{\parbox[t]{.29\textwidth}{
\exdisplay\noexno\strut\textenglish
a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa.
\xe}\hfill
\parbox[t]{.69\textwidth}{\begin{hebrew}\ex\begingl
\gla א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא //
\glb a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glc a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\endgl\xe\end{hebrew}}}%

\noindent\textbf{Before \textsf{example number} fix - English only, no Hebrew}

\noindent\makebox[\textwidth]{\parbox[t]{.29\textwidth}{
\exdisplay\noexno\strut
a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa.
\xe}\hfill
\parbox[t]{.69\textwidth}{\ex\begingl
\gla a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glb a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glc a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\endgl\xe}}%

\noindent\textbf{Before \textsf{example number} fix - English only, no example number. PROPER parbox SPACING}

\noindent\makebox[\textwidth]{\parbox[t]{.29\textwidth}{
\exdisplay\noexno\strut
a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa.
\xe}\hfill
\parbox[t]{.69\textwidth}{\exdisplay\noexno\begingl
\gla a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glb a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glc a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\endgl\xe}}%    

\makeatletter
\def\ex@c{%
   \ex@setup
   \leavevmode
   \setbox\numbox=\hbox{\hskip\lingnumoffset\ep@actualexnoprint}%
   \epd@numright=\wd\numbox
   \ifcase\ep@textanchor                          % numleft
         \ep@settosum\leftskip\lingnumoffset\lingtextoffset
      \or                                         % normal
         \ep@settosum\leftskip\epd@numright\lingtextoffset
      \fi
   % begin changes
   % \llap{\hbox to\leftskip{\unhbox\numbox \hss}}%
   \if@RTL
     \hbox to\leftskip{\unhbox\numbox \hss}%
   \else
     \llap{\hbox to\leftskip{\unhbox\numbox \hss}}%
   \fi
   % end changes
   \lingeveryex
   \latex@tagex
   \ignorespaces
}

\def\glw@begingl@a{%
   \bgroup
   \parindent0pt
   \ep@setglstrut
   \ifdim\ling@glwidth=0pt
      \ifling@glossbreaking
         \bgroup
       \else
         \vtop\bgroup
           % begin changes
           % \advance\hsize by -\leftskip
           \if@RTL
              \advance\hsize by -2\leftskip
           \else
              \advance\hsize by -\leftskip
           \fi
           % end changes
            \advance\hsize by -\rightskip
            \leftskip=0pt
       \fi
   \else
      \vtop\bgroup
         \hsize=\ling@glwidth
         \leftskip=0pt
   \fi
   \bgroup
   \parindent=0pt
   \@glpreamblefalse
   \@glftfalse
   \let\mainlist=\empty
   \let\itemtypelist=\empty
   \let\aboveskiplist=\empty
   \let\strutlist=\empty
   \let\everylist=\empty
}
\makeatother

\noindent \textbf{After \textsf{example number} fix.}

\noindent\makebox[\textwidth]{\parbox[t]{.29\textwidth}{
\exdisplay\noexno\strut\textenglish
a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa.
\xe}\hfill
\parbox[t]{.69\textwidth}{\begin{hebrew}\ex\begingl
\gla א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא //
\glb a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glc a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\endgl\xe\end{hebrew}}}%    

\end{document}

enter image description here

6
+50

The problem is that \leftskip is used to leave space for the number, but in RTL typesetting the skip is needed on the right.

You can define a \beginskip, which is \rightskip or \leftskip depending on the direction and use this instead:

\documentclass[11pt]{scrartcl}

\usepackage[showframe]{geometry} 
\usepackage{expex}
\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \setotherlanguage{hebrew}
    \newfontfamily\hebrewfont[Script=Hebrew]{Linux Libertine O}
    \newfontfamily\englishfont[Ligatures=NoCommon]{Linux Libertine O}

\begin{document}

\section{Bar of Foo 1}
\makeatletter
\newcommand\beginskip{\if@RTL\rightskip\else\leftskip\fi}% added macro 
\def\ex@c{%
   \ex@setup
   \leavevmode
   \setbox\numbox=\hbox{\hskip\lingnumoffset\ep@actualexnoprint}%
   \epd@numright=\wd\numbox
   % begin changes: replace every `\leftskip` with `\beginskip`
   \ifcase\ep@textanchor                          % numleft
        \ep@settosum\beginskip\lingnumoffset\lingtextoffset
      \or                                         % normal
        \ep@settosum\beginskip\epd@numright\lingtextoffset
      \fi
   \llap{\hbox to\beginskip{\unhbox\numbox \hss}}%
   % end changes
   \lingeveryex
   \latex@tagex
   \ignorespaces
}
\makeatother

\noindent \textbf{After \textsf{example number} fix.}

\noindent\makebox[\textwidth]{\parbox[t]{.29\textwidth}{
\exdisplay\noexno\strut\textenglish
a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa.
\xe}\hfill
\parbox[t]{.69\textwidth}{\begin{hebrew}\ex\begingl
\gla א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא א אא אאא //
\glb a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\glc a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa a aa aaa //
\endgl\xe\end{hebrew}}}%    

\end{document}

enter image description here

1
  • Much more elegant than the original, partial solution. Would you please comment the line \def\beginskip{\if@RTL\rightskip\else\leftskip\fi} so that we know that is also new?
    – AML
    May 2 '18 at 11:32

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.