{
    "mode": "man",
    "parameter": "CHEM",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/CHEM/1/json",
    "generated": "2026-06-03T09:46:01Z",
    "synopsis": "chem [--] [filespec ...]",
    "sections": {
        "NAME": {
            "content": "chem - groff preprocessor for producing chemical structure diagrams\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "chem [--] [filespec ...]\n",
            "subsections": [
                {
                    "name": "chem -h",
                    "content": ""
                },
                {
                    "name": "chem --help",
                    "content": ""
                },
                {
                    "name": "chem -v",
                    "content": ""
                },
                {
                    "name": "chem --version",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "chem  produces chemical structure diagrams.  Today's version is best suited for organic chem‐\nistry (bonds, rings).  The chem program is a groff preprocessor like eqn, pic, tbl, etc.   It\ngenerates  pic  output  such that all chem parts are translated into diagrams of the pic lan‐\nguage.\n\nA filespec argument is either a file name of an existing file or a minus character -, meaning\nstandard  input.  If no argument is specified then standard input is taken automatically.  -h\nand --help display a usage message, whereas -v and --version display version information; all\nexit.\n\nThe  program  chem  originates  from the Perl source file chem.pl.  It tells pic to include a\ncopy of the macro file chem.pic.  Moreover the groff source file pic.tmac is loaded.\n\nIn a style reminiscent of eqn and pic, the chem diagrams are written in a special language.\n\nA set of chem lines looks like this\n\n.cstart\nchem data\n.cend\n\nLines containing the keywords .cstart and .cend start and end the  input  for  chem,  respec‐\ntively.  In pic context, i.e., after the call of .PS, chem input can optionally be started by\nthe line begin chem and ended by the line with the single word end instead.\n\nAnything outside these initialization lines is copied through without modification; all  data\nbetween the initialization lines is converted into pic commands to draw the diagram.\n\nAs an example,\n\n.cstart\nCH3\nbond\nCH3\n.cend\n\nprints two CH3 groups with a bond between them.\n\nTo actually view this, you must run chem followed by groffer:\n\nchem [file ...] | groffer\n\nIf  you want to create just groff output, you must run chem followed by groff with the option",
            "subsections": [
                {
                    "name": "-p",
                    "content": "chem [file ...] | groff -p ...\n",
                    "flag": "-p"
                }
            ]
        },
        "THE LANGUAGE": {
            "content": "The chem input language is rather small.  It provides rings of several styles and  a  way  to\nglue  them  together  as  desired,  bonds of several styles, moieties (e.g., C, NH3, ..., and\nstrings.\n",
            "subsections": [
                {
                    "name": "Setting Variables",
                    "content": "There are some variables that can be set by commands.  Such commands have two possible forms,\neither\n\nvariable value\n\nor\n\nvariable = value\n\nThis  sets  the  given  variable to the argument value.  If more arguments are given only the\nlast argument is taken, all other arguments are ignored.\n\nThere are only a few variables to be set by these commands:\n\ntextht arg\nSet the height of the text to arg; default is 0.16.\n\ncwid arg\nSet the character width to arg; default is 0.12.\n\ndb arg Set the bond length to arg; default is 0.2.\n\nsize arg\nScale the diagram to make it look plausible at point size arg; default is 10 point.\n"
                },
                {
                    "name": "Bonds",
                    "content": "This\n\nbond [direction] [length n] [from Name|picstuff]\n\ndraws a single bond in direction from nearest corner of Name.  bond can also be double  bond,\nfront bond, back bond, etc.  (We will get back to Name soon.)\n\ndirection  is  the  angle  in degrees (0 up, positive clockwise) or a direction word like up,\ndown, sw (= southwest), etc.  If no direction is specified, the bond goes in the current  di‐\nrection (usually that of the last bond).\n\nNormally  the  bond  begins  at the last object placed;  this can be changed by naming a from\nplace.  For instance, to make a simple alkyl chain:\n\nCH3\nbond                (this one goes right from the CH3)\nC                   (at the right end of the bond)\ndouble bond up      (from the C)\nO                   (at the end of the double bond)\nbond right from C\nCH3\n\nA length in inches may be specified to override the default length.  Other pic  commands  can\nbe  tacked on to the end of a bond command, to created dotted or dashed bonds or to specify a\nto place.\n"
                },
                {
                    "name": "Rings",
                    "content": "There are lots of rings, but only 5 and 6-sided rings get much support.  ring by itself is  a\n6-sided  ring; benzene is the benzene ring with a circle inside.  aromatic puts a circle into\nany kind of ring.\n\nring [pointing (up|right|left|down)] [aromatic] [put Mol at n] [double i,j k,l ...\n[picstuff]\n\nThe vertices of a ring are numbered 1, 2, ... from the vertex that points in the natural com‐\npass direction.  So for a hexagonal ring with the point at the top,  the  top  vertex  is  1,\nwhile if the ring has a point at the east side, that is vertex 1.  This is expressed as\n\nR1: ring pointing up\nR2: ring pointing right\n\nThe  ring  vertices are named .V1, ..., .Vn, with .V1 in the pointing direction.  So the cor‐\nners of R1 are R1.V1 (the top), R1.V2, R1.V3, R1.V4 (the bottom), etc., whereas for R2, R2.V1\nis  the  rightmost vertex and R2.V4 the leftmost.  These vertex names are used for connecting\nbonds or other rings.  For example,\n\nR1: benzene pointing right\nR2: benzene pointing right with .V6 at R1.V2\n\ncreates two benzene rings connected along a side.\n\nInterior double bonds are specified as double n1,n2 n3,n4 ...; each number pair adds an inte‐\nrior bond.  So the alternate form of a benzene ring is\n\nring double 1,2 3,4 5,6\n\nHeterocycles  (rings with something other than carbon at a vertex) are written as put X at V,\nas in\n\nR: ring put N at 1 put O at 2\n\nIn this heterocycle, R.N and R.O become synonyms for R.V1 and R.V2.\n\nThere are two 5-sided rings.  ring5 is pentagonal with a side that matches the 6-sided  ring;\nit  has four natural directions.  A flatring is a 5-sided ring created by chopping one corner\nof a 6-sided ring so that it exactly matches the 6-sided rings.\n\nThe description of a ring has to fit on a single line.\n"
                },
                {
                    "name": "Moieties and Strings",
                    "content": "A moiety is a string of characters beginning with a capital letter, such as  N(C2H5)2.   Num‐\nbers  are  converted to subscripts (unless they appear to be fractional values, as in N2.5H).\nThe name of a moiety is determined  from  the  moiety  after  special  characters  have  been\nstripped out: e.g., N(C2H5)2) has the name NC2H52.\n\nMoieties  can  be  specified  in two kinds.  Normally a moiety is placed right after the last\nthing mentioned, separated by a semicolon surrounded by spaces, e.g.,\n\nB1: bond ; OH\n\nHere the moiety is OH; it is set after a bond.\n\nAs the second kind a moiety can be positioned as the first word in a pic-like command, e.g.,\n\nCH3 at C + (0.5,0.5)\n\nHere the moiety is CH3.  It is placed at a position relative to C, a moiety used  earlier  in\nthe chemical structure.\n\nSo  moiety  names  can  be  specified as chem positions everywhere in the chem code.  Beneath\ntheir printing moieties are names for places.\n\nThe moiety BP is special.  It is not printed but just serves as a mark to be referred  to  in\nlater chem commands.  For example,\n\nbond ; BP\n\nsets  a mark at the end of the bond.  This can be used then for specifying a place.  The name\nBP is derived from branch point (i.e., line crossing).\n\nA string within double quotes \" is interpreted as a part of a chem command.  It represents  a\nstring that should be printed (without the quotes).  Text within quotes \"...\" is treated more\nor less like a moiety except that no changes are made to the quoted part.\n"
                },
                {
                    "name": "Names",
                    "content": "In the alkyl chain above, notice that the carbon atom C was used both to draw  something  and\nas  the  name for a place.  A moiety always defines a name for a place;  you can use your own\nnames for places instead, and indeed, for rings you will have to.  A name is just\n\nName: ...\n\nName is often the name of a moiety like CH3, but it need not to be.   Any  name  that  begins\nwith a capital letter and which contains only letters and numbers is valid:\n\nFirst: bond\nbond 30 from First\n"
                },
                {
                    "name": "Miscellaneous",
                    "content": "The specific construction\n\nbond ... ; moiety\n\nis equivalent to\n\nbond\nmoiety\n\nOtherwise,  each item has to be on a separate line (and only one line).  Note that there must\nbe whitespace after the semicolon which separates the commands.\n\nA period character . or a single quote ' in the first column of a line signals a  troff  com‐\nmand, which is copied through as-is.\n\nA  line  whose  first non-blank character is a hash character (#) is treated as a comment and\nthus ignored.  However, hash characters within a word are kept.\n\nA line whose first word is pic is copied through as-is after the word pic has been removed.\n\nThe command\n\nsize n\n\nscales the diagram to make it look plausible at point size n (default is 10 point).\n\nAnything else is assumed to be pic code, which is copied through with a label.\n\nSince chem is a pic preprocessor, it is possible to include pic statements in the middle of a\ndiagram  to  draw  things not provided for by chem itself.  Such pic statements should be in‐\ncluded in chem code by adding pic as the first word of this line for clarity.\n\nThe following pic commands are accepted as chem commands, so no pic command word is needed:\n\ndefine Start the definition of pic macro within chem.\n\n[      Start a block composite.\n\n]      End a block composite.\n\n{      Start a macro definition block.\n\n}      End a macro definition block.\n\nThe macro names from define statements are stored and their call is accepted as a  chem  com‐\nmand as well.\n\nWISH LIST\nThis TODO list was collected by Brian Kernighan.\n\nError  checking is minimal; errors are usually detected and reported in an oblique fashion by\npic.\n\nThere is no library or file inclusion mechanism, and there is  no  shorthand  for  repetitive\nstructures.\n\nThe  extension mechanism is to create pic macros, but these are tricky to get right and don't\nhave all the properties of built-in objects.\n\nThere is no in-line chemistry yet (e.g., analogous to the $...$ construct of eqn).\n\nThere is no way to control entry point for bonds on groups.  Normally a bond connects to  the\ncarbon atom if entering from the top or bottom and otherwise to the nearest corner.\n\nBonds from substituted atoms on heterocycles do not join at the proper place without adding a\nbit of pic.\n\nThere is no decent primitive for brackets.\n\nText (quoted strings) doesn't work very well.\n\nA squiggle bond is needed.\n"
                }
            ]
        },
        "FILES": {
            "content": "/usr/share/groff/1.22.4/pic/chem.pic\nA collection of pic macros needed by chem.\n\n/usr/share/groff/1.22.4/tmac/pic.tmac\nA macro file which redefines .PS and .PE to center pic diagrams.\n\n/usr/share/doc/groff-base/examples/chem/*.chem\nExample files for chem.\n\n/usr/share/doc/groff-base/examples/chem/122/*.chem\nExample files from the classical chem article CHEM – A Program for Typesetting  Chemi‐\ncal Structure Diagrams [CSTR #122].\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "The  GNU  version  of chem was written by Bernd Warken ⟨groff-bernd.warken-72@web.de⟩.  It is\nbased on the documentation of Brian Kernighan's original awk  version  of  chem  at  ⟨http://\ncm.bell-labs.com/cm/cs/who/bwk/index.html⟩.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "groff(1), pic(1), groffer(1).\n\nYou  can  still get the original chem awk source ⟨http://cm.bell-labs.com/netlib/typesetting/\nchem.gz⟩.  Its README file was used for this manual page.\n\nThe other classical document on chem is CHEM – A Program for Typesetting  Chemical  Structure\nDiagrams [CSTR #122] ⟨http://cm.bell-labs.com/cm/cs/cstr/122.ps.gz⟩.\n\n\n\ngroff 1.22.4                                23 March 2022                                    CHEM(1)",
            "subsections": []
        }
    },
    "summary": "chem - groff preprocessor for producing chemical structure diagrams",
    "flags": [
        {
            "flag": "-p",
            "long": null,
            "arg": null,
            "description": "chem [file ...] | groff -p ..."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "groff",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/groff/1/json"
        },
        {
            "name": "pic",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pic/1/json"
        },
        {
            "name": "groffer",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/groffer/1/json"
        }
    ]
}