## LaTeX forum ⇒ LyX ⇒ Prevent Page Breaks in linguistic Gloss

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Hiram
Posts: 15
Joined: Thu Nov 29, 2012 2:05 am

### Prevent Page Breaks in linguistic Gloss

Hi folks,

after some trial and error, I came up with some global code to keep all the linguistic glosses in your document from splitting across pages. I'm sure this would work with modification for equations, etc... Thanks to the hint in the TeX UK FAQ.

In LyX just put the following code in your preamble.
\let\oldlinggloss\linggloss\let\endoldlinggloss\endlinggloss\renewenvironment{linggloss}{%   \filbreak   \begin{oldlinggloss}%}{%   \end{oldlinggloss}%}

Voilà! Glossed examples previously broken across pages will now occur fully on a single page.

Hiram

[EDIT]

So the above solution didn't work as well as I hoped. I got some weird page breaks, which, when I re-read the linked page noted above, made sense.

After a bit more experimentation, with samepage and minipage, I discovered that adding a \needspace command provided the necessary number of lines for most of my glossed examples. The 4 represents the number of lines - 3 was actually sufficient generally, but some of my examples were a bit long, so I used 4 just to be on the safe side. And it will still require a bit of individual editing.

This fix requires the needspace package

So the better code for your preamble:

\usepackage{needspace} \let\oldlinggloss\linggloss\let\endoldlinggloss\endlinggloss\renewenvironment{linggloss}{%  \needspace{4\baselineskip}   \begin{oldlinggloss}%}{%   \end{oldlinggloss}%}

Tags: