[comp.text] nroff/mm problem

don@seila.UUCP (Don Kossman) (08/22/88)

this is driving us crazy:

how do you force nroff (using the mm macro package)
to leave n spaces at the top of a page?  .sp and .SP seem
to have no effect.  we've RTFM (several of them) and have
had no luck.  we are using page headers and footers and i
think that's what's causing the problem, but don't know
how to solve it (beyond inserting an empty table with the
right number of lines...)

environment is ultrix 2.0; i've tried another mm macro
package (sco xenix 2.2) and had the same problem;
i'm pretty sure both packages are pre-DWB 2.0.  

what are we doing wrong?

-- 
Don Kossman, SEI Information Technology, Los Angeles
usenet:  ...sun!tsunami!seila!don, ...uunet!mahendo!jplgodo!seila!don

brianc@daedalus (Brian Colfer) (08/23/88)

In article <372@seila.UUCP> don@seila.UUCP (Don Kossman) writes:
>this is driving us crazy:
>
>how do you force nroff (using the mm macro package)
>to leave n spaces at the top of a page?  .sp and .SP seem
>to have no effect.  we've RTFM (several of them) and have
>had no luck.  we are using page headers and footers and i
>think that's what's causing the problem, but don't know
>how to solve it (beyond inserting an empty table with the
>right number of lines...)

Have you tried redefining .TP?
I have used this method many times... I am less certain about the
.VM macro but it probably would work also.

.TP has been in mm for a very long time? I don't know about .VM.
I'm using DWB2.0 and these techniques are in sections 3.4.[7,9]
"Top and Bottom (Vertical) Margins" and "Generalized Top-of-Page
Processing".  

>
>environment is ultrix 2.0; i've tried another mm macro
>package (sco xenix 2.2) and had the same problem;
>i'm pretty sure both packages are pre-DWB 2.0.  
>
.TP will work...

===============================================================================
Brian    : UC San Francisco       :...!{ucbvax,uunet}!daedalus.ucsf.edu!brianc 
Colfer   : Dept. of Lab. Medicine : brianc@daedalus.ucsf.edu 
         :  PH. 415-476-2325      : BRIANC@UCSFCCA.BITNET
===============================================================================

kjk@pbhyf.PacBell.COM (Ken Keirnan) (08/23/88)

In article <372@seila.UUCP> don@seila.UUCP (Don Kossman) writes:
>this is driving us crazy:
>
>how do you force nroff (using the mm macro package)
>to leave n spaces at the top of a page?  .sp and .SP seem
>to have no effect.  we've RTFM (several of them) and have
>had no luck.  we are using page headers and footers and i
>think that's what's causing the problem, but don't know
>how to solve it (beyond inserting an empty table with the
>right number of lines...)
>
>environment is ultrix 2.0; i've tried another mm macro
>package (sco xenix 2.2) and had the same problem;
>i'm pretty sure both packages are pre-DWB 2.0.  
>
>what are we doing wrong?
>


Don, I'm not sure about about pre-DWB2.0 mm macro packages, but in
2.0 you want the ".VM" macro (vertical margin).

The usage is:		.VM [top] [bottom]

where "top" and "bottom" are given in vertical line spaces.  A value
of zero (0) for either adds no additional space.  By the way, I
discovered a bug in the VM macro (at least the version I have) that
caused the spacing to be in device units instead of line spaces.
the last line of the macro was

			.(E 5 0\\$2 \}

but should be

			.(E 5 0\\$2v \}

I hope this is useful to you.

Ken Keirnan
-- 

Ken Keirnan - Pacific Bell - {att,bellcore,sun,ames,pyramid}!pacbell!pbhyf!kjk
  San Ramon, California	                    kjk@pbhyf.PacBell.COM

hxe@rayssd.ray.com (Heather Emanuel) (08/24/88)

In article <372@seila.UUCP> don@seila.UUCP (Don Kossman) writes:
> this is driving us crazy:
> 
> how do you force nroff (using the mm macro package)
> to leave n spaces at the top of a page?  .sp and .SP seem
> to have no effect.

MM counts on two things: 1) You don't know, when you are inputting the
document, where the page breaks will fall; and 2) you want nice and
even top margins.  So MM assumes that when you have any spaces, even
those specifically called for with a ".sp", that you don't want them
to fall at the top of a page or else you won't have en even top
margin.  To accomplish this, it turns "no space" mode on for page
breaks.

There are two easy ways around this.  The first is to enter a bogus
top line of the page after your ".SK" or ".bp" (or whatever you use
to break the page).  Do this by typing a backslash-space; e.g.:

	.SK
	\<sp>
	.sp 20
	text

Remember that the first line takes up space so you have to adjust
for it in your ".sp" call.

The other way is to use the ".rs" ("restore spacing") command at the
top of the page, before your ".sp" call; e.g.:

	.SK
	.rs
	.sp 10
	text

I'm not familiar with Ultrix, but these are standard nroff
conventions.  Hope it helps.

-- 
           Heather Emanuel           hxe@rayssd.ray.com
{att,decuac,gatech,ihnp4,mimsy,necntc,raybed2,sun,uiucdcs,ukma}!rayssd!hxe
--------------------------------------------------------------------
   I don't think my company *has* an opinion, so the ones in this
                  article are obviously my own.
--------------------------------------------------------------------
"There's madness in the family.  I'm just nervous, that's all."
		-Cormac McCarthy

ekrell@hector.UUCP (Eduardo Krell) (08/24/88)

In article <372@seila.UUCP> don@seila.UUCP writes:
>this is driving us crazy:
>
>how do you force nroff (using the mm macro package)
>to leave n spaces at the top of a page?  .sp and .SP seem
>to have no effect.

.sp at the top of a page doesn't do anything. You have to force
it to output some text. I do

\ 
.sp <whatever>

There's a space after the backslash. That forces a space to be printed
and the .sp will now be honored.

I've converted to LaTeX years ago, but I still remember some of these
terrible troff kludges.
    
Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ

UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell@ulysses.att.com

morrell@hpsal2.HP.COM (Michael Morrell) (08/24/88)

/ hpsal2:comp.text / don@seila.UUCP (Don Kossman) / 11:22 pm  Aug 21, 1988 /
this is driving us crazy:

how do you force nroff (using the mm macro package)
to leave n spaces at the top of a page?  .sp and .SP seem
to have no effect.  we've RTFM (several of them) and have
had no luck.  we are using page headers and footers and i
think that's what's causing the problem, but don't know
how to solve it (beyond inserting an empty table with the
right number of lines...)

what are we doing wrong?

-- 
Don Kossman, SEI Information Technology, Los Angeles
usenet:  ...sun!tsunami!seila!don, ...uunet!mahendo!jplgodo!seila!don
----------

The Page Header macros in mm use the ".ns" request, which inhibits spacing
until some text is output.  If you precede the .sp or .SP with a ".rs"
request, this will restore spacing and all should be well.

   Michael

kg@elan.UUCP (Ken Greer) (08/24/88)

From article <372@seila.UUCP>, by don@seila.UUCP (Don Kossman):
> 
> how do you force nroff (using the mm macro package)
> to leave n spaces at the top of a page? 

This always works, regardless of the macro package...
	
|		.br
|		.rs
|		.sp <whatever>
-- 
Ken Greer
Elan Computer Group, Inc.
{ames,hplabs}!elan!kg
415-322-2450

dns@sq.uucp (David Slocombe) (08/25/88)

In article <372@seila.UUCP> don@seila.UUCP (Don Kossman) writes:
 
> how do you force nroff (using the mm macro package)
> to leave n spaces at the top of a page?  .sp and .SP seem
> to have no effect. 

The fact that .sp and .SP have no effect (normally) at the top of
a new page is an important feature of all macro packages that I know of.
TeX *must* have something similar. The reason is that the extra spaces
you usually want between blocks of text *within* a page are
undesirable when they happen to occur at the top of a new page.
Troff (or nroff) has a special pair of builtin requests for assisting
in this: .ns ("nospace": i.e.  ignore any space request until there
has been a line of actual text), and .rs ("restore space": cancel
the "nospace" mode).

The top of page traps of the macro packages do a ".ns" just before
exiting, so a ".sp" request that occurs immediately following will be
ignored.  The -mm ".SP" macro should normally be used because it does
a number of extra useful things, but it calls ".sp" so the above applies to
it too.

Now, having defended the *normal* behaviour of -mm with troff (or
nroff), I'd better show how to get the specific effect you want:

With -mm I think the most intuitively natural is:

	.DS
	.SP 2i \" or whatever: i.e. we have a contiguous block of whitespace.
	.DE

But there are several other quite sensible ways to do it.  The
following troff (or nroff) input illustrates both the normal
behaviour and various ways of achieving the effect you want:

	.P
	This is on Page 1 (at top).
	.sp \n(.tu-0.5v  \" (This ensures that next line is last on page.)
	And this is the last line on Page 1.
	.\" The page traps set you up at the top of a new page here.
	.sp 2i \" (ignored, because "nospace" (.ns) is in effect.)
	This is on Page 2 (at top, correctly, though you wish it weren't).
	.sp \n(.tu-0.5v
	And this is the last line on Page 2.
	.SP 2i \" (same effect as .sp, above)
	This is on Page 3 (at top, correctly, though you wish it weren't).
	.sp \n(.tu-0.5v
	And this is the last line on Page 3.
	.\"
	.\" OK, now we force blank space at the top of a page:
	.\"
	.br \" needed to force above line to end and spring page-trap 
	.rs \" This is first line processed after top-of-page trap
	.sp 2i \" and lo! this works now!
	This is on Page 4 (2 inches down, as it should be).
	.sp \n(.tu-0.5v
	And this is the last line on Page 4.
	.br
	.rs
	.SP 2i (same effect as .sp above)
	This is on Page 5 (2 inches down, as it should be).
	.sp \n(.tu-0.5v
	And this is the last line on Page 5.
	.\" ---------------------------------------------------------------
	.\" The following two examples are conceptually better for -mm users:
	.\" ---------------------------------------------------------------
	.DS
	.sp 2i
	.DE
	This is on Page 6 (2 inches down, as it should be).
	.sp \n(.tu-0.5v
	And this is the last line on Page 6.
	.DS
	.SP 2i
	.DE
	This is on Page 7 (2 inches down, as it should be).
	.P
	And that's all folks!

Finally, my colleague Murray Maloney has pointed out that if you
want to put some extra white space at the top of *every* page (below
the page header), you can define the special "user-exit" macro "PX"
at the start of the document, thus:

	.de PX
	.rs
	'sp 5 \" or whatever: note the "'" no-break control character
	..

This macro is automatically called by the top-of-page trap just before
it exits. (Actually the top-of-page macro does a ".ns" to establish
nospace mode *again* after calling .PX just in case you've done
something like the above, to ensure that "accidental" space is
ignored at the top of page.)

----------------------------------------------------------------
David Slocombe				(416) 963-8337
Vice-President, Research & Development
SoftQuad Inc.				uucp: {uunet!attcan!utzoo, utai}!sq!dns
720 Spadina Ave.			Internet: dns@sq.com
Toronto, Ontario, Canada M5S 2T9

syd@dsinc.UUCP (Syd Weinstein) (08/25/88)

At top of page, nroff/troff set a ignore space flag to prevent
accidental spaces when a page break is encountered.  As per the
nroff/troff reference manual, the .rs command (restore spacing)
turns off this flag and allows spacing at the top of a page.

Thus
.rs
.SP space

works correctly.
-- 
=====================================================================
Sydney S. Weinstein, CDP, CCP
Datacomp Systems, Inc.				Voice: (215) 947-9900
{allegra,bellcore,bpa,vu-vlsi}!dsinc!syd	FAX:   (215) 938-0235

crocker@ihlpf.ATT.COM (Crocker) (08/25/88)

In article <372@seila.UUCP>, don@seila.UUCP (Don Kossman) writes:
> this is driving us crazy:
> 
> how do you force nroff (using the mm macro package)
> to leave n spaces at the top of a page?  .sp and .SP seem
> to have no effect.  
> what are we doing wrong?
> 
> -- 
> Don Kossman, SEI Information Technology, Los Angeles
> usenet:  ...sun!tsunami!seila!don, ...uunet!mahendo!jplgodo!seila!don

When you begin a new page by executing a .bp (this is inherent in
.SK or hitting the bottom of a page), you are put into "no-space"
mode.  In no-space mode, .sp and .bp requests are ingored (see
"Nroff/Troff User's Manual, October 11, 1976, section 5).  What
this means to you is that your .sp requests are being ignored
because you are in no-space mode.  There are a multitude of
mechanisms for getting out of no space mode, such as printing a
character (a blank works nicely for this because you can't really
tell it is there), or using the .rs (Restore spacing, same section)
request to turn off no-space mode.

For example, you could have the following in your document:

 ...
text
 ...
.SK	\" move to new page
.rs	\" darn it, i really want to put some space here
.SP 10	\" and 10 lines is the space I want
 ...
more text.
 ...

Or, you could just do the following

.am SK
.rs
..

This makes the .SK macro turn no-space mode off for you so you
don't have to remember every time you start a new page to turn off
no-space mode.

Hope this helps!

Ron Crocker
IHP 1A-213
x5262
-- 
Ron Crocker
IHP 1A-213
x5262

don@seila.UUCP (Don Kossman) (08/27/88)

thanks one and all for the many mailed and posted answers to the
"space at the top of the page with mm" question.

the .VM suggestion didn't work, in that it inserts vertical space
ABOVE the page header.  also, .rs alone somehow doesn't seem to work
with our macro package.  simplest answer was to insert a line containing
a space or tab [\tab] preceding the .sp request.

don
-- 
Don Kossman, SEI Information Technology, Los Angeles
usenet:  ...sun!tsunami!seila!don, ...uunet!mahendo!jplgodo!seila!don