Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / groff / contrib / chem / chem.man
1 .ig
2 @g@chem.1 - man page for @g@chem (section 1).
3
4 Source file position:  <groff_source_top>/contrib/chem/chem.man
5 Installed position:    $prefix/share/man/man1/@g@chem.1
6
7 Last update: 05 Jan 2009
8 ..
9 .
10 .
11 .de au
12 This file was written by Bernd Warken.
13 It is based on the documentation of
14 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:who/\:bwk/\:index.html
15 Brian Kernighan
16 .UE 's
17 original
18 .I awk
19 version of
20 .IR chem .
21 ..
22 .
23 .
24 .de co
25 Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
26 .
27 .
28 .P
29 This file is part of
30 .IR chem ,
31 which is part of
32 .IR groff ,
33 a free software project.
34 .
35 You can redistribute it and/or modify it under the terms of the
36 .nh
37 .B "GNU General Public License"
38 .hy
39 as published by the
40 .nh
41 .BR "Free Software Foundation" ,
42 .hy
43 either version\~2, or (at your option) any later version.
44 .
45 .
46 .P
47 You should have received a copy of the \f(CRGNU General Public
48 License\fP along with
49 .IR groff ,
50 see the files \%\f(CBCOPYING\fP and \%\f(CBLICENSE\fP in the top
51 directory of the
52 .I groff
53 source package.
54 .
55 Or read the
56 .I man page
57 .BR gpl (1).
58 You can also write to the
59 .nh
60 .B "Free Software Foundation, 51 Franklin St - Fifth Floor, Boston,"
61 .BR "MA 02110-1301, USA" .
62 .hy
63 ..
64 .
65 .
66 .\" --------------------------------------------------------------------
67 .\" Local macro definitions
68 .
69 .ds El \&.\|.\|.\&
70 .
71 .\" .File_name  (<path_name>)
72 .\"
73 .\" Display a file or directory name in CB font.
74 .\"
75 .de FN
76 .  CB \\$@
77 ..
78 .
79 .\" .CB  (<path_name>)
80 .\"
81 .\" Display a line in CB font, for example after .TP
82 .\"
83 .de CB
84 .nh
85 \\&\\f(CB\\$1\\fP\\$2
86 .hy
87 ..
88 .
89 .\" End of macro definitions
90 .
91 .
92 .TH @G@CHEM @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
93 .SH NAME
94 @g@chem \- groff preprocessor for producing chemical structure diagrams
95 .
96 .
97 .SH "SYNOPSIS"
98 .\" --------------------------------------------------------------------
99 .\" SH "SYNOPSIS"
100 .\" --------------------------------------------------------------------
101 .
102 .SY @g@chem
103 .RI [ "\%option" \*(El]
104 .OP \-\-
105 .RI [ "\%filespec" \*(El]
106 .
107 .SY @g@chem
108 .B \-h
109 |
110 .B \-\-help
111 .
112 .SY @g@chem
113 .B \-v
114 |
115 .B \-\-version
116 .YS
117 .
118 .
119 .\" --------------------------------------------------------------------
120 .SH OPTION USAGE
121 .\" --------------------------------------------------------------------
122 .
123 .P
124 There are no other options than
125 .BR \-h ,
126 .BR \-\-help ,
127 .BR \-v ,
128 and
129 .BR \%\-\-version ;
130 these options provoke the printing of a version or usage information,
131 respectively, and all
132 .I filespec
133 arguments are ignored.
134 .
135 A
136 .I filespec
137 argument is either a file name of an existing file or a minus
138 character
139 .BR \- ,
140 meaning standard input.
141 .
142 If no argument is specified then standard input is taken
143 automatically.
144 .
145 .
146 .\" --------------------------------------------------------------------
147 .SH DESCRIPTION
148 .\" --------------------------------------------------------------------
149 .
150 .I chem
151 produces chemical structure diagrams.
152 .
153 Today's version is best suited for organic chemistry (bonds, rings).
154 .
155 The
156 .B @g@chem
157 program is a
158 .B groff
159 preprocessor like
160 .BR @g@eqn ,
161 .BR @g@pic ,
162 .BR @g@tbl ,
163 etc.
164 .
165 It generates
166 .I pic
167 output such that all
168 .I chem
169 parts are translated into diagrams of the
170 .I pic
171 language.
172 .
173 .
174 .P
175 The program
176 .B @g@chem
177 originates from the Perl source file
178 .FN chem.pl .
179 It tells
180 .B @g@pic
181 to include a copy of the macro file
182 .FN chem.pic .
183 .
184 Moreover the
185 .I groff
186 source file
187 .FN pic.tmac
188 is loaded.
189 .
190 .
191 .P
192 In a style reminiscent of
193 .I eqn
194 and
195 .IR pic ,
196 the
197 .I chem
198 diagrams are written in a special language.
199 .
200 .
201 .P
202 A set of
203 .I chem
204 lines looks like this
205 .
206 .
207 .IP
208 .nf
209 .ft B
210 \&.cstart
211 \fIchem data\fP
212 \&.cend
213 .ft
214 .fi
215 .
216 .
217 .P
218 Lines containing the keywords
219 .B .cstart
220 and
221 .B .cend
222 start and end the input for
223 .BR @g@chem ,
224 respectively.
225 .
226 In
227 .I pic
228 context, i.e., after the call of
229 .BR .PS ,
230 .I chem
231 input can optionally be started by the line
232 .B \%begin\~chem
233 and ended by the line with the single word
234 .B end
235 instead.
236 .
237 .
238 .P
239 Anything outside these initialization lines is copied through
240 without modification;
241 all data between the initialization lines is converted into
242 .I pic
243 commands to draw the diagram.
244 .
245 .
246 .P
247 As an example,
248 .
249 .IP
250 .nf
251 .ft B
252 \&.cstart
253 CH3
254 bond
255 CH3
256 \&.cend
257 .ft
258 .fi
259 .
260 .
261 .P
262 prints two
263 .B CH3
264 groups with a bond between them.
265 .
266 .
267 .P
268 To actually view this, you must run
269 .B @g@chem
270 followed by
271 .BR groffer :
272 .
273 .IP
274 .B "@g@chem [file\*(El] | groffer"
275 .
276 .P
277 If you want to create just
278 .B groff
279 output, you must run
280 .B @g@chem
281 followed by
282 .B groff
283 with the option
284 .B \-p
285 for the activation of
286 .BR @g@pic :
287 .IP
288 .B "@g@chem [file\*(El] | groff -p \*(El"
289 .
290 .
291 .\" --------------------------------------------------------------------
292 .SH THE LANGUAGE
293 .\" --------------------------------------------------------------------
294 .
295 The
296 .I chem
297 input language is rather small.  It provides rings of several styles
298 and a way to glue them together as desired, bonds of several styles,
299 moieties (e.g.,
300 .BR C ,
301 .BR NH3 ,
302 \*(El), and strings.
303 .
304 .
305 .\" --------------------------------------------------------------------
306 .SS Setting Variables
307 .\" --------------------------------------------------------------------
308 .
309 There are some variables that can be set by commands.
310 .
311 Such commands have two possible forms, either
312 .
313 .RS
314 .P
315 .I "variable value"
316 .RE
317 .
318 .P
319 or
320 .
321 .RS
322 .P
323 .IB "variable " = " value"
324 .RE
325 .
326 .P
327 This sets the given
328 .I variable
329 to the argument
330 .IR value .
331 If more arguments are given only the last argument is taken, all other
332 arguments are ignored.
333 .
334 .
335 .P
336 There are only a few variables to be set by these commands:
337 .
338 .TP
339 .BI textht " arg"
340 Set the height of the text to
341 .IR arg ;
342 default is 0.16.
343 .
344 .TP
345 .BI cwid " arg"
346 Set the character width to
347 .IR arg ;
348 default is 0.12.
349 .
350 .TP
351 .BI db " arg"
352 Set the bond length to
353 .IR arg ;
354 default is 0.2.
355 .
356 .TP
357 .BI size " arg"
358 Scale the diagram to make it look plausible at point size
359 .IR arg ;
360 default is 10 point.
361 .
362 .
363 .\" --------------------------------------------------------------------
364 .SS Bonds
365 .\" --------------------------------------------------------------------
366 .
367 This
368 .
369 .RS
370 .SY bond
371 .RI [ direction ]
372 .RI [ length\ n ]
373 .RB [ from\ \c
374 .IR Name | picstuff ]
375 .YS
376 .RE
377 .
378 .P
379 draws a single bond in direction from nearest corner of
380 .IR Name .
381 .B bond
382 can also be
383 .BR "double bond" ,
384 .BR "front bond" ,
385 .BR "back bond" ,
386 etc.
387 .
388 (We will get back to
389 .I Name
390 soon.)
391 .
392 .
393 .P
394 .I direction
395 is the angle in degrees (0\~up, positive clockwise)
396 or a direction word like
397 .BR up ,
398 .BR down ,
399 .B sw
400 (=\~southwest), etc.
401 .
402 If no direction is specified, the bond goes in the current direction
403 (usually that of the last bond).
404 .
405 .
406 .P
407 Normally the bond begins at the last object placed;  this
408 can be changed by naming a
409 .B from
410 place.
411 .
412 For instance, to make a simple alkyl chain:
413 .
414 .RS
415 .TS
416 tab (@);
417 lb l.
418 CH3
419 bond@(this one goes right from the CH3)
420 C@(at the right end of the bond)
421 double bond up@(from the C)
422 O@(at the end of the double bond)
423 bond right from C
424 CH3
425 .TE
426 .RE
427 .
428 .
429 .P
430 A length in inches may be specified to override the default length.
431 .
432 Other
433 .I pic
434 commands can be tacked on to the end of a bond command, to created
435 dotted or dashed bonds or to specify a
436 .B to
437 place.
438 .
439 .
440 .\" --------------------------------------------------------------------
441 .SS Rings
442 .\" --------------------------------------------------------------------
443 .
444 There are lots of rings, but only 5 and 6-sided rings get
445 much support.
446 .
447 .B ring
448 by itself is a 6-sided ring;
449 .B benzene
450 is the benzene ring with a circle inside.
451 .B aromatic
452 puts a circle into any kind of ring.
453 .
454 .RS
455 .SY ring
456 .RB [ \%pointing\  ( up | right | left | down )]
457 .RB [ \%aromatic ]
458 .RB [ put\ Mol\ at\ \fIn\fP ]
459 .RB [ \%double\ \c
460 .IR i , j\ \c
461 .IR k , l\ \c
462 \*(El]
463 .RI [ picstuff ]
464 .YS
465 .RE
466 .
467 .
468 .P
469 The vertices of a ring are numbered 1, 2, \*(El from the
470 vertex that points in the natural compass direction.
471 .
472 So for a hexagonal ring with the point at the top, the top vertex
473 is\~1, while if the ring has a point at the east side, that is
474 vertex\~1.
475 .
476 This is expressed as
477 .
478 .IP
479 .ft B
480 .nf
481 R1: ring pointing up
482 R2: ring pointing right
483 .fi
484 .ft
485 .
486 .
487 .P
488 The ring vertices are named
489 .BR .V1 ,
490 \*(El,
491 .BI .V n\fR,\fP
492 with
493 .B .V1
494 in the pointing direction.
495 .
496 So the corners of
497 .B R1
498 are
499 .B R1.V1
500 (the
501 .IR top ),
502 .BR R1.V2 ,
503 .BR R1.V3 ,
504 .B R1.V4
505 (the
506 .IR bottom ),
507 etc., whereas for
508 .BR R2 ,
509 .B R2.V1
510 is the rightmost vertex and
511 .B R2.V4
512 the leftmost.
513 .
514 These vertex names are used for connecting bonds or other rings.  For
515 example,
516 .
517 .IP
518 .ft B
519 .nf
520 R1: benzene pointing right
521 R2: benzene pointing right with .V6 at R1.V2
522 .fi
523 .ft
524 .P
525 creates two benzene rings connected along a side.
526 .
527 .
528 .P
529 Interior double bonds are specified as
530 .BI \%double\  n1 , n2\ n3 , n4\ \fR\*(El;\fP
531 each number pair adds an interior bond.
532 .
533 So the alternate form of a benzene ring is
534 .
535 .IP
536 .B "ring double 1,2 3,4 5,6"
537 .
538 .
539 .P
540 Heterocycles (rings with something other than carbon at a vertex) are
541 written as
542 .BI put\  X\  at\  V\fR,\fP
543 as in
544 .
545 .IP
546 .B "R: ring put N at 1 put O at 2"
547 .
548 .
549 .P
550 In this heterocycle,
551 .B R.N
552 and
553 .B R.O
554 become synonyms for
555 .B R.V1
556 and
557 .BR R.V2 .
558 .
559 .
560 .P
561 There are two 5-sided rings.
562 .
563 .B ring5
564 is pentagonal with a side that matches the 6-sided ring; it has four
565 natural directions.
566 .
567 A
568 .B \%flatring
569 is a 5-sided ring created by chopping one corner of a 6-sided ring so
570 that it exactly matches the 6-sided rings.
571 .
572 .
573 .P
574 The description of a ring has to fit on a single line.
575 .
576 .
577 .\" --------------------------------------------------------------------
578 .SS Moieties and Strings
579 .\" --------------------------------------------------------------------
580 .
581 A moiety is a string of characters beginning with a capital letter,
582 such as N(C2H5)2.
583 .
584 Numbers are converted to subscripts (unless they appear to be
585 fractional values, as in N2.5H).
586 .
587 The name of a moiety is determined from the moiety after special
588 characters have been stripped out: e.g., N(C2H5)2) has the name NC2H52.
589 .
590 .
591 .P
592 Moieties can be specified in two kinds.
593 .
594 Normally a moiety is placed right after the last thing mentioned,
595 separated by a semicolon surrounded by spaces, e.g.,
596 .
597 .IP
598 .B "B1: bond ; OH"
599 .
600 .P
601 Here the moiety is
602 .BR OH ;
603 it is set after a bond.
604 .
605 .
606 .P
607 As the second kind a moiety can be positioned as the first word in a
608 .IR pic -like
609 command, e.g.,
610 .
611 .IP
612 .B "CH3 at C + (0.5,0.5)"
613 .
614 .P
615 Here the moiety is
616 .BR CH3 .
617 It is placed at a position relative to
618 .BR C ,
619 a moiety used earlier in the chemical structure.
620 .
621 .
622 .P
623 So moiety names can be specified as
624 .I chem
625 positions everywhere in the
626 .I chem
627 code.
628 .
629 Beneath their printing moieties are names for places.
630 .
631 .
632 .P
633 The moiety
634 .B BP
635 is special.
636 .
637 It is not printed but just serves as a mark to be referred to in later
638 .I chem
639 commands.
640 .
641 For example,
642 .
643 .IP
644 .B "bond ; BP"
645 .
646 .P
647 sets a mark at the end of the bond.
648 .
649 This can be used then for specifying a place.
650 .
651 The name
652 .B BP
653 is derived from
654 .I branch point
655 (i.e., line crossing).
656 .
657 .
658 .P
659 A string within double quotes
660 .B \(dq
661 is interpreted as a part of a
662 .I chem
663 command.
664 .
665 It represents a string that should be printed (without the quotes).
666 .
667 Text within quotes \(dq\*(El\(dq is treated more or less
668 like a moiety except that no changes are made to the quoted part.
669 .
670 .
671 .\" --------------------------------------------------------------------
672 .SS Names
673 .\" --------------------------------------------------------------------
674 .
675 In the alkyl chain above, notice that the carbon atom
676 .B C
677 was used both to draw something and as the name for a place.
678 .
679 A moiety always defines a name for a place;  you can use
680 your own names for places instead, and indeed, for rings
681 you will have to.
682 .
683 A name is just
684 .
685 .IP
686 .IB Name :
687 \*(El
688 .
689 .
690 .P
691 .I Name
692 is often the name of a moiety like
693 .BR CH3 ,
694 but it need not to be.
695 .
696 Any name that begins with a capital letter and which contains
697 only letters and numbers is valid:
698 .
699 .RS
700 .TP
701 .B First:
702 .B bond
703 .TQ
704 \&
705 .B "bond 30 from First"
706 .RE
707 .
708 .
709 .\" --------------------------------------------------------------------
710 .SS Miscellaneous
711 .\" --------------------------------------------------------------------
712 .
713 The specific construction
714 .RS
715 .TP
716 .BR bond\  \*(El " ; moiety"
717 .RE
718 .P
719 is equivalent to
720 .IP
721 .ft B
722 .nf
723 bond
724 moiety
725 .fi
726 .ft
727 .
728 .
729 .P
730 Otherwise, each item has to be on a separate line (and only one line).
731 Note that there must be whitespace after the semicolon which separates
732 the commands.
733 .
734 .
735 .P
736 A period character
737 .B .\&
738 or a single quote
739 .B '
740 in the first column of a line signals a
741 .I troff
742 command, which is copied through as-is.
743 .
744 .
745 .P
746 A line whose first non-blank character is a hash character
747 .RB ( # )
748 is treated as a comment and thus ignored.
749 .
750 However, hash characters within a word are kept.
751 .
752 .
753 .P
754 A line whose first word is
755 .B pic
756 is copied through as-is after the word
757 .B pic
758 has been removed.
759 .
760 .
761 .P
762 The command
763 .IP
764 .B size
765 .I n
766 .P
767 scales the diagram to make it look plausible at point size\~\c
768 .I n
769 (default is 10\~point).
770 .
771 .
772 .P
773 Anything else is assumed to be
774 .I pic
775 code, which is copied through with a label.
776 .
777 .
778 .P
779 Since
780 .B @g@chem
781 is a
782 .B @g@pic
783 preprocessor, it is possible to include
784 .I pic
785 statements in the middle of a diagram to draw things not provided for
786 by
787 .I chem
788 itself.
789 .
790 Such
791 .I pic
792 statements should be included in
793 .I chem
794 code by adding
795 .B pic
796 as the first word of this line for clarity.
797 .
798 .
799 .P
800 The following
801 .I pic
802 commands are accepted as
803 .I chem
804 commands, so no
805 .B pic
806 command word is needed:
807 .
808 .IP
809 .B define
810 Start the definition of
811 .I pic
812 macro within
813 .IR chem .
814 .
815 .RS
816 .TP
817 .B [
818 Start a block composite.
819 .
820 .TP
821 .B ]
822 End a block composite.
823 .
824 .TP
825 .B {
826 Start a macro definition block.
827 .
828 .TP
829 .B }
830 End a macro definition block.
831 .RE
832 .
833 .P
834 The macro names from
835 .B define
836 statements are stored and their call is accepted as a
837 .I chem
838 command as well.
839 .
840 .
841 .\" --------------------------------------------------------------------
842 .SS WISH LIST
843 .\" --------------------------------------------------------------------
844 .
845 .P
846 This TODO list was collected by Brian Kernighan.
847 .
848 .
849 .P
850 Error checking is minimal; errors are usually detected and reported in
851 an oblique fashion by
852 .IR pic .
853 .
854 .
855 .P
856 There is no library or file inclusion mechanism, and there is no
857 shorthand for repetitive structures.
858 .
859 .
860 .P
861 The extension mechanism is to create
862 .I pic
863 macros, but these are tricky to get right and don't have all the
864 properties of built-in objects.
865 .
866 .
867 .P
868 There is no in-line chemistry yet (e.g., analogous to the $\*(El$
869 construct of eqn).
870 .
871 .
872 .P
873 There is no way to control entry point for bonds on groups.
874 .
875 Normally a bond connects to the carbon atom if entering from
876 the top or bottom and otherwise to the nearest corner.
877 .
878 .
879 .P
880 Bonds from substituted atoms on heterocycles do not join at the proper
881 place without adding a bit of
882 .IR pic .
883 .
884 .
885 .P
886 There is no decent primitive for brackets.
887 .
888 .
889 .P
890 Text (quoted strings) doesn't work very well.
891 .
892 .
893 .P
894 A squiggle bond is needed.
895 .
896 .
897 .\" --------------------------------------------------------------------
898 .SH "FILES"
899 .\" --------------------------------------------------------------------
900 .
901 .TP
902 .FN @DATASUBDIR@/pic/chem.pic
903 A collection of
904 .I pic
905 macros needed by
906 .BR @g@chem .
907 .
908 .TP
909 .FN @MACRODIR@/pic.tmac
910 A macro file which redefines
911 .B .PS
912 and
913 .BR .PE
914 to center
915 .I pic
916 diagrams.
917 .
918 .TP
919 .FN @DOCDIR@/examples/chem/*.chem
920 Example files for
921 .IR chem .
922 .
923 .TP
924 .FN @DOCDIR@/examples/chem/122/*.chem
925 Example files from the classical
926 .I chem
927 book
928 .BR 122.ps .
929 .
930 .
931 .\" --------------------------------------------------------------------
932 .SH "BUGS"
933 .\" --------------------------------------------------------------------
934 .
935 Report bugs to the
936 .MT bug-groff@\:gnu.org
937 bug-groff mailing list
938 .ME .
939 .
940 Include a complete, self-contained example that will allow the bug to
941 be reproduced, and say which version of
942 .I groff
943 and
944 .I chem
945 you are using.
946 .
947 You can get both version numbers by calling
948 .BR "@g@chem --version" .
949 .
950 .
951 .P
952 You can also use the
953 .MT groff@\:gnu.org
954 groff mailing list
955 .ME ,
956 but you must first subscribe to this list.
957 .
958 You can do that by visiting the
959 .UR http://\:lists.gnu.org/\:mailman/\:listinfo/\:groff
960 groff mailing list web page
961 .UE .
962 .
963 .
964 .P
965 See
966 .BR \%groff (@MAN1EXT@)
967 for information on availability.
968 .
969 .
970 .\" --------------------------------------------------------------------
971 .SH "SEE ALSO"
972 .\" --------------------------------------------------------------------
973 .
974 .BR \%groff (@MAN1EXT@),
975 .BR \%@g@pic (@MAN1EXT@),
976 .BR \%groffer (@MAN1EXT@).
977 .
978 .
979 .P
980 You can still get the original
981 .UR http://\:cm.bell-labs.com/\:netlib/\:typesetting/\:chem.gz
982 chem awk source
983 .UE .
984 .
985 Its
986 .FN README
987 file was used for this manual page.
988 .
989 .
990 .P
991 The other classical document on
992 .I chem
993 is
994 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:122.ps.gz
995 122.ps
996 .UE .
997 .
998 .
999 .\" --------------------------------------------------------------------
1000 .SH "AUTHOR"
1001 .\" --------------------------------------------------------------------
1002 .au
1003 .
1004 .
1005 .\" --------------------------------------------------------------------
1006 .SH "COPYING"
1007 .\" --------------------------------------------------------------------
1008 .co
1009 .
1010 .
1011 .\" --------------------------------------------------------------------
1012 .\" Emacs settings
1013 .\" --------------------------------------------------------------------
1014 .
1015 .\" Local Variables:
1016 .\" mode: nroff
1017 .\" End: