In a Metanorma document
@cite-annotated molecules become bibliography entries
automatically — Chemistry in Metanorma.
A molecule in a standards document is a substance with identity, not glyphs. AsciiChem closes that loop: resolve an identifier, then emit a dataset-type Relaton bibitem for the source you choose to cite.
substance = AsciiChem::Resolver.resolve(value: "50-78-2", convention: "cas")xml = AsciiChem::Citation.to_xml(substance) # Relaton <bibitem type="dataset">From the CLI:
asciichem cite --cas 50-78-2A bibitem can only be built from a resolved substance — the resolver’s provenance (source, retrieved-at, attribution) is what the citation is made of. Ask a hand-built substance for a bibitem and the builder tells you to resolve it first.
@citeAttach the citation intent to the molecule itself. The @cite
property annotation names the source you want to cite, and the
molecule’s other identifiers say who to resolve it as:
CC(=O)OC1=CC=CC=C1C(=O)O @cas("50-78-2") @cite("pubchem")asciichem gem to see this rendered.
Then the bibitem is a function of the parse tree:
molecule = AsciiChem.parse(source).nodes.firstAsciiChem::Citation.for_molecule(molecule)# => [["pubchem", #<Relaton::Bibitem ...>]]for_molecule resolves via the strongest identifier available
(@cas, @inchikey, @inchi/@smiles, then names) and returns one
[source, bibitem] pair per cited source. Annotate once, cite
anywhere — the citation follows the molecule through every format.
This is the real output for aspirin resolved from PubChem (whitespace as emitted):
<bibitem id="PubChemCID2244" type="dataset"> <title type="main">2-acetyloxybenzoic acid - PubChem, U.S. National Library of Medicine substance record</title> <uri type="src">https://pubchem.ncbi.nlm.nih.gov/compound/2244</uri> <docidentifier type="pubchem">PubChem CID 2244</docidentifier> <date type="accessed"> <on>2026-11-03</on> </date> <contributor> <role type="publisher"/> <organization> <name>PubChem, U.S. National Library of Medicine</name> </organization> </contributor> <keyword><vocab>pubchem-cid=2244</vocab></keyword> <keyword><vocab>inchikey=BSYNRYMUTXBXSQ-UHFFFAOYSA-N</vocab></keyword> <keyword><vocab>inchi=InChI=1S/C9H8O4/...</vocab></keyword> <keyword><vocab>canonical-smiles=CC(=O)OC1=CC=CC=C1C(=O)O</vocab></keyword></bibitem>Every field answers a data-citation question (who published this, what exactly, where, as of when) — and the keywords carry every identifier the source returned, so a citation stays machine-checkable against its InChIKey long after a URL changes.
Per source, the fields differ the way two documents about one substance differ:
| Field | PubChem | CAS Common Chemistry |
|---|---|---|
| Publisher | PubChem, U.S. National Library of Medicine | CAS Common Chemistry |
| Title | name - PubChem, U.S. National Library of Medicine substance record | name - CAS Common Chemistry substance record |
| Docidentifier | PubChem CID 2244 | CAS RN 50-78-2 |
| Source link | pubchem.ncbi.nlm.nih.gov/compound/{cid} | commonchemistry.cas.org/detail?cas_rn={rn} |
| Version | accessed date, from the record’s provenance | accessed date, from the record’s provenance |
| Extra identifiers | CID, InChIKey, InChI, canonical SMILES | CAS RN, InChIKey, canonical SMILES, InChI, IUPAC name |
Adding a source means adding one citation profile next to its resolver adapter — the builder itself never changes.
Two databases agreeing on a substance are still two different documents. Resolution is multi-source; citation is per-source — pick the sources you trust, cite each once. The same substance cited twice from one source yields one deduplicated entry; the same substance cited from two sources yields two entries, both describing the same molecule.
Deduplication and cross-referencing anchor on the InChIKey — the
fixed-length, structure-derived identifier that plays the role for
substances that the DOI plays for literature. In Metanorma documents
the plugin rewrites each bibitem’s anchor to its InChIKey
(BSYNRYMUTXBXSQ-UHFFFAOYSA-N above), so <<BSYNRYMUTXBXSQ-UHFFFAOYSA-N>>
cross-references work regardless of which source was cited, and two
documents citing the same substance from different databases still
link to the same identity.
Every resolved record carries its provenance — source, retrieved-at
timestamp, license attribution — and the bibitem’s accessed date comes
straight from that provenance. Resolution caches records in your user
cache directory (never inside the gem), with a 7-day TTL; --refresh
bypasses it.
That makes document builds reproducible: point a Metanorma document
at a seeded cache (:asciichem-cache-dir:, see
Chemistry in Metanorma) and every rebuild emits
byte-identical bibitems — the accessed dates come from the cached
records, not from the wall clock.
Which source you cite is also a licensing decision:
# all shipped sources (PubChem, OPSIN, Common Chemistry) are registeredAsciiChem::Resolver.resolve(value: '50-78-2', convention: 'cas')
# limit the set when your use requires itAsciiChem::Resolver.resolve(value: '50-78-2', convention: 'cas', sources: [:pubchem, :opsin])Live availability. CAS key-gated the Common Chemistry API:
anonymous calls answer 401 Unauthorized. The token is the user’s
to provide — request one at
cas.org/services/commonchemistry-api
(valid 12 months; CAS emails a renewal notice) and either export it
as COMMON_CHEMISTRY_API_KEY or store it at
~/.config/cas-common-chemistry-api.key (asciichem 0.31.15 sends
it as the X-API-KEY header on the /direct-api endpoint, exactly
as CAS’s access email specifies). Without a token, live lookups
against common_chemistry return no record: the resolver skips the
source (a failing source never poisons the others), documents warn
and emit no bibitem, and seeded-cache records keep resolving
offline. Resolution continues against PubChem and OPSIN. There is
no bulk-download or GitHub copy of the Common Chemistry dataset —
the API and the web UI are CAS’s only distribution channels, and
the CC-derived records PubChem mirrors resolve key-free through
PubChem itself, with PubChem provenance.
The obligations ride with the data, and the gem is built so you can
meet them: the required attribution
(CAS Common Chemistry (CC BY-NC 4.0)) rides in every record’s
provenance — including cached records — and into every emitted
bibitem as a type="provenance" note, so whatever you publish
downstream still carries it. Keep that attribution intact when you
redistribute. If the NC terms don’t fit your use, limit sources (in
Ruby with sources:, or in Metanorma documents with the
:asciichem-sources: attribute — see
Chemistry in Metanorma); PubChem’s record for
the same substance remains available either way.
Results are cached in your user cache directory (TTL’d, attribution
included); --refresh bypasses the cache.
In a Metanorma document
@cite-annotated molecules become bibliography entries
automatically — Chemistry in Metanorma.
Where records come from
Resolution, provenance, and the interchange subset — Structures and resolution.
Try it live
Paste a database SMILES and see the model — the playground parses SMILES and molfile in your browser.