4

I need Devanagari counters in package expex.

%!TeX TS-Program=xelatex
\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{marathi}
\setmainfont[Script=Devanagari,Mapping=devanagarinumerals]{Shobhika}
\usepackage{expex}

\begin{document}
\pex
\a\begingl
\gla रामः आम्रफलम् खादति//
\glb राम आंबा खातो//
\glft राम आंबा खातो.//
\endgl
\a\begingl
\gla रामः आम्रफलम् खादति//
\glb राम आंबा खातो//
\glft राम आंबा खातो.//
\endgl
\xe
\end{document}

This generates a decent output, but unfortunately the second level items are in English. I want Devanagari counters. (अ, आ, इ, ई, उ, ऊ, ए, ऐ, ओ, औ, अं, अः) How to achieve it?

13
  • ExPex unfortunately uses a weird trick using \char to format alpha labels. It may not be trivial to make it use regular LaTeX methods.
    – Alan Munn
    Commented Jun 9, 2020 at 20:15
  • Do you mean it can't be changed?
    – Niranjan
    Commented Jun 9, 2020 at 20:18
  • I'm not saying it's impossible, but because of the way it formats example numbers, it might not be very easy.
    – Alan Munn
    Commented Jun 9, 2020 at 20:32
  • It turns out not to be too difficult after all!
    – Alan Munn
    Commented Jun 9, 2020 at 20:46
  • The babel language files provide a way to map \alph counters to Hindi letters, but as of June 2020, this is not available for Marathi.
    – Davislor
    Commented Jun 10, 2020 at 2:48

1 Answer 1

4

ExPex allows you to stipulate a list of items for a label list, so we can simply define a labeltype called devanagari and set it to the list of the corresponding alpha labels. I've used the width parameter from the uppercase alpha labels; this might not be appropriate for the Devanagari labels, so adjust the labelwidth accordingly.

The labelgen key can be thought of as a function that provides the mapping between the counter of the subexample to its label. It accepts four values: char, number, romannumber or list. Using char will give you the equivalent of \alph in LaTeX, but because ExPex doesn't implement it using \alph it won't work with language definitions that redefine \alph like polyglossia or babel. The number and romannumber values are self-explanatory. The list value tells ExPex to consult an ordered list of characters to construct the label. This is the recommended solution for non-Latin alphabets.

ExPex also uses a somewhat idiosyncratic method for specifying the label and reference format. These are the keys labelformat and fullrefformat. The labelformat provides a template for formatting the label, where A is a stand-in for the label. So using labelformat=A. says format the label with a period after it. If you wanted the label to be parenthesized, you could specify labelformat=(A) for example.

The fullrefformat key specifies how references to the label will appear (using ExPex's builtin \getref system (which is not the usual LaTeX \label and \ref system.)) The fullrefformat key provides a template for formatting the reference, where X is a stand-in the example number and A is the stand-in for the subexample label. Since the label includes a period (labelformat=A.) but we typically don't want the reference to the label to include the ., we specify the fullrefformat to be XA.

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{marathi}
\setmainfont[Script=Devanagari,Mapping=devanagarinumerals]{ITF Devanagari}
\usepackage{expex}
\usepackage{etoolbox}
\makeatletter
\makeatother
\definelabeltype{devanagari}
  {labelgen=list,labellist={अ, आ, इ, ई, उ, ऊ, ए, ऐ, ओ, औ, अं, अः},
  labelformat=A.,fullrefformat=XA,labelalign=left,labelwidth=.92em}

\begin{document}
\lingset{labeltype=devanagari}
\pex
\a\begingl
\gla रामः आम्रफलम् खादति//
\glb राम आंबा खातो//
\glft राम आंबा खातो.//
\endgl
\a\begingl
\gla रामः आम्रफलम् खादति//
\glb राम आंबा खातो//
\glft राम आंबा खातो.//
\endgl
\xe
\end{document}

output of code

7
  • Output produced with expex is unbeatable in all the example packages. Thank you so much Alan :)
    – Niranjan
    Commented Jun 10, 2020 at 4:05
  • It would be very helpful for me as well as other users if you explain with comments the parameters used in this definition. i.e. labelgen=list, labelformat=A., fullrefformat=XA
    – Niranjan
    Commented Jun 10, 2020 at 4:08
  • 1
    @Niranjan I've added some more explanation. All of this is fairly well described in the ExPex documentation.
    – Alan Munn
    Commented Jun 10, 2020 at 14:32
  • Thank you so much :)
    – Niranjan
    Commented Jun 10, 2020 at 14:39
  • 1
    @Niranjan This is a separate question. You can link to this one but ask it as a new question. Your first question was using xelatex, polyglossia and a problem with the subexample numbering. This is a totally different problem.
    – Alan Munn
    Commented Jun 12, 2020 at 19:59

You must log in to answer this question.

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