# line of text preceding equation breaking over page using Lyx

I'm in the process of implementing copy-edit comments on a book that has lots of math and lots of single lines before equations in a displayed equation environment. LaTeX likes to break pages between these lines and the equation and I'd prefer if it broke at better locations, like just before the line of text. Is there any way to encourage LaTeX to do this as a general practice.

I do know that I can encapsulate my line of text with the equation in a minipage, but I really want to set a variable or flag somewhere to encourage this behavior.

Edit: After looking at the comments, I see the problem and it is Lyx related, not LaTeX. In Lyx, you cannot easily see whether a line preceding an equation is in the same paragraph as the equation following. I solved my problem by turning on view of paragraph end marks, and by systematically pressing delete at the end of lines preceding equations, and the end of equations that are in the same sentence.

• Page breaks before equations ordinarily happen only at paragraph breaks. Check your file. Is there a blank line before an equation? Get rid of it! (Or, if you prefer the visual space, put a `%` at the beginning of the line so that it's ignored.) If you're copy-pasting from something printed, blank lines may have been inserted during that process; not all copy-paste apps follow tex's rules. – barbara beeton Aug 20 '19 at 2:39
• @barbarabeeton - My problem is that I have a sentence followed by a numbered equation in a displayed equation environment. LaTeX seems to always treat these as a new paragraph, even though what is meant is that the equation is actually part of a sentence. I guess what I'm looking for is a cross between an inline equation (which is in the sentence) and a displayed (numbered) equation - an inline numbered equation that sits on it's own line, but does not start a new paragraph. Do you understand what I mean? – Pete P Aug 20 '19 at 13:23
• Inline equations aren't automatically numbered, at least not by any LaTeX package I'm aware of. Only display equations get that treatment, and logically such equations are assumed traditionally to be part of the paragraph text that precedes them. And there should (almost) never be a page break separating them -- that is built into the system. So a page break has to be explicitly triggered. That is usually done by a blank line, although the command `\par` has the same effect. I don't know of any automatic method to overcome this, though it may be possible to script it using regular expressions. – barbara beeton Aug 20 '19 at 13:45
• @barbarabeeton Thanks for your statement that mostly helped me solve this problem. I am using LyX as my editor and I noticed that usually I press enter and enter the equation in the displayed equation environment. When I use the LyX LaTeX code preview on the line preceding the equation, I see only that line - the same goes for the equation. But if I go to the left of the equation and press backspace, the two are now joined together with no blank line between them. The only problem I have is that I can't easily see these in LyX. I had erroneously thought that LaTeX had this rule. – Pete P Aug 20 '19 at 14:28
• Hmmm. This seems like a bug in LyX (or at least insufficient documentation on how to properly enter displays). You might report it to LyX and ask for help there. – barbara beeton Aug 20 '19 at 14:48