PIC(1) | General Commands Manual | PIC(1) |
NAME
pic - compile pictures for troff or TeXSYNOPSIS
pic [ -nvCSU ] [ filename ... ]DESCRIPTION
This manual page describes the GNU version of pic, which is part of the groff document formatting system. pic compiles descriptions of pictures embedded within troff or TeX input files into commands that are understood by TeX or troff. Each picture starts with a line beginning with .PS and ends with a line beginning with .PE. Anything outside of .PS and .PE is passed through without change.OPTIONS
Options that do not take arguments may be grouped behind a single -. The special option -- can be used to mark the end of the options. A filename of - refers to the standard input.- -C
- Recognize .PS and .PE even when followed by a character other than space or newline.
- -S
- Safer mode; do not execute sh commands. This can be useful when operating on untrustworthy input. (enabled by default)
- -U
- Unsafe mode; revert the default option -S.
- -n
- Don't use the groff extensions to the troff drawing commands. You should use this if you are using a postprocessor that doesn't support these extensions. The extensions are described in groff_out(5). The -n option also causes pic not to use zero-length lines to draw dots in troff mode.
- -t
- TeX mode.
- -c
- Be more compatible with tpic. Implies -t. Lines beginning with \ are not passed through transparently. Lines beginning with . are passed through with the initial . changed to \. A line beginning with .ps is given special treatment: it takes an optional integer argument specifying the line thickness (pen size) in milliinches; a missing argument restores the previous line thickness; the default line thickness is 8 milliinches. The line thickness thus specified takes effect only when a non-negative line thickness has not been specified by use of the thickness attribute or by setting the linethick variable.
- -v
- Print the version number.
- -z
- In TeX mode draw dots using zero-length lines.
- -D
- Draw all lines using the \D escape sequence. pic always does this.
- -T dev
- Generate output for the troff device dev. This is unnecessary because the troff output generated by pic is device-independent.
USAGE
This section describes only the differences between GNU pic and the original version of pic. Many of these differences also apply to newer versions of Unix pic. A complete documentation is available in the file
/share/doc/groff-1.22/pic.ms
TeX mode
TeX mode is enabled by the -t option. In TeX mode, pic will define a vbox called \graph for each picture. Use the figname command to change the name of the vbox. You must yourself print that vbox using, for example, the commandCommands
- for variable = expr1 to expr2 [by [*]expr3] do X body X
- Set variable to expr1. While the value of variable is less than or equal to expr2, do body and increment variable by expr3; if by is not given, increment variable by 1. If expr3 is prefixed by * then variable will instead be multiplied by expr3. The value of expr3 can be negative for the additive case; variable is then tested whether it is greater than or equal to expr2. For the multiplicative case, expr3 must be greater than zero. If the constraints aren't met, the loop isn't executed. X can be any character not occurring in body.
- if expr then X if-true X [else Y if-false Y]
- Evaluate expr; if it is non-zero then do if-true, otherwise do if-false. X can be any character not occurring in if-true. Y can be any character not occurring in if-false.
- print arg...
- Concatenate the arguments and print as a line on stderr. Each arg must be an expression, a position, or text. This is useful for debugging.
- command arg...
- Concatenate the arguments and pass them through as a line to troff or TeX. Each arg must be an expression, a position, or text. This has a similar effect to a line beginning with . or \, but allows the values of variables to be passed through. For example,
-
.PS
x = 14
command ".ds string x is " x "."
.PE
\*[string]
- prints
- x is 14.
- sh X command X
- Pass command to a shell. X can be any character not occurring in command.
- copy "filename"
- Include filename at this point in the file.
- copy ["filename"] thru X body X [until "word/"]
- copy ["filename"] thru macro [until "word/"]
- This construct does body once for each line of filename; the line is split into blank-delimited words, and occurrences of $i in body, for i between 1 and 9, are replaced by the i-th word of the line. If filename is not given, lines are taken from the current input up to .PE. If an until clause is specified, lines will be read only until a line the first word of which is word; that line will then be discarded. X can be any character not occurring in body. For example,
-
.PS
copy thru % circle at ($1,$2) % until "END"
1 2
3 4
5 6
END
box
.PE
- is equivalent to
-
.PS
circle at (1,2)
circle at (3,4)
circle at (5,6)
box
.PE
- The commands to be performed for each line can also be taken from a macro defined earlier by giving the name of the macro as the argument to thru.
- reset variable1[,] variable2 ...
- Reset pre-defined variables variable1, variable2 ... to their default values. If no arguments are given, reset all pre-defined variables to their default values. Note that assigning a value to scale also causes all pre-defined variables that control dimensions to be reset to their default values times the new value of scale.
- plot expr ["text/"]
- This is a text object which is constructed by using text as a format string for sprintf with an argument of expr. If text is omitted a format string of "%g" is used. Attributes can be specified in the same way as for a normal text object. Be very careful that you specify an appropriate format string; pic does only very limited checking of the string. This is deprecated in favour of sprintf.
- variable := expr
- This is similar to = except variable must already be defined, and expr will be assigned to variable without creating a variable local to the current block. (By contrast, = defines the variable in the current block if it is not already defined there, and then changes the value in the current block only.) For example, the following:
-
.PS
x = 3
y = 3
[
x := 5
y = 5
]
print x " " y
.PE
- prints
- 5 3
- X anything X
- { anything }
Expressions
The syntax for expressions has been significantly extended:Other Changes
A bare expression, expr, is acceptable as an attribute; it is equivalent to dir expr, where dir is the current direction. For example
line 2i
- sprintf("format", arg,...)
-
for i = 1 to 4 do {
line from `i'th box.nw to `i+1'th box.se
}
CONVERSION
To obtain a stand-alone picture from a pic file, enclose your pic code with .PS and .PE requests; roff configuration commands may be added at the beginning of the file, but no roff text..de PS
..
.de PE
..
gs -sDEVICE=<devname>
gs --help
FILES
- /share/groff/1.22.1/tmac/pic.tmac
- Example definitions of the PS and PE macros.
SEE ALSO
troff(1), groff_out(5), tex(1), gs(1), ps2eps(1), pstopnm(1), ps2epsi(1), pnm(5)BUGS
Input characters that are invalid for groff (i.e., those with ASCII code 0, or 013 octal, or between 015 and 037 octal, or between 0200 and 0237 octal) are rejected even in TeX mode.30 December 2012 | Groff Version 1.22.1 |