3

The example number in the expex package can be adjusted horizontally with the numoffset and textoffset commands, as documented on page 11 of the documentation (links to PDF). But how can it be adjusted vertically (relative to the \gla baseline? The commands aboveexskip and belowexskip do not adjust the example number itself.

I would like the solution to work with both LTR and RTL languages.

%XeLaTeX
\documentclass{scrbook}

\usepackage{libertine}
\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \setotherlanguage{hebrew}
    \newfontfamily\hebrewfont[Script=Hebrew]{Linux Libertine O}
    \newfontfamily\englishfont{Linux Libertine O}

\usepackage{expex} %gloss package

\lingset{everygla=\LARGE}

% to fix RTL example number going into margin
\makeatletter
\def\beginskip{\if@RTL\rightskip\else\leftskip\fi}
\def\ex@c{%
   \ex@setup
   \leavevmode
   \setbox\numbox=\hbox{\hskip\lingnumoffset\ep@actualexnoprint}%
   \epd@numright=\wd\numbox
   \ifcase\ep@textanchor
        \ep@settosum\beginskip\lingnumoffset\lingtextoffset
      \or
        \ep@settosum\beginskip\epd@numright\lingtextoffset
      \fi
   \llap{\hbox to\beginskip{\unhbox\numbox \hss}}
   \lingeveryex
   \latex@tagex
   \ignorespaces
}
\makeatother

\begin{document}

\noindent Left-to-right (LTR) example:

\ex\begingl
\gla Lorem ipsum //
\glb lorem ipsum //
\endgl\xe


\hfill Right-to-left (RTL) example:

\begin{hebrew}\ex\begingl
\gla לוראם איפסום //
\glb lorem ipsum //
\endgl\xe\end{hebrew}

\end{document}

enter image description here

1 Answer 1

2

You can add a new dimension key to ExPex and adjust the number using that. The following code works for \ex examples, but not \pex examples, since that code hasn't been included in your RTL/LTR fix.

%XeLaTeX
\documentclass{scrbook}

\usepackage{libertine}
\usepackage{polyglossia}
    \setdefaultlanguage{english}
    \setotherlanguage{hebrew}
    \newfontfamily\hebrewfont[Script=Hebrew]{Linux Libertine O}
    \newfontfamily\englishfont{Linux Libertine O}

\usepackage{expex} %gloss package



% to fix RTL example number going into margin
\makeatletter
% add a new dimension key numvoffset
\define@lingincdimenkeys{numoffset,textoffset,numvoffset}

\def\beginskip{\if@RTL\rightskip\else\leftskip\fi}
\def\ex@c{%
   \ex@setup
   \leavevmode
   \setbox\numbox=\hbox{\hskip\lingnumoffset\ep@actualexnoprint}%
   \epd@numright=\wd\numbox
   \ifcase\ep@textanchor
        \ep@settosum\beginskip\lingnumoffset\lingtextoffset
      \or
        \ep@settosum\beginskip\epd@numright\lingtextoffset
      \fi
   % add \lingnumvoffset to the example number output code
   \llap{\raise\lingnumvoffset\hbox to\beginskip{\unhbox\numbox \hss}}
   \lingeveryex
   \latex@tagex
   \ignorespaces
}
\makeatother

% set the dimension key globally
\lingset{everygla=\LARGE,numvoffset=.5ex}
\begin{document}

\noindent Left-to-right (LTR) example:

\ex\begingl
\gla Lorem ipsum //
\glb lorem ipsum //
\endgl\xe


\hfill Right-to-left (RTL) example:

\begin{hebrew}\ex\begingl
\gla לוראם איפסום //
\glb lorem ipsum //
\endgl\xe\end{hebrew}

\end{document}

output of code

2
  • Excellent. I feel like this should exist in the expex package. Maybe I'll suggest it to John.
    – AML
    Jun 6, 2018 at 23:57
  • @AML Be my guest. It will need to be updated for the \pex examples anyway.
    – Alan Munn
    Jun 7, 2018 at 0:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .