Create symbols, arrows, text at beginning of hanging indents in ExPex











up vote
3
down vote

favorite












I am using the expex package with numerous examples which break into two or more lines due to the length of either gla or glb contents. The normal and cascading options for glhangstyle work without issue.



However, I sometimes find the examples text-heavy and difficult to follow visually. I was considering the possibility of including a symbol or arrow at the beginning of each line which is a hanging indent. After playing around with xpatchcmd, I have determined that I am not familiar enough with expex to figure it out - if it is even possible.



I have no MWE, but am including an image from the expex documentation followed by one that I touched up to show an example of what I am hoping to accomplish. This example includes an arrow, but I am hoping that I could include basically anything there, such as a symbol. Assuming this is possible, I think it should be available for both normal and cascading options...possibly even none?



Current cascading appearance:
enter image description here



MWE for cascading example excerpt from expex-demo.tex:



documentclass{article}

usepackage{expex}


begin{document}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s}//
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

end{document}


Trying to do with arrows:
enter image description here










share|improve this question




















  • 2




    You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
    – Ulrike Fischer
    Dec 21 '17 at 22:19










  • Ok, I copied the example from expex-demo.tex.
    – whatisit
    Dec 22 '17 at 5:45










  • @whatisit Doesn't cascading feature preclude the need for arrows?
    – AML
    Apr 18 at 17:12










  • I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
    – whatisit
    Apr 22 at 17:03















up vote
3
down vote

favorite












I am using the expex package with numerous examples which break into two or more lines due to the length of either gla or glb contents. The normal and cascading options for glhangstyle work without issue.



However, I sometimes find the examples text-heavy and difficult to follow visually. I was considering the possibility of including a symbol or arrow at the beginning of each line which is a hanging indent. After playing around with xpatchcmd, I have determined that I am not familiar enough with expex to figure it out - if it is even possible.



I have no MWE, but am including an image from the expex documentation followed by one that I touched up to show an example of what I am hoping to accomplish. This example includes an arrow, but I am hoping that I could include basically anything there, such as a symbol. Assuming this is possible, I think it should be available for both normal and cascading options...possibly even none?



Current cascading appearance:
enter image description here



MWE for cascading example excerpt from expex-demo.tex:



documentclass{article}

usepackage{expex}


begin{document}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s}//
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

end{document}


Trying to do with arrows:
enter image description here










share|improve this question




















  • 2




    You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
    – Ulrike Fischer
    Dec 21 '17 at 22:19










  • Ok, I copied the example from expex-demo.tex.
    – whatisit
    Dec 22 '17 at 5:45










  • @whatisit Doesn't cascading feature preclude the need for arrows?
    – AML
    Apr 18 at 17:12










  • I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
    – whatisit
    Apr 22 at 17:03













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I am using the expex package with numerous examples which break into two or more lines due to the length of either gla or glb contents. The normal and cascading options for glhangstyle work without issue.



However, I sometimes find the examples text-heavy and difficult to follow visually. I was considering the possibility of including a symbol or arrow at the beginning of each line which is a hanging indent. After playing around with xpatchcmd, I have determined that I am not familiar enough with expex to figure it out - if it is even possible.



I have no MWE, but am including an image from the expex documentation followed by one that I touched up to show an example of what I am hoping to accomplish. This example includes an arrow, but I am hoping that I could include basically anything there, such as a symbol. Assuming this is possible, I think it should be available for both normal and cascading options...possibly even none?



Current cascading appearance:
enter image description here



MWE for cascading example excerpt from expex-demo.tex:



documentclass{article}

usepackage{expex}


begin{document}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s}//
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

end{document}


Trying to do with arrows:
enter image description here










share|improve this question















I am using the expex package with numerous examples which break into two or more lines due to the length of either gla or glb contents. The normal and cascading options for glhangstyle work without issue.



However, I sometimes find the examples text-heavy and difficult to follow visually. I was considering the possibility of including a symbol or arrow at the beginning of each line which is a hanging indent. After playing around with xpatchcmd, I have determined that I am not familiar enough with expex to figure it out - if it is even possible.



I have no MWE, but am including an image from the expex documentation followed by one that I touched up to show an example of what I am hoping to accomplish. This example includes an arrow, but I am hoping that I could include basically anything there, such as a symbol. Assuming this is possible, I think it should be available for both normal and cascading options...possibly even none?



Current cascading appearance:
enter image description here



MWE for cascading example excerpt from expex-demo.tex:



documentclass{article}

usepackage{expex}


begin{document}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s}//
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

end{document}


Trying to do with arrows:
enter image description here







symbols arrows expex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 22 '17 at 5:44

























asked Dec 21 '17 at 22:01









whatisit

352112




352112








  • 2




    You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
    – Ulrike Fischer
    Dec 21 '17 at 22:19










  • Ok, I copied the example from expex-demo.tex.
    – whatisit
    Dec 22 '17 at 5:45










  • @whatisit Doesn't cascading feature preclude the need for arrows?
    – AML
    Apr 18 at 17:12










  • I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
    – whatisit
    Apr 22 at 17:03














  • 2




    You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
    – Ulrike Fischer
    Dec 21 '17 at 22:19










  • Ok, I copied the example from expex-demo.tex.
    – whatisit
    Dec 22 '17 at 5:45










  • @whatisit Doesn't cascading feature preclude the need for arrows?
    – AML
    Apr 18 at 17:12










  • I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
    – whatisit
    Apr 22 at 17:03








2




2




You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
– Ulrike Fischer
Dec 21 '17 at 22:19




You should add an example. Don't let the people who want to help you spent their time to write the needed test document.
– Ulrike Fischer
Dec 21 '17 at 22:19












Ok, I copied the example from expex-demo.tex.
– whatisit
Dec 22 '17 at 5:45




Ok, I copied the example from expex-demo.tex.
– whatisit
Dec 22 '17 at 5:45












@whatisit Doesn't cascading feature preclude the need for arrows?
– AML
Apr 18 at 17:12




@whatisit Doesn't cascading feature preclude the need for arrows?
– AML
Apr 18 at 17:12












I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
– whatisit
Apr 22 at 17:03




I don't see any reason the two options must be mutually exclusive. Even with the cascading, I have difficulty focusing on the the next line down. The arrow does the work for your eyes and helps focus them.
– whatisit
Apr 22 at 17:03










3 Answers
3






active

oldest

votes

















up vote
1
down vote













Here is a solution that was inspired by this post with some minor changes.
I posted here a question about automating this.



documentclass{article}

usepackage{expex}

usepackage{tikz}
usepackage{xparse}

% https://tex.stackexchange.com/a/231044/121944
newcommandTikzmark[2]{%
tikz[remember picture]node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
}

NewDocumentCommandDrawArrow{O{}mmmmO{3}}{
tikz[remember picture,overlay]
draw[->,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
(#2) -- ++(0,-#6htstrutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux);
}
%

begin{document}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} Tikzmark{enda}hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s} //
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

DrawArrow{starta}{enda}{}{}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} Tikzmark{starta}hold hoe \{3s} and carry.on.back back.basket \{3s}
while at along Tikzmark{enda}trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s} //
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

DrawArrow{starta}{enda}{}{}

ex[glhangstyle=cascade]
let\=textsc
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
glb
\{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
machete \{3s} Tikzmark{enda}hTikzmark{startb}old hoe \{3s} and carry.on.back back.basket \{3s}
while at along Tikzmark{endb}trail \{3s} go field \{3s} see one \{clf} peacock
stay at \{drct} -- nest \{3s} //
glft
`There was an old person who went to work in the field. He took
along his machete, he took along his hoe, and he carried his
basket on his back. While he was on his way to the farm, he saw a
peacock beside its nest.'//
endgl
xe

DrawArrow{starta}{enda}{}{}
DrawArrow{startb}{endb}{}{}

end{document}


enter image description here






share|improve this answer























  • Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
    – whatisit
    Apr 22 at 17:07










  • Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
    – whatisit
    Apr 22 at 17:11




















up vote
1
down vote













The answer to this question helped provide a starting point for this answer, which does not require any additional packages (except for expex). I did include mathabx because it conveniently has an angled arrow. The answer below, however, can take any text or symbol.



This also needed the tlap which I found in this answer to an unrelated question.



documentclass{memoir}

usepackage[mathb]{mathabx}

usepackage{expex}
% Define spacing and example number format for (all) ExPex examples
lingset{exnotype=chapter.arabic,%
glhangstyle=cascade,
glhangindent=2em}%

newcommand{tlap}[1]{vbox to 0pt{vsshbox{#1}}}%

newcommand{insertcascadeexpexsymbol}[2]{%
lettmpdimarelax%
newlengthtmpdima%
tmpdima=1.5em%
newcounttmpcnta%
tmpcnta=numexpr#1-1relax%
newcounttmpcntc%
tmpcntc=numexpr#1-2relax%
newcounttmpcntb%
tmpcntb=0%

letindentdiminitialrelax%
newlengthindentdiminitial%
indentdiminitial=-0.8em%
letindentdimincrementrelax%
newlengthindentdimincrement%
indentdimincrement=2.0em%

lettmpdiminitialrelax%
newlengthtmpdiminitial%
tmpdiminitial=5.475em%
lettmpdimincrementrelax%
newlengthtmpdimincrement%
tmpdimincrement=2.475em%

lettmpdimeachlineinitialrelax%
newlengthtmpdimeachlineinitial%
tmpdimeachlineinitial=1.475em%
lettmpdimeachlineincrementrelax%
newlengthtmpdimeachlineincrement%
tmpdimeachlineincrement=0.035em%

letdimverticalfixrelax%
newlengthdimverticalfix%
dimverticalfix=-dimexprtmpdiminitial+tmpcntctmpdimincrementrelax%

letdimverticaleachlinefixrelax%
newlengthdimverticaleachlinefix%
dimverticaleachlinefix=dimexprtmpdimeachlineinitial-tmpcntctmpdimeachlineincrementrelax%
tlap{vspace*{dimverticalfix}%
rlap{vbox{loopifnumtmpcntb < tmpcnta%
advancetmpcntb by 1%
hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax}{#2}vspace*{dimverticaleachlinefix}newline%
repeat}}}}%

begin{document}

let\=textsc

ex
begingl
gla
Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //insertcascadeexpexsymbol{4}{$drsh$}
glb
\{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
glft
`There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
endgl
xe

end{document}


Example of compiled answer for arrows before hanging indents in expex



If you replace hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax} with hspace*{1em}, for example, you can make the symbols move down vertically but not following the cascading indents:



Example of compiled answer for arrows dropping vertically before hanging indents in expex



And if you prefer to use expex with normal for glhangstyle, it is not a problem:



Example of compiled answer for arrows before normal hanging indents in expex



By calling the insertcascadeexpexsymbol command immediately after the // of the gla line which contains a tlap and an rlap which contains a vbox, you can get the arrows overlapping the examples.



This answer is far from perfect, but it does accomplish a rough approximation of the arrows and works for 2-line examples up to at least 6-line examples, based on my testing.



The first argument for insertcascadeexpexsymbol is the number of lines (which can be determined after compiling the example once.



The second argument for insertcascadeexpexsymbol is the symbol or text that you want to insert. I used drsh which is a math symbol defined in mathabx package.



Some explanation for those interested:



Inside insertcascadeexpexsymbol there is a lot of messing around with vertical positions. I couldn't figure any better way, but maybe a more savvy TeX user might know how to improve this. The basic problem that I found was that the line inter/intra-line spacing seemed to change slightly depending on the total number of lines in gla and glab. I attempt to just use newlines but it ran into the same problem. All of the calculations are simply to try and equalize the positions of the symbol/text for 2-line, 3-line, 4-line, etc. examples.



There are also a bunch of hard-coded lengths used. I was hoping to use variables from expex, but couldn't figure out how to reference them outside of expex without getting undefined errors. For example, rather than hard-coding the hanging indent value inside the command, I would have preferred to have it be relative to the hanging indent used in expex - either the default one or the one defined in lingset. I expect that being able to access these variables would help, at least in part, to improve this command, possibly including the vertical calculation shenanigans that I used.






share|improve this answer






























    up vote
    1
    down vote



    accepted










    My previous answer worked, but did not work very well. For example, if you change aboveglbskip and aboveglcskip values then all the hardcoded calculations would need to be tweaked very carefully. There were a lot of details which may help someone in the future, which is why I'm posting the new answer instead of editing the old one.



    Improved Answer



    I patched two commands within expex to allow a vbox to overlap the interlinear gloss lines. There is a difference in behavior between a single gloss line (i.e. only gla) and using multiple gloss lines (e.g. gla and glb, or gla and glb and glc).



    CAVEAT: This does not work for nlevel glosses.



    Comments are included for most lines. So, see MWE for comments on the explanation for why/what is happening.



    documentclass[a4paper,12pt,final]{memoir}

    usepackage{xpatch}

    %%%%%%%%%%%%%%%%
    % (begin) ExPex update to allow arrows
    %%%%%%%%%%%%%%%%
    makeatletter
    @ifclassloaded{memoir}{lettttexttt}{}%This is required, because expex uses tt, which memoir does not allow
    makeatother
    % Include ExPex for having sentences with glossing and translation
    usepackage{expex}

    makeatletter
    % Create an additional gl@maxhtlast (to complement existing gl@maxdplast)
    %% --inside glw@updatelists
    newdimengl@maxhtlast
    xpatchcmd{glw@updatelists}
    {globalgl@maxdplast=glw@maxdp}
    {globalgl@maxhtlast=glw@maxht
    globalgl@maxdplast=glw@maxdp}
    {}{}%

    % Add a new box to overlay arrows (or whatever) to the left side of the top interlinear gloss line
    %% --inside glw@printilg@a
    xpatchcmd{glw@printilg@a}
    {glw@printilg@b par }
    {glw@printilg@b par %

    % DO NOTHING, IF NO GLARROW WAS SPECIFIED BY USER
    ifxling@glarrowempty%
    %do nothing
    % OTHERWISE, USER DID SPECIFY A GLARROW
    else%
    % Create new dimension for above skips (e.g. aboveglaskip, aboveglbskip, aboveglcskip etc.)
    newdimendim@aboveskip%
    % Give a default value of 0pt
    globaldim@aboveskip=0pt%
    % Create a new counter for the number if interlinear gloss lines
    newcountnumglwlines%
    % Give a default value of 0
    globalnumglwlines=0%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% Loop through one GLWORD
    %%% Calculate the abovegl<N>skip total (into dim@aboveskip)
    %%% and Count number of gloss lines (into numglwlines)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
    % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
    lettemp@currentitem@currentitem%
    letcountlineslistmainlist%
    letgl@lop@tempgl@lop%

    % Get the first GLWORD from token list
    % and use it to to count the interlinear gloss lines
    gl@lop@tempcountlineslisttotemp@currentitemrelax%
    % If the item is empty, ignore. Otherwise, count the lines
    ifxtemp@currentitemempty%
    else%
    % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
    % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
    lettemp@aboveskip@aboveskip%
    lettempaboveskiplistaboveskiplist%
    letgltoks@next@tempgltoks@next%
    letgl@lopTL@tempgl@lopTL%

    % GLWORD is not empty, therefore it contains at least one line
    % Add one to numglwlines counter
    globaladvancenumglwlines by 1%
    % Set value to TRUE to loop through GLWORD lines
    gl@loopmoretrue%
    loopifgl@loopmore%
    % Get the `aboveskip' value for current gloss line
    gl@loptempaboveskiplisttotemp@aboveskip%
    % If value is 0pt, do nothing
    ifdimtemp@aboveskip=0pt%
    %do nothing
    % Otherwise, above skip value is set to something
    else%
    % Store current dim@aboveskip value into temporary value
    letdim@aboveskip@tempdim@aboveskip%
    % Add current `above skip' value to existing sum of `above skip' values
    globaldim@aboveskip=dimexprdim@aboveskip@temp+temp@aboveskiprelax%
    fi%
    % Get the next token (i.e. line) of the GLWORD
    gl@lopTLtemp@currentitemtogltoks@next@temp%
    % If token (line) is empty, we are finished looping
    ifxtemp@currentitemempty%
    gl@loopmorefalse%
    % Otherwise, increment the number of lines, and continue looping
    else
    globaladvancenumglwlines by 1%
    fi%
    repeat%
    % Set to FALSE as a precaution
    gl@loopmorefalse%
    % Free up memory of temporary items
    lettemp@aboveskiprelax%
    lettempaboveskiplistrelax%
    letgltoks@next@temprelax%
    letgl@lopTL@temprelax%
    fi%
    % Free up memory of temporary items
    lettemp@currentitemrelax%
    letcountlineslistrelax%
    letgl@lop@temprelax%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    % Countdown of wrapped lines in the interlinear glosses `paragraph' to zero
    %% used for looping until we reach the final line
    newcountep@countdown@ilg@para@lines%
    ep@countdown@ilg@para@lines=prevgraf%
    % Number of wrapped lines in the interlinear glosses `paragraph'
    newcountep@num@ilg@para@lines%
    ep@num@ilg@para@lines=prevgraf%
    % Count the number of lines processed so far
    newcountep@num@lines%
    ep@num@lines=0%

    % Create a vbox to overlay on top of the interlinear glosses
    setbox0vbox
    {%
    ifnumnumglwlines=1%only gla exists
    %do nothing
    else%
    % If at least 2 paragraph lines, the initialize the vertical skip
    %% (note: the first line does not contain an arrow, so only other lines are `processed')
    ifnumep@num@ilg@para@lines>1%
    %Shift upwards, the amount of space between each interlinear line
    %e.g. between gla and glb, between glb and glc, etc.
    %these spaces are defined by variables: aboveglbskip, aboveglcskip, aboveglftskip, etc.
    vskip -dimexprdim@aboveskip*(ep@num@ilg@para@lines-1)relax%
    %Shift upwards, the amount of gl@maxhtlast (height, not depth, of each glword)
    vskip -dimexprgl@maxhtlast*numglwlines*(ep@num@ilg@para@lines-1)relax%
    %Shift upwards, the amount of gl@maxdplast (depth, not height, of each glword)
    vskip -dimexprgl@maxdplast*numglwlines*(ep@num@ilg@para@lines-1)relax%
    %Shift upwards, the amount of lingextraglskip (interlinear skips)
    vskip -dimexprlingextraglskip*(ep@num@ilg@para@lines-2)relax%
    fi%
    fi%

    % For some reason, the paragraph glue values
    % need be used in vskip
    % IS THIS ALWAYS TRUE?? ONLY SOMETIMES??
    vskip -thegluestretchparskip%
    vskip -theglueshrinkparskip%

    %Loop through the paragraph lines
    loop%
    ifnumep@countdown@ilg@para@lines=ep@num@ilg@para@lines%
    %do nothing
    else%
    ling@everygla%
    newdimenep@dim@arrow@indent%
    ep@dim@arrow@indent=0pt%
    % If hangstyle is `normal' then use a consistent horizontal offset
    ifnumep@glhangstyle=1%
    % Use the standard hanging indent
    ep@dim@arrow@indent=dimexprling@glhangindentrelax%
    fi%
    % If hangstyle is `cascade' then use a cascading horizontal offset
    ifnumep@glhangstyle=2%
    % Set offset to the hanging indent amount multiplied by the current line number
    ep@dim@arrow@indent=dimexpr(ling@glhangindent*ep@num@lines)relax%
    fi%
    % Create hbox to contain the arrow and indent offset
    hbox{%
    % Create horizontal indentation
    hspace*{ep@dim@arrow@indent}%
    % Create the arrow
    raisebox{-ling@aboveglarrowskip}[height][0pt]{llap{ling@glarrow}}%
    % Use a vrule to make sure the line height is consistent
    vrule heightdimexprgl@maxhtlastrelax depthdimexprgl@maxdplastrelax width 0pt%
    }%

    % Add `above skips' for one horizontal line of GLWORDS
    vskip dim@aboveskip%
    % Add remaining heights for one horizontal line of GLWORDS
    vskip dimexpr(gl@maxdplast)*numexprnumglwlines-1relaxrelax%
    % Add remaining depths for one horizontal line of GLWORDS
    vskip dimexpr(gl@maxhtlast)*numexprnumglwlines-1relaxrelax%
    % Add extraglskip vertical skip, if necessary
    ifnumnumglwlines=1%only gla exists, no lingextraglskip is used in this case
    %do nothing
    else%
    % If there are 3 or more wrapped lines, then also add
    % vertical skip defined by extraglskip (lingextraglskip)
    ifnumep@countdown@ilg@para@lines>1%
    vskip lingextraglskip%
    fi%
    fi%
    fi%
    % Line countdown to zero (by increments of 1)
    advanceep@countdown@ilg@para@lines -1%
    % Processed line counter (by increments of 1)
    advanceep@num@lines 1%
    % If countdown has not reached zero yet, keep looping
    ifnumep@countdown@ilg@para@lines>0%
    repeat%
    }%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Display the vbox content
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % If only one line, GLWORDS function similar to a regular paragraph
    %% therefore, use a raisebox to overlap the arrows
    ifnumnumglwlines=1
    raisebox{dimexpr(gl@maxhtlast+gl@maxdplast)*(ep@num@ilg@para@lines-1)relax}[height][0pt]{box0}%
    % Otherwise, display the box normally (because overlapping is already possible)
    else%
    box0%
    fi%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    fi%
    }
    {}{}%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% DEFINE TWO NEW KEYS FOR USE WITHIN lingset{}
    %%% glarrow -> an arrow symbol (but could be any symbol or text)
    %%% aboveglarrowskip -> vertical space above the arrow (similar to aboveglbskip and aboveglcskip)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    define@lingkey{glarrow}{defling@glarrow{#1}}%
    lingset{glarrow=}%
    define@lingkey{aboveglarrowskip}{defling@aboveglarrowskip{#1}}%
    lingset{aboveglarrowskip=0pt}%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    makeatother

    lingset{numoffset=leftmargin,%
    textoffset=0.75em,%
    extraglskip=!1.1ex,%
    glspace=!0.01em,%
    belowglpreambleskip=!0ex,%
    aboveglbskip=-0.9ex,%
    aboveglcskip=-0.9ex,%
    aboveglftskip=-0.1ex,%
    exnotype=chapter.arabic,%
    aboveglarrowskip=0pt,%DEFAULT
    glarrow=tiny$hookrightarrow$,%DEFAULT IS glarrow= (i.e. empty)
    glhangstyle=cascade,%
    glhangindent=2em}%



    begin{document}

    let\=textsc
    ex
    begingl
    gla
    Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //
    glb
    \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
    glft
    `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
    endgl
    xe

    end{document}


    Which results in:



    $hookrightarrow$ cascading



    Also works with normal hanging style. Changing lingset{glhangstyle=cascade} to lingset{glhangstyle=normal} results in:



    $hookrightarrow$ normal



    If you want the arrow (in this case), to point at the middle of the text instead of the baseline, you can use aboveglarrowskip to tweak the position. Changing lingset{aboveglarrowskip=0pt} (the default) to lingset{aboveglarrowskip=-2pt} results in:



    $hookrightarrow$ cascading -2pt$hookrightarrow$ normal -2pt



    You can choose to use other arrow symbols from other packages. For example, usepackage[mathb]{mathabx} and lingset{glarrow=tiny$drsh$}



    $drsh$ cascading$drsh$ normal



    Or, you can use usepackage{fdsymbol} and lingset{glarrow=tiny$Rdsh$}



    $Rdsh$ cascading$Rdsh$ normal



    If you want to use something other than an arrow, that's also fine. For example, lingset{glarrow=tiny{--test--}}



    --test-- cascading--test-- normal



    You can add some spacing, for example, lingset{glarrow={--test--hspace*{5pt}}}



    --test--+hspace cascading--test--+hspace normal



    Really, this patch is quite flexible. For example, you can throw in a TikZ arrow that is really big. But because the height will be too large, you can surround it in raisebox with zero height, using:



    usepackage{tikz}

    newcommand{myarrow}[1]{%
    begin{tikzpicture}[#1]%
    draw (0,2.7ex) -- (0,0) -- (0.75em,0);
    draw (0.55em,0.2em) -- (0.75em,0) -- (0.55em,-0.2em);
    end{tikzpicture}%
    }


    lingset{numoffset=leftmargin,%
    textoffset=0.75em,%
    extraglskip=!1.1ex,%
    glspace=!0.01em,%
    belowglpreambleskip=!0ex,%
    aboveglbskip=-0.9ex,%
    aboveglcskip=-0.9ex,%
    aboveglftskip=-0.1ex,%
    exnotype=chapter.arabic,%
    glarrow={raisebox{0pt}[0pt][0pt]{myarrow[scale=1.35,draw=red]}},%
    glhangstyle=cascade,%
    glhangindent=2em}%


    tikz arrow inside raisebox cascading



    and glhangstyle=normal



    tikz arrow inside raisebox normal



    It is also great because you can use it universally via lingset{} or specify it for only individual exxe or pexxe examples. You only need to be using the standard glossing (not nlevel) and specify the symbol/text you want and a vertical skip (if desired).






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f407205%2fcreate-symbols-arrows-text-at-beginning-of-hanging-indents-in-expex%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      Here is a solution that was inspired by this post with some minor changes.
      I posted here a question about automating this.



      documentclass{article}

      usepackage{expex}

      usepackage{tikz}
      usepackage{xparse}

      % https://tex.stackexchange.com/a/231044/121944
      newcommandTikzmark[2]{%
      tikz[remember picture]node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
      }

      NewDocumentCommandDrawArrow{O{}mmmmO{3}}{
      tikz[remember picture,overlay]
      draw[->,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
      (#2) -- ++(0,-#6htstrutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux);
      }
      %

      begin{document}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{starta}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{enda}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hTikzmark{startb}old hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{endb}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}
      DrawArrow{startb}{endb}{}{}

      end{document}


      enter image description here






      share|improve this answer























      • Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
        – whatisit
        Apr 22 at 17:07










      • Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
        – whatisit
        Apr 22 at 17:11

















      up vote
      1
      down vote













      Here is a solution that was inspired by this post with some minor changes.
      I posted here a question about automating this.



      documentclass{article}

      usepackage{expex}

      usepackage{tikz}
      usepackage{xparse}

      % https://tex.stackexchange.com/a/231044/121944
      newcommandTikzmark[2]{%
      tikz[remember picture]node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
      }

      NewDocumentCommandDrawArrow{O{}mmmmO{3}}{
      tikz[remember picture,overlay]
      draw[->,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
      (#2) -- ++(0,-#6htstrutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux);
      }
      %

      begin{document}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{starta}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{enda}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hTikzmark{startb}old hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{endb}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}
      DrawArrow{startb}{endb}{}{}

      end{document}


      enter image description here






      share|improve this answer























      • Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
        – whatisit
        Apr 22 at 17:07










      • Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
        – whatisit
        Apr 22 at 17:11















      up vote
      1
      down vote










      up vote
      1
      down vote









      Here is a solution that was inspired by this post with some minor changes.
      I posted here a question about automating this.



      documentclass{article}

      usepackage{expex}

      usepackage{tikz}
      usepackage{xparse}

      % https://tex.stackexchange.com/a/231044/121944
      newcommandTikzmark[2]{%
      tikz[remember picture]node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
      }

      NewDocumentCommandDrawArrow{O{}mmmmO{3}}{
      tikz[remember picture,overlay]
      draw[->,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
      (#2) -- ++(0,-#6htstrutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux);
      }
      %

      begin{document}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{starta}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{enda}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hTikzmark{startb}old hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{endb}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}
      DrawArrow{startb}{endb}{}{}

      end{document}


      enter image description here






      share|improve this answer














      Here is a solution that was inspired by this post with some minor changes.
      I posted here a question about automating this.



      documentclass{article}

      usepackage{expex}

      usepackage{tikz}
      usepackage{xparse}

      % https://tex.stackexchange.com/a/231044/121944
      newcommandTikzmark[2]{%
      tikz[remember picture]node[inner sep=0pt,outer sep=0pt] (#1) {#2};%
      }

      NewDocumentCommandDrawArrow{O{}mmmmO{3}}{
      tikz[remember picture,overlay]
      draw[->,line width=0.5pt,shorten >= 2pt,shorten <= 2pt,#1]
      (#2) -- ++(0,-#6htstrutbox) coordinate (aux) -- node[#4] {#5} (#3|-aux);
      }
      %

      begin{document}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{starta}hold hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{enda}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}

      ex[glhangstyle=cascade]
      let\=textsc
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u
      dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o
      ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa
      droi mru{a} du{o} bboi gah, a, hruh ~{n}u.//
      glb
      \{Tikzmark{starta}exist} one \{clf} person old \{3s} go do field \{3s} hold
      machete \{3s} Tikzmark{enda}hTikzmark{startb}old hoe \{3s} and carry.on.back back.basket \{3s}
      while at along Tikzmark{endb}trail \{3s} go field \{3s} see one \{clf} peacock
      stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took
      along his machete, he took along his hoe, and he carried his
      basket on his back. While he was on his way to the farm, he saw a
      peacock beside its nest.'//
      endgl
      xe

      DrawArrow{starta}{enda}{}{}
      DrawArrow{startb}{endb}{}{}

      end{document}


      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 18 at 19:23

























      answered Apr 18 at 18:28









      AML

      1,3432325




      1,3432325












      • Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
        – whatisit
        Apr 22 at 17:07










      • Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
        – whatisit
        Apr 22 at 17:11




















      • Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
        – whatisit
        Apr 22 at 17:07










      • Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
        – whatisit
        Apr 22 at 17:11


















      Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
      – whatisit
      Apr 22 at 17:07




      Is it possible for you to edit this and include a version where the arrow points to the top line (not the interlinear gloss), as asked in the original question? Your version is a bonus, so keep it.
      – whatisit
      Apr 22 at 17:07












      Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
      – whatisit
      Apr 22 at 17:11






      Regarding the implementation, this obviously works... However, this is not a feasible answer for more than a handful of ExPex examples - for one thing, you need to compile it once first to determine where the line breaks are, not to mention manually inserting the end/start commands surrounding the letter (not the word). I will mark this as an answer until an automated way is determined.
      – whatisit
      Apr 22 at 17:11












      up vote
      1
      down vote













      The answer to this question helped provide a starting point for this answer, which does not require any additional packages (except for expex). I did include mathabx because it conveniently has an angled arrow. The answer below, however, can take any text or symbol.



      This also needed the tlap which I found in this answer to an unrelated question.



      documentclass{memoir}

      usepackage[mathb]{mathabx}

      usepackage{expex}
      % Define spacing and example number format for (all) ExPex examples
      lingset{exnotype=chapter.arabic,%
      glhangstyle=cascade,
      glhangindent=2em}%

      newcommand{tlap}[1]{vbox to 0pt{vsshbox{#1}}}%

      newcommand{insertcascadeexpexsymbol}[2]{%
      lettmpdimarelax%
      newlengthtmpdima%
      tmpdima=1.5em%
      newcounttmpcnta%
      tmpcnta=numexpr#1-1relax%
      newcounttmpcntc%
      tmpcntc=numexpr#1-2relax%
      newcounttmpcntb%
      tmpcntb=0%

      letindentdiminitialrelax%
      newlengthindentdiminitial%
      indentdiminitial=-0.8em%
      letindentdimincrementrelax%
      newlengthindentdimincrement%
      indentdimincrement=2.0em%

      lettmpdiminitialrelax%
      newlengthtmpdiminitial%
      tmpdiminitial=5.475em%
      lettmpdimincrementrelax%
      newlengthtmpdimincrement%
      tmpdimincrement=2.475em%

      lettmpdimeachlineinitialrelax%
      newlengthtmpdimeachlineinitial%
      tmpdimeachlineinitial=1.475em%
      lettmpdimeachlineincrementrelax%
      newlengthtmpdimeachlineincrement%
      tmpdimeachlineincrement=0.035em%

      letdimverticalfixrelax%
      newlengthdimverticalfix%
      dimverticalfix=-dimexprtmpdiminitial+tmpcntctmpdimincrementrelax%

      letdimverticaleachlinefixrelax%
      newlengthdimverticaleachlinefix%
      dimverticaleachlinefix=dimexprtmpdimeachlineinitial-tmpcntctmpdimeachlineincrementrelax%
      tlap{vspace*{dimverticalfix}%
      rlap{vbox{loopifnumtmpcntb < tmpcnta%
      advancetmpcntb by 1%
      hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax}{#2}vspace*{dimverticaleachlinefix}newline%
      repeat}}}}%

      begin{document}

      let\=textsc

      ex
      begingl
      gla
      Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //insertcascadeexpexsymbol{4}{$drsh$}
      glb
      \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
      glft
      `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
      endgl
      xe

      end{document}


      Example of compiled answer for arrows before hanging indents in expex



      If you replace hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax} with hspace*{1em}, for example, you can make the symbols move down vertically but not following the cascading indents:



      Example of compiled answer for arrows dropping vertically before hanging indents in expex



      And if you prefer to use expex with normal for glhangstyle, it is not a problem:



      Example of compiled answer for arrows before normal hanging indents in expex



      By calling the insertcascadeexpexsymbol command immediately after the // of the gla line which contains a tlap and an rlap which contains a vbox, you can get the arrows overlapping the examples.



      This answer is far from perfect, but it does accomplish a rough approximation of the arrows and works for 2-line examples up to at least 6-line examples, based on my testing.



      The first argument for insertcascadeexpexsymbol is the number of lines (which can be determined after compiling the example once.



      The second argument for insertcascadeexpexsymbol is the symbol or text that you want to insert. I used drsh which is a math symbol defined in mathabx package.



      Some explanation for those interested:



      Inside insertcascadeexpexsymbol there is a lot of messing around with vertical positions. I couldn't figure any better way, but maybe a more savvy TeX user might know how to improve this. The basic problem that I found was that the line inter/intra-line spacing seemed to change slightly depending on the total number of lines in gla and glab. I attempt to just use newlines but it ran into the same problem. All of the calculations are simply to try and equalize the positions of the symbol/text for 2-line, 3-line, 4-line, etc. examples.



      There are also a bunch of hard-coded lengths used. I was hoping to use variables from expex, but couldn't figure out how to reference them outside of expex without getting undefined errors. For example, rather than hard-coding the hanging indent value inside the command, I would have preferred to have it be relative to the hanging indent used in expex - either the default one or the one defined in lingset. I expect that being able to access these variables would help, at least in part, to improve this command, possibly including the vertical calculation shenanigans that I used.






      share|improve this answer



























        up vote
        1
        down vote













        The answer to this question helped provide a starting point for this answer, which does not require any additional packages (except for expex). I did include mathabx because it conveniently has an angled arrow. The answer below, however, can take any text or symbol.



        This also needed the tlap which I found in this answer to an unrelated question.



        documentclass{memoir}

        usepackage[mathb]{mathabx}

        usepackage{expex}
        % Define spacing and example number format for (all) ExPex examples
        lingset{exnotype=chapter.arabic,%
        glhangstyle=cascade,
        glhangindent=2em}%

        newcommand{tlap}[1]{vbox to 0pt{vsshbox{#1}}}%

        newcommand{insertcascadeexpexsymbol}[2]{%
        lettmpdimarelax%
        newlengthtmpdima%
        tmpdima=1.5em%
        newcounttmpcnta%
        tmpcnta=numexpr#1-1relax%
        newcounttmpcntc%
        tmpcntc=numexpr#1-2relax%
        newcounttmpcntb%
        tmpcntb=0%

        letindentdiminitialrelax%
        newlengthindentdiminitial%
        indentdiminitial=-0.8em%
        letindentdimincrementrelax%
        newlengthindentdimincrement%
        indentdimincrement=2.0em%

        lettmpdiminitialrelax%
        newlengthtmpdiminitial%
        tmpdiminitial=5.475em%
        lettmpdimincrementrelax%
        newlengthtmpdimincrement%
        tmpdimincrement=2.475em%

        lettmpdimeachlineinitialrelax%
        newlengthtmpdimeachlineinitial%
        tmpdimeachlineinitial=1.475em%
        lettmpdimeachlineincrementrelax%
        newlengthtmpdimeachlineincrement%
        tmpdimeachlineincrement=0.035em%

        letdimverticalfixrelax%
        newlengthdimverticalfix%
        dimverticalfix=-dimexprtmpdiminitial+tmpcntctmpdimincrementrelax%

        letdimverticaleachlinefixrelax%
        newlengthdimverticaleachlinefix%
        dimverticaleachlinefix=dimexprtmpdimeachlineinitial-tmpcntctmpdimeachlineincrementrelax%
        tlap{vspace*{dimverticalfix}%
        rlap{vbox{loopifnumtmpcntb < tmpcnta%
        advancetmpcntb by 1%
        hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax}{#2}vspace*{dimverticaleachlinefix}newline%
        repeat}}}}%

        begin{document}

        let\=textsc

        ex
        begingl
        gla
        Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //insertcascadeexpexsymbol{4}{$drsh$}
        glb
        \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
        glft
        `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
        endgl
        xe

        end{document}


        Example of compiled answer for arrows before hanging indents in expex



        If you replace hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax} with hspace*{1em}, for example, you can make the symbols move down vertically but not following the cascading indents:



        Example of compiled answer for arrows dropping vertically before hanging indents in expex



        And if you prefer to use expex with normal for glhangstyle, it is not a problem:



        Example of compiled answer for arrows before normal hanging indents in expex



        By calling the insertcascadeexpexsymbol command immediately after the // of the gla line which contains a tlap and an rlap which contains a vbox, you can get the arrows overlapping the examples.



        This answer is far from perfect, but it does accomplish a rough approximation of the arrows and works for 2-line examples up to at least 6-line examples, based on my testing.



        The first argument for insertcascadeexpexsymbol is the number of lines (which can be determined after compiling the example once.



        The second argument for insertcascadeexpexsymbol is the symbol or text that you want to insert. I used drsh which is a math symbol defined in mathabx package.



        Some explanation for those interested:



        Inside insertcascadeexpexsymbol there is a lot of messing around with vertical positions. I couldn't figure any better way, but maybe a more savvy TeX user might know how to improve this. The basic problem that I found was that the line inter/intra-line spacing seemed to change slightly depending on the total number of lines in gla and glab. I attempt to just use newlines but it ran into the same problem. All of the calculations are simply to try and equalize the positions of the symbol/text for 2-line, 3-line, 4-line, etc. examples.



        There are also a bunch of hard-coded lengths used. I was hoping to use variables from expex, but couldn't figure out how to reference them outside of expex without getting undefined errors. For example, rather than hard-coding the hanging indent value inside the command, I would have preferred to have it be relative to the hanging indent used in expex - either the default one or the one defined in lingset. I expect that being able to access these variables would help, at least in part, to improve this command, possibly including the vertical calculation shenanigans that I used.






        share|improve this answer

























          up vote
          1
          down vote










          up vote
          1
          down vote









          The answer to this question helped provide a starting point for this answer, which does not require any additional packages (except for expex). I did include mathabx because it conveniently has an angled arrow. The answer below, however, can take any text or symbol.



          This also needed the tlap which I found in this answer to an unrelated question.



          documentclass{memoir}

          usepackage[mathb]{mathabx}

          usepackage{expex}
          % Define spacing and example number format for (all) ExPex examples
          lingset{exnotype=chapter.arabic,%
          glhangstyle=cascade,
          glhangindent=2em}%

          newcommand{tlap}[1]{vbox to 0pt{vsshbox{#1}}}%

          newcommand{insertcascadeexpexsymbol}[2]{%
          lettmpdimarelax%
          newlengthtmpdima%
          tmpdima=1.5em%
          newcounttmpcnta%
          tmpcnta=numexpr#1-1relax%
          newcounttmpcntc%
          tmpcntc=numexpr#1-2relax%
          newcounttmpcntb%
          tmpcntb=0%

          letindentdiminitialrelax%
          newlengthindentdiminitial%
          indentdiminitial=-0.8em%
          letindentdimincrementrelax%
          newlengthindentdimincrement%
          indentdimincrement=2.0em%

          lettmpdiminitialrelax%
          newlengthtmpdiminitial%
          tmpdiminitial=5.475em%
          lettmpdimincrementrelax%
          newlengthtmpdimincrement%
          tmpdimincrement=2.475em%

          lettmpdimeachlineinitialrelax%
          newlengthtmpdimeachlineinitial%
          tmpdimeachlineinitial=1.475em%
          lettmpdimeachlineincrementrelax%
          newlengthtmpdimeachlineincrement%
          tmpdimeachlineincrement=0.035em%

          letdimverticalfixrelax%
          newlengthdimverticalfix%
          dimverticalfix=-dimexprtmpdiminitial+tmpcntctmpdimincrementrelax%

          letdimverticaleachlinefixrelax%
          newlengthdimverticaleachlinefix%
          dimverticaleachlinefix=dimexprtmpdimeachlineinitial-tmpcntctmpdimeachlineincrementrelax%
          tlap{vspace*{dimverticalfix}%
          rlap{vbox{loopifnumtmpcntb < tmpcnta%
          advancetmpcntb by 1%
          hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax}{#2}vspace*{dimverticaleachlinefix}newline%
          repeat}}}}%

          begin{document}

          let\=textsc

          ex
          begingl
          gla
          Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //insertcascadeexpexsymbol{4}{$drsh$}
          glb
          \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
          glft
          `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
          endgl
          xe

          end{document}


          Example of compiled answer for arrows before hanging indents in expex



          If you replace hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax} with hspace*{1em}, for example, you can make the symbols move down vertically but not following the cascading indents:



          Example of compiled answer for arrows dropping vertically before hanging indents in expex



          And if you prefer to use expex with normal for glhangstyle, it is not a problem:



          Example of compiled answer for arrows before normal hanging indents in expex



          By calling the insertcascadeexpexsymbol command immediately after the // of the gla line which contains a tlap and an rlap which contains a vbox, you can get the arrows overlapping the examples.



          This answer is far from perfect, but it does accomplish a rough approximation of the arrows and works for 2-line examples up to at least 6-line examples, based on my testing.



          The first argument for insertcascadeexpexsymbol is the number of lines (which can be determined after compiling the example once.



          The second argument for insertcascadeexpexsymbol is the symbol or text that you want to insert. I used drsh which is a math symbol defined in mathabx package.



          Some explanation for those interested:



          Inside insertcascadeexpexsymbol there is a lot of messing around with vertical positions. I couldn't figure any better way, but maybe a more savvy TeX user might know how to improve this. The basic problem that I found was that the line inter/intra-line spacing seemed to change slightly depending on the total number of lines in gla and glab. I attempt to just use newlines but it ran into the same problem. All of the calculations are simply to try and equalize the positions of the symbol/text for 2-line, 3-line, 4-line, etc. examples.



          There are also a bunch of hard-coded lengths used. I was hoping to use variables from expex, but couldn't figure out how to reference them outside of expex without getting undefined errors. For example, rather than hard-coding the hanging indent value inside the command, I would have preferred to have it be relative to the hanging indent used in expex - either the default one or the one defined in lingset. I expect that being able to access these variables would help, at least in part, to improve this command, possibly including the vertical calculation shenanigans that I used.






          share|improve this answer














          The answer to this question helped provide a starting point for this answer, which does not require any additional packages (except for expex). I did include mathabx because it conveniently has an angled arrow. The answer below, however, can take any text or symbol.



          This also needed the tlap which I found in this answer to an unrelated question.



          documentclass{memoir}

          usepackage[mathb]{mathabx}

          usepackage{expex}
          % Define spacing and example number format for (all) ExPex examples
          lingset{exnotype=chapter.arabic,%
          glhangstyle=cascade,
          glhangindent=2em}%

          newcommand{tlap}[1]{vbox to 0pt{vsshbox{#1}}}%

          newcommand{insertcascadeexpexsymbol}[2]{%
          lettmpdimarelax%
          newlengthtmpdima%
          tmpdima=1.5em%
          newcounttmpcnta%
          tmpcnta=numexpr#1-1relax%
          newcounttmpcntc%
          tmpcntc=numexpr#1-2relax%
          newcounttmpcntb%
          tmpcntb=0%

          letindentdiminitialrelax%
          newlengthindentdiminitial%
          indentdiminitial=-0.8em%
          letindentdimincrementrelax%
          newlengthindentdimincrement%
          indentdimincrement=2.0em%

          lettmpdiminitialrelax%
          newlengthtmpdiminitial%
          tmpdiminitial=5.475em%
          lettmpdimincrementrelax%
          newlengthtmpdimincrement%
          tmpdimincrement=2.475em%

          lettmpdimeachlineinitialrelax%
          newlengthtmpdimeachlineinitial%
          tmpdimeachlineinitial=1.475em%
          lettmpdimeachlineincrementrelax%
          newlengthtmpdimeachlineincrement%
          tmpdimeachlineincrement=0.035em%

          letdimverticalfixrelax%
          newlengthdimverticalfix%
          dimverticalfix=-dimexprtmpdiminitial+tmpcntctmpdimincrementrelax%

          letdimverticaleachlinefixrelax%
          newlengthdimverticaleachlinefix%
          dimverticaleachlinefix=dimexprtmpdimeachlineinitial-tmpcntctmpdimeachlineincrementrelax%
          tlap{vspace*{dimverticalfix}%
          rlap{vbox{loopifnumtmpcntb < tmpcnta%
          advancetmpcntb by 1%
          hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax}{#2}vspace*{dimverticaleachlinefix}newline%
          repeat}}}}%

          begin{document}

          let\=textsc

          ex
          begingl
          gla
          Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //insertcascadeexpexsymbol{4}{$drsh$}
          glb
          \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
          glft
          `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
          endgl
          xe

          end{document}


          Example of compiled answer for arrows before hanging indents in expex



          If you replace hspace*{dimexprindentdiminitial+tmpcntbindentdimincrementrelax} with hspace*{1em}, for example, you can make the symbols move down vertically but not following the cascading indents:



          Example of compiled answer for arrows dropping vertically before hanging indents in expex



          And if you prefer to use expex with normal for glhangstyle, it is not a problem:



          Example of compiled answer for arrows before normal hanging indents in expex



          By calling the insertcascadeexpexsymbol command immediately after the // of the gla line which contains a tlap and an rlap which contains a vbox, you can get the arrows overlapping the examples.



          This answer is far from perfect, but it does accomplish a rough approximation of the arrows and works for 2-line examples up to at least 6-line examples, based on my testing.



          The first argument for insertcascadeexpexsymbol is the number of lines (which can be determined after compiling the example once.



          The second argument for insertcascadeexpexsymbol is the symbol or text that you want to insert. I used drsh which is a math symbol defined in mathabx package.



          Some explanation for those interested:



          Inside insertcascadeexpexsymbol there is a lot of messing around with vertical positions. I couldn't figure any better way, but maybe a more savvy TeX user might know how to improve this. The basic problem that I found was that the line inter/intra-line spacing seemed to change slightly depending on the total number of lines in gla and glab. I attempt to just use newlines but it ran into the same problem. All of the calculations are simply to try and equalize the positions of the symbol/text for 2-line, 3-line, 4-line, etc. examples.



          There are also a bunch of hard-coded lengths used. I was hoping to use variables from expex, but couldn't figure out how to reference them outside of expex without getting undefined errors. For example, rather than hard-coding the hanging indent value inside the command, I would have preferred to have it be relative to the hanging indent used in expex - either the default one or the one defined in lingset. I expect that being able to access these variables would help, at least in part, to improve this command, possibly including the vertical calculation shenanigans that I used.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 27 at 22:41

























          answered Apr 26 at 23:19









          whatisit

          352112




          352112






















              up vote
              1
              down vote



              accepted










              My previous answer worked, but did not work very well. For example, if you change aboveglbskip and aboveglcskip values then all the hardcoded calculations would need to be tweaked very carefully. There were a lot of details which may help someone in the future, which is why I'm posting the new answer instead of editing the old one.



              Improved Answer



              I patched two commands within expex to allow a vbox to overlap the interlinear gloss lines. There is a difference in behavior between a single gloss line (i.e. only gla) and using multiple gloss lines (e.g. gla and glb, or gla and glb and glc).



              CAVEAT: This does not work for nlevel glosses.



              Comments are included for most lines. So, see MWE for comments on the explanation for why/what is happening.



              documentclass[a4paper,12pt,final]{memoir}

              usepackage{xpatch}

              %%%%%%%%%%%%%%%%
              % (begin) ExPex update to allow arrows
              %%%%%%%%%%%%%%%%
              makeatletter
              @ifclassloaded{memoir}{lettttexttt}{}%This is required, because expex uses tt, which memoir does not allow
              makeatother
              % Include ExPex for having sentences with glossing and translation
              usepackage{expex}

              makeatletter
              % Create an additional gl@maxhtlast (to complement existing gl@maxdplast)
              %% --inside glw@updatelists
              newdimengl@maxhtlast
              xpatchcmd{glw@updatelists}
              {globalgl@maxdplast=glw@maxdp}
              {globalgl@maxhtlast=glw@maxht
              globalgl@maxdplast=glw@maxdp}
              {}{}%

              % Add a new box to overlay arrows (or whatever) to the left side of the top interlinear gloss line
              %% --inside glw@printilg@a
              xpatchcmd{glw@printilg@a}
              {glw@printilg@b par }
              {glw@printilg@b par %

              % DO NOTHING, IF NO GLARROW WAS SPECIFIED BY USER
              ifxling@glarrowempty%
              %do nothing
              % OTHERWISE, USER DID SPECIFY A GLARROW
              else%
              % Create new dimension for above skips (e.g. aboveglaskip, aboveglbskip, aboveglcskip etc.)
              newdimendim@aboveskip%
              % Give a default value of 0pt
              globaldim@aboveskip=0pt%
              % Create a new counter for the number if interlinear gloss lines
              newcountnumglwlines%
              % Give a default value of 0
              globalnumglwlines=0%

              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %% Loop through one GLWORD
              %%% Calculate the abovegl<N>skip total (into dim@aboveskip)
              %%% and Count number of gloss lines (into numglwlines)
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

              % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
              % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
              lettemp@currentitem@currentitem%
              letcountlineslistmainlist%
              letgl@lop@tempgl@lop%

              % Get the first GLWORD from token list
              % and use it to to count the interlinear gloss lines
              gl@lop@tempcountlineslisttotemp@currentitemrelax%
              % If the item is empty, ignore. Otherwise, count the lines
              ifxtemp@currentitemempty%
              else%
              % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
              % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
              lettemp@aboveskip@aboveskip%
              lettempaboveskiplistaboveskiplist%
              letgltoks@next@tempgltoks@next%
              letgl@lopTL@tempgl@lopTL%

              % GLWORD is not empty, therefore it contains at least one line
              % Add one to numglwlines counter
              globaladvancenumglwlines by 1%
              % Set value to TRUE to loop through GLWORD lines
              gl@loopmoretrue%
              loopifgl@loopmore%
              % Get the `aboveskip' value for current gloss line
              gl@loptempaboveskiplisttotemp@aboveskip%
              % If value is 0pt, do nothing
              ifdimtemp@aboveskip=0pt%
              %do nothing
              % Otherwise, above skip value is set to something
              else%
              % Store current dim@aboveskip value into temporary value
              letdim@aboveskip@tempdim@aboveskip%
              % Add current `above skip' value to existing sum of `above skip' values
              globaldim@aboveskip=dimexprdim@aboveskip@temp+temp@aboveskiprelax%
              fi%
              % Get the next token (i.e. line) of the GLWORD
              gl@lopTLtemp@currentitemtogltoks@next@temp%
              % If token (line) is empty, we are finished looping
              ifxtemp@currentitemempty%
              gl@loopmorefalse%
              % Otherwise, increment the number of lines, and continue looping
              else
              globaladvancenumglwlines by 1%
              fi%
              repeat%
              % Set to FALSE as a precaution
              gl@loopmorefalse%
              % Free up memory of temporary items
              lettemp@aboveskiprelax%
              lettempaboveskiplistrelax%
              letgltoks@next@temprelax%
              letgl@lopTL@temprelax%
              fi%
              % Free up memory of temporary items
              lettemp@currentitemrelax%
              letcountlineslistrelax%
              letgl@lop@temprelax%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

              % Countdown of wrapped lines in the interlinear glosses `paragraph' to zero
              %% used for looping until we reach the final line
              newcountep@countdown@ilg@para@lines%
              ep@countdown@ilg@para@lines=prevgraf%
              % Number of wrapped lines in the interlinear glosses `paragraph'
              newcountep@num@ilg@para@lines%
              ep@num@ilg@para@lines=prevgraf%
              % Count the number of lines processed so far
              newcountep@num@lines%
              ep@num@lines=0%

              % Create a vbox to overlay on top of the interlinear glosses
              setbox0vbox
              {%
              ifnumnumglwlines=1%only gla exists
              %do nothing
              else%
              % If at least 2 paragraph lines, the initialize the vertical skip
              %% (note: the first line does not contain an arrow, so only other lines are `processed')
              ifnumep@num@ilg@para@lines>1%
              %Shift upwards, the amount of space between each interlinear line
              %e.g. between gla and glb, between glb and glc, etc.
              %these spaces are defined by variables: aboveglbskip, aboveglcskip, aboveglftskip, etc.
              vskip -dimexprdim@aboveskip*(ep@num@ilg@para@lines-1)relax%
              %Shift upwards, the amount of gl@maxhtlast (height, not depth, of each glword)
              vskip -dimexprgl@maxhtlast*numglwlines*(ep@num@ilg@para@lines-1)relax%
              %Shift upwards, the amount of gl@maxdplast (depth, not height, of each glword)
              vskip -dimexprgl@maxdplast*numglwlines*(ep@num@ilg@para@lines-1)relax%
              %Shift upwards, the amount of lingextraglskip (interlinear skips)
              vskip -dimexprlingextraglskip*(ep@num@ilg@para@lines-2)relax%
              fi%
              fi%

              % For some reason, the paragraph glue values
              % need be used in vskip
              % IS THIS ALWAYS TRUE?? ONLY SOMETIMES??
              vskip -thegluestretchparskip%
              vskip -theglueshrinkparskip%

              %Loop through the paragraph lines
              loop%
              ifnumep@countdown@ilg@para@lines=ep@num@ilg@para@lines%
              %do nothing
              else%
              ling@everygla%
              newdimenep@dim@arrow@indent%
              ep@dim@arrow@indent=0pt%
              % If hangstyle is `normal' then use a consistent horizontal offset
              ifnumep@glhangstyle=1%
              % Use the standard hanging indent
              ep@dim@arrow@indent=dimexprling@glhangindentrelax%
              fi%
              % If hangstyle is `cascade' then use a cascading horizontal offset
              ifnumep@glhangstyle=2%
              % Set offset to the hanging indent amount multiplied by the current line number
              ep@dim@arrow@indent=dimexpr(ling@glhangindent*ep@num@lines)relax%
              fi%
              % Create hbox to contain the arrow and indent offset
              hbox{%
              % Create horizontal indentation
              hspace*{ep@dim@arrow@indent}%
              % Create the arrow
              raisebox{-ling@aboveglarrowskip}[height][0pt]{llap{ling@glarrow}}%
              % Use a vrule to make sure the line height is consistent
              vrule heightdimexprgl@maxhtlastrelax depthdimexprgl@maxdplastrelax width 0pt%
              }%

              % Add `above skips' for one horizontal line of GLWORDS
              vskip dim@aboveskip%
              % Add remaining heights for one horizontal line of GLWORDS
              vskip dimexpr(gl@maxdplast)*numexprnumglwlines-1relaxrelax%
              % Add remaining depths for one horizontal line of GLWORDS
              vskip dimexpr(gl@maxhtlast)*numexprnumglwlines-1relaxrelax%
              % Add extraglskip vertical skip, if necessary
              ifnumnumglwlines=1%only gla exists, no lingextraglskip is used in this case
              %do nothing
              else%
              % If there are 3 or more wrapped lines, then also add
              % vertical skip defined by extraglskip (lingextraglskip)
              ifnumep@countdown@ilg@para@lines>1%
              vskip lingextraglskip%
              fi%
              fi%
              fi%
              % Line countdown to zero (by increments of 1)
              advanceep@countdown@ilg@para@lines -1%
              % Processed line counter (by increments of 1)
              advanceep@num@lines 1%
              % If countdown has not reached zero yet, keep looping
              ifnumep@countdown@ilg@para@lines>0%
              repeat%
              }%

              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              % Display the vbox content
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              % If only one line, GLWORDS function similar to a regular paragraph
              %% therefore, use a raisebox to overlap the arrows
              ifnumnumglwlines=1
              raisebox{dimexpr(gl@maxhtlast+gl@maxdplast)*(ep@num@ilg@para@lines-1)relax}[height][0pt]{box0}%
              % Otherwise, display the box normally (because overlapping is already possible)
              else%
              box0%
              fi%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

              fi%
              }
              {}{}%

              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              %% DEFINE TWO NEW KEYS FOR USE WITHIN lingset{}
              %%% glarrow -> an arrow symbol (but could be any symbol or text)
              %%% aboveglarrowskip -> vertical space above the arrow (similar to aboveglbskip and aboveglcskip)
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
              define@lingkey{glarrow}{defling@glarrow{#1}}%
              lingset{glarrow=}%
              define@lingkey{aboveglarrowskip}{defling@aboveglarrowskip{#1}}%
              lingset{aboveglarrowskip=0pt}%
              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

              makeatother

              lingset{numoffset=leftmargin,%
              textoffset=0.75em,%
              extraglskip=!1.1ex,%
              glspace=!0.01em,%
              belowglpreambleskip=!0ex,%
              aboveglbskip=-0.9ex,%
              aboveglcskip=-0.9ex,%
              aboveglftskip=-0.1ex,%
              exnotype=chapter.arabic,%
              aboveglarrowskip=0pt,%DEFAULT
              glarrow=tiny$hookrightarrow$,%DEFAULT IS glarrow= (i.e. empty)
              glhangstyle=cascade,%
              glhangindent=2em}%



              begin{document}

              let\=textsc
              ex
              begingl
              gla
              Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //
              glb
              \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
              glft
              `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
              endgl
              xe

              end{document}


              Which results in:



              $hookrightarrow$ cascading



              Also works with normal hanging style. Changing lingset{glhangstyle=cascade} to lingset{glhangstyle=normal} results in:



              $hookrightarrow$ normal



              If you want the arrow (in this case), to point at the middle of the text instead of the baseline, you can use aboveglarrowskip to tweak the position. Changing lingset{aboveglarrowskip=0pt} (the default) to lingset{aboveglarrowskip=-2pt} results in:



              $hookrightarrow$ cascading -2pt$hookrightarrow$ normal -2pt



              You can choose to use other arrow symbols from other packages. For example, usepackage[mathb]{mathabx} and lingset{glarrow=tiny$drsh$}



              $drsh$ cascading$drsh$ normal



              Or, you can use usepackage{fdsymbol} and lingset{glarrow=tiny$Rdsh$}



              $Rdsh$ cascading$Rdsh$ normal



              If you want to use something other than an arrow, that's also fine. For example, lingset{glarrow=tiny{--test--}}



              --test-- cascading--test-- normal



              You can add some spacing, for example, lingset{glarrow={--test--hspace*{5pt}}}



              --test--+hspace cascading--test--+hspace normal



              Really, this patch is quite flexible. For example, you can throw in a TikZ arrow that is really big. But because the height will be too large, you can surround it in raisebox with zero height, using:



              usepackage{tikz}

              newcommand{myarrow}[1]{%
              begin{tikzpicture}[#1]%
              draw (0,2.7ex) -- (0,0) -- (0.75em,0);
              draw (0.55em,0.2em) -- (0.75em,0) -- (0.55em,-0.2em);
              end{tikzpicture}%
              }


              lingset{numoffset=leftmargin,%
              textoffset=0.75em,%
              extraglskip=!1.1ex,%
              glspace=!0.01em,%
              belowglpreambleskip=!0ex,%
              aboveglbskip=-0.9ex,%
              aboveglcskip=-0.9ex,%
              aboveglftskip=-0.1ex,%
              exnotype=chapter.arabic,%
              glarrow={raisebox{0pt}[0pt][0pt]{myarrow[scale=1.35,draw=red]}},%
              glhangstyle=cascade,%
              glhangindent=2em}%


              tikz arrow inside raisebox cascading



              and glhangstyle=normal



              tikz arrow inside raisebox normal



              It is also great because you can use it universally via lingset{} or specify it for only individual exxe or pexxe examples. You only need to be using the standard glossing (not nlevel) and specify the symbol/text you want and a vertical skip (if desired).






              share|improve this answer



























                up vote
                1
                down vote



                accepted










                My previous answer worked, but did not work very well. For example, if you change aboveglbskip and aboveglcskip values then all the hardcoded calculations would need to be tweaked very carefully. There were a lot of details which may help someone in the future, which is why I'm posting the new answer instead of editing the old one.



                Improved Answer



                I patched two commands within expex to allow a vbox to overlap the interlinear gloss lines. There is a difference in behavior between a single gloss line (i.e. only gla) and using multiple gloss lines (e.g. gla and glb, or gla and glb and glc).



                CAVEAT: This does not work for nlevel glosses.



                Comments are included for most lines. So, see MWE for comments on the explanation for why/what is happening.



                documentclass[a4paper,12pt,final]{memoir}

                usepackage{xpatch}

                %%%%%%%%%%%%%%%%
                % (begin) ExPex update to allow arrows
                %%%%%%%%%%%%%%%%
                makeatletter
                @ifclassloaded{memoir}{lettttexttt}{}%This is required, because expex uses tt, which memoir does not allow
                makeatother
                % Include ExPex for having sentences with glossing and translation
                usepackage{expex}

                makeatletter
                % Create an additional gl@maxhtlast (to complement existing gl@maxdplast)
                %% --inside glw@updatelists
                newdimengl@maxhtlast
                xpatchcmd{glw@updatelists}
                {globalgl@maxdplast=glw@maxdp}
                {globalgl@maxhtlast=glw@maxht
                globalgl@maxdplast=glw@maxdp}
                {}{}%

                % Add a new box to overlay arrows (or whatever) to the left side of the top interlinear gloss line
                %% --inside glw@printilg@a
                xpatchcmd{glw@printilg@a}
                {glw@printilg@b par }
                {glw@printilg@b par %

                % DO NOTHING, IF NO GLARROW WAS SPECIFIED BY USER
                ifxling@glarrowempty%
                %do nothing
                % OTHERWISE, USER DID SPECIFY A GLARROW
                else%
                % Create new dimension for above skips (e.g. aboveglaskip, aboveglbskip, aboveglcskip etc.)
                newdimendim@aboveskip%
                % Give a default value of 0pt
                globaldim@aboveskip=0pt%
                % Create a new counter for the number if interlinear gloss lines
                newcountnumglwlines%
                % Give a default value of 0
                globalnumglwlines=0%

                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %% Loop through one GLWORD
                %%% Calculate the abovegl<N>skip total (into dim@aboveskip)
                %%% and Count number of gloss lines (into numglwlines)
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                lettemp@currentitem@currentitem%
                letcountlineslistmainlist%
                letgl@lop@tempgl@lop%

                % Get the first GLWORD from token list
                % and use it to to count the interlinear gloss lines
                gl@lop@tempcountlineslisttotemp@currentitemrelax%
                % If the item is empty, ignore. Otherwise, count the lines
                ifxtemp@currentitemempty%
                else%
                % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                lettemp@aboveskip@aboveskip%
                lettempaboveskiplistaboveskiplist%
                letgltoks@next@tempgltoks@next%
                letgl@lopTL@tempgl@lopTL%

                % GLWORD is not empty, therefore it contains at least one line
                % Add one to numglwlines counter
                globaladvancenumglwlines by 1%
                % Set value to TRUE to loop through GLWORD lines
                gl@loopmoretrue%
                loopifgl@loopmore%
                % Get the `aboveskip' value for current gloss line
                gl@loptempaboveskiplisttotemp@aboveskip%
                % If value is 0pt, do nothing
                ifdimtemp@aboveskip=0pt%
                %do nothing
                % Otherwise, above skip value is set to something
                else%
                % Store current dim@aboveskip value into temporary value
                letdim@aboveskip@tempdim@aboveskip%
                % Add current `above skip' value to existing sum of `above skip' values
                globaldim@aboveskip=dimexprdim@aboveskip@temp+temp@aboveskiprelax%
                fi%
                % Get the next token (i.e. line) of the GLWORD
                gl@lopTLtemp@currentitemtogltoks@next@temp%
                % If token (line) is empty, we are finished looping
                ifxtemp@currentitemempty%
                gl@loopmorefalse%
                % Otherwise, increment the number of lines, and continue looping
                else
                globaladvancenumglwlines by 1%
                fi%
                repeat%
                % Set to FALSE as a precaution
                gl@loopmorefalse%
                % Free up memory of temporary items
                lettemp@aboveskiprelax%
                lettempaboveskiplistrelax%
                letgltoks@next@temprelax%
                letgl@lopTL@temprelax%
                fi%
                % Free up memory of temporary items
                lettemp@currentitemrelax%
                letcountlineslistrelax%
                letgl@lop@temprelax%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                % Countdown of wrapped lines in the interlinear glosses `paragraph' to zero
                %% used for looping until we reach the final line
                newcountep@countdown@ilg@para@lines%
                ep@countdown@ilg@para@lines=prevgraf%
                % Number of wrapped lines in the interlinear glosses `paragraph'
                newcountep@num@ilg@para@lines%
                ep@num@ilg@para@lines=prevgraf%
                % Count the number of lines processed so far
                newcountep@num@lines%
                ep@num@lines=0%

                % Create a vbox to overlay on top of the interlinear glosses
                setbox0vbox
                {%
                ifnumnumglwlines=1%only gla exists
                %do nothing
                else%
                % If at least 2 paragraph lines, the initialize the vertical skip
                %% (note: the first line does not contain an arrow, so only other lines are `processed')
                ifnumep@num@ilg@para@lines>1%
                %Shift upwards, the amount of space between each interlinear line
                %e.g. between gla and glb, between glb and glc, etc.
                %these spaces are defined by variables: aboveglbskip, aboveglcskip, aboveglftskip, etc.
                vskip -dimexprdim@aboveskip*(ep@num@ilg@para@lines-1)relax%
                %Shift upwards, the amount of gl@maxhtlast (height, not depth, of each glword)
                vskip -dimexprgl@maxhtlast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                %Shift upwards, the amount of gl@maxdplast (depth, not height, of each glword)
                vskip -dimexprgl@maxdplast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                %Shift upwards, the amount of lingextraglskip (interlinear skips)
                vskip -dimexprlingextraglskip*(ep@num@ilg@para@lines-2)relax%
                fi%
                fi%

                % For some reason, the paragraph glue values
                % need be used in vskip
                % IS THIS ALWAYS TRUE?? ONLY SOMETIMES??
                vskip -thegluestretchparskip%
                vskip -theglueshrinkparskip%

                %Loop through the paragraph lines
                loop%
                ifnumep@countdown@ilg@para@lines=ep@num@ilg@para@lines%
                %do nothing
                else%
                ling@everygla%
                newdimenep@dim@arrow@indent%
                ep@dim@arrow@indent=0pt%
                % If hangstyle is `normal' then use a consistent horizontal offset
                ifnumep@glhangstyle=1%
                % Use the standard hanging indent
                ep@dim@arrow@indent=dimexprling@glhangindentrelax%
                fi%
                % If hangstyle is `cascade' then use a cascading horizontal offset
                ifnumep@glhangstyle=2%
                % Set offset to the hanging indent amount multiplied by the current line number
                ep@dim@arrow@indent=dimexpr(ling@glhangindent*ep@num@lines)relax%
                fi%
                % Create hbox to contain the arrow and indent offset
                hbox{%
                % Create horizontal indentation
                hspace*{ep@dim@arrow@indent}%
                % Create the arrow
                raisebox{-ling@aboveglarrowskip}[height][0pt]{llap{ling@glarrow}}%
                % Use a vrule to make sure the line height is consistent
                vrule heightdimexprgl@maxhtlastrelax depthdimexprgl@maxdplastrelax width 0pt%
                }%

                % Add `above skips' for one horizontal line of GLWORDS
                vskip dim@aboveskip%
                % Add remaining heights for one horizontal line of GLWORDS
                vskip dimexpr(gl@maxdplast)*numexprnumglwlines-1relaxrelax%
                % Add remaining depths for one horizontal line of GLWORDS
                vskip dimexpr(gl@maxhtlast)*numexprnumglwlines-1relaxrelax%
                % Add extraglskip vertical skip, if necessary
                ifnumnumglwlines=1%only gla exists, no lingextraglskip is used in this case
                %do nothing
                else%
                % If there are 3 or more wrapped lines, then also add
                % vertical skip defined by extraglskip (lingextraglskip)
                ifnumep@countdown@ilg@para@lines>1%
                vskip lingextraglskip%
                fi%
                fi%
                fi%
                % Line countdown to zero (by increments of 1)
                advanceep@countdown@ilg@para@lines -1%
                % Processed line counter (by increments of 1)
                advanceep@num@lines 1%
                % If countdown has not reached zero yet, keep looping
                ifnumep@countdown@ilg@para@lines>0%
                repeat%
                }%

                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                % Display the vbox content
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                % If only one line, GLWORDS function similar to a regular paragraph
                %% therefore, use a raisebox to overlap the arrows
                ifnumnumglwlines=1
                raisebox{dimexpr(gl@maxhtlast+gl@maxdplast)*(ep@num@ilg@para@lines-1)relax}[height][0pt]{box0}%
                % Otherwise, display the box normally (because overlapping is already possible)
                else%
                box0%
                fi%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                fi%
                }
                {}{}%

                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %% DEFINE TWO NEW KEYS FOR USE WITHIN lingset{}
                %%% glarrow -> an arrow symbol (but could be any symbol or text)
                %%% aboveglarrowskip -> vertical space above the arrow (similar to aboveglbskip and aboveglcskip)
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                define@lingkey{glarrow}{defling@glarrow{#1}}%
                lingset{glarrow=}%
                define@lingkey{aboveglarrowskip}{defling@aboveglarrowskip{#1}}%
                lingset{aboveglarrowskip=0pt}%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                makeatother

                lingset{numoffset=leftmargin,%
                textoffset=0.75em,%
                extraglskip=!1.1ex,%
                glspace=!0.01em,%
                belowglpreambleskip=!0ex,%
                aboveglbskip=-0.9ex,%
                aboveglcskip=-0.9ex,%
                aboveglftskip=-0.1ex,%
                exnotype=chapter.arabic,%
                aboveglarrowskip=0pt,%DEFAULT
                glarrow=tiny$hookrightarrow$,%DEFAULT IS glarrow= (i.e. empty)
                glhangstyle=cascade,%
                glhangindent=2em}%



                begin{document}

                let\=textsc
                ex
                begingl
                gla
                Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //
                glb
                \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
                glft
                `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
                endgl
                xe

                end{document}


                Which results in:



                $hookrightarrow$ cascading



                Also works with normal hanging style. Changing lingset{glhangstyle=cascade} to lingset{glhangstyle=normal} results in:



                $hookrightarrow$ normal



                If you want the arrow (in this case), to point at the middle of the text instead of the baseline, you can use aboveglarrowskip to tweak the position. Changing lingset{aboveglarrowskip=0pt} (the default) to lingset{aboveglarrowskip=-2pt} results in:



                $hookrightarrow$ cascading -2pt$hookrightarrow$ normal -2pt



                You can choose to use other arrow symbols from other packages. For example, usepackage[mathb]{mathabx} and lingset{glarrow=tiny$drsh$}



                $drsh$ cascading$drsh$ normal



                Or, you can use usepackage{fdsymbol} and lingset{glarrow=tiny$Rdsh$}



                $Rdsh$ cascading$Rdsh$ normal



                If you want to use something other than an arrow, that's also fine. For example, lingset{glarrow=tiny{--test--}}



                --test-- cascading--test-- normal



                You can add some spacing, for example, lingset{glarrow={--test--hspace*{5pt}}}



                --test--+hspace cascading--test--+hspace normal



                Really, this patch is quite flexible. For example, you can throw in a TikZ arrow that is really big. But because the height will be too large, you can surround it in raisebox with zero height, using:



                usepackage{tikz}

                newcommand{myarrow}[1]{%
                begin{tikzpicture}[#1]%
                draw (0,2.7ex) -- (0,0) -- (0.75em,0);
                draw (0.55em,0.2em) -- (0.75em,0) -- (0.55em,-0.2em);
                end{tikzpicture}%
                }


                lingset{numoffset=leftmargin,%
                textoffset=0.75em,%
                extraglskip=!1.1ex,%
                glspace=!0.01em,%
                belowglpreambleskip=!0ex,%
                aboveglbskip=-0.9ex,%
                aboveglcskip=-0.9ex,%
                aboveglftskip=-0.1ex,%
                exnotype=chapter.arabic,%
                glarrow={raisebox{0pt}[0pt][0pt]{myarrow[scale=1.35,draw=red]}},%
                glhangstyle=cascade,%
                glhangindent=2em}%


                tikz arrow inside raisebox cascading



                and glhangstyle=normal



                tikz arrow inside raisebox normal



                It is also great because you can use it universally via lingset{} or specify it for only individual exxe or pexxe examples. You only need to be using the standard glossing (not nlevel) and specify the symbol/text you want and a vertical skip (if desired).






                share|improve this answer

























                  up vote
                  1
                  down vote



                  accepted







                  up vote
                  1
                  down vote



                  accepted






                  My previous answer worked, but did not work very well. For example, if you change aboveglbskip and aboveglcskip values then all the hardcoded calculations would need to be tweaked very carefully. There were a lot of details which may help someone in the future, which is why I'm posting the new answer instead of editing the old one.



                  Improved Answer



                  I patched two commands within expex to allow a vbox to overlap the interlinear gloss lines. There is a difference in behavior between a single gloss line (i.e. only gla) and using multiple gloss lines (e.g. gla and glb, or gla and glb and glc).



                  CAVEAT: This does not work for nlevel glosses.



                  Comments are included for most lines. So, see MWE for comments on the explanation for why/what is happening.



                  documentclass[a4paper,12pt,final]{memoir}

                  usepackage{xpatch}

                  %%%%%%%%%%%%%%%%
                  % (begin) ExPex update to allow arrows
                  %%%%%%%%%%%%%%%%
                  makeatletter
                  @ifclassloaded{memoir}{lettttexttt}{}%This is required, because expex uses tt, which memoir does not allow
                  makeatother
                  % Include ExPex for having sentences with glossing and translation
                  usepackage{expex}

                  makeatletter
                  % Create an additional gl@maxhtlast (to complement existing gl@maxdplast)
                  %% --inside glw@updatelists
                  newdimengl@maxhtlast
                  xpatchcmd{glw@updatelists}
                  {globalgl@maxdplast=glw@maxdp}
                  {globalgl@maxhtlast=glw@maxht
                  globalgl@maxdplast=glw@maxdp}
                  {}{}%

                  % Add a new box to overlay arrows (or whatever) to the left side of the top interlinear gloss line
                  %% --inside glw@printilg@a
                  xpatchcmd{glw@printilg@a}
                  {glw@printilg@b par }
                  {glw@printilg@b par %

                  % DO NOTHING, IF NO GLARROW WAS SPECIFIED BY USER
                  ifxling@glarrowempty%
                  %do nothing
                  % OTHERWISE, USER DID SPECIFY A GLARROW
                  else%
                  % Create new dimension for above skips (e.g. aboveglaskip, aboveglbskip, aboveglcskip etc.)
                  newdimendim@aboveskip%
                  % Give a default value of 0pt
                  globaldim@aboveskip=0pt%
                  % Create a new counter for the number if interlinear gloss lines
                  newcountnumglwlines%
                  % Give a default value of 0
                  globalnumglwlines=0%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %% Loop through one GLWORD
                  %%% Calculate the abovegl<N>skip total (into dim@aboveskip)
                  %%% and Count number of gloss lines (into numglwlines)
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                  % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                  lettemp@currentitem@currentitem%
                  letcountlineslistmainlist%
                  letgl@lop@tempgl@lop%

                  % Get the first GLWORD from token list
                  % and use it to to count the interlinear gloss lines
                  gl@lop@tempcountlineslisttotemp@currentitemrelax%
                  % If the item is empty, ignore. Otherwise, count the lines
                  ifxtemp@currentitemempty%
                  else%
                  % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                  % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                  lettemp@aboveskip@aboveskip%
                  lettempaboveskiplistaboveskiplist%
                  letgltoks@next@tempgltoks@next%
                  letgl@lopTL@tempgl@lopTL%

                  % GLWORD is not empty, therefore it contains at least one line
                  % Add one to numglwlines counter
                  globaladvancenumglwlines by 1%
                  % Set value to TRUE to loop through GLWORD lines
                  gl@loopmoretrue%
                  loopifgl@loopmore%
                  % Get the `aboveskip' value for current gloss line
                  gl@loptempaboveskiplisttotemp@aboveskip%
                  % If value is 0pt, do nothing
                  ifdimtemp@aboveskip=0pt%
                  %do nothing
                  % Otherwise, above skip value is set to something
                  else%
                  % Store current dim@aboveskip value into temporary value
                  letdim@aboveskip@tempdim@aboveskip%
                  % Add current `above skip' value to existing sum of `above skip' values
                  globaldim@aboveskip=dimexprdim@aboveskip@temp+temp@aboveskiprelax%
                  fi%
                  % Get the next token (i.e. line) of the GLWORD
                  gl@lopTLtemp@currentitemtogltoks@next@temp%
                  % If token (line) is empty, we are finished looping
                  ifxtemp@currentitemempty%
                  gl@loopmorefalse%
                  % Otherwise, increment the number of lines, and continue looping
                  else
                  globaladvancenumglwlines by 1%
                  fi%
                  repeat%
                  % Set to FALSE as a precaution
                  gl@loopmorefalse%
                  % Free up memory of temporary items
                  lettemp@aboveskiprelax%
                  lettempaboveskiplistrelax%
                  letgltoks@next@temprelax%
                  letgl@lopTL@temprelax%
                  fi%
                  % Free up memory of temporary items
                  lettemp@currentitemrelax%
                  letcountlineslistrelax%
                  letgl@lop@temprelax%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  % Countdown of wrapped lines in the interlinear glosses `paragraph' to zero
                  %% used for looping until we reach the final line
                  newcountep@countdown@ilg@para@lines%
                  ep@countdown@ilg@para@lines=prevgraf%
                  % Number of wrapped lines in the interlinear glosses `paragraph'
                  newcountep@num@ilg@para@lines%
                  ep@num@ilg@para@lines=prevgraf%
                  % Count the number of lines processed so far
                  newcountep@num@lines%
                  ep@num@lines=0%

                  % Create a vbox to overlay on top of the interlinear glosses
                  setbox0vbox
                  {%
                  ifnumnumglwlines=1%only gla exists
                  %do nothing
                  else%
                  % If at least 2 paragraph lines, the initialize the vertical skip
                  %% (note: the first line does not contain an arrow, so only other lines are `processed')
                  ifnumep@num@ilg@para@lines>1%
                  %Shift upwards, the amount of space between each interlinear line
                  %e.g. between gla and glb, between glb and glc, etc.
                  %these spaces are defined by variables: aboveglbskip, aboveglcskip, aboveglftskip, etc.
                  vskip -dimexprdim@aboveskip*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of gl@maxhtlast (height, not depth, of each glword)
                  vskip -dimexprgl@maxhtlast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of gl@maxdplast (depth, not height, of each glword)
                  vskip -dimexprgl@maxdplast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of lingextraglskip (interlinear skips)
                  vskip -dimexprlingextraglskip*(ep@num@ilg@para@lines-2)relax%
                  fi%
                  fi%

                  % For some reason, the paragraph glue values
                  % need be used in vskip
                  % IS THIS ALWAYS TRUE?? ONLY SOMETIMES??
                  vskip -thegluestretchparskip%
                  vskip -theglueshrinkparskip%

                  %Loop through the paragraph lines
                  loop%
                  ifnumep@countdown@ilg@para@lines=ep@num@ilg@para@lines%
                  %do nothing
                  else%
                  ling@everygla%
                  newdimenep@dim@arrow@indent%
                  ep@dim@arrow@indent=0pt%
                  % If hangstyle is `normal' then use a consistent horizontal offset
                  ifnumep@glhangstyle=1%
                  % Use the standard hanging indent
                  ep@dim@arrow@indent=dimexprling@glhangindentrelax%
                  fi%
                  % If hangstyle is `cascade' then use a cascading horizontal offset
                  ifnumep@glhangstyle=2%
                  % Set offset to the hanging indent amount multiplied by the current line number
                  ep@dim@arrow@indent=dimexpr(ling@glhangindent*ep@num@lines)relax%
                  fi%
                  % Create hbox to contain the arrow and indent offset
                  hbox{%
                  % Create horizontal indentation
                  hspace*{ep@dim@arrow@indent}%
                  % Create the arrow
                  raisebox{-ling@aboveglarrowskip}[height][0pt]{llap{ling@glarrow}}%
                  % Use a vrule to make sure the line height is consistent
                  vrule heightdimexprgl@maxhtlastrelax depthdimexprgl@maxdplastrelax width 0pt%
                  }%

                  % Add `above skips' for one horizontal line of GLWORDS
                  vskip dim@aboveskip%
                  % Add remaining heights for one horizontal line of GLWORDS
                  vskip dimexpr(gl@maxdplast)*numexprnumglwlines-1relaxrelax%
                  % Add remaining depths for one horizontal line of GLWORDS
                  vskip dimexpr(gl@maxhtlast)*numexprnumglwlines-1relaxrelax%
                  % Add extraglskip vertical skip, if necessary
                  ifnumnumglwlines=1%only gla exists, no lingextraglskip is used in this case
                  %do nothing
                  else%
                  % If there are 3 or more wrapped lines, then also add
                  % vertical skip defined by extraglskip (lingextraglskip)
                  ifnumep@countdown@ilg@para@lines>1%
                  vskip lingextraglskip%
                  fi%
                  fi%
                  fi%
                  % Line countdown to zero (by increments of 1)
                  advanceep@countdown@ilg@para@lines -1%
                  % Processed line counter (by increments of 1)
                  advanceep@num@lines 1%
                  % If countdown has not reached zero yet, keep looping
                  ifnumep@countdown@ilg@para@lines>0%
                  repeat%
                  }%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  % Display the vbox content
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  % If only one line, GLWORDS function similar to a regular paragraph
                  %% therefore, use a raisebox to overlap the arrows
                  ifnumnumglwlines=1
                  raisebox{dimexpr(gl@maxhtlast+gl@maxdplast)*(ep@num@ilg@para@lines-1)relax}[height][0pt]{box0}%
                  % Otherwise, display the box normally (because overlapping is already possible)
                  else%
                  box0%
                  fi%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  fi%
                  }
                  {}{}%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %% DEFINE TWO NEW KEYS FOR USE WITHIN lingset{}
                  %%% glarrow -> an arrow symbol (but could be any symbol or text)
                  %%% aboveglarrowskip -> vertical space above the arrow (similar to aboveglbskip and aboveglcskip)
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  define@lingkey{glarrow}{defling@glarrow{#1}}%
                  lingset{glarrow=}%
                  define@lingkey{aboveglarrowskip}{defling@aboveglarrowskip{#1}}%
                  lingset{aboveglarrowskip=0pt}%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  makeatother

                  lingset{numoffset=leftmargin,%
                  textoffset=0.75em,%
                  extraglskip=!1.1ex,%
                  glspace=!0.01em,%
                  belowglpreambleskip=!0ex,%
                  aboveglbskip=-0.9ex,%
                  aboveglcskip=-0.9ex,%
                  aboveglftskip=-0.1ex,%
                  exnotype=chapter.arabic,%
                  aboveglarrowskip=0pt,%DEFAULT
                  glarrow=tiny$hookrightarrow$,%DEFAULT IS glarrow= (i.e. empty)
                  glhangstyle=cascade,%
                  glhangindent=2em}%



                  begin{document}

                  let\=textsc
                  ex
                  begingl
                  gla
                  Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //
                  glb
                  \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
                  glft
                  `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
                  endgl
                  xe

                  end{document}


                  Which results in:



                  $hookrightarrow$ cascading



                  Also works with normal hanging style. Changing lingset{glhangstyle=cascade} to lingset{glhangstyle=normal} results in:



                  $hookrightarrow$ normal



                  If you want the arrow (in this case), to point at the middle of the text instead of the baseline, you can use aboveglarrowskip to tweak the position. Changing lingset{aboveglarrowskip=0pt} (the default) to lingset{aboveglarrowskip=-2pt} results in:



                  $hookrightarrow$ cascading -2pt$hookrightarrow$ normal -2pt



                  You can choose to use other arrow symbols from other packages. For example, usepackage[mathb]{mathabx} and lingset{glarrow=tiny$drsh$}



                  $drsh$ cascading$drsh$ normal



                  Or, you can use usepackage{fdsymbol} and lingset{glarrow=tiny$Rdsh$}



                  $Rdsh$ cascading$Rdsh$ normal



                  If you want to use something other than an arrow, that's also fine. For example, lingset{glarrow=tiny{--test--}}



                  --test-- cascading--test-- normal



                  You can add some spacing, for example, lingset{glarrow={--test--hspace*{5pt}}}



                  --test--+hspace cascading--test--+hspace normal



                  Really, this patch is quite flexible. For example, you can throw in a TikZ arrow that is really big. But because the height will be too large, you can surround it in raisebox with zero height, using:



                  usepackage{tikz}

                  newcommand{myarrow}[1]{%
                  begin{tikzpicture}[#1]%
                  draw (0,2.7ex) -- (0,0) -- (0.75em,0);
                  draw (0.55em,0.2em) -- (0.75em,0) -- (0.55em,-0.2em);
                  end{tikzpicture}%
                  }


                  lingset{numoffset=leftmargin,%
                  textoffset=0.75em,%
                  extraglskip=!1.1ex,%
                  glspace=!0.01em,%
                  belowglpreambleskip=!0ex,%
                  aboveglbskip=-0.9ex,%
                  aboveglcskip=-0.9ex,%
                  aboveglftskip=-0.1ex,%
                  exnotype=chapter.arabic,%
                  glarrow={raisebox{0pt}[0pt][0pt]{myarrow[scale=1.35,draw=red]}},%
                  glhangstyle=cascade,%
                  glhangindent=2em}%


                  tikz arrow inside raisebox cascading



                  and glhangstyle=normal



                  tikz arrow inside raisebox normal



                  It is also great because you can use it universally via lingset{} or specify it for only individual exxe or pexxe examples. You only need to be using the standard glossing (not nlevel) and specify the symbol/text you want and a vertical skip (if desired).






                  share|improve this answer














                  My previous answer worked, but did not work very well. For example, if you change aboveglbskip and aboveglcskip values then all the hardcoded calculations would need to be tweaked very carefully. There were a lot of details which may help someone in the future, which is why I'm posting the new answer instead of editing the old one.



                  Improved Answer



                  I patched two commands within expex to allow a vbox to overlap the interlinear gloss lines. There is a difference in behavior between a single gloss line (i.e. only gla) and using multiple gloss lines (e.g. gla and glb, or gla and glb and glc).



                  CAVEAT: This does not work for nlevel glosses.



                  Comments are included for most lines. So, see MWE for comments on the explanation for why/what is happening.



                  documentclass[a4paper,12pt,final]{memoir}

                  usepackage{xpatch}

                  %%%%%%%%%%%%%%%%
                  % (begin) ExPex update to allow arrows
                  %%%%%%%%%%%%%%%%
                  makeatletter
                  @ifclassloaded{memoir}{lettttexttt}{}%This is required, because expex uses tt, which memoir does not allow
                  makeatother
                  % Include ExPex for having sentences with glossing and translation
                  usepackage{expex}

                  makeatletter
                  % Create an additional gl@maxhtlast (to complement existing gl@maxdplast)
                  %% --inside glw@updatelists
                  newdimengl@maxhtlast
                  xpatchcmd{glw@updatelists}
                  {globalgl@maxdplast=glw@maxdp}
                  {globalgl@maxhtlast=glw@maxht
                  globalgl@maxdplast=glw@maxdp}
                  {}{}%

                  % Add a new box to overlay arrows (or whatever) to the left side of the top interlinear gloss line
                  %% --inside glw@printilg@a
                  xpatchcmd{glw@printilg@a}
                  {glw@printilg@b par }
                  {glw@printilg@b par %

                  % DO NOTHING, IF NO GLARROW WAS SPECIFIED BY USER
                  ifxling@glarrowempty%
                  %do nothing
                  % OTHERWISE, USER DID SPECIFY A GLARROW
                  else%
                  % Create new dimension for above skips (e.g. aboveglaskip, aboveglbskip, aboveglcskip etc.)
                  newdimendim@aboveskip%
                  % Give a default value of 0pt
                  globaldim@aboveskip=0pt%
                  % Create a new counter for the number if interlinear gloss lines
                  newcountnumglwlines%
                  % Give a default value of 0
                  globalnumglwlines=0%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %% Loop through one GLWORD
                  %%% Calculate the abovegl<N>skip total (into dim@aboveskip)
                  %%% and Count number of gloss lines (into numglwlines)
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                  % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                  lettemp@currentitem@currentitem%
                  letcountlineslistmainlist%
                  letgl@lop@tempgl@lop%

                  % Get the first GLWORD from token list
                  % and use it to to count the interlinear gloss lines
                  gl@lop@tempcountlineslisttotemp@currentitemrelax%
                  % If the item is empty, ignore. Otherwise, count the lines
                  ifxtemp@currentitemempty%
                  else%
                  % DON'T MODIFY EXISTING TOKENS, LISTS, OR OPERATORS (TO BE SAFE)
                  % INSTEAD, USE A TEMPORARY VERSION WITH THE SAME VALUE
                  lettemp@aboveskip@aboveskip%
                  lettempaboveskiplistaboveskiplist%
                  letgltoks@next@tempgltoks@next%
                  letgl@lopTL@tempgl@lopTL%

                  % GLWORD is not empty, therefore it contains at least one line
                  % Add one to numglwlines counter
                  globaladvancenumglwlines by 1%
                  % Set value to TRUE to loop through GLWORD lines
                  gl@loopmoretrue%
                  loopifgl@loopmore%
                  % Get the `aboveskip' value for current gloss line
                  gl@loptempaboveskiplisttotemp@aboveskip%
                  % If value is 0pt, do nothing
                  ifdimtemp@aboveskip=0pt%
                  %do nothing
                  % Otherwise, above skip value is set to something
                  else%
                  % Store current dim@aboveskip value into temporary value
                  letdim@aboveskip@tempdim@aboveskip%
                  % Add current `above skip' value to existing sum of `above skip' values
                  globaldim@aboveskip=dimexprdim@aboveskip@temp+temp@aboveskiprelax%
                  fi%
                  % Get the next token (i.e. line) of the GLWORD
                  gl@lopTLtemp@currentitemtogltoks@next@temp%
                  % If token (line) is empty, we are finished looping
                  ifxtemp@currentitemempty%
                  gl@loopmorefalse%
                  % Otherwise, increment the number of lines, and continue looping
                  else
                  globaladvancenumglwlines by 1%
                  fi%
                  repeat%
                  % Set to FALSE as a precaution
                  gl@loopmorefalse%
                  % Free up memory of temporary items
                  lettemp@aboveskiprelax%
                  lettempaboveskiplistrelax%
                  letgltoks@next@temprelax%
                  letgl@lopTL@temprelax%
                  fi%
                  % Free up memory of temporary items
                  lettemp@currentitemrelax%
                  letcountlineslistrelax%
                  letgl@lop@temprelax%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  % Countdown of wrapped lines in the interlinear glosses `paragraph' to zero
                  %% used for looping until we reach the final line
                  newcountep@countdown@ilg@para@lines%
                  ep@countdown@ilg@para@lines=prevgraf%
                  % Number of wrapped lines in the interlinear glosses `paragraph'
                  newcountep@num@ilg@para@lines%
                  ep@num@ilg@para@lines=prevgraf%
                  % Count the number of lines processed so far
                  newcountep@num@lines%
                  ep@num@lines=0%

                  % Create a vbox to overlay on top of the interlinear glosses
                  setbox0vbox
                  {%
                  ifnumnumglwlines=1%only gla exists
                  %do nothing
                  else%
                  % If at least 2 paragraph lines, the initialize the vertical skip
                  %% (note: the first line does not contain an arrow, so only other lines are `processed')
                  ifnumep@num@ilg@para@lines>1%
                  %Shift upwards, the amount of space between each interlinear line
                  %e.g. between gla and glb, between glb and glc, etc.
                  %these spaces are defined by variables: aboveglbskip, aboveglcskip, aboveglftskip, etc.
                  vskip -dimexprdim@aboveskip*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of gl@maxhtlast (height, not depth, of each glword)
                  vskip -dimexprgl@maxhtlast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of gl@maxdplast (depth, not height, of each glword)
                  vskip -dimexprgl@maxdplast*numglwlines*(ep@num@ilg@para@lines-1)relax%
                  %Shift upwards, the amount of lingextraglskip (interlinear skips)
                  vskip -dimexprlingextraglskip*(ep@num@ilg@para@lines-2)relax%
                  fi%
                  fi%

                  % For some reason, the paragraph glue values
                  % need be used in vskip
                  % IS THIS ALWAYS TRUE?? ONLY SOMETIMES??
                  vskip -thegluestretchparskip%
                  vskip -theglueshrinkparskip%

                  %Loop through the paragraph lines
                  loop%
                  ifnumep@countdown@ilg@para@lines=ep@num@ilg@para@lines%
                  %do nothing
                  else%
                  ling@everygla%
                  newdimenep@dim@arrow@indent%
                  ep@dim@arrow@indent=0pt%
                  % If hangstyle is `normal' then use a consistent horizontal offset
                  ifnumep@glhangstyle=1%
                  % Use the standard hanging indent
                  ep@dim@arrow@indent=dimexprling@glhangindentrelax%
                  fi%
                  % If hangstyle is `cascade' then use a cascading horizontal offset
                  ifnumep@glhangstyle=2%
                  % Set offset to the hanging indent amount multiplied by the current line number
                  ep@dim@arrow@indent=dimexpr(ling@glhangindent*ep@num@lines)relax%
                  fi%
                  % Create hbox to contain the arrow and indent offset
                  hbox{%
                  % Create horizontal indentation
                  hspace*{ep@dim@arrow@indent}%
                  % Create the arrow
                  raisebox{-ling@aboveglarrowskip}[height][0pt]{llap{ling@glarrow}}%
                  % Use a vrule to make sure the line height is consistent
                  vrule heightdimexprgl@maxhtlastrelax depthdimexprgl@maxdplastrelax width 0pt%
                  }%

                  % Add `above skips' for one horizontal line of GLWORDS
                  vskip dim@aboveskip%
                  % Add remaining heights for one horizontal line of GLWORDS
                  vskip dimexpr(gl@maxdplast)*numexprnumglwlines-1relaxrelax%
                  % Add remaining depths for one horizontal line of GLWORDS
                  vskip dimexpr(gl@maxhtlast)*numexprnumglwlines-1relaxrelax%
                  % Add extraglskip vertical skip, if necessary
                  ifnumnumglwlines=1%only gla exists, no lingextraglskip is used in this case
                  %do nothing
                  else%
                  % If there are 3 or more wrapped lines, then also add
                  % vertical skip defined by extraglskip (lingextraglskip)
                  ifnumep@countdown@ilg@para@lines>1%
                  vskip lingextraglskip%
                  fi%
                  fi%
                  fi%
                  % Line countdown to zero (by increments of 1)
                  advanceep@countdown@ilg@para@lines -1%
                  % Processed line counter (by increments of 1)
                  advanceep@num@lines 1%
                  % If countdown has not reached zero yet, keep looping
                  ifnumep@countdown@ilg@para@lines>0%
                  repeat%
                  }%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  % Display the vbox content
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  % If only one line, GLWORDS function similar to a regular paragraph
                  %% therefore, use a raisebox to overlap the arrows
                  ifnumnumglwlines=1
                  raisebox{dimexpr(gl@maxhtlast+gl@maxdplast)*(ep@num@ilg@para@lines-1)relax}[height][0pt]{box0}%
                  % Otherwise, display the box normally (because overlapping is already possible)
                  else%
                  box0%
                  fi%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  fi%
                  }
                  {}{}%

                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %% DEFINE TWO NEW KEYS FOR USE WITHIN lingset{}
                  %%% glarrow -> an arrow symbol (but could be any symbol or text)
                  %%% aboveglarrowskip -> vertical space above the arrow (similar to aboveglbskip and aboveglcskip)
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  define@lingkey{glarrow}{defling@glarrow{#1}}%
                  lingset{glarrow=}%
                  define@lingkey{aboveglarrowskip}{defling@aboveglarrowskip{#1}}%
                  lingset{aboveglarrowskip=0pt}%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

                  makeatother

                  lingset{numoffset=leftmargin,%
                  textoffset=0.75em,%
                  extraglskip=!1.1ex,%
                  glspace=!0.01em,%
                  belowglpreambleskip=!0ex,%
                  aboveglbskip=-0.9ex,%
                  aboveglcskip=-0.9ex,%
                  aboveglftskip=-0.1ex,%
                  exnotype=chapter.arabic,%
                  aboveglarrowskip=0pt,%DEFAULT
                  glarrow=tiny$hookrightarrow$,%DEFAULT IS glarrow= (i.e. empty)
                  glhangstyle=cascade,%
                  glhangindent=2em}%



                  begin{document}

                  let\=textsc
                  ex
                  begingl
                  gla
                  Hom^{a}o sa v{c}^{o} p^{o} tha ~{n}u nao ngu{a} hmua. ~{N}u dju{a} gu{a}, ~{n}u dju{a} v{c}u{o}ng ~{n}u, laih gui r^{e}o ~{n}u. Todang bboi r^{o}k jolan ~{n}u nao hma, ~{n}u bb^{o}h sa droi mru{a} du{o} bboi gah, a, hruh ~{n}u. //
                  glb
                  \{exist} one \{clf} person old \{3s} go do field \{3s} hold machete \{3s} hold hoe \{3s} and carry.on.back back.basket \{3s} while at along trail \{3s} go field \{3s} see one \{clf} peacock stay at \{drct} -- nest \{3s} //
                  glft
                  `There was an old person who went to work in the field. He took along his machete, he took along his hoe, and he carried his basket on his back. While he was on his way to the farm, he saw a peacock beside its nest.' //
                  endgl
                  xe

                  end{document}


                  Which results in:



                  $hookrightarrow$ cascading



                  Also works with normal hanging style. Changing lingset{glhangstyle=cascade} to lingset{glhangstyle=normal} results in:



                  $hookrightarrow$ normal



                  If you want the arrow (in this case), to point at the middle of the text instead of the baseline, you can use aboveglarrowskip to tweak the position. Changing lingset{aboveglarrowskip=0pt} (the default) to lingset{aboveglarrowskip=-2pt} results in:



                  $hookrightarrow$ cascading -2pt$hookrightarrow$ normal -2pt



                  You can choose to use other arrow symbols from other packages. For example, usepackage[mathb]{mathabx} and lingset{glarrow=tiny$drsh$}



                  $drsh$ cascading$drsh$ normal



                  Or, you can use usepackage{fdsymbol} and lingset{glarrow=tiny$Rdsh$}



                  $Rdsh$ cascading$Rdsh$ normal



                  If you want to use something other than an arrow, that's also fine. For example, lingset{glarrow=tiny{--test--}}



                  --test-- cascading--test-- normal



                  You can add some spacing, for example, lingset{glarrow={--test--hspace*{5pt}}}



                  --test--+hspace cascading--test--+hspace normal



                  Really, this patch is quite flexible. For example, you can throw in a TikZ arrow that is really big. But because the height will be too large, you can surround it in raisebox with zero height, using:



                  usepackage{tikz}

                  newcommand{myarrow}[1]{%
                  begin{tikzpicture}[#1]%
                  draw (0,2.7ex) -- (0,0) -- (0.75em,0);
                  draw (0.55em,0.2em) -- (0.75em,0) -- (0.55em,-0.2em);
                  end{tikzpicture}%
                  }


                  lingset{numoffset=leftmargin,%
                  textoffset=0.75em,%
                  extraglskip=!1.1ex,%
                  glspace=!0.01em,%
                  belowglpreambleskip=!0ex,%
                  aboveglbskip=-0.9ex,%
                  aboveglcskip=-0.9ex,%
                  aboveglftskip=-0.1ex,%
                  exnotype=chapter.arabic,%
                  glarrow={raisebox{0pt}[0pt][0pt]{myarrow[scale=1.35,draw=red]}},%
                  glhangstyle=cascade,%
                  glhangindent=2em}%


                  tikz arrow inside raisebox cascading



                  and glhangstyle=normal



                  tikz arrow inside raisebox normal



                  It is also great because you can use it universally via lingset{} or specify it for only individual exxe or pexxe examples. You only need to be using the standard glossing (not nlevel) and specify the symbol/text you want and a vertical skip (if desired).







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 11 mins ago

























                  answered 10 hours ago









                  whatisit

                  352112




                  352112






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f407205%2fcreate-symbols-arrows-text-at-beginning-of-hanging-indents-in-expex%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Accessing regular linux commands in Huawei's Dopra Linux

                      Can't connect RFCOMM socket: Host is down

                      Kernel panic - not syncing: Fatal Exception in Interrupt