Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #16351

Re: Paragraph Wrapping

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.programming
Subject Re: Paragraph Wrapping
Date 2023-01-27 01:22 +0000
Organization A noiseless patient Spider
Message-ID <87o7qkwz3o.fsf@bsb.me.uk> (permalink)
References <wrap-20230126195034@ram.dialup.fu-berlin.de>

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:

>   To wrap a paragraph, I wrote a Python script that searched for
>   the best wrap, given a quality function that included penalties
>   for interpunction near the end of a line (but not at the end)
>   or adjacent lines that differed greatly in length.
>
>   It worked, but as the number of lines approached ten, it became
>   painfully slow.
>
>   By an incredible twist of fate, I came across a chapter of
>   a book that explained dynamic programming and how to use it
>   to reduce the complexity of global paragraph wrapping from
>   exponential to quadratic!

The TeX Book describes two-level algorithm to calculate optimal line
breaks in paragraphs and the optimal page breaks.

-- 
Ben.

Back to comp.programming | Previous | Next | Find similar


Thread

Re: Paragraph Wrapping Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-01-27 01:22 +0000

csiph-web