groff
[Top][All Lists]
Advanced

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

Re: [Groff] oddity in pic : absolute positioning requires "move" first.


From: Ted Harding
Subject: Re: [Groff] oddity in pic : absolute positioning requires "move" first.
Date: Tue, 07 Aug 2012 10:28:47 +0100 (BST)

On 07-Aug-2012 08:27:11 emmanuel chemla wrote:
> Hello to all,
> 
> I have a small quizz asking to define a task priority. The user can answer
> using one of the four options.
> I want those options to have a small ident of 0.8 i.
> 
> So here's the code [I have inserted "\" line continuations. Ted]:

\f[BMB]\s11Task priority : \s0\fP
.sp 0.05i
.char \[radiobutton] \f(ZD\N'109'
.PS
"\f[BMR]\s11 \[radiobutton] important and urgent \s0\fP" \
  at (0.8i, 0.25i) ljust ;
"\f[BMR]\s11 \[radiobutton] important and not urgent\s0\fP" \
  at (3.5i,0.25i) ljust ;
"\f[BMR]\s11 \[radiobutton] not important and urgent\s0\fP" \
  at (0.8i, 0i) ljust  ;
"\f[BMR]\s11 \[radiobutton] not important and not urgent\s0\fP" \
  at(3.5i,0i) ljust ;
.PE

> But strangely, it won't  work !

It's not quite clear exactly what layout you seek, but here are some
comments and suggestions.

First, pic determines the extent of the diagram from the locations of
the leftmost and rightmost plotted or mentioned points in the code.
In your case these are (0.8i,0.25i) and (3.5i,0.25i); text is not taken
into account in this determination. Therefore the "internal" width
of the diagram is (3.5i - 0.8i) = 2.7i.

When pic emits code for troff, this will be such as to re-scale the
diagram so that its width (from leftmost point to rightmost point.
not counting text) is equal either to the line length (when no
width option is given in ".PS") or to the width option: for example,

  .PS 4i

would set the width to 4i, so that (0.8i,0.25i) would be at the left
of the diagram, and (3.5i,0.25i) would be 4i to thwe right of that;
and the diagram would be centred on the page.

A better way to ensure that things will appear on the page where
you want them is to put an "invisible line" command into the pic code.
So, in your case, something like the code (assuming that the troff
line length at the time is 6i):

\f[BMB]\s11Task priority : \s0\fP
.sp 0.05i
.char \[radiobutton] \f(ZD\N'109'
.PS
line invis from (0,0) to (6i,0) ### Invisible line
"\f[BMR]\s11 \[radiobutton] important and urgent \s0\fP" \
  at (0.8i, 0.25i) ljust ;
"\f[BMR]\s11 \[radiobutton] important and not urgent\s0\fP" \
  at (3.5i,0.25i) ljust ;
"\f[BMR]\s11 \[radiobutton] not important and urgent\s0\fP" \
  at (0.8i, 0i) ljust  ;
"\f[BMR]\s11 \[radiobutton] not important and not urgent\s0\fP" \
  at(3.5i,0i) ljust ;
.PE

will determine the leftmost and rightmost extents of the diagram
to be at 0i and at 6i, and the positioning of everything else will
be computed relative to these points (vertical scaling equal to
horizontal scaling, so you may wish to change the vertical
coordinates for your text placements).

Your "dummy move" below has a similar effect, by setting the leftmost
point of the diagram at (0.0001i,0). However, the rightmost will still
be at (3.5i,0).

Hoping this helps,
Ted.

> In order to fix it (that is, getting the options indented) I have to insert
> a dummy 'move' first, like this :
> 
> \f[BMB]\s11Task priority : \s0\fP
> .sp 0.05i
> .char \[radiobutton] \f(ZD\N'109'
> .PS
> .\" dummy move :
> move 0.0001i;
> "\f[BMR]\s11 \[radiobutton] important and urgent \s0\fP" at (0.8i, 0.25i)
> ljust ;
> "\f[BMR]\s11 \[radiobutton] important and not urgent\s0\fP" at (3.5i,
> 0.25i) ljust ;
> "\f[BMR]\s11 \[radiobutton] not important and urgent\s0\fP" at (0.8i, 0i)
> ljust  ;
> "\f[BMR]\s11 \[radiobutton] not important and not urgent\s0\fP" at(3.5i,
> 0i) ljust ;
> .PE
> 
> With this fix, it does work as intended.
> I use cygwin with groff version 1.21.
> I'd like to know if it's a normal behaviour, and if indeed, can someone
> explain the logic ?
> 
> Thanks.
> 
> --
> Emmanuel

-------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 07-Aug-2012  Time: 10:28:43
This message was sent by XFMail
-------------------------------------------------


reply via email to

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