groff
[Top][All Lists]
Advanced

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

Re: [Groff] (no subject)


From: Ted Harding
Subject: Re: [Groff] (no subject)
Date: Fri, 23 Nov 2012 23:27:40 -0000 (GMT)

On 23-Nov-2012 22:11:35 Anonymous wrote:
> Subject: Re: Exact column widths in 'tbl'
> References: <address@hidden>
> 
>>Greetings all!
>>This is a follow-up to Chriss Schaller's query yesterday,
>>and the subsequent replies. I have opened e new thread,
>>since it is a topic of general interest.
> 
>>Of course the keyword w(...) in the table format line,
>>e.g.
> 
>>.TS
>>tab(#);
>>l lw(3i) lw(1.25i).
>>[...]
>>.TE
> 
>>specifies a *minimum* column width. So it will not do
>>for setting a maximum column width, especially where there
>>are long text blocks in some cells.
> 
>>The following example shows how to do it in general. The
>>basis is that a ".ll" request in a text block sets a line
>>length and this will be reflected in the resulting column
>>width (unless something else, e.g. a long entry which is
>>not a text block, forces a wider column).
> 
>>Put the following into a file temp.tr :
> 
>>--8<--cut here--8<--------------------------------------------
>>.TS
>>tab(#);
>>| l | l | l |.
>>_
>>08/08/2011#T{
>>.ll 3i
>>This is quite a long paragraph of text specially composed
>>for yesterday's date.
>>The purpose is to see what happens to it in a 3-inch
>>column width.
>>T}#T{
>>.ll 1.25i
>>And this is some silly stuff to fill column 3,
>>1.25 inches wide.
>>T}
>>09/08/2011//12:15#T{
>>.ll 3i
>>And this is another long paragraph specially composed
>>to suit the particular circumstances that apply at this moment
>>of this date.
>>T}#T{
>>.ll 1.25i
>>And this is more silly stuff to fill column 3,
>>still 1.25 inches wide.
>>T}
>>_
>>.TE
>>.sp 0.5m
>>Finally, we follow up with a lot of text outside the table
>>just to show that the per-column settings of \f[CB].ll\fP
>>in the above table have not affected the general ambient
>>line-length outside the table.
>>--8<--cut here--8<--------------------------------------------
> 
>>Then execute
> 
>>groff -t temp.tr > temp.ps
> 
>>and view the resulting PostScript file temp.ps
> 
> Does that actually use the tbl command?  If not, how can this be done
> with tbl, given the following broken example:
> 
> tbl<<EOF | nroff -Tascii | uniq
> .TS
> box tab(|);
> cb|cb|cb|cb.
> col1 | col2 | col3 | long column
> .T&
> l|c|c|lp20.
> short|short|short|this is a very long string of text that should be wrapped
> into several lines so it will not run off the page
> .TE
> EOF

My example does use 'tbl' since the flag "-t" causes groff to pre-process
with 'tbl. From 'man groff':

  -t     Preprocess with tbl.

Similarly with:
  -e     Preprocess with eqn.
  -p     Preprocess with pic.
  -s     Preprocess with soelim.
etc. You can combine them:

  groff -tpe ...

preprocesses with 'tbl', 'pic' and 'eqn' (in that order), i.e. it builds
a pipeline

  input > tbl | pic | eqn | troff ...

As for your "broken" example, it is only so because your long text entry
is not bracketed between T{ ... T}. Try instead:

tbl<<EOF | nroff -Tascii | uniq
.TS
box tab(|);
cb|cb|cb|cb.
col1 | col2 | col3 | long column
.T&
l|c|c|lp20.
short|short|short|T{
this is a very long string of text that should
be wrapped into several lines so it will not run off the page
T}
.TE
EOF

See 'man tbl' and scroll down to:

  A text block can be used to enter data as a single entry which
  would be too  long as a simple string between tabs. It is started 
  with 'T{' and closed with 'T}'. The latter must start a line,
  probably followed by  other data columns (separated with tabs).

Without 'T{ ... T}', the entire text line will be treated as if it
to be a single line in the table. 'tbl' does not take account of the
line-length in use by 'troff' ourside the environment of the table,
so long lines can run off the page.

The result will be set using a "default" line length to break the
text. You can change this using 'w':

  w,W  Minimal  column  width  value.   Must  be  followed  either
       by a troff(1) width expression in parentheses or a unitless
       integer. If  no  unit  is  given,  en  units  are used. 
       Also used as the default line length for included text
       blocks. If used  multiple times, the last entry takes effect.

On the other hand, as in my example, ".ll" as a line with a table
will impose that line length on the following text in the column
in which it appears, so text which follows it will be broken at
that line length. You can get interesting effects in this way!
For example:

tbl<<EOF | nroff -Tascii | uniq
.TS
box tab(|);
cb|cb|cb|cb.
col1 | col2 | col3 | long column
.T&
l|c|c|lp20.
short|short|short|T{
.ll 2i
this is a very long string of text that should
be wrapped into several lines so it will not run off the page
T}
short|short|short|T{
.ll 3i
this is a very long string of text that should
be wrapped into several lines so it will not run off the page
T}
.TE
EOF

so the upper half of col 4 is using shorter lines than the lower
half; and the resulting column width is such as to accomodate the
longer lines of the lower half -- i.e. the column width is set
to accommodate the longest line in the column as set by ".ll".

Hoping this helps,
Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 23-Nov-2012  Time: 23:27:37
This message was sent by XFMail
-------------------------------------------------


reply via email to

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