trying to get LaTeX to format grammar

Actually as it turns out, LaTeX does an absolutely horrible job of laying out
text. The design document is horribly disgusting, with headings stuck to their
preceding paragraph, orphans and widow paragraphs, you name it. I have
absolutely no idea how this bullshit comes about, as LaTeX is supposed to be
very good at these things. But even a remotely challening layout, such as a few
lstlistings on a page, completely break the layout. You can actually see the
headings moving closer to the previous paragraph as a page progresses, as if the
layout engine had no clue at all what to do. Damn.