groff
[Top][All Lists]
Advanced

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

Re: [Groff] Reformatting material


From: Tadziu Hoffmann
Subject: Re: [Groff] Reformatting material
Date: Fri, 12 Dec 2008 14:15:17 +0100
User-agent: Mutt/1.5.17 (2007-11-01)

> Relating to a recent thread, I've long searched for a way to
> reformat the same material three times, on each pass using
> information gleaned from earlier passes. Only the final pass
> would produce output. Examples of this could be balancing
> multi-column output, or avoiding ragged bottoms.
>
> Diverting will not do as some undoable formatting is
> performed on them, for example vertical spacing is set
> in concrete. A further idea was to write the material to a
> termporary file, but I could not see a way to do this.
>
> Any tried this or have ideas?


If you just want to adjust the spacing between paragraphs
(with line lengths fixed), then you can divert the text
and transparently embed calls to a suitable spacing macro
between paragraphs, which is then adjusted to give the
correct spacing when the diversion is finally output.
(This is what I do to adjust the bottom margin in my own
macro package.)

I believe this is also sufficient for multicolumn adjustment:
divert everything into one very long column until you have
enough text for one page or until the end of the text is
reached, then redivert and cut into sections of suitable height,
and finally output with individually adjusted paragraph spacing
for each column.

If you want to reflow the text several times to determine
some kind of optimum configuration (e.g., trying different
line lengths), then I guess the most general way is to save
the stuff in a macro instead of a diversion, like so:

.\"
.\" ----------------------------------------------------------------
.\" begin block of text for multiple processing
.de BB
.tm starting to read text...
.de XX EB
..
.\" ----------------------------------------------------------------
.\" end block
.de EB
.tm finished reading text.
..
.\" ----------------------------------------------------------------
.\" delayed space macro, counts occurrences as well
.de SP
.nr NN +1
.sp \\n(QQu
..
.\" ----------------------------------------------------------------
.\" now gather text
.BB
This text can be
.SP
processed
.SP
multiple
.SP
times.
.EB
.\" ----------------------------------------------------------------
.\" process text once to determine height
.nr QQ 0
.nr NN 0
.di YY
.XX
.br
.di
.tm the text has a height of \n(dn units
.\" ----------------------------------------------------------------
.\" now make text fit into exactly 2 cm
.nr QQ 2c-\n(dnu/\n(NNu \" note left-to-right, no precedence rules
.\" reprocessing to verify is not really necessary, just for demo
.di YY
.XX
.br
.di
.nr OO 2c
.tm the text now has a height of \n(dn units, 2 cm is \n(OO units
.\" ----------------------------------------------------------------
.\" output text
.sp 3c
Text before.
.br
\M[yellow]\h'-.1c'\v'-.75v'\D'P 0 2c \n(dlu+.2c 0 0 -2c'
This yellow box has a height of 2 cm.
.sp -1
.XX
.br
Text after.







reply via email to

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