Page Layouta way to move selected words to the new row

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ciema7
Posts: 22
Joined: Sat Nov 10, 2018 2:31 am

a way to move selected words to the new row

Post by ciema7 »

Hello, the question is included in the topic :) Is it possible to use command for whole document, which will allow to move some words (for example i dont want to leave on the end of the row words as "and", "with", etc.) to the next line (row below)?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

a way to move selected words to the new row

Post by Ijon Tichy »

With pdflatex or xelatex: No.
With lualatex it could be possible to detect such words and replace the space after it by a non-breakable space. But I do not know much about the callbacks for nodes etc. so I cannot write the lua code for this.

Alternatively you could pre-process the document code using awk, sed or perl to replace the space after such words by a ~ or to immediately add \nobreakspace after such words.

However: Doing so would make it much harder to break the paragraphs into lines. So TeX would more often report underfull oer overfull \hboxes. So I would not recommend to do this unless you are using something like \RaggedLeft (from ragged2e).
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply