TransWikia.com

Problems with linguex regarding spacing

TeX - LaTeX Asked by paulez on February 17, 2021

I have a problem regarding changing values of parameters of linguex. In the documentation it says that you can change the value of Extopsep, which is responsible for spacing before and after the enviroment. I tried this with setlength{Extopsep}{.3baselineskip}. Could there maybe be a problem with the package setspace in combination with linguex which i am using too?

This is how my Programm looks

documentclass[12pt, a4paper]{article}
usepackage{setspace}

usepackage{linguex}
leteachwordone=it
setlength{Extopsep}{.3baselineskip}

begin{document}

begin{spacing}{1.5}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
end{spacing}
end{document}

PDF that the Code creates

The spacing before the example seems to be much larger than after.
I can’t seem to find out the issue with my code. Could anyone maybe help me with this?

EDIT:

It seems to be the case that as soon as you try to modify baselinestretch in any way the spacing comes out incorrect. I also tried it without setspace and instead with linespread{1.5} and it still didn’t come out right – using setspace doesn’t really seem to make a difference.

documentclass[12pt, a4paper]{article}
linespread{1.5}

usepackage{linguex}
leteachwordone=it
AtBeginDocument{setlength{Extopsep}{.3baselineskip}}

begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
end{document} 

PDF line spacing issues

The spacing is still uneven, even in the absence of a setspace enviroment, the problem seems to occur because of linguex alone

2 Answers

linguex can not control the spacing after the display as well as the space before it as it constructs a two line vbox with the reference point on the baseline of the first line, that allows an automatic baselineskip calculation at the top to control baseline to baseline space, however at the bottom Tex sees all of the second line as depth so gives up and just inserts lineskip (1pt) space.

@wipet gave a nice simpler example of this and a fix for the problem the other day here

vertical spacing around tabular

The only problem here is to find the vbox where you want to save prevdepth and where to restore it. Staring at tracingall for a while leads to twosent from the cgloss4e package. The following is one way (perhaps not the best) of saving prevdepth at the right place to set it to (here) the depth of j on the second line.

documentclass[12pt, a4paper]{article}
usepackage{setspace}

usepackage{linguex}
makeatletter
gdeftwosent#1 #2{% #1 = first line, #2 = second line
    getwords(lineone,eachwordone)#1 %
    getwords(linetwo,eachwordtwo)#2 %
%%%%
xdefzz{prevdepththedplinetworelax}%
aftergroupaftergroupaftergroupzz
%%%%
    looplastword{eachwordone}{lineone}{wordone}%
         lastword{eachwordtwo}{linetwo}{wordtwo}%
         globalsetboxgline=hbox{unhboxgline
                                    hskipglossglue
                                    vtop{boxwordone   % vtop was vbox
                                          nointerlineskip
                                          boxwordtwo
                                         }%
                                   }%
         testdone
         ifnotdone
    repeat
    egroup % matches bgroup in gloss
   gl@stop}





begin{document}

begin{spacing}{1.5}setlength{Extopsep}{0pt}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 


exg.
At vero eos et accusam 
et justo duo doloregs et 


ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
end{spacing}
end{document}

enter image description here

Correct answer by David Carlisle on February 17, 2021

There are two issues with your example. First, the linguex package resets all its default lengths using AtBeginDocument, so any change you make to them in the preamble is overridden. So the change you've made is not actually being used in the document; it's still using the default, which is .66baselineskip. To actually change the length globally for your document you need to use:

AtBeginDocument{setlength{Extopsep}{.3baselineskip}}

But this may not really be doing what you expect, since this will set the length to be .3*14.5pt, i.e., .3 of the baseline skip for 12pt normal text. This value will not change within the spacing environment, unless you set it locally within it.

To see this, consider the document below. In the first example with no spacing factor set, the example is correctly spaced, but as soon as we add the spacing environment, the extra space appears. This space has nothing to do with the setting of the Extopsep length directly but instead it's the text line of the spacing environment that's adding the extra space that appears at the "top" of the example.

documentclass[12pt, a4paper]{article}
usepackage{setspace}

usepackage{linguex}
leteachwordone=it
AtBeginDocument{setlength{Extopsep}{.3baselineskip}}
newcommandshowskips{Baseline skip: thebaselineskip Extopsep: theExtopseppar}
begin{document}

showskips
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 

begin{spacing}{1.5}showskips
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
end{spacing}

begin{spacing}{1.5}setlength{Extopsep}{.3baselineskip}showskips
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 
exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
end{spacing}
end{document}

output of code

We can see this effect more clearly if we make the Extopsep length 0pt:

begin{spacing}{1.5}setlength{Extopsep}{0pt}showskips
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 

exg.
At vero eos et accusam 
et justo duo dolores et 

ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
end{spacing}

output of code fragment

David Carlisle's answer gives a solution, but I'll leave this answer up as it might be helpful for others to understand how to set the spacing parameters in the first place.

Answered by Alan Munn on February 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP