[comp.text] troff floating display blows away centering of caption

owen@methods.UUCP (Owen Plowman Mr. Tech.) (09/02/87)

Hello everyone.

I am having a somewhat minor but fairly horrible problem using troff
and MM macros.  The problem is concerned with floating displays.  Any
insights you may have would be most welcome (please respond via e-mail).

The problem is this.  I am using floating displays, via .DF, to ensure
that figures in my document are positioned neatly at the top of a page,
and there are not large chunks of blank space at the bottom of many
pages, as the would be if I used a simple .DS command.  Now, in order
to ensure that the caption for the picture or whatever is associated
with the correct figure, the .FG command is placed inside the .DF/.DE
pair.  All is okay so far.  The kicker is that, if I have some "pic"
specifications in my figure, I have to use ".DF CB" in order to get a
result that is centered on the page.  But, this blows the centering of
the caption all over the place.  Usually, the left part of the caption
is aligned with the leftmost item of the picture.

Maybe a diagram would help:

I start off with:

	.DF CB
	.PS
	some
	pic
	stuff
	.PE
	.FG "title"
	.DE

and I want:


			  a
		        pretty
		       centered 
		       picture


		     FIGURE X  title

but I get:
			  a
		        pretty
		       centered 
		       picture


		       FIGURE X  title


See how the caption is moved over?  Usually, my diagrams are such that
the caption is over way to far to the left, but I hope that you get the
idea.

Any clues?


Owen Plowman 		"Have you figured it out yet, Diamond?"
Meta Systems, 3385 Harvester Rd., Burlington, Ontario, L7N 3N2
phone: (416) 632-6500

UUCP:     ...!{utzoo!mnetor!genat!maccs,watmath}!methods!owen

pls@sortac.UUCP (Pat Sullivan) (09/04/87)

In article <425@methods.UUCP> owen@methods.UUCP (Owen Plowman    Mr. Tech.) writes:
>pair.  All is okay so far.  The kicker is that, if I have some "pic"
>specifications in my figure, I have to use ".DF CB" in order to get a
>result that is centered on the page.  But, this blows the centering of
>the caption all over the place.  Usually, the left part of the caption
>is aligned with the leftmost item of the picture.

I had the same problem here ... I even went so far as trying to hack up
the macros, still with unsatisfactory results.  I ended up putting 
everything back like it was and putting the caption inside an invisible
box in the pic.  This worked okay, but seems like a terrible kludge.

If anybody has a better idea, please post - thanks!!

============================================================
Pat Sullivan - {akgua|ihnp4}!sortac!pls - voice 404-257-7382

morrell@hpsal2.HP.COM (Michael Morrell) (09/05/87)

In article <425@methods.UUCP> owen@methods.UUCP (Owen Plowman    Mr. Tech.) writes:
>pair.  All is okay so far.  The kicker is that, if I have some "pic"
>specifications in my figure, I have to use ".DF CB" in order to get a
>result that is centered on the page.  But, this blows the centering of
>the caption all over the place.  Usually, the left part of the caption
>is aligned with the leftmost item of the picture.

As I understand the CB option to .DF (or .DS), it finds the widest line
in the display (which includes the caption in your case), centers that
and then left justifies all the other lines with respect to that widest
line.  I would not use this.  My pic documentation says that the preferred
way to get centered pictures is to redefine .PS and .PE.  I use the
following:

.de PS                 \" centered pic start
.if t .sp .3
.in (\\n(.lu-\\$2u)/2u
.ne \\$1u
..
.de PE                 \" centered pic end
.in
.if t .sp .5
..

Then, one can simply use .DF with no arguments:

.DF
.PS
some
picture
here
.PE
.FG "picture caption"
.DE

The .PS and .PE macros can also be defined so that the pic centering
can be done on a case by case basis (each picture can be centered or
not).   Hope this helps,

   Michael Morrell
   {ucbvax,hplabs}!hpda!morrell