The argument code is a set of characters that describes the structure of the molecule according to the rules described in this manual. ChemFig always places the first atom of a molecule on the baseline of the preceding code.
Complete structural diagram
Condensed structural diagram
Cram representation
Skeleton diagram
Lewis diagrams
The command\setbondoffset{
Absolute angles
This optional argument can customize every aspect of a connection, and consists of five optional fields separated by commas. When the angle field contains an integer, it represents the angle the bond makes relative to the horizontal, in multiples of 45◦.
Relative angles
90◦ and 90◦ (modulo 360◦), then the bond is formed between the last atom in the first group and the first atom in the second group. In all other cases, the bond is formed between the first atom of the first group and the last atom of the second group.
Nesting
Each sub-molecule's code can define its own default values, which will be valid across the entire sub-molecule. We see that the angle between the B-C bond and the B-X bond is 30◦ because it is a relative angle for the "-X-Y" submolecule.
Method
Another submolecule X-Y" is attached to "B" with a standard bond angle 60◦ smaller than that of the previous bond (which will be the one between "A" and "B") and with an interatomic distance of 1.5 times the standard value: .Secondly, the field can be one of the binding characters, provided that character is enclosed in braces.
Syntax
On the first occurrence of the hook with this name, only this field is used. lt;bond>specifies how the atom with the current occurrence of the named hook should bond to the atom with the first occurrence of the hook. The previous example shows how to draw a regular polygon, but the method used is tedious because the angles depend on the number of sides of the polygon.
Angular position
At the start
If this angular position is not convenient, it is possible to specify a different angle using the optional argument at the beginning of the molecule.
After a bond
Branches on a ring
It is worth noting that in the third case, where a relative angle of 0◦ was given, the branch bonds are drawn according to the previous bond in the ring. This is the rule on page 13 which states that the reference angle is the angle of the last bond drawn.
Nested rings
In this example, it can be seen that the fourth side of the second 5-ring just passes through the center of the "E" atom. This is normal because the second 5-ring (which is attached to the "D" atom) is drawn before ChemFig learns about the "E" atom.
Rings and groups of atoms
We can use all the power of tikz instructions to change the style of the arrow. Note that the tail of the arrow does not correctly depart from our electrons; it departs from the center of the top edge of the node.
Reaction mechanisms
A horizontal bond leaves the center of the right side of the bounding box of the exit atom of that bond. It follows that the vertical position of the future atom depends on the height of the outgoing atom. The atoms remaining in each group are aligned so that their baseline coincides with the baseline of the preceding atom.
The atoms "B" and "F" are correctly aligned as they reflect the height of the atoms in front of them due to their\vphantom. For the atoms "C" and "F" the heights of the immediately preceding atoms are taken into account, but those of the atoms "A^1" and "E_1" are ignored. It is possible to move a double bond so that one of the line segments lies on the imaginary line.
But in some cases, this feature saves a lot of space in the molecule code and increases readability. All the decorations drawn by \lewis are not included in the bounding box of the atom; are drawn subsequently.
Stacking characters
The impression of greater distance is due to the shape of the letter "O" which is further from one of the border boxes in the corners, that is to say in strange directions. To move closer (or further) to the Lewis drawings in strange directions, the\lewisand\Lewis accepts an optional argument containing a factor that multiplies the gap between the bounding box and decoration that Lewis sets by the\setlewis command.
Chemical reactions
- Absolute angles
- Relative angles
- Ring
- Nested rings
These defaults can be overridden with macro\setnodestyle, whose argument is passed to tikz and specifies the style of the nodes containing the atoms. In this example we only specify "draw,inner sep=2pt", which has the effect of drawing the outline of the nodes and separating the outline and content of the node by 2pt. We also specify\setbondoffset{0pt}\setbondoffset so that the bonds touch the edges of the nodes.
The goal here is to show a logical order for assembling a molecule so that the user unfamiliar with ChemFig will learn how to build complex molecules. In addition, several options will be shown - some intuitive and others less so - which give the same graphical results, in order to show that ChemFiga allows some flexibility in the coding of molecules. The three hydrogen atoms still need to be placed in the correct orientation with the help of predetermined angles.
Since the angles between the bonds are 120◦ it is possible to use a 6-ring, although this method is less natural. A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete 6-ring11 Despite its brevity, this code does not give a perfect drawing.
Glucose
Skeleton diagram
Fisher projection
Let's choose "x" which we will put in place of the lowercase letters a, c and d, and "y" which will replace the letter c. To do this, we will first draw five sides of the chair and connect the first vertex to the last with a hook.
Haworth projection
Next, we define two aliases for the horizontal bonds and the atoms at their ends. Next, to give the impression of perspective to the ring, the diagonal bonds will be shortened by a coefficient of 0.7. For the bold diagonal lines we will use Cram bindings, after redefining the base of the triangles to be 2pt.
The bold horizontal line should be drawn with a thickness of 2 pt, so it will be its optional argument. All that needs to be done now is to add the branches in the right places, give the right absolute angles and sometimes reduce the length to better create the illusion of perspective:.
Adrenaline
Using one ring
Using two rings
Guanine
Write a colored atom
Add a superscript without modifying a bond
If you want to use the command\oplus that shows "⊕", some may find the charge too low:A⊕. In fact, since we specify "-0.5pt" for the optional argument \chemabove to lower the charge, it is necessary to prevent ChemFig from understanding the "-" sign as a single bond.
Draw a curve bond
Modify the size of a molecule
Draw a ploymer element
Draw the symmetrical of a molecule
Add text above bonds and arc to angles
The connections at the beginning and at the end of the arrow are called "n1" and "n2" respectively. As noted above, arrows lie on the line connecting the center of the bounding boxes of the connections. Within the parenthetical argument of the \arrow command, the name of the arrow can be followed by optional arguments enclosed in parentheses.
Label angles can be specified, while default is the same angle as that of the arrow. CF@arrow@start@nameand\CF@arrow@end@name include the names of the connections (considered by tikz to be nodes) between which the arrow is drawn;. After these names, user-defined anchors can be specified in the bracketed argument of the . arrow command, unless the field is left blank;.
CF@arrow@current@styled\CF@arrow@current@angle contain the style and angle of the arrow to be drawn;. This is done with the macro\CF@arrow@shift@nodes, so the arrow code will start with:\CF@arrow@shift@nodes{#3}%.
Curved arrow
First, the position of the nodes between which the arrow is to be drawn must be changed to account for the third argument shift. Then plot the arrow itself, taking the opportunity to put a node on the middle of the segment, which will be called "mid@point". As with the \arrow command, the "n.a[s]" command includes the name, anchor, and style of the target link.
In terms of arrow geometry, it consists of segments that extend from the compounds to the perpendicular line connecting them: the default length of the shortest of these segments is half the compound separation distance defined by \setcompoundsep. The arrow drawn from the connecting line to the target complex has the same default length, its origin is in the middle of the connecting line. If an argument is left blank or if the argument in parentheses is missing, the dimensions take their default values, which can be specified with the command\setandsign{
A common problem can be the misalignment of the "+" sign with the molecules before or after it. Here the "+" sign sits on the same baseline as the compound before it, and this baseline is that of the top carbon atom. Thus, the first compound "c1" consists of the first molecule and the second compound consists of all the others, i.e.
Lewis[coeff]{.