tikz.dev / chemfig Manual

chemfig

Operation of chemfig

1 The \chemfig macro

The macro \chemfig has the following syntax

\chemfig[list of ⟨keys⟩=⟨values⟩]{⟨molecule code⟩}

The optional argument in square brackets sets the parameters used for this molecule. It should be noted that the parameters are only modified for the current molecule and will be restored to their previous values after the macro has been executed. To permanently modify parameters, the macro \setchemfig{⟨key⟩=⟨values⟩} should be used.

Here is the complete list of parameters for the \chemfig macro, their default values, and a brief description.

⟨keys⟩default ⟨values⟩Description
chemfig style⟨empty⟩style given to tikz
use atom strutfalseput in the the strut of previous atom in the argument of \printaom
atom style⟨empty⟩style of tikz nodes containing atoms
bond joinfalseboolean for bond joins
fixed lengthfalseboolean for fixed bond widths
cram rectanglefalseboolean to draw rectangle Cram bond
cram width1.5exlength of the base of the triangles Cram bonds
cram dash width1ptwidth of dash Cram bonds
cram dash sep2ptspace between dash Cram bonds
atom sep3emspace between atoms
bond offset2ptspace between atom and bond
double bond sep2ptspace between multiple bonds lines
angle increment45increment of the angle of bonds
node style⟨empty⟩style of atoms
bond style⟨empty⟩style of bonds
baseline0ptdimension or name of node to set the vertical position
debugfalseshow nodes, anchors and names of nodes
cycle radius coeff0.75shrinkage ratio of the circle or arc inside cycles
stack sep1.5ptvertical gap between arguments of \chemabove and \chembelow macros
show cntcyclefalseshow rings numbers
autoreset cntcycletruereset ring counter at \chemfig execution
gchemnametrueif true, makes the depth assignments made by \chemnameinit and \chemname global
savefalseif ⟨true⟩, saves the TikZ commands generated by the \chemfig macro to a file
save name\jobname-fig*sets the file name

The ⟨molecule code⟩ contains instructions for drawing the molecule according to a syntax that will be explained in this document. There are no restrictions on the characters accepted in the code:

  • all catcode 11 or 12 characters, i. e. upper and lower-case letters, numbers, mathematical operators (+ - * / =), punctuation marks whether active or not (. , ; : ! ? ' ` " |), parenthesis and brackets;

  • more special characters such as "~", "#"1 as well as "^" and "_" which have their normal mathematical mode properties;

  • spaces, but these are ignored by default because the atoms are composed in mathematical mode;

  • the "{" and "}" braces that have their normal behavior as group markers or macro argument delimiters;

  • macros.

1 To avoid that # is doubled when the macro \chemfig is in the argument of a macro, instead of #, the macro \# or the macro \CFhash can be used.