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