example number
包中的可以使用和命令expex
进行水平调整,如第 11 页所述numoffset
textoffset
文档(PDF 链接). 但如何调整垂直(相对于\gla
基线?命令本身aboveexskip
并不belowexskip
调整example number
。
我希望该解决方案能够适用于 LTR 和 RTL 语言。
%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}
答案1
您可以向 ExPex 添加新的维度键,并使用该键调整数字。以下代码适用于\ex
示例,但不适用于\pex
示例,因为该代码尚未包含在您的 RTL/LTR 修复中。
%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}