* src/roff/troff/node.cpp (left_italic_corrected_node::add_self):
[s-roff.git] / contrib / chem / chem.man
bloba76fbe4c6256e106b3c815cf0e35a431f6b1fb11
1 .ig
2 @g@chem.1 - man page for @g@chem (section 1).
4 Source file position:  <groff_source_top>/contrib/chem/chem.man
5 Installed position:    $prefix/share/man/man1/@g@chem.1
7 Last update:
8 04 Jan 2008
9 ..
12 .de au
13 This file was written by Bernd Warken.
14 It is based on the documentation of
15 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:who/\:bwk/\:index.html
16 Brian Kernighan
17 .UE 's
18 original
19 .I awk
20 version of
21 .IR chem .
25 .de co
26 Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
30 This file is part of
31 .IR chem ,
32 which is part of
33 .IR groff ,
34 a free software project.
36 You can redistribute it and/or modify it under the terms of the
37 .nh
38 .B "GNU General Public License"
39 .hy
40 as published by the
41 .nh
42 .BR "Free Software Foundation" ,
43 .hy
44 either version\~2, or (at your option) any later version.
48 You should have received a copy of the \f(CRGNU General Public
49 License\fP along with
50 .IR groff ,
51 see the files \%\f(CBCOPYING\fP and \%\f(CBLICENSE\fP in the top
52 directory of the
53 .I groff
54 source package.
56 Or read the
57 .I man page
58 .BR gpl (1).
59 You can also write to the
60 .nh
61 .B "Free Software Foundation, 51 Franklin St - Fifth Floor, Boston,"
62 .BR "MA 02110-1301, USA" .
63 .hy
67 .\" --------------------------------------------------------------------
68 .\" Local macro definitions
70 .ds El \&.\|.\|.\&
72 .\" .File_name  (<path_name>)
73 .\"
74 .\" Display a file or directory name in CB font.
75 .\"
76 .de FN
77 .  CB \\$@
80 .\" .CB  (<path_name>)
81 .\"
82 .\" Display a line in CB font, for example after .TP
83 .\"
84 .de CB
85 .nh
86 \\&\\f(CB\\$1\\fP\\$2
87 .hy
90 .\" End of macro definitions
93 .TH @G@CHEM @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
94 .SH NAME
95 @g@chem \- groff preprocessor for producing chemical structure diagrams
98 .SH "SYNOPSIS"
99 .\" --------------------------------------------------------------------
100 .\" SH "SYNOPSIS"
101 .\" --------------------------------------------------------------------
103 .SY @g@chem
104 .RI [ "\%option" \*(El]
105 .OP \-\-
106 .RI [ "\%filespec" \*(El]
108 .SY @g@chem
109 .B \-h
111 .B \-\-help
113 .SY @g@chem
114 .B \-v
116 .B \-\-version
120 .\" --------------------------------------------------------------------
121 .SH OPTION USAGE
122 .\" --------------------------------------------------------------------
125 There are no other options than
126 .BR \-h ,
127 .BR \-\-help ,
128 .BR \-v ,
130 .BR \%\-\-version ;
131 these options provoke the printing of a version or usage information,
132 respectively, and all
133 .I filespec
134 arguments are ignored.
137 .I filespec
138 argument is either a file name of an existing file or a minus
139 character
140 .BR \- ,
141 meaning standard input.
143 If no argument is specified then standard input is taken
144 automatically.
147 .\" --------------------------------------------------------------------
148 .SH DESCRIPTION
149 .\" --------------------------------------------------------------------
151 .I chem
152 produces chemical structure diagrams.
154 Today's version is best suited for organic chemistry (bonds, rings).
157 .B @g@chem
158 program is a
159 .B groff
160 preprocessor like
161 .BR @g@eqn ,
162 .BR @g@pic ,
163 .BR @g@tbl ,
164 etc.
166 It generates
167 .I pic
168 output such that all
169 .I chem
170 parts are translated into diagrams of the
171 .I pic
172 language.
176 The program
177 .B @g@chem
178 originates from the Perl source file
179 .FN chem.pl .
180 It tells
181 .B @g@pic
182 to include a copy of the macro file
183 .FN chem.pic .
185 Moreover the
186 .I groff
187 source file
188 .FN pic.tmac
189 is loaded.
193 In a style reminiscent of
194 .I eqn
196 .IR pic ,
198 .I chem
199 diagrams are written in a special language.
203 A set of
204 .I chem
205 lines looks like this
210 .ft B
211 \&.cstart
212 \fIchem data\fP
213 \&.cend
219 Lines containing the keywords
220 .B .cstart
222 .B .cend
223 start and end the input for
224 .BR @g@chem ,
225 respectively.
228 .I pic
229 context, i.e., after the call of
230 .BR .PS ,
231 .I chem
232 input can optionally be started by the line
233 .B \%begin\~chem
234 and ended by the line with the single word
235 .B end
236 instead.
240 Anything outside these initialization lines is copied through
241 without modification;
242 all data between the initialization lines is converted into
243 .I pic
244 commands to draw the diagram.
248 As an example,
252 .ft B
253 \&.cstart
255 bond
257 \&.cend
263 prints two
264 .B CH3
265 groups with a bond between them.
269 To actually view this, you must run
270 .B @g@chem
271 followed by
272 .BR groffer :
275 .B "@g@chem [file\*(El] | groffer"
278 If you want to create just
279 .B groff
280 output, you must run
281 .B @g@chem
282 followed by
283 .B groff
284 with the option
285 .B \-p
286 for the activation of
287 .BR @g@pic :
289 .B "@g@chem [file\*(El] | groff -p \*(El"
292 .\" --------------------------------------------------------------------
293 .SH THE LANGUAGE
294 .\" --------------------------------------------------------------------
297 .I chem
298 input language is rather small.  It provides rings of several styles
299 and a way to glue them together as desired, bonds of several styles,
300 moieties (e.g.,
301 .BR C ,
302 .BR NH3 ,
303 \*(El), and strings.
306 .\" --------------------------------------------------------------------
307 .SS Setting Variables
308 .\" --------------------------------------------------------------------
310 There are some variables that can be set by commands.
312 Such commands have two possible forms, either
316 .I "variable value"
324 .IB "variable " = " value"
328 This sets the given
329 .I variable
330 to the argument
331 .IR value .
332 If more arguments are given only the last argument is taken, all other
333 arguments are ignored.
337 There are only a few variables to be set by these commands:
340 .BI textht " arg"
341 Set the height of the text to
342 .IR arg ;
343 default is 0.16.
346 .BI cwid " arg"
347 Set the character width to
348 .IR arg ;
349 default is 0.12.
352 .BI db " arg"
353 Set the bond length to
354 .IR arg ;
355 default is 0.2.
358 .BI size " arg"
359 Scale the diagram to make it look plausible at point size
360 .IR arg ;
361 default is 10 point.
364 .\" --------------------------------------------------------------------
365 .SS Bonds
366 .\" --------------------------------------------------------------------
368 This
371 .SY bond
372 .RI [ direction ]
373 .RI [ length\ n ]
374 .RB [ from\ \c
375 .IR Name | picstuff ]
380 draws a single bond in direction from nearest corner of
381 .IR Name .
382 .B bond
383 can also be
384 .BR "double bond" ,
385 .BR "front bond" ,
386 .BR "back bond" ,
387 etc.
389 (We will get back to
390 .I Name
391 soon.)
395 .I direction
396 is the angle in degrees (0\~up, positive clockwise)
397 or a direction word like
398 .BR up ,
399 .BR down ,
400 .B sw
401 (=\~southwest), etc.
403 If no direction is specified, the bond goes in the current direction
404 (usually that of the last bond).
408 Normally the bond begins at the last object placed;  this
409 can be changed by naming a
410 .B from
411 place.
413 For instance, to make a simple alkyl chain:
417 tab (@);
418 lb l.
420 bond@(this one goes right from the CH3)
421 C@(at the right end of the bond)
422 double bond up@(from the C)
423 O@(at the end of the double bond)
424 bond right from C
431 A length in inches may be specified to override the default length.
433 Other
434 .I pic
435 commands can be tacked on to the end of a bond command, to created
436 dotted or dashed bonds or to specify a
437 .B to
438 place.
441 .\" --------------------------------------------------------------------
442 .SS Rings
443 .\" --------------------------------------------------------------------
445 There are lots of rings, but only 5 and 6-sided rings get
446 much support.
448 .B ring
449 by itself is a 6-sided ring;
450 .B benzene
451 is the benzene ring with a circle inside.
452 .B aromatic
453 puts a circle into any kind of ring.
456 .SY ring
457 .RB [ \%pointing\  ( up | right | left | down )]
458 .RB [ \%aromatic ]
459 .RB [ put\ Mol\ at\ \fIn\fP ]
460 .RB [ \%double\ \c
461 .IR i , j\ \c
462 .IR k , l\ \c
463 \*(El]
464 .RI [ picstuff ]
470 The vertices of a ring are numbered 1, 2, \*(El from the
471 vertex that points in the natural compass direction.
473 So for a hexagonal ring with the point at the top, the top vertex
474 is\~1, while if the ring has a point at the east side, that is
475 vertex\~1.
477 This is expressed as
480 .ft B
482 R1: ring pointing up
483 R2: ring pointing right
489 The ring vertices are named
490 .BR .V1 ,
491 \*(El,
492 .BI .V n\fR,\fP
493 with
494 .B .V1
495 in the pointing direction.
497 So the corners of
498 .B R1
500 .B R1.V1
501 (the
502 .IR top ),
503 .BR R1.V2 ,
504 .BR R1.V3 ,
505 .B R1.V4
506 (the
507 .IR bottom ),
508 etc., whereas for
509 .BR R2 ,
510 .B R2.V1
511 is the rightmost vertex and
512 .B R2.V4
513 the leftmost.
515 These vertex names are used for connecting bonds or other rings.  For
516 example,
519 .ft B
521 R1: benzene pointing right
522 R2: benzene pointing right with .V6 at R1.V2
526 creates two benzene rings connected along a side.
530 Interior double bonds are specified as
531 .BI \%double\  n1 , n2\ n3 , n4\ \fR\*(El;\fP
532 each number pair adds an interior bond.
534 So the alternate form of a benzene ring is
537 .B "ring double 1,2 3,4 5,6"
541 Heterocycles (rings with something other than carbon at a vertex) are
542 written as
543 .BI put\  X\  at\  V\fR,\fP
544 as in
547 .B "R: ring put N at 1 put O at 2"
551 In this heterocycle,
552 .B R.N
554 .B R.O
555 become synonyms for
556 .B R.V1
558 .BR R.V2 .
562 There are two 5-sided rings.
564 .B ring5
565 is pentagonal with a side that matches the 6-sided ring; it has four
566 natural directions.
569 .B \%flatring
570 is a 5-sided ring created by chopping one corner of a 6-sided ring so
571 that it exactly matches the 6-sided rings.
575 The description of a ring has to fit on a single line.
578 .\" --------------------------------------------------------------------
579 .SS Moieties and Strings
580 .\" --------------------------------------------------------------------
582 A moiety is a string of characters beginning with a capital letter,
583 such as N(C2H5)2.
585 Numbers are converted to subscripts (unless they appear to be
586 fractional values, as in N2.5H).
588 The name of a moiety is determined from the moiety after special
589 characters have been stripped out: e.g., N(C2H5)2) has the name NC2H52.
593 Moieties can be specified in two kinds.
595 Normally a moiety is placed right after the last thing mentioned,
596 separated by a semicolon surrounded by spaces, e.g.,
599 .B "B1: bond ; OH"
602 Here the moiety is
603 .BR OH ;
604 it is set after a bond.
608 As the second kind a moiety can be positioned as the first word in a
609 .IR pic -like
610 command, e.g.,
613 .B "CH3 at C + (0.5,0.5)"
616 Here the moiety is
617 .BR CH3 .
618 It is placed at a position relative to
619 .BR C ,
620 a moiety used earlier in the chemical structure.
624 So moiety names can be specified as
625 .I chem
626 positions everywhere in the
627 .I chem
628 code.
630 Beneath their printing moieties are names for places.
634 The moiety
635 .B BP
636 is special.
638 It is not printed but just serves as a mark to be referred to in later
639 .I chem
640 commands.
642 For example,
645 .B "bond ; BP"
648 sets a mark at the end of the bond.
650 This can be used then for specifying a place.
652 The name
653 .B BP
654 is derived from
655 .I branch point
656 (i.e., line crossing).
660 A string within double quotes
661 .B \(dq
662 is interpreted as a part of a
663 .I chem
664 command.
666 It represents a string that should be printed (without the quotes).
668 Text within quotes \(dq\*(El\(dq is treated more or less
669 like a moiety except that no changes are made to the quoted part.
672 .\" --------------------------------------------------------------------
673 .SS Names
674 .\" --------------------------------------------------------------------
676 In the alkyl chain above, notice that the carbon atom
677 .B C
678 was used both to draw something and as the name for a place.
680 A moiety always defines a name for a place;  you can use
681 your own names for places instead, and indeed, for rings
682 you will have to.
684 A name is just
687 .IB Name :
688 \*(El
692 .I Name
693 is often the name of a moiety like
694 .BR CH3 ,
695 but it need not to be.
697 Any name that begins with a capital letter and which contains
698 only letters and numbers is valid:
702 .B First:
703 .B bond
706 .B "bond 30 from First"
710 .\" --------------------------------------------------------------------
711 .SS Miscellaneous
712 .\" --------------------------------------------------------------------
714 The specific construction
717 .BR bond\  \*(El " ; moiety"
720 is equivalent to
722 .ft B
724 bond
725 moiety
731 Otherwise, each item has to be on a separate line (and only one line).
732 Note that there must be whitespace after the semicolon which separates
733 the commands.
737 A period character
738 .B .\&
739 or a single quote
740 .B '
741 in the first column of a line signals a
742 .I troff
743 command, which is copied through as-is.
747 A line whose first non-blank character is a hash character
748 .RB ( # )
749 is treated as a comment and thus ignored.
751 However, hash characters within a word are kept.
755 A line whose first word is
756 .B pic
757 is copied through as-is after the word
758 .B pic
759 has been removed.
763 The command
765 .B size
766 .I n
768 scales the diagram to make it look plausible at point size\~\c
769 .I n
770 (default is 10\~point).
774 Anything else is assumed to be
775 .I pic
776 code, which is copied through with a label.
780 Since
781 .B @g@chem
782 is a
783 .B @g@pic
784 preprocessor, it is possible to include
785 .I pic
786 statements in the middle of a diagram to draw things not provided for
788 .I chem
789 itself.
791 Such
792 .I pic
793 statements should be included in
794 .I chem
795 code by adding
796 .B pic
797 as the first word of this line for clarity.
801 The following
802 .I pic
803 commands are accepted as
804 .I chem
805 commands, so no
806 .B pic
807 command word is needed:
810 .B define
811 Start the definition of
812 .I pic
813 macro within
814 .IR chem .
818 .B [
819 Start a block composite.
822 .B ]
823 End a block composite.
826 .B {
827 Start a macro definition block.
830 .B }
831 End a macro definition block.
835 The macro names from
836 .B define
837 statements are stored and their call is accepted as a
838 .I chem
839 command as well.
842 .\" --------------------------------------------------------------------
843 .SS WISH LIST
844 .\" --------------------------------------------------------------------
847 This TODO list was collected by Brian Kernighan.
851 Error checking is minimal; errors are usually detected and reported in
852 an oblique fashion by
853 .IR pic .
857 There is no library or file inclusion mechanism, and there is no
858 shorthand for repetitive structures.
862 The extension mechanism is to create
863 .I pic
864 macros, but these are tricky to get right and don't have all the
865 properties of built-in objects.
869 There is no in-line chemistry yet (e.g., analogous to the $\*(El$
870 construct of eqn).
874 There is no way to control entry point for bonds on groups.
876 Normally a bond connects to the carbon atom if entering from
877 the top or bottom and otherwise to the nearest corner.
881 Bonds from substituted atoms on heterocycles do not join at the proper
882 place without adding a bit of
883 .IR pic .
887 There is no decent primitive for brackets.
891 Text (quoted strings) doesn't work very well.
895 A squiggle bond is needed.
898 .\" --------------------------------------------------------------------
899 .SH "FILES"
900 .\" --------------------------------------------------------------------
903 .FN @DATASUBDIR@/pic/chem.pic
904 A collection of
905 .I pic
906 macros needed by
907 .BR @g@chem .
910 .FN @MACRODIR@/pic.tmac
911 A macro file which redefines
912 .B .PS
914 .BR .PE
915 to center
916 .I pic
917 diagrams.
920 .FN @DOCDIR@/examples/chem/*.chem
921 Example files for
922 .IR chem .
925 .FN @DOCDIR@/examples/chem/122/*.chem
926 Example files from the classical
927 .I chem
928 book
929 .BR 122.ps .
932 .\" --------------------------------------------------------------------
933 .SH "BUGS"
934 .\" --------------------------------------------------------------------
936 Report bugs to the
937 .MT bug-groff@\:gnu.org
938 bug-groff mailing list
939 .ME .
941 Include a complete, self-contained example that will allow the bug to
942 be reproduced, and say which version of
943 .I groff
945 .I chem
946 you are using.
948 You can get both version numbers by calling
949 .BR "@g@chem --version" .
953 You can also use the
954 .MT groff@\:gnu.org
955 groff mailing list
956 .ME ,
957 but you must first subscribe to this list.
959 You can do that by visiting the
960 .UR http://\:lists.gnu.org/\:mailman/\:listinfo/\:groff
961 groff mailing list web page
962 .UE .
967 .BR \%groff (@MAN1EXT@)
968 for information on availability.
971 .\" --------------------------------------------------------------------
972 .SH "SEE ALSO"
973 .\" --------------------------------------------------------------------
975 .BR \%groff (@MAN1EXT@),
976 .BR \%@g@pic (@MAN1EXT@),
977 .BR \%groffer (@MAN1EXT@).
981 You can still get the original
982 .UR http://\:cm.bell-labs.com/\:netlib/\:typesetting/\:chem.gz
983 chem awk source
984 .UE .
987 .FN README
988 file was used for this manual page.
992 The other classical document on
993 .I chem
995 .UR http://\:cm.bell-labs.com/\:cm/\:cs/\:cstr/\:122.ps.gz
996 122.ps
997 .UE .
1000 .\" --------------------------------------------------------------------
1001 .SH "AUTHOR"
1002 .\" --------------------------------------------------------------------
1006 .\" --------------------------------------------------------------------
1007 .SH "COPYING"
1008 .\" --------------------------------------------------------------------
1012 .\" --------------------------------------------------------------------
1013 .\" Emacs settings
1014 .\" --------------------------------------------------------------------
1016 .\" Local Variables:
1017 .\" mode: nroff
1018 .\" End: