TransWikia.com

Adaptive justification for the last line of a paragraph

TeX - LaTeX Asked by Daniel S. on August 16, 2020

is it possible to condition the justification parameters of the last line of a paragraph according to the length of the paragraph? If yes, how?

Actually, there are three problems in one. Let me explain. Consider the following paragraphs:

enter image description here

1) The last line of the text is sometimes shorter than a certain fixed value, for example the value of parindent. It would be preferable to either reduce the paragraph by one line or lengthen the last line.

2) Similarly, sometimes there is very little space left between the end of the last line and the margin. Here, it would be preferable to either reduce the length of the last line or extend the last line to the margin.

These two situations are framed in red on the diagram.

3) I consider both of these cases to be very unsightly. However, in the case of short paragraphs, changing the last line may change the entire paragraph and lead to an even more unsightly rendering. Also, I would like to know if we can give a minimum number of lines in the paragraph (for example 5 lines) to make the changes to cases 1 and 2.

Is it possible to create a code that can satisfy the three points above? (using the power of LuaLaTeX for example).

Currently, I use the command (setlengthparfillskip {0pt @plus 0.9textwidth}) but it is not satisfactory. I thought about using prevgraf to solve problem 3), but I don’t know how to do that.

Thanks for your help.

One Answer

In 2007 I wrote an article in TUGboat describing ways of producing a variety of paragraph shapes https://tug.org/TUGboat/tb28-2/tb89glister.pdf. I think that one of these may suit you.

Answered by Peter Wilson on August 16, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP