# Ending all pages with period/fullstop

I want to have LaTeX (LyX) make its pages end at a fullstop (.). In other words no broken sentences carried to next page.

I hope to use \raggedbottom so that pages will be shortened by a few lines when the Fullstoppenalty acts on the way Latex does its page break.

Can any one help me with code for \fullstoppenalty a new penalty command macro. Can you tell me how I can build this into my tex system or least wise into the Memoir class. I hope that I would then put the command \fullstoppenalty= -5000 in the preamble. Being a negative penalty would I think make it favour breaking the page at a full stop and the \raggedbottom will facilitate reducing the number of lines on a page.

• Hi, welcome to TeX.SX. Surrounding code with backticks () makes it format like code. I also took the liberty of adding the American name for .. – Matthew Leingang Apr 5 '11 at 12:38
• I've seen this question before: latex-community.org/forum/… – Joseph Wright Apr 5 '11 at 12:38

As I've said elsewhere, TeX does not have a penalty for this particular case. I think it's not such a good idea to try to do this (rather limits TeX's ability to break lines), but you could try

\AtBeginDocument{
\let\savedfullstop.
\catcode\.=\active
\def.{\savedfullstop\penalty-1000\relax}%
}


which will make . active and include a strong encouragement for line breaking after a full stop. The danger is that this may 'blow up' if . is used in cases other than at the end of a sentence (for example in a file name). Use with care!

• It should be noted that this method is not guaranteed to force a line break at a fullstop (it's just encouraging TeX to break there). I doubt there is a safe, foolproof way of doing it without re-implementing TeX's line breaking algorithms. There are also some trivial instances when this method will fail (e.g., try and run it on a standard article on letter paper with \lipsum). I would suggest adding \let\savedpar\par\def\par{\savedpar\penalty-5000\relax}` which seems to fix the problem. – ESultanik Apr 5 '11 at 12:57
• I note your concerns about damaging the systems ability to correctly do line breaks. – Llewellyn Apr 5 '11 at 13:05
• I want this fullstop ending for pages under the memoir class so there would not be "." any place but in end of sentences. – Llewellyn Apr 5 '11 at 13:11
• I hope to use this with Memoir class. My application never puts things like filenames in the text. A fullstop just ends a sentence. – Llewellyn Apr 5 '11 at 13:16
• Sorry this is a mess I keep hitting return and it makes bits and pieces like the above. Please would someone confirm I put the code given in the Preamble for my memoir class document – Llewellyn Apr 5 '11 at 13:21

Tex doesn't really allow you to do this, because it uses a 2-stage process. In the first stage paragraphs are divided into lines. In the second stage the lines are distributed over pages. Unfortunately, what you are asking for would require feedback from the second stage into the first stage.

Joseph Wright's suggestion will strongly encourage every full stop in the document to be at the end of a line, which will really mess up all your formatting, and it will still do nothing special to encourage the page break to fall at a full stop rather than one of the other lines of the paragraph.

Alternatively if you would do some Appendix-D-level trickery to implement a vertical-mode fullstoppenalty for lines ending in full stops, this would still be insufficient, because there is nothing that guarantees that any of the lines on the page will end with full stops, so you would still need to combine this trickery with something like Joseph's suggestion (with all of its caveats).

In order to get what you want, tex would have to do chapter-at-once optimization of line and page breaks, rather than the paragraph-at-once optimization that it gets from the Knuth-Plass algorithm. Chapter-at-once optimization is much more difficult because you have to solve a much harder problem (NP-complete in the presence of floats) that is not amenable to the dynamic-programming trick that lets Knuth-Plass be so efficient.

• I think that LuaTeX might at some stage manage global page break optimisation - there's a lot of interest in the problem. – Joseph Wright Apr 5 '11 at 19:18
• @Lev Bishop: is it possible to reflow the last paragraph of a page in the output routine? Or it might be possible to typeset each paragraph twice: in the normal way, and with a negative penalty at each period. Then build the page with the normal version, and then replace the last paragraph by its sloppy version, finding the page break, and perhaps re-flowing the paragraph on both sides of the page break? – Bruno Le Floch Apr 5 '11 at 23:02
• @Joseph: When people talk about adding global page break optimization to LuaTeX, I believe they are generally only talking about globally optimizing for the page breaks and positions of floats using the already linebroken paragraphs, in contrast to standard TeX's "greedy" approach of simply taking the first decent pagebreak that comes along (I simplify only slightly). Even this type of global pagebreaking is already a very tricky algorithmic problem, but it is nothing compared to the global simultaneous line-and-page-breaking optimization that would be needed to reach Llewellyn's goal. – Lev Bishop Apr 6 '11 at 3:57
• @Bruno: something like that might give a usable result. (At least only the last paragraph of a page would look bad.) Writing that output routine will need a grand wizard though. – Lev Bishop Apr 6 '11 at 4:02
• @Bruno: I would call this "feedforward", from the paragraph builder to the page builder and it is certainly present. "Feedback" would be the page builder telling the paragraph builder to modify the penalty for a discretionary (or in this case a period) on, say either the 5th or 6th line of the paragraph because those are the optimal page-breaking lines. – Lev Bishop Apr 6 '11 at 13:47