修改后的 RTL expex 环境中两个 parbox 之间存在很大差距

修改后的 RTL expex 环境中两个 parbox 之间存在很大差距

下面是几组并排的相同版本parbox;右边的版本parbox包含行间注释(expex),左侧包含常规文本。前三组在expex从这个答案修改的代码,底部的集合是使用修改后的代码实现的。修改后的代码只是将example numberRTL 上下文中的边距放在正确的一侧(参见底部与顶部的示例)。

根据我的parboxes 的设置方式,它们之间应该几乎没有间隙,但正如您所看到的,注释和文本之间存在很大间隙。即使我修改了大小,间隙parbox也不会缩小。我怎样才能使两个parboxes 之间的距离按我想要的方式发挥作用?

我猜测发生的事情是,也许expexMWE 中修改后的代码在example number通常会出现的位置留下了一个空白,而parbox不允许填补它。但我不确定如何解决这个问题。

%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}

在此处输入图片描述

答案1

问题是\leftskip用来给数字留出空间,但在 RTL 排版中需要在右侧跳过。

您可以定义一个\beginskip,它是\rightskip\leftskip取决于方向,并改用这个:

\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}

在此处输入图片描述

相关内容