table of contents
CHEM(1) | General Commands Manual | CHEM(1) |
NAME¶
chem - groff preprocessor for producing chemical structure diagramsSYNOPSIS¶
[option...] [--] [filespec...] -h | --help -v | --versionOPTION USAGE¶
There are no other options than -h, --help, -v, and --version; these options provoke the printing of a version or usage information, respectively, and all filespec arguments are ignored. A filespec argument is either a file name of an existing file or a minus character -, meaning standard input. If no argument is specified then standard input is taken automatically.DESCRIPTION¶
chem produces chemical structure diagrams. Today's version is best suited for organic chemistry (bonds, rings). The chem program is a groff preprocessor like eqn, pic, tbl, etc. It generates pic output such that all chem parts are translated into diagrams of the pic language. The program chem originates from the Perl source file $@ It tells pic to include a copy of the macro file $@ Moreover the groff source file $@ is loaded. In a style reminiscent of eqn and pic, the chem diagrams are written in a special language. A set of chem lines looks like this-
.cstart chem data .cend
-
.cstart CH3 bond CH3 .cend
- chem [file...] | groffer
- chem [file...] | groff -p ...
THE LANGUAGE¶
The chem input language is rather small. It provides rings of several styles and a way to glue them together as desired, bonds of several styles, moieties (e.g., C, NH3, ...), and strings.Setting Variables¶
There are some variables that can be set by commands. Such commands have two possible forms, either
variable value
or
variable = value
This sets the given variable to the argument value. If more
arguments are given only the last argument is taken, all other arguments are
ignored.
There are only a few variables to be set by these commands:
- textht arg
- Set the height of the text to arg; default is 0.16.
- cwid arg
- Set the character width to arg; default is 0.12.
- db arg
- Set the bond length to arg; default is 0.2.
- size arg
- Scale the diagram to make it look plausible at point size arg; default is 10 point.
Bonds¶
This[direction] [length n]
[from Name|picstuff]
draws a single bond in direction from nearest corner of Name. bond
can also be double bond, front bond, back bond, etc. (We
will get back to Name soon.)
direction is the angle in degrees (0 up, positive clockwise) or a
direction word like up, down, sw (= southwest),
etc. If no direction is specified, the bond goes in the current direction
(usually that of the last bond).
Normally the bond begins at the last object placed; this can be changed by
naming a from place. For instance, to make a simple alkyl chain:
CH3 | |
bond | (this one goes right from the CH3) |
C | (at the right end of the bond) |
double bond up | (from the C) |
O | (at the end of the double bond) |
bond right from C | |
CH3 |
Rings¶
There are lots of rings, but only 5 and 6-sided rings get much support. ring by itself is a 6-sided ring; benzene is the benzene ring with a circle inside. aromatic puts a circle into any kind of ring.[pointing (up|right|left|down)]
[aromatic] [put Mol at n]
[double i,j k,l ...]
[picstuff]
The vertices of a ring are numbered 1, 2, ... from the vertex that points in the
natural compass direction. So for a hexagonal ring with the point at the top,
the top vertex is 1, while if the ring has a point at the east side,
that is vertex 1. This is expressed as
-
R1: ring pointing up R2: ring pointing right
-
R1: benzene pointing right R2: benzene pointing right with .V6 at R1.V2
- ring double 1,2 3,4 5,6
- R: ring put N at 1 put O at 2
Moieties and Strings¶
A moiety is a string of characters beginning with a capital letter, such as N(C2H5)2. Numbers are converted to subscripts (unless they appear to be fractional values, as in N2.5H). The name of a moiety is determined from the moiety after special characters have been stripped out: e.g., N(C2H5)2) has the name NC2H52. Moieties can be specified in two kinds. Normally a moiety is placed right after the last thing mentioned, separated by a semicolon surrounded by spaces, e.g.,- B1: bond ; OH
- CH3 at C + (0.5,0.5)
- bond ; BP
Names¶
In the alkyl chain above, notice that the carbon atom C was used both to draw something and as the name for a place. A moiety always defines a name for a place; you can use your own names for places instead, and indeed, for rings you will have to. A name is just- Name: ...
- First:
- bond bond 30 from First
Miscellaneous¶
The specific construction- bond ... ; moiety
-
bond moiety
- size n
- define Start the definition of pic macro within chem.
- [
- Start a block composite.
- ]
- End a block composite.
- {
- Start a macro definition block.
- }
- End a macro definition block.
WISH LIST¶
This TODO list was collected by Brian Kernighan. Error checking is minimal; errors are usually detected and reported in an oblique fashion by pic. There is no library or file inclusion mechanism, and there is no shorthand for repetitive structures. The extension mechanism is to create pic macros, but these are tricky to get right and don't have all the properties of built-in objects. There is no in-line chemistry yet (e.g., analogous to the $...$ construct of eqn). There is no way to control entry point for bonds on groups. Normally a bond connects to the carbon atom if entering from the top or bottom and otherwise to the nearest corner. Bonds from substituted atoms on heterocycles do not join at the proper place without adding a bit of pic. There is no decent primitive for brackets. Text (quoted strings) doesn't work very well. A squiggle bond is needed.FILES¶
- $@
- A collection of pic macros needed by chem.
- $@
- A macro file which redefines .PS and .PE to center pic diagrams.
- $@
- Example files for chem.
- $@
- Example files from the classical chem book 122.ps.
BUGS¶
Report bugs to the bug-groff mailing list Include a complete, self-contained example that will allow the bug to be reproduced, and say which version of groff and chem you are using. You can get both version numbers by calling chem --version. You can also use the groff mailing list but you must first subscribe to this list. You can do that by visiting the groff mailing list web page See groff(1) for information on availability.SEE ALSO¶
groff(1), pic(1), groffer(1). You can still get the original chem awk source Its $@ file was used for this manual page. The other classical document on chem is 122.psAUTHOR¶
This file was written by Bernd Warken <groff-bernd.warken-72@web.de>. It is based on the documentation of Brian Kernighan original awk version of chem.COPYING¶
Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of chem, which is part of groff, a free software project. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2, or (at your option) any later version. You should have received a copy of the GNU General Public License along with groff, see the files COPYING and LICENSE in the top directory of the groff source package. Or read the man page gpl(1). You can also write to the Free Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.07 February 2013 | Groff Version 1.22.2 |