groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] TeX's 'line breaking algorithm'


From: Thomas Baruchel
Subject: Re: [Groff] TeX's 'line breaking algorithm'
Date: Sat, 10 Mar 2001 18:08:03 +0100
User-agent: Mutt/1.2.5i

Hi Ted,

On Sat, Mar 10, 2001 at 12:23:40PM -0000, Ted Harding wrote:
> However, there is no direct mechanism in [g]troff for saving
> _un_formatted input for re-cycling: the contents of a diversion
> are lines which have already been formatted, and a diversion
> is really a form of delayed output of formatted text.
> 
> The only way I can think of would involve writing out the input
> for a paragraph (or page or other unit) to a temporary file
> (using the .open/.opena .write .close and .so requests), so
> that the temporary file could be repeatedly re-read as input,
> under varying troff environments (including track-kerning, changing
> minimum inter-word space, ... ), until the formatted results were
> satisfactory.

I think there is one way of doing it without using an external file: put the
content of the paragraph in a macro. For instance, each time the user would
type:

   .PP
   This is my paragraph.

The .PP macro would enclose the whole paragraph (until either the next
paragraph, the next section title, the end of the file, etc.) between two
other macros: .P1 and .P2
These two macros would make of the unformatted input a macro, called .P0 by
using the .de request. After having closed the definition, .P2 would then
try in several diversions, several ways of formatting the paragraph. How could
the several versions be compared ? With this general idea. The job should first
be done with left justification only (.ad l), in order to have a significant
value in the .n register for each line.

The most difficult part of the job is the following one. How can I force a line
to break before the longest length it can take ? Inserting a \p escape
sequence in several points of .P0 would be too difficult. Maybe I can play
with the length of the line, with spaces ?

Do you think it is possible ?
If it is, I would like to make a macro package with a TeX like environment:
  - a .PP macro with an algorithm to have the prettiest paragraph
  - vertical justification
  - etc.

> Nevertheless, writing a macro on these lines which could even begin
> to approach the sophistication of TeX's approach would be a
> horrendous task!

If it wasn't the case, I wouldn't have come from TeX to groff ;-)

-- 
        ,--._
      .'o    `-.__
      |     (~'   ~~--.__
      ),-.'  `. '' ,,    ~`-.
     //   \    ( ,,  ,, ''   `)    Thomas Baruchel
    //     `.   `. ,,  ,,'' .'
   //        ~.   `._,,   ,'  <address@hidden>
   '   _tb_    `-.___.,-~'
                   \  \                 Brest
                  _/ _/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]