OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / GNU_groff / original / man1 / pic.1
1 .ig
2 Copyright (C) 1989-2000, 2001 Free Software Foundation, Inc.
3
4 Permission is granted to make and distribute verbatim copies of
5 this manual provided the copyright notice and this permission notice
6 are preserved on all copies.
7
8 Permission is granted to copy and distribute modified versions of this
9 manual under the conditions for verbatim copying, provided that the
10 entire resulting derived work is distributed under the terms of a
11 permission notice identical to this one.
12
13 Permission is granted to copy and distribute translations of this
14 manual into another language, under the above conditions for modified
15 versions, except that this permission notice may be included in
16 translations approved by the Free Software Foundation instead of in
17 the original English.
18 ..
19 .\" Like TP, but if specified indent is more than half
20 .\" the current line-length - indent, use the default indent.
21 .de Tp
22 .ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
23 .el .TP "\\$1"
24 ..
25 .ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
26 .el .ds tx TeX
27 .ie \n(.g .ds ic \/
28 .el .ds ic \^
29 .\" The BSD man macros can't handle " in arguments to font change macros,
30 .\" so use \(ts instead of ".
31 .tr \(ts"
32 .TH PIC 1 "27 June 2001" "Groff Version 1.17.2"
33 .SH NAME
34 pic \- compile pictures for troff or TeX
35 .SH SYNOPSIS
36 .B pic
37 [
38 .B \-nvCSU
39 ]
40 [
41 .I filename
42 \&.\|.\|.
43 ]
44 .br
45 .B pic
46 .B \-t
47 [
48 .B \-cvzCSU
49 ]
50 [
51 .I filename
52 \&.\|.\|.
53 ]
54 .SH DESCRIPTION
55 This manual page describes the GNU version of
56 .BR pic ,
57 which is part of the groff document formatting system.
58 .B pic
59 compiles descriptions of pictures embedded within
60 .B troff
61 or \*(tx input files into commands that are understood by \*(tx or
62 .BR troff .
63 Each picture starts with a line beginning with
64 .B .PS
65 and ends with a line beginning with
66 .BR .PE .
67 Anything outside of
68 .B .PS
69 and
70 .B .PE
71 is passed through without change.
72 .LP
73 It is the user's responsibility to provide appropriate definitions of the
74 .B PS
75 and
76 .B PE
77 macros.
78 When the macro package being used does not supply such definitions
79 (for example, old versions of \-ms),
80 appropriate definitions can be obtained with
81 .BR \-mpic :
82 these will center each picture.
83 .SH OPTIONS
84 Options that do not take arguments may be grouped behind a single
85 .BR \- .
86 The special option
87 .B \-\^\-
88 can be used to mark the end of the options.
89 A filename of
90 .B \-
91 refers to the standard input.
92 .TP
93 .B \-C
94 Recognize
95 .B .PS
96 and
97 .B .PE
98 even when followed by a character other than space or newline.
99 .TP
100 .B \-S
101 Safer mode; do not execute
102 .B sh
103 commands.
104 This can be useful when operating on untrustworthy input.
105 (enabled by default)
106 .TP
107 .B \-U
108 Unsafe mode; revert the default option
109 .BR \-S .
110 .TP
111 .B \-n
112 Don't use the groff extensions to the troff drawing commands.
113 You should use this if you are using a postprocessor that doesn't support
114 these extensions.
115 The extensions are described in
116 .BR groff_out (5).
117 The
118 .B \-n
119 option also causes
120 .B pic
121 not to use zero-length lines to draw dots in troff mode.
122 .TP
123 .B \-t
124 \*(tx mode.
125 .TP
126 .B \-c
127 Be more compatible with
128 .BR tpic .
129 Implies
130 .BR \-t .
131 Lines beginning with
132 .B \e
133 are not passed through transparently.
134 Lines beginning with
135 .B .
136 are passed through with the initial
137 .B .
138 changed to
139 .BR \e .
140 A line beginning with
141 .B .ps
142 is given special treatment:
143 it takes an optional integer argument specifying
144 the line thickness (pen size) in milliinches;
145 a missing argument restores the previous line thickness;
146 the default line thickness is 8 milliinches.
147 The line thickness thus specified takes effect only
148 when a non-negative line thickness has not been
149 specified by use of the
150 .B thickness
151 attribute or by setting the
152 .B linethick
153 variable.
154 .TP
155 .B \-v
156 Print the version number.
157 .TP
158 .B \-z
159 In \*(tx mode draw dots using zero-length lines.
160 .LP
161 The following options supported by other versions of
162 .B pic
163 are ignored:
164 .TP
165 .B \-D
166 Draw all lines using the \eD escape sequence.
167 .B pic
168 always does this.
169 .TP
170 .BI \-T \ dev
171 Generate output for the
172 .B troff
173 device
174 .IR dev .
175 This is unnecessary because the
176 .B troff
177 output generated by
178 .B pic
179 is device-independent.
180 .SH USAGE
181 This section describes only the differences between GNU
182 .B pic
183 and the original version of
184 .BR pic .
185 Many of these differences also apply to newer versions of Unix
186 .BR pic .
187 .SS \*(tx mode
188 .LP
189 \*(tx mode is enabled by the
190 .B \-t
191 option.
192 In \*(tx mode,
193 .B pic
194 will define a vbox called
195 .B \egraph
196 for each picture.
197 You must yourself print that vbox using, for example, the command
198 .RS
199 .LP
200 .B
201 \ecenterline{\ebox\egraph}
202 .RE
203 .LP
204 Actually, since the vbox has a height of zero this will produce
205 slightly more vertical space above the picture than below it;
206 .RS
207 .LP
208 .B
209 \ecenterline{\eraise 1em\ebox\egraph}
210 .RE
211 .LP
212 would avoid this.
213 .LP
214 You must use a \*(tx driver that supports the
215 .B tpic
216 specials, version 2.
217 .LP
218 Lines beginning with
219 .B \e
220 are passed through transparently; a
221 .B %
222 is added to the end of the line to avoid unwanted spaces.
223 You can safely use this feature to change fonts or to
224 change the value of
225 .BR \ebaselineskip .
226 Anything else may well produce undesirable results; use at your own risk.
227 Lines beginning with a period are not given any special treatment.
228 .SS Commands
229 .TP
230 \fBfor\fR \fIvariable\fR \fB=\fR \fIexpr1\fR \fBto\fR \fIexpr2\fR \
231 [\fBby\fR [\fB*\fR]\fIexpr3\fR] \fBdo\fR \fIX\fR \fIbody\fR \fIX\fR
232 Set
233 .I variable
234 to
235 .IR expr1 .
236 While the value of
237 .I variable
238 is less than or equal to
239 .IR expr2 ,
240 do
241 .I body
242 and increment
243 .I variable
244 by
245 .IR expr3 ;
246 if
247 .B by
248 is not given, increment
249 .I variable
250 by 1.
251 If
252 .I expr3
253 is prefixed by
254 .B *
255 then
256 .I variable
257 will instead be multiplied by
258 .IR expr3 .
259 .I X
260 can be any character not occurring in
261 .IR body .
262 .TP
263 \fBif\fR \fIexpr\fR \fBthen\fR \fIX\fR \fIif-true\fR \fIX\fR \
264 [\fBelse\fR \fIY\fR \fIif-false\fR \fIY\fR]
265 Evaluate
266 .IR expr ;
267 if it is non-zero then do
268 .IR if-true ,
269 otherwise do
270 .IR if-false .
271 .I X
272 can be any character not occurring in
273 .IR if-true .
274 .I Y
275 can be any character not occurring in
276 .IR if-false .
277 .TP
278 \fBprint\fR \fIarg\fR\|.\|.\|.
279 Concatenate the arguments and print as a line on stderr.
280 Each
281 .I arg
282 must be an expression, a position, or text.
283 This is useful for debugging.
284 .TP
285 \fBcommand\fR \fIarg\fR\|.\|.\|.
286 Concatenate the arguments
287 and pass them through as a line to troff or\*(tx.
288 Each
289 .I arg
290 must be an expression, a position, or text.
291 This has a similar effect to a line beginning with
292 .B .
293 or
294 .BR \e ,
295 but allows the values of variables to be passed through.
296 .TP
297 \fBsh\fR \fIX\fR \fIcommand\fR \fIX\fR
298 Pass
299 .I command
300 to a shell.
301 .I X
302 can be any character not occurring in
303 .IR command .
304 .TP
305 \fBcopy\fR \fB"\fIfilename\fB"\fR
306 Include
307 .I filename
308 at this point in the file.
309 .TP
310 \fBcopy\fR [\fB"\fIfilename\fB"\fR] \fBthru\fR \fIX\fR \fIbody\fR \fIX\fR \
311 [\fBuntil\fR \fB"\fIword\*(ic\fB"\fR]
312 .ns
313 .TP
314 \fBcopy\fR [\fB"\fIfilename\fB"\fR] \fBthru\fR \fImacro\fR \
315 [\fBuntil\fR \fB"\fIword\*(ic\fB"\fR]
316 This construct does
317 .I body
318 once for each line of
319 .IR filename ;
320 the line is split into blank-delimited words,
321 and occurrences of
322 .BI $ i
323 in
324 .IR body ,
325 for
326 .I i
327 between 1 and 9,
328 are replaced by the
329 .IR i -th
330 word of the line.
331 If
332 .I filename
333 is not given, lines are taken from the current input up to
334 .BR .PE .
335 If an
336 .B until
337 clause is specified,
338 lines will be read only until a line the first word of which is
339 .IR word ;
340 that line will then be discarded.
341 .I X
342 can be any character not occurring in
343 .IR body .
344 For example,
345 .RS
346 .IP
347 .ft B
348 .nf
349 \&.PS
350 copy thru % circle at ($1,$2) % until "END"
351 1 2
352 3 4
353 5 6
354 END
355 box
356 \&.PE
357 .ft
358 .fi
359 .RE
360 .IP
361 is equivalent to
362 .RS
363 .IP
364 .ft B
365 .nf
366 \&.PS
367 circle at (1,2)
368 circle at (3,4)
369 circle at (5,6)
370 box
371 \&.PE
372 .ft
373 .fi
374 .RE
375 .IP
376 The commands to be performed for each line can also be taken
377 from a macro defined earlier by giving the name of the macro
378 as the argument to
379 .BR thru .
380 .LP
381 .B reset
382 .br
383 .ns
384 .TP
385 \fBreset\fI variable1\fB,\fI variable2 .\^.\^.
386 Reset pre-defined variables
387 .IR variable1 ,
388 .I variable2
389 \&.\^.\^. to their default values.
390 If no arguments are given, reset all pre-defined variables
391 to their default values.
392 Note that assigning a value to
393 .B scale
394 also causes all pre-defined variables that control dimensions
395 to be reset to their default values times the new value of scale.
396 .TP
397 \fBplot\fR \fIexpr\fR [\fB"\fItext\*(ic\fB"\fR]
398 This is a text object which is constructed by using
399 .I text
400 as a format string for sprintf
401 with an argument of
402 .IR expr .
403 If
404 .I text
405 is omitted a format string of
406 .B "\(ts%g\(ts"
407 is used.
408 Attributes can be specified in the same way as for a normal text
409 object.
410 Be very careful that you specify an appropriate format string;
411 .B pic
412 does only very limited checking of the string.
413 This is deprecated in favour of
414 .BR sprintf .
415 .TP
416 .IB variable := expr
417 This is similar to
418 .B =
419 except
420 .I variable
421 must already be defined,
422 and the value of
423 .I variable
424 will be changed only in the innermost block in which it is defined.
425 (By contrast,
426 .B =
427 defines the variable in the current block if it is not already defined there,
428 and then changes the value in the current block.)
429 .LP
430 Arguments of the form
431 .IP
432 .IR X\  anything\  X
433 .LP
434 are also allowed to be of the form
435 .IP
436 .BI {\  anything\  }
437 .LP
438 In this case
439 .I anything
440 can contain balanced occurrences of
441 .B {
442 and
443 .BR } .
444 Strings may contain
445 .I X
446 or imbalanced occurrences of
447 .B {
448 and
449 .BR } .
450 .SS Expressions
451 The syntax for expressions has been significantly extended:
452 .LP
453 .IB  x\  ^\  y
454 (exponentiation)
455 .br
456 .BI sin( x )
457 .br
458 .BI cos( x )
459 .br
460 .BI atan2( y , \ x )
461 .br
462 .BI log( x )
463 (base 10)
464 .br
465 .BI exp( x )
466 (base 10, ie 10\v'-.4m'\fIx\*(ic\fR\v'.4m')
467 .br
468 .BI sqrt( x )
469 .br
470 .BI int( x )
471 .br
472 .B rand()
473 (return a random number between 0 and 1)
474 .br
475 .BI rand( x )
476 (return a random number between 1 and
477 .IR x ;
478 deprecated)
479 .br
480 .BI srand( x )
481 (set the random number seed)
482 .br
483 .BI max( e1 , \ e2 )
484 .br
485 .BI min( e1 , \ e2 )
486 .br
487 .BI ! e
488 .br
489 \fIe1\fB && \fIe2\fR
490 .br
491 \fIe1\fB || \fIe2\fR
492 .br
493 \fIe1\fB == \fIe2\fR
494 .br
495 \fIe1\fB != \fIe2\fR
496 .br
497 \fIe1\fB >= \fIe2\fR
498 .br
499 \fIe1\fB > \fIe2\fR
500 .br
501 \fIe1\fB <= \fIe2\fR
502 .br
503 \fIe1\fB < \fIe2\fR
504 .br
505 \fB"\fIstr1\*(ic\fB" == "\fIstr2\*(ic\fB"\fR
506 .br
507 \fB"\fIstr1\*(ic\fB" != "\fIstr2\*(ic\fB"\fR
508 .br
509 .LP
510 String comparison expressions must be parenthesised in some contexts
511 to avoid ambiguity.
512 .SS Other Changes
513 .LP
514 A bare expression,
515 .IR expr ,
516 is acceptable as an attribute;
517 it is equivalent to
518 .IR dir\ expr ,
519 where
520 .I dir
521 is the current direction.
522 For example
523 .IP
524 .B line 2i
525 .LP
526 means draw a line 2 inches long in the current direction.
527 .LP
528 The maximum width and height of the picture are taken from the variables
529 .B maxpswid
530 and
531 .BR maxpsht .
532 Initially these have values 8.5 and 11.
533 .LP
534 Scientific notation is allowed for numbers.
535 For example
536 .RS
537 .B
538 x = 5e\-2
539 .RE
540 .LP
541 Text attributes can be compounded.
542 For example,
543 .RS
544 .B
545 "foo" above ljust
546 .RE
547 is legal.
548 .LP
549 There is no limit to the depth to which blocks can be examined.
550 For example,
551 .RS
552 .B
553 [A: [B: [C: box ]]] with .A.B.C.sw at 1,2
554 .br
555 .B
556 circle at last [\^].A.B.C
557 .RE
558 is acceptable.
559 .LP
560 Arcs now have compass points
561 determined by the circle of which the arc is a part.
562 .LP
563 Circles and arcs can be dotted or dashed.
564 In \*(tx mode splines can be dotted or dashed.
565 .LP
566 Boxes can have rounded corners.
567 The
568 .B rad
569 attribute specifies the radius of the quarter-circles at each corner.
570 If no
571 .B rad
572 or
573 .B diam
574 attribute is given, a radius of
575 .B boxrad
576 is used.
577 Initially,
578 .B boxrad
579 has a value of 0.
580 A box with rounded corners can be dotted or dashed.
581 .LP
582 The
583 .B .PS
584 line can have a second argument specifying a maximum height for
585 the picture.
586 If the width of zero is specified the width will be ignored in computing
587 the scaling factor for the picture.
588 Note that GNU
589 .B pic
590 will always scale a picture by the same amount vertically as horizontally.
591 This is different from the
592 .SM DWB
593 2.0
594 .B pic
595 which may scale a picture by a different amount vertically than
596 horizontally if a height is specified.
597 .LP
598 Each text object has an invisible box associated with it.
599 The compass points of a text object are determined by this box.
600 The implicit motion associated with the object is also determined
601 by this box.
602 The dimensions of this box are taken from the width and height attributes;
603 if the width attribute is not supplied then the width will be taken to be
604 .BR textwid ;
605 if the height attribute is not supplied then the height will be taken to be
606 the number of text strings associated with the object
607 times
608 .BR textht .
609 Initially
610 .B textwid
611 and
612 .B textht
613 have a value of 0.
614 .LP
615 In places where a quoted text string can be used,
616 an expression of the form
617 .IP
618 .BI sprintf(\(ts format \(ts,\  arg ,\fR.\|.\|.\fB)
619 .LP
620 can also be used;
621 this will produce the arguments formatted according to
622 .IR format ,
623 which should be a string as described in
624 .BR printf (3)
625 appropriate for the number of arguments supplied,
626 using only the
627 .BR e ,
628 .BR f ,
629 .B g
630 or
631 .B %
632 format characters.
633 .LP
634 The thickness of the lines used to draw objects is controlled by the
635 .B linethick
636 variable.
637 This gives the thickness of lines in points.
638 A negative value means use the default thickness:
639 in \*(tx output mode, this means use a thickness of 8 milliinches;
640 in \*(tx output mode with the
641 .B -c
642 option, this means use the line thickness specified by
643 .B .ps
644 lines;
645 in troff output mode, this means use a thickness proportional
646 to the pointsize.
647 A zero value means draw the thinnest possible line supported by
648 the output device.
649 Initially it has a value of -1.
650 There is also a
651 .BR thick [ ness ]
652 attribute.
653 For example,
654 .RS
655 .LP
656 .B circle thickness 1.5
657 .RE
658 .LP
659 would draw a circle using a line with a thickness of 1.5 points.
660 The thickness of lines is not affected by the
661 value of the
662 .B scale
663 variable, nor by the width or height given in the
664 .B .PS
665 line.
666 .LP
667 Boxes (including boxes with rounded corners),
668 circles and ellipses can be filled by giving then an attribute of
669 .BR fill [ ed ].
670 This takes an optional argument of an expression with a value between
671 0 and 1; 0 will fill it with white, 1 with black, values in between
672 with a proportionally gray shade.
673 A value greater than 1 can also be used:
674 this means fill with the
675 shade of gray that is currently being used for text and lines.
676 Normally this will be black, but output devices may provide
677 a mechanism for changing this.
678 Without an argument, then the value of the variable
679 .B fillval
680 will be used.
681 Initially this has a value of 0.5.
682 The invisible attribute does not affect the filling of objects.
683 Any text associated with a filled object will be added after the
684 object has been filled, so that the text will not be obscured
685 by the filling.
686 .LP
687 Arrow heads will be drawn as solid triangles if the variable
688 .B arrowhead
689 is non-zero and either \*(tx mode is enabled or
690 the
691 .B \-x
692 option has been given.
693 Initially
694 .B arrowhead
695 has a value of 1.
696 .LP
697 The troff output of
698 .B pic
699 is device-independent.
700 The
701 .B \-T
702 option is therefore redundant.
703 All numbers are taken to be in inches; numbers are never interpreted
704 to be in troff machine units.
705 .LP
706 Objects can have an
707 .B aligned
708 attribute.
709 This will only work when the postprocessor is
710 .BR grops .
711 Any text associated with an object having the
712 .B aligned
713 attribute will be rotated about the center of the object
714 so that it is aligned in the direction from the start point
715 to the end point of the object.
716 Note that this attribute will have no effect for objects whose start and
717 end points are coincident.
718 .LP
719 In places where
720 .IB n th
721 is allowed
722 .BI ` expr 'th
723 is also allowed.
724 Note that
725 .B 'th
726 is a single token: no space is allowed between the
727 .B '
728 and the
729 .BR th .
730 For example,
731 .IP
732 .B
733 .nf
734 for i = 1 to 4 do {
735    line from `i'th box.nw to `i+1'th box.se
736 }
737 .fi
738 .SH CONVERSION
739 To obtain a stand-alone picture from a
740 .B pic
741 file, enclose your
742 .B pic
743 code with
744 .B .PS
745 and
746 .B .PE
747 requests;
748 .B roff
749 configuration commands may be added at the beginning of the file, but no
750 .B roff
751 text.
752 .LP
753 It is necessary to feed this file into
754 .B groff
755 without adding any page information, so you must check which
756 .B .PS
757 and
758 .B .PE
759 requests are actually called.
760 For example, the mm macro package adds a page number, which is very
761 annoying.
762 At the moment, calling standard
763 .B groff
764 without any macro package works.
765 Alternatively, you can define your own requests, e.g. to do nothing:
766 .LP
767 .RS
768 .nf
769 .ft B
770 \&.de PS
771 \&..
772 \&.de PE
773 \&..
774 .ft
775 .fi
776 .RE
777 .LP
778 .B groff
779 itself does not provide direct conversion into other graphics file
780 formats.
781 But there are lots of possibilities if you first transform your picture
782 into PostScript\*R format using the
783 .B groff
784 option
785 .BR -Tps .
786 Since this
787 .IR ps -file
788 lacks BoundingBox information it is not very useful by itself, but it
789 may be fed into other conversion programs, usually named
790 .BI ps2 other
791 or
792 .BI psto other
793 or the like.
794 Moreover, the PostScript interpreter
795 .B ghostscript
796 .RB ( gs )
797 has built-in graphics conversion devices that are called with the option
798 .LP
799 .RS
800 .BI "gs -sDEVICE=" <devname>
801 .RE
802 .LP
803 Call
804 .RS
805 .B gs --help
806 .RE
807 .LP
808 for a list of the available devices.
809 .LP
810 As the Encapsulated PostScript File Format
811 .B EPS
812 is getting more and more important, and the conversion wasn't regarded
813 trivial in the past you might be interested to know that there is a
814 conversion tool named
815 .B ps2eps
816 which does the right job.
817 It is much better than the tool
818 .B ps2epsi
819 packaged with
820 .BR gs .
821 .LP
822 For bitmapped graphic formats, you should use
823 .BR pstopnm ;
824 the resulting (intermediate)
825 .B PNM
826 file can be then converted to virtually any graphics format using the tools
827 of the
828 .B netpbm
829 package .
830 .SH FILES
831 .Tp \w'\fB/usr/share/groff/1.17.2/tmac/pic.tmac'u+3n
832 .B
833 /usr/share/groff/1.17.2/tmac/pic.tmac
834 Example definitions of the
835 .B PS
836 and
837 .B PE
838 macros.
839 .SH "SEE ALSO"
840 .BR troff (1),
841 .BR groff_out (5),
842 .BR tex (1),
843 .BR gs (1),
844 .BR ps2eps (1),
845 .BR pstopnm (1),
846 .BR ps2epsi (1),
847 .BR pnm (5)
848 .LP
849 Tpic: Pic for \*(tx
850 .LP
851 Brian W. Kernighan,
852 PIC \(em A Graphics Language for Typesetting (User Manual).
853 AT&T Bell Laboratories, Computing Science Technical Report No.\ 116
854 <URL:http://cm.bell-labs.com/cm/cs/cstr/116.ps.gz>
855 (revised May, 1991).
856 .LP
857 .B ps2eps
858 is available from CTAN mirrors, e.g.
859 .br
860 <ftp://ftp.dante.de/tex-archive/support/ps2eps/>
861 .LP
862 W. Richard Stevens - Turning PIC Into HTML
863 .br
864 <http://www.kohala.com/start/troff/pic2html.html>
865 .LP
866 W. Richard Stevens - Examples of picMacros
867 .br
868 <http://www.kohala.com/start/troff/pic.examples.ps>
869 .SH BUGS
870 .LP
871 Input characters that are illegal for
872 .B groff
873 (ie those with
874 .SM ASCII
875 code 0 or between 013 and 037 octal or between 0200 and 0237 octal)
876 are rejected even in \*(tx mode.
877 .LP
878 The interpretation of
879 .B fillval
880 is incompatible with the pic in 10th edition Unix,
881 which interprets 0 as black and 1 as white.
882 .LP
883 PostScript\*R is a registered trademark of Adobe Systems Incorporation.
884 .
885 .\" Local Variables:
886 .\" mode: nroff
887 .\" End: