# Justifying text within ExPex

LaTeX justifies text by default, but this seems to not be the case for text within the ExPex package. I would like to fully justify the \gla, \glb, and \glc together, as well as the \glft. Here is a MWE:

\documentclass{book}
\usepackage{expex}
\begin{document}
\exdisplay[glftpos=right,glhangstyle=none]
\begingl
\gla aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa //

\glb bbbb b bbb bbb b bbbb bbbb bbbb bb bb bbbbbbbb bbbb bbbb b bbb bbb b bbbb bbbb bbbb bb bb bbbbbbbb bbbb//

\glc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc//

\glft dddd d ddd ddd d dddd dddd dddd dd dd dddddddd dddd dddd d ddd ddd d dddd dddd dddd dd dd dddddddd dddd//
\endgl
\xe
\end{document}


As you can see below, the text comes out non-justified.

How does one get justified text in ExPex? Ideally, the solution should also work using non-Latin letters, including right-to-left languages.

• Have you ever seen a publication with interlinear examples justified like this? I don't think I ever have. Whether it's possible to implement in expex is a fair question, but the package has not been designed with justified examples in mind, and it's worth asking whether you really need justified examples or not. – Jason Zentz Mar 3 '17 at 14:47
• This is from p. 38 of the expex documentation: "Val(glspace) is the horizontal skip between glwords and Val(glrightskip) is the right skip. The initial settings allow considerable stretch and some shrinkage in the space between glwords and up to 10% of the page width in whitespace at the right margin. This minimizes the chances of overfull lines and, since interlinear glosses generally have a somewhat ragged appearance, does not detract from their appearance." You would have to manipulate glspace and glrightskip to get justification, but it's clear that is not the intent. – Jason Zentz Mar 3 '17 at 14:49
• Yes, there are examples. Please check out Hebrew-English Interlinear ESV Old Testament: Biblia Hebraica Stuttgartensia (BHS) and English Standard Version (ESV) on Amazon. Regarding me needing justification, I mean, I need it as much as a non-ExPex user does. It looks better. I want justification. – AML Mar 3 '17 at 15:00
• fair enough. It's fine if that's the norm in your field, it's just that expex (and similar packages like gb4e, linguex, etc.) were designed by linguists for the kinds of examples we use in our field, which, as the quotation above suggests, aren't justified. If you were a linguist, I would tell you it's not worth trying to justify the examples because that doesn't follow our field's conventions. But given that you're in another field that uses interlinear examples, it's fine to want the justification and try to see if expex can do that for you. I'm working on an answer for you. – Jason Zentz Mar 3 '17 at 15:05
• After posting my answer, I just checked out the interlinear OT you suggested to see how they format things. You might want to check out this answer to get centered glwords. – Jason Zentz Mar 3 '17 at 16:53

There are two subproblems that have to be solved: (i) getting justification in the aligned lines (\gla, \glb, \glc, etc.) and (ii) getting justification in the free translation (\glft).

## Justification in the aligned lines

The expex package provides two parameters whose default values can be manipulated to get justification in the aligned lines.

The glrightskip parameter determines how much space is possible between the right margin and the last glword on a line. (A glword is the box that consists of a word in \gla and a gloss on lower aligned lines; see section 9.1 of the documentation). This parameter's default value is set to 0pt plus .1\hsize (p. 38), which allows for up to 10% of the line width to be whitespace before the right margin. If you remove the plus .1\hsize, you can force the final glword to be at the right margin.

You should also adjust the glspace parameter, which determines the amount of space between glwords. Its default value is set to .5em plus .4em minus .15em (p. 38), so if you want to allow more whitespace between glwords (which may be necessary for justification), you can increase plus .4em; in the example below I've made it plus 3em.

## Justification in the free translation

To get justification in the free translation, you can load the ragged2e package and put \justifying\noindent in the definition of the everyglft parameter. (See this answer.) Beware that the column for your free translation is very narrow in the MWE you provided, so you may run into some issues with overfull hboxes when you justify your free translations. See this question and its answers if that is the case.

## Example

In the following example, I modified your MWE to make longer words in the aligned lines, which cause the (lack of) justification to be more noticeable since expex won't break any glwords across lines.

\documentclass{book}

\usepackage{ragged2e}
\usepackage{expex}

\lingset{% you can use \lingset to define parameters globally for your document
glftpos=right%
,glhangstyle=none%
}

\definelingstyle{justified}{glrightskip=0pt% the default value for this parameter is 0pt plus .1hsize; by removing the "plus .1hsize" you force the last glword to be at the right margin
,glspace=0.5em plus 3em minus 0.15em% the default value for this parameter is .5em plus .4em minus .15em; by increasing the "plus" value from 0.4em to 3em, you increase how much stretch there is between glwords; if this isn't enough for your needs, you can always increase the value
,everyglft=\justifying\noindent% \justifying is provided by the ragged2e package
}

\begin{document}

\exdisplay
\begingl
\glpreamble \textbf{Without justification}//

\gla aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa //

\glb bbbb b bbbbbbbbbb bbb b bbbbbbbbbbbbbb bbbb bbbb bb bbbbbbbbbb bbbbbbbb bbbb bbbb bbb bbb bbb bbbbbbbbb bbbbbbbbbbbbbbb bbbb bbbbbbbbbbbbbbbb bb bbbb bbbbbbbb bbbb//

\glc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc//

\glft Some actual English text so that you can see whether the hyphenation and justification provided by \LaTeX{} are actually working in this free translation.//
\endgl
\xe

\exdisplay[lingstyle=justified]
\begingl
\glpreamble \textbf{With justification}//

\gla aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa aaaa a aaa aaa a aaaa aaaa aaaa aa aa aaaaaaaa aaaa //

\glb bbbb b bbbbbbbbbb bbb b bbbbbbbbbbbbbb bbbb bbbb bb bbbbbbbbbb bbbbbbbb bbbb bbbb bbb bbb bbb bbbbbbbbb bbbbbbbbbbbbbbb bbbb bbbbbbbbbbbbbbbb bb bbbb bbbbbbbb bbbb//

\glc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc cccc c ccc ccc c cccc cccc cccc cc cc cccccccc cccc//

\glft Some actual English text so that you can see whether the hyphenation and justification provided by \LaTeX{} are actually working in this free translation.//
\endgl
\xe
\end{document}


I don't see any reason this solution should not work equally well for non-Latin letters or RTL text, but you should ask a separate question about that if it doesn't work in those particular scenarios.