LaTeX forum ⇒ Page Layout ⇒ a way to move selected words to the new row Topic is solved

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

a way to move selected words to the new row

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)?

Ijon Tichy
Posts: 139
Joined: Mon Dec 24, 2018 10:12 am
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).