LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

chem

groff preprocessor for chemical structure diagrams

TLDR

Process a chem file and view the output
$ chem [path/to/file.chem] | groffer
copy
Process and convert to PostScript
$ chem [path/to/file.chem] | groff -p -Tps > [output.ps]
copy
Process from stdin
$ echo '.cstart\nCH3\nbond\nCH3\n.cend' | chem | groffer
copy
Display version information
$ chem --version
copy

SYNOPSIS

chem [option...] [--] [filespec...]chem -h | --helpchem -v | --version

DESCRIPTION

chem is a groff preprocessor for producing chemical structure diagrams. It translates chemical notation into pic language diagrams, which can then be processed by groff for rendering.The tool is best suited for organic chemistry, supporting bonds, rings, moieties (like CH3, NH3), and strings. Chemical diagrams are enclosed between .cstart and .cend markers.Example input:

$ .cstart
CH3
bond
CH3
.cend
copy
Since chem is a pic preprocessor, raw pic statements can be included within diagrams for custom drawings.

PARAMETERS

-h, --help

Display usage message and exit
-v, --version
Display version information and exit
filespec
Input file or - for stdin. Without arguments, reads stdin

INSTALL

sudo apt install groff
copy
sudo dnf install groff
copy
sudo pacman -S groff
copy
sudo apk add groff
copy
sudo zypper install groff
copy
brew install groff
copy
nix profile install nixpkgs#groff
copy

CAVEATS

No library or file inclusion mechanism exists. No shorthand for repetitive structures. The extension mechanism uses pic macros, which can be tricky to implement correctly.There is no in-line chemistry syntax (like eqn's $...$ construct) and no way to control bond entry points on groups.

HISTORY

The GNU version of chem was written by Bernd Warken, based on documentation of Brian Kernighan's original awk version. The chemical structure diagram language was developed at Bell Labs alongside other troff preprocessors like eqn and pic.

SEE ALSO

groff(1), pic(1), eqn(1), groffer(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid