64
ChemFig v0.4b April 24, 2011 Christian Tellechea AT E X package for drawing molecules O O N H OH O O H O CH3 CH3 O H O CH3 OH O O CH3 O O O CH3 Taxotere R 0 R N OH H R 0 R N O H2 -H2O R 0 N C R R 0 N C R H2 O R 0 N R O H2 -H R 0 N R OH R 0 N H R O The Beckmann rearrangement

Chemfig Doc En

Embed Size (px)

Citation preview

Page 1: Chemfig Doc En

ChemFigv04b

April 24 2011

Christian Tellechea

A TEX package for drawing molecules

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

Taxotere

Rprime R

NOH

Hoplus

Rprime R

NOoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2 minusH

oplus

Rprime

N R

OH

Rprime

NH

R

O

The Beckmann rearrangement

ChemFig CONTENTS

Contents

I Introduction 3

1 New in version 04b 3

2 Foreword 3

3 Presenting ChemFig 4

II ChemFig for the impatient 5

1 Syntax 5

2 The diUerent types of bonds 5

3 DiUerent types of diagrams 631 Complete structural diagram 632 Condensed structural diagram 633 Cram representation 734 Skeleton diagram 735 Lewis diagrams 7

4 Branched molecules 7

5 Rings 8

6 Ions 9

7 Chemical equations 9

III Operation of ChemFig 10

1 Groups of atoms 10

2 DiUerent types of bonds 10

3 Bond angle 1231 PredeVned angles 1232 Absolute angles 1233 Relative angles 12

4 Length of a bond 13

5 Departure and arrival atoms 14

6 Customization of bonds 14

7 Default values 15

8 Branches 1581 Principle 1582 Nesting 1683 Method 16

9 Connecting distant atoms 17

LATEXed by Christian Tellechea the April 24 2011 1

ChemFig CONTENTS

10 Rings 18101 Syntax 18102 Angular position 19

1021 At the start 191022 After a bond 20

103 Branches on a ring 20104 Nested rings 21105 Rings and groups of atoms 22

11 Representing electron movements 22111 Mesomeric eUects 23112 Reaction mechanisms 25

12 Writing a name under a molecule 25

IV Advanced usage 27

1 Separating atoms 27

2 Displaying atoms 27

3 Optional arguments 28

4 Vertical alignment 29

5 Shifted double bonds 30

6 Delocalized double bonds 31

7 Saving a sub-molecule 31

8 Decorations 3281 Lewis diagrams 3282 Stacking characters 3383 Chemical reactions 34

9 Using chemfig in the tikzpicture environment 35

10 Beyond chemistry 35

11 Annotated examples 36111 Ethanal 37112 2-amino-4-oxohexanoic acid 37

1121 Absolute angles 371122 Relative angles 381123 Ring 381124 Nested rings 38

113 Glucose 391131 Skeleton diagram 391132 Fisher projection 391133 ldquoChairrdquo representation 401134 Haworth projection 41

114 Adrenaline 411141 Using one ring 411142 Using two rings 42

115 Guanine 43

LATEXed by Christian Tellechea the April 24 2011 2

ChemFig 2 FOREWORD

12 How to 44121 Write a colored atom 44122 Add a superscript without modifying a bond 45123 Draw a curve bond 45124 Modify the size of a molecule 46125 Draw a ploymer element 46126 Draw the symmetrical of a molecule 47127 Add text above bonds and arc to angles 47

13 List of commands 48

V Gallery 50

Index 62

PART I

Introduction

1 New in version 04b

Herersquos whatrsquos new in version 04b

1 the argument of the chemfig command is no longer dependent of the catcode regime Therefore thechemfig command can be put inside arguments of macros even if the molecule code contains characterswith an active catcode like ldquo~rdquo It is now possible to write1 in a LATEX document something like

sectionThe molecule protectchemfigN~N

ldquordquo is the exception to this rule In order to put in an argument of a macro the command chemfig with amolecule code containing you must wrap it between ldquocatcodelsquo=12rdquo and ldquocatcodelsquo=6rdquo

2 The new setbondstyle command sets the style of the bonds see page 11

2 Foreword

This package has seen the light of day thanks to the assistance of Christophe Casseau who had the idea afterbeing confronted with the complexity of the syntax of the ppchtex package

Throughout the writing of the code he helped me Vnd interesting features He always encouraged me to writemore advanced features even though I was sometimes (nearly always) reluctant if ChemFig has the features itdoes it is in large part thanks to him I thank him as well for his testing of beta versions of this package and forhis contributions to the writing of this manual

1The protect command makes chemfig robust ie able to be stored without being altered by section and reused later especially inthe table of content

LATEXed by Christian Tellechea the April 24 2011 3

ChemFig 3 PRESENTING ChemFig

Experience shows that is it has been diXcult to combine drawing of molecules with the typographicquality of a program like LATEX leaving little choice for the user who wishes to have a vector formatfor these drawings After having abandoned the ppchtex package (developed for conTEXt and availableunder LATEX) because of the complexity of its syntax I turned to the world of programs outside LATEXThe diXculty in this case is Vnding a compromise between quality and price After many unsuccessfulattempts I found the only option was a new package and I would like to thank Christian Tellechea forbringing it to life To meet my requirements ChemFig needed to be easy to use but still have advancedfeatures something well nigh impossible Yet he was able to put together a very Wexible TEX code whichmakes it a pleasure for me to write my molecules I hope it will be the same for you readers looking for apackage useful in the Veld of chemistry

Christophe Casseau

Finally I wish to warmly thank Theo Hopman for oUering to translate this manual into English

3 Presenting ChemFig

To use this package start by adding the following code to the preamble

bull input chemfigtex with εTEXbull usepackagechemfig with LATEXbull usemodule[chemfig] with ConTEXt

In all cases the tikz package if not loaded before is loaded by ChemFig

The most important command for drawing molecules is chemfigltcodegt The argument code is a set ofcharacters describing the structure of the molecule according to the rules which are described in this manual

Care has been taken to make it possible to draw the greatest possible number of molecular conVgurations whilemaintaining a simple Wexible and intuitive syntax Despite this the ltcodegt which describes the 2D structure ofthe molecule increases in complexity in proportion to that of the molecule being drawn

The command chemfig draws a molecule using the commands provided by the tikz package placed inside atikzpicture environment The choice of tikz implies that

bull the user has a choice of compilation method pdfLATEX can be used equally well in dvi mode (tex minusrarrdvi minusrarr ps minusrarr pdf) or in pdf mode (tex minusrarr pdf) In eUect tikz via the underlying pgf gives identicalgraphical results in the two modes

bull the bounding box is automatically calculated by tikz and the user need not worry about any overlap withthe text However care must be taken with alignment when the molecule is drawn in a paragraph In the

following example we have drawn the bounding box for the molecule H3C C

OH

O

ChemFig

always places the Vrst atom of the molecule on the baseline of the preceding code

LATEXed by Christian Tellechea the April 24 2011 4

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 2: Chemfig Doc En

ChemFig CONTENTS

Contents

I Introduction 3

1 New in version 04b 3

2 Foreword 3

3 Presenting ChemFig 4

II ChemFig for the impatient 5

1 Syntax 5

2 The diUerent types of bonds 5

3 DiUerent types of diagrams 631 Complete structural diagram 632 Condensed structural diagram 633 Cram representation 734 Skeleton diagram 735 Lewis diagrams 7

4 Branched molecules 7

5 Rings 8

6 Ions 9

7 Chemical equations 9

III Operation of ChemFig 10

1 Groups of atoms 10

2 DiUerent types of bonds 10

3 Bond angle 1231 PredeVned angles 1232 Absolute angles 1233 Relative angles 12

4 Length of a bond 13

5 Departure and arrival atoms 14

6 Customization of bonds 14

7 Default values 15

8 Branches 1581 Principle 1582 Nesting 1683 Method 16

9 Connecting distant atoms 17

LATEXed by Christian Tellechea the April 24 2011 1

ChemFig CONTENTS

10 Rings 18101 Syntax 18102 Angular position 19

1021 At the start 191022 After a bond 20

103 Branches on a ring 20104 Nested rings 21105 Rings and groups of atoms 22

11 Representing electron movements 22111 Mesomeric eUects 23112 Reaction mechanisms 25

12 Writing a name under a molecule 25

IV Advanced usage 27

1 Separating atoms 27

2 Displaying atoms 27

3 Optional arguments 28

4 Vertical alignment 29

5 Shifted double bonds 30

6 Delocalized double bonds 31

7 Saving a sub-molecule 31

8 Decorations 3281 Lewis diagrams 3282 Stacking characters 3383 Chemical reactions 34

9 Using chemfig in the tikzpicture environment 35

10 Beyond chemistry 35

11 Annotated examples 36111 Ethanal 37112 2-amino-4-oxohexanoic acid 37

1121 Absolute angles 371122 Relative angles 381123 Ring 381124 Nested rings 38

113 Glucose 391131 Skeleton diagram 391132 Fisher projection 391133 ldquoChairrdquo representation 401134 Haworth projection 41

114 Adrenaline 411141 Using one ring 411142 Using two rings 42

115 Guanine 43

LATEXed by Christian Tellechea the April 24 2011 2

ChemFig 2 FOREWORD

12 How to 44121 Write a colored atom 44122 Add a superscript without modifying a bond 45123 Draw a curve bond 45124 Modify the size of a molecule 46125 Draw a ploymer element 46126 Draw the symmetrical of a molecule 47127 Add text above bonds and arc to angles 47

13 List of commands 48

V Gallery 50

Index 62

PART I

Introduction

1 New in version 04b

Herersquos whatrsquos new in version 04b

1 the argument of the chemfig command is no longer dependent of the catcode regime Therefore thechemfig command can be put inside arguments of macros even if the molecule code contains characterswith an active catcode like ldquo~rdquo It is now possible to write1 in a LATEX document something like

sectionThe molecule protectchemfigN~N

ldquordquo is the exception to this rule In order to put in an argument of a macro the command chemfig with amolecule code containing you must wrap it between ldquocatcodelsquo=12rdquo and ldquocatcodelsquo=6rdquo

2 The new setbondstyle command sets the style of the bonds see page 11

2 Foreword

This package has seen the light of day thanks to the assistance of Christophe Casseau who had the idea afterbeing confronted with the complexity of the syntax of the ppchtex package

Throughout the writing of the code he helped me Vnd interesting features He always encouraged me to writemore advanced features even though I was sometimes (nearly always) reluctant if ChemFig has the features itdoes it is in large part thanks to him I thank him as well for his testing of beta versions of this package and forhis contributions to the writing of this manual

1The protect command makes chemfig robust ie able to be stored without being altered by section and reused later especially inthe table of content

LATEXed by Christian Tellechea the April 24 2011 3

ChemFig 3 PRESENTING ChemFig

Experience shows that is it has been diXcult to combine drawing of molecules with the typographicquality of a program like LATEX leaving little choice for the user who wishes to have a vector formatfor these drawings After having abandoned the ppchtex package (developed for conTEXt and availableunder LATEX) because of the complexity of its syntax I turned to the world of programs outside LATEXThe diXculty in this case is Vnding a compromise between quality and price After many unsuccessfulattempts I found the only option was a new package and I would like to thank Christian Tellechea forbringing it to life To meet my requirements ChemFig needed to be easy to use but still have advancedfeatures something well nigh impossible Yet he was able to put together a very Wexible TEX code whichmakes it a pleasure for me to write my molecules I hope it will be the same for you readers looking for apackage useful in the Veld of chemistry

Christophe Casseau

Finally I wish to warmly thank Theo Hopman for oUering to translate this manual into English

3 Presenting ChemFig

To use this package start by adding the following code to the preamble

bull input chemfigtex with εTEXbull usepackagechemfig with LATEXbull usemodule[chemfig] with ConTEXt

In all cases the tikz package if not loaded before is loaded by ChemFig

The most important command for drawing molecules is chemfigltcodegt The argument code is a set ofcharacters describing the structure of the molecule according to the rules which are described in this manual

Care has been taken to make it possible to draw the greatest possible number of molecular conVgurations whilemaintaining a simple Wexible and intuitive syntax Despite this the ltcodegt which describes the 2D structure ofthe molecule increases in complexity in proportion to that of the molecule being drawn

The command chemfig draws a molecule using the commands provided by the tikz package placed inside atikzpicture environment The choice of tikz implies that

bull the user has a choice of compilation method pdfLATEX can be used equally well in dvi mode (tex minusrarrdvi minusrarr ps minusrarr pdf) or in pdf mode (tex minusrarr pdf) In eUect tikz via the underlying pgf gives identicalgraphical results in the two modes

bull the bounding box is automatically calculated by tikz and the user need not worry about any overlap withthe text However care must be taken with alignment when the molecule is drawn in a paragraph In the

following example we have drawn the bounding box for the molecule H3C C

OH

O

ChemFig

always places the Vrst atom of the molecule on the baseline of the preceding code

LATEXed by Christian Tellechea the April 24 2011 4

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 3: Chemfig Doc En

ChemFig CONTENTS

10 Rings 18101 Syntax 18102 Angular position 19

1021 At the start 191022 After a bond 20

103 Branches on a ring 20104 Nested rings 21105 Rings and groups of atoms 22

11 Representing electron movements 22111 Mesomeric eUects 23112 Reaction mechanisms 25

12 Writing a name under a molecule 25

IV Advanced usage 27

1 Separating atoms 27

2 Displaying atoms 27

3 Optional arguments 28

4 Vertical alignment 29

5 Shifted double bonds 30

6 Delocalized double bonds 31

7 Saving a sub-molecule 31

8 Decorations 3281 Lewis diagrams 3282 Stacking characters 3383 Chemical reactions 34

9 Using chemfig in the tikzpicture environment 35

10 Beyond chemistry 35

11 Annotated examples 36111 Ethanal 37112 2-amino-4-oxohexanoic acid 37

1121 Absolute angles 371122 Relative angles 381123 Ring 381124 Nested rings 38

113 Glucose 391131 Skeleton diagram 391132 Fisher projection 391133 ldquoChairrdquo representation 401134 Haworth projection 41

114 Adrenaline 411141 Using one ring 411142 Using two rings 42

115 Guanine 43

LATEXed by Christian Tellechea the April 24 2011 2

ChemFig 2 FOREWORD

12 How to 44121 Write a colored atom 44122 Add a superscript without modifying a bond 45123 Draw a curve bond 45124 Modify the size of a molecule 46125 Draw a ploymer element 46126 Draw the symmetrical of a molecule 47127 Add text above bonds and arc to angles 47

13 List of commands 48

V Gallery 50

Index 62

PART I

Introduction

1 New in version 04b

Herersquos whatrsquos new in version 04b

1 the argument of the chemfig command is no longer dependent of the catcode regime Therefore thechemfig command can be put inside arguments of macros even if the molecule code contains characterswith an active catcode like ldquo~rdquo It is now possible to write1 in a LATEX document something like

sectionThe molecule protectchemfigN~N

ldquordquo is the exception to this rule In order to put in an argument of a macro the command chemfig with amolecule code containing you must wrap it between ldquocatcodelsquo=12rdquo and ldquocatcodelsquo=6rdquo

2 The new setbondstyle command sets the style of the bonds see page 11

2 Foreword

This package has seen the light of day thanks to the assistance of Christophe Casseau who had the idea afterbeing confronted with the complexity of the syntax of the ppchtex package

Throughout the writing of the code he helped me Vnd interesting features He always encouraged me to writemore advanced features even though I was sometimes (nearly always) reluctant if ChemFig has the features itdoes it is in large part thanks to him I thank him as well for his testing of beta versions of this package and forhis contributions to the writing of this manual

1The protect command makes chemfig robust ie able to be stored without being altered by section and reused later especially inthe table of content

LATEXed by Christian Tellechea the April 24 2011 3

ChemFig 3 PRESENTING ChemFig

Experience shows that is it has been diXcult to combine drawing of molecules with the typographicquality of a program like LATEX leaving little choice for the user who wishes to have a vector formatfor these drawings After having abandoned the ppchtex package (developed for conTEXt and availableunder LATEX) because of the complexity of its syntax I turned to the world of programs outside LATEXThe diXculty in this case is Vnding a compromise between quality and price After many unsuccessfulattempts I found the only option was a new package and I would like to thank Christian Tellechea forbringing it to life To meet my requirements ChemFig needed to be easy to use but still have advancedfeatures something well nigh impossible Yet he was able to put together a very Wexible TEX code whichmakes it a pleasure for me to write my molecules I hope it will be the same for you readers looking for apackage useful in the Veld of chemistry

Christophe Casseau

Finally I wish to warmly thank Theo Hopman for oUering to translate this manual into English

3 Presenting ChemFig

To use this package start by adding the following code to the preamble

bull input chemfigtex with εTEXbull usepackagechemfig with LATEXbull usemodule[chemfig] with ConTEXt

In all cases the tikz package if not loaded before is loaded by ChemFig

The most important command for drawing molecules is chemfigltcodegt The argument code is a set ofcharacters describing the structure of the molecule according to the rules which are described in this manual

Care has been taken to make it possible to draw the greatest possible number of molecular conVgurations whilemaintaining a simple Wexible and intuitive syntax Despite this the ltcodegt which describes the 2D structure ofthe molecule increases in complexity in proportion to that of the molecule being drawn

The command chemfig draws a molecule using the commands provided by the tikz package placed inside atikzpicture environment The choice of tikz implies that

bull the user has a choice of compilation method pdfLATEX can be used equally well in dvi mode (tex minusrarrdvi minusrarr ps minusrarr pdf) or in pdf mode (tex minusrarr pdf) In eUect tikz via the underlying pgf gives identicalgraphical results in the two modes

bull the bounding box is automatically calculated by tikz and the user need not worry about any overlap withthe text However care must be taken with alignment when the molecule is drawn in a paragraph In the

following example we have drawn the bounding box for the molecule H3C C

OH

O

ChemFig

always places the Vrst atom of the molecule on the baseline of the preceding code

LATEXed by Christian Tellechea the April 24 2011 4

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 4: Chemfig Doc En

ChemFig 2 FOREWORD

12 How to 44121 Write a colored atom 44122 Add a superscript without modifying a bond 45123 Draw a curve bond 45124 Modify the size of a molecule 46125 Draw a ploymer element 46126 Draw the symmetrical of a molecule 47127 Add text above bonds and arc to angles 47

13 List of commands 48

V Gallery 50

Index 62

PART I

Introduction

1 New in version 04b

Herersquos whatrsquos new in version 04b

1 the argument of the chemfig command is no longer dependent of the catcode regime Therefore thechemfig command can be put inside arguments of macros even if the molecule code contains characterswith an active catcode like ldquo~rdquo It is now possible to write1 in a LATEX document something like

sectionThe molecule protectchemfigN~N

ldquordquo is the exception to this rule In order to put in an argument of a macro the command chemfig with amolecule code containing you must wrap it between ldquocatcodelsquo=12rdquo and ldquocatcodelsquo=6rdquo

2 The new setbondstyle command sets the style of the bonds see page 11

2 Foreword

This package has seen the light of day thanks to the assistance of Christophe Casseau who had the idea afterbeing confronted with the complexity of the syntax of the ppchtex package

Throughout the writing of the code he helped me Vnd interesting features He always encouraged me to writemore advanced features even though I was sometimes (nearly always) reluctant if ChemFig has the features itdoes it is in large part thanks to him I thank him as well for his testing of beta versions of this package and forhis contributions to the writing of this manual

1The protect command makes chemfig robust ie able to be stored without being altered by section and reused later especially inthe table of content

LATEXed by Christian Tellechea the April 24 2011 3

ChemFig 3 PRESENTING ChemFig

Experience shows that is it has been diXcult to combine drawing of molecules with the typographicquality of a program like LATEX leaving little choice for the user who wishes to have a vector formatfor these drawings After having abandoned the ppchtex package (developed for conTEXt and availableunder LATEX) because of the complexity of its syntax I turned to the world of programs outside LATEXThe diXculty in this case is Vnding a compromise between quality and price After many unsuccessfulattempts I found the only option was a new package and I would like to thank Christian Tellechea forbringing it to life To meet my requirements ChemFig needed to be easy to use but still have advancedfeatures something well nigh impossible Yet he was able to put together a very Wexible TEX code whichmakes it a pleasure for me to write my molecules I hope it will be the same for you readers looking for apackage useful in the Veld of chemistry

Christophe Casseau

Finally I wish to warmly thank Theo Hopman for oUering to translate this manual into English

3 Presenting ChemFig

To use this package start by adding the following code to the preamble

bull input chemfigtex with εTEXbull usepackagechemfig with LATEXbull usemodule[chemfig] with ConTEXt

In all cases the tikz package if not loaded before is loaded by ChemFig

The most important command for drawing molecules is chemfigltcodegt The argument code is a set ofcharacters describing the structure of the molecule according to the rules which are described in this manual

Care has been taken to make it possible to draw the greatest possible number of molecular conVgurations whilemaintaining a simple Wexible and intuitive syntax Despite this the ltcodegt which describes the 2D structure ofthe molecule increases in complexity in proportion to that of the molecule being drawn

The command chemfig draws a molecule using the commands provided by the tikz package placed inside atikzpicture environment The choice of tikz implies that

bull the user has a choice of compilation method pdfLATEX can be used equally well in dvi mode (tex minusrarrdvi minusrarr ps minusrarr pdf) or in pdf mode (tex minusrarr pdf) In eUect tikz via the underlying pgf gives identicalgraphical results in the two modes

bull the bounding box is automatically calculated by tikz and the user need not worry about any overlap withthe text However care must be taken with alignment when the molecule is drawn in a paragraph In the

following example we have drawn the bounding box for the molecule H3C C

OH

O

ChemFig

always places the Vrst atom of the molecule on the baseline of the preceding code

LATEXed by Christian Tellechea the April 24 2011 4

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 5: Chemfig Doc En

ChemFig 3 PRESENTING ChemFig

Experience shows that is it has been diXcult to combine drawing of molecules with the typographicquality of a program like LATEX leaving little choice for the user who wishes to have a vector formatfor these drawings After having abandoned the ppchtex package (developed for conTEXt and availableunder LATEX) because of the complexity of its syntax I turned to the world of programs outside LATEXThe diXculty in this case is Vnding a compromise between quality and price After many unsuccessfulattempts I found the only option was a new package and I would like to thank Christian Tellechea forbringing it to life To meet my requirements ChemFig needed to be easy to use but still have advancedfeatures something well nigh impossible Yet he was able to put together a very Wexible TEX code whichmakes it a pleasure for me to write my molecules I hope it will be the same for you readers looking for apackage useful in the Veld of chemistry

Christophe Casseau

Finally I wish to warmly thank Theo Hopman for oUering to translate this manual into English

3 Presenting ChemFig

To use this package start by adding the following code to the preamble

bull input chemfigtex with εTEXbull usepackagechemfig with LATEXbull usemodule[chemfig] with ConTEXt

In all cases the tikz package if not loaded before is loaded by ChemFig

The most important command for drawing molecules is chemfigltcodegt The argument code is a set ofcharacters describing the structure of the molecule according to the rules which are described in this manual

Care has been taken to make it possible to draw the greatest possible number of molecular conVgurations whilemaintaining a simple Wexible and intuitive syntax Despite this the ltcodegt which describes the 2D structure ofthe molecule increases in complexity in proportion to that of the molecule being drawn

The command chemfig draws a molecule using the commands provided by the tikz package placed inside atikzpicture environment The choice of tikz implies that

bull the user has a choice of compilation method pdfLATEX can be used equally well in dvi mode (tex minusrarrdvi minusrarr ps minusrarr pdf) or in pdf mode (tex minusrarr pdf) In eUect tikz via the underlying pgf gives identicalgraphical results in the two modes

bull the bounding box is automatically calculated by tikz and the user need not worry about any overlap withthe text However care must be taken with alignment when the molecule is drawn in a paragraph In the

following example we have drawn the bounding box for the molecule H3C C

OH

O

ChemFig

always places the Vrst atom of the molecule on the baseline of the preceding code

LATEXed by Christian Tellechea the April 24 2011 4

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 6: Chemfig Doc En

ChemFig 2 THE DIFFERENT TYPES OF BONDS

PART II

ChemFig for the impatientThis part is a non-exhaustive overview of the features of ChemFig The goal is to introduce the basic ideasallowing the user to get started drawing molecules as quickly as possible This part does not go into detailadvanced use and a more formal approach to ChemFig commands will be discussed in the following parts

1 Syntax

The command chemfig is used in the following way

chemfigltatom1gtltbond typegt[ltanglegtltcoeffgtltn1gtltn2gtlttikz codegt]ltatom2gt

bull ltanglegt is the bond angle between the two atomsbull ltcoeffgt is a coeXcient multiplying the default bond lengthbull ltn1gt and ltn2gt are the numbers of the departure and arrival atoms of the bondbull lttikz codegt is additional options concerning the colour or style of a bond

Each bond takes optional arguments which are placed in square brackets These arguments can adjust everythingone needs for the bond Each argument has a default value so one can simply write

chemfigH-O-H H O H

The water molecule

In all the examples the grey line represents the baseline

2 The diUerent types of bonds

For ChemFig bonds between two atoms are one of nine types represented by the characters - = ~ gt lt gtlt gt| and lt|

Bond Code Result Bond type1 chemfigA-B A B Single2 chemfigA=B A B Double3 chemfigA~B A B Triple4 chemfigAgtB A B right Cram plain5 chemfigAltB A B left Cram plain6 chemfigAgtB A B right Cram dashed7 chemfigAltB A B left Cram dashed8 chemfigAgt|B A B right Cram hollow9 chemfigAlt|B A B left Cram hollow

The command setdoublesepltdimgt adjusts the spacing between the lines in double or triple bonds Thisspacing is 2pt by default

LATEXed by Christian Tellechea the April 24 2011 5

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 7: Chemfig Doc En

ChemFig 3 DIFFERENT TYPES OF DIAGRAMS

3 DiUerent types of diagrams

31 Complete structural diagram

chemfigC(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H C

H

H

H

C

H

H

H

Ethane

Each bond takes several optional arguments The Vrst optional argument deVnes the ltanglegt of the bond Anglesincrease counterclockwise If no angle is give then its default value is 0

Note the parentheses allow multiple bonds from the same atom see ldquoBranched moleculesrdquo page 7

There are many ways of specifying the angle of a bond

PredeVned angles When the optional argument contains a whole number this represents the angle that thebond makes with the horizontal in multiples of 45

chemfig(-[1]1)(-[2]2)(-[3]3)(-[4]4)(-[5]5)(-[6]6)(-[7]7)-0

12

3

4

56

7

0

Predefined angles

Absolute angle To give an angle in degrees relative to the horizontal the optional argument must take this form[ltabsolute anglegt] The ltabsolute anglegt may be positive or negative and may have decimal placesIt is reduced to the interval [0 360)

Relative angle It is often useful to give the bond angle relative to the preceding bond In this case the followingsyntax must be used[ltrelative anglegt] The ltrelative anglegt may be positive or negative and mayhave decimal places

32 Condensed structural diagram

chemfigH_3C-(CH_2)_3-CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

It is sometimes useful to change the length of a bond In the preceding example the Vrst two bonds need to belengthened they are too short compared to the double bond To do this the ltcoeffgt is needed in the optionalarguments

chemfigH_3C-[15](CH_2)_3-[15]CH=CH_2 H3C (CH2)3 CH CH2

Hex-1-ene

Notes

bull in the notation [15] the comma indicates that the value placed in brackets corresponds to the secondargument (coeff) To give a value for the fourth argument one would write [2]

bull characters between braces are not interpreted by ChemFig which allows (for example) groupings ofatoms to be written inside parentheses without having them treated as part of a branched molecule (seepage 7)

LATEXed by Christian Tellechea the April 24 2011 6

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 8: Chemfig Doc En

ChemFig 4 BRANCHED MOLECULES

33 Cram representation

Another way of showing the bond angle between two atoms

chemfigC(-[5]H)(-[2]H)(lt[-70]H)(lt[-20]H) C

H

H

H

H

Methane

34 Skeleton diagram

The simplest input only covalent bonds are listed with their possible settings

chemfig-[30]=[-30red]-[30]

But-2-ene

The double bond lines are drawn on either side of where the single bond line would be To keep graphicalconsistency between skeleton diagrams of various compounds it is useful to shift the second double bond lineabove or below the single bond line Just follow the = symbol with ^ or _ as shown below

chemfig-[-30]=[30]-[-30] chemfig-[-30]=^[30]-[-30]parchemfig=[-30]-[30]=[-30] chemfig=_[-30]-[30]=^[-30]

Comparison between double bonds and shifted double bonds

35 Lewis diagrams

The syntax is as follows

lewisltposition indexgtltelectron stategtltatomgt

The electron states can be a lone pair an empty electron slot or a single electron By default the electron state isa lone pair A single electron is represented by the character and an empty slot by |

chemfigC(-[2]H)(-[4]H)(-[6]H)-lewis260Clhspace1cmchemfig[40]H-lewis13O-[-80]H

C

H

H

H

Cl H

O

H

Chloromethane and water

Note the positions take whole number values between 0 and 7

lewis0246Chspace1cmlewis0|246Chspace1cmlewis1357Ar

C C Ar

Positions

4 Branched molecules

To indicate a branch simply follow the atom holding the branch with a ltcodegt in parentheses This ltcodegt is thecode of the submolecule which will be attached to the atom Multiple branches can be attached to the same atomand these can be nested

LATEXed by Christian Tellechea the April 24 2011 7

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 9: Chemfig Doc En

ChemFig 5 RINGS

chemfigH_3C-CH(-[2]CH_3)-CH_3hspace5cmchemfig-(-[2])(-[6])-

H3C CH

CH3

CH3

Alkanes

In this type of representation it is sometimes necessary to connect to distant atoms To do this the character isused which creates a hook between two atoms The function

[ltnamegtltbondgtlttikzgt]

takes three arguments the name of the hook the bond type and tikz code The following example shows how tomake two diUerent hooks

Cocaine

chemfigH_2C(-C[a]H-[-30]CH_2-[30]C[b]H-O-CO-C_6H_5)

-[2]CH_2-[17]CH(-[3]N[a]-[3]H_3C)(-[135]C[b]H-CO-OCH_3)

H2C CH

CH2

CH O CO C6H5

CH2 CH

N

CH3

CH CO OCH3

5 Rings

ChemFig can easily draw regular polygons The syntax is the following

chemfign(ltcode for the moleculegt)

chemfig3(---)hspace5cmchemfig5(-=-=-)hspace5cmchemfig6(-=-=-=)

Some rings

Branches are used in the same way as before

chemfig4(-(--[1]4(----))---)

Rings and branches

Note a ring does not start or Vnish with the atom or group of atoms with which one wants to close the ring Thechemical entity on which the ring is based must be outside the ring deVnition

chemfigA4(-B-C-D-)

A B

CD

Proper coding

chemfig4(A-B-C-D-)hspace1cmchemfig4(-B-C-D-A)

A B

CD

B

CD

Bad coding

LATEXed by Christian Tellechea the April 24 2011 8

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 10: Chemfig Doc En

ChemFig 7 CHEMICAL EQUATIONS

6 Ions

The chemfig commands enters the math mode2 of TEX so it is very simple to write an ion A negative charge (minus)must always be enclosed in braces to avoid ChemFig confusing it with the symbol for a single bond

chemfig-(-[1]O^-)=[7]O

Ominus

O

Acetate ion

For purists it is possible to circle the charge of an ion by using the commands ominus and oplus

To meet all requirements there are two other commands chemabove and chembelow which allow placement ofcharges above or below the current atom

chemfig-(-[1]O^ominus)=[7]Ohspace1cmchemfiglewis35O=lewis26Cl-chemabovelewis026Oominusvskip5ptchemfig-chemaboveNscriptstyleoplus(=[1]O)-[7]O^ominus

O

O

O Cl O

Noplus

O

O

Some ions

For those who are extremely picky the commands chemabove and chembelow accept an optional argumentwhich sets the distance between the charge and the atom

chemfiglewis35O=C-chemabove[3pt]lewis246Ohspace5cmominus

O C O

Charge position

7 Chemical equations

Here is an example of a chemical reaction

Chemical reaction

chemfig6(------) hspace5cm + hspace5cm chemfigH_3C-Cl

hspace5cm $xrightarrowcatalyst$ hspace5cm

chemfig6(---(-)---) hspace5cm + hspace5cm chemfigH-Cl

+ H3C Clcatalystminusminusminusminusminusminusrarr + H Cl

ChemFig adds two new commands chemsign and chemrel which slightly simplify the preceding syntax

Using the ChemFig commands

setchemrel0pt12em6em

chemfig6(------)chemsign[05cm]+chemfigH_3C-Cl

chemrel[itshapetiny Catalyst]-gt

chemfig6(---(-)---)chemsign[05cm]+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

2There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 9

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 11: Chemfig Doc En

ChemFig 2 DIFFERENT TYPES OF BONDS

PART III

Operation of ChemFig

This part is devoted to describing the most common features of ChemFig The outline of this description farexceeds that of ldquoChemFig for the impatientldquo but the user will Vnd here explanations suXcient to draw mostmolecules The presentation of features is done from a theoretical angle and the goal of this part is not to drawreal molecules but to give the user a formal description of the functionality of ChemFig The ldquoAdvanced usagerdquopage 27 will be more practical and will illustrate advanced features for the most demanding uses It will alsohighlight methods of building real molecules page 36 Finally the last part will give examples of molecules andthe code used to draw them

1 Groups of atoms

Drawing a molecule consists inherently of connecting groups of atoms with lines Thus in the molecule O Othere are two groups of atoms each consisting of a single atom ldquoOrdquo

However in this molecule

H3C C

OH

O

there are four groups of atoms ldquoH3Crdquo ldquoCrdquo ldquoOrdquo and ldquoOHrdquo For reasons which we shall see later ChemFig splitseach group into single atoms Each atom extends up to the next capital letter or one of these special characters -= ~ ( lt gt ChemFig ignores all characters inside braces when splitting groups into atoms

Therefore the Vrst group of atoms ldquoH3Crdquo is split into two atoms H3 and C In terms of chemistry of coursethese are not real atoms H3 for example consists of three hydrogen atoms In what follows the word atom refersto ChemFigrsquos deVnition Thus ChemFig sees the preceding molecule as follows

H3 C C

O

O H

2 DiUerent types of bonds

As we have already seen (see page 5) bonds can be one of nine types each corresponding to the characters - =~ gt lt gt lt gt| and lt|

We must understand that when a bond is made between two atoms these atoms are contained within invisiblerectangular boxes The centres of these two rectangles are separated by an adjustable distance ∆ called theldquointeratomic distancerdquo Furthermore bonds do not connect to the exact edges of the rectangles a length δ alsoadjustable separates the edges of the rectangles and the beginning and end of the bond line The rectangularboxes are made visible in the diagram below to help understanding

A Bδδ

LATEXed by Christian Tellechea the April 24 2011 10

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 12: Chemfig Doc En

ChemFig 2 DIFFERENT TYPES OF BONDS

The macro setatomsepltdimensiongt adjusts the interatomic distance ∆ If the ltdimensiongt is empty it takesthe default value of 3em This command like all other settings commands aUects all the following molecules

setatomsep2emchemfigA-Bparsetatomsep50ptchemfigA-B

A BA B

Interatomic distance

The command setbondoffsetltdimensiongt sets the spacing δ between the bond line and the atom If theltdimensiongt is empty δ takes the default value of 2pt

setbondoffset0ptchemfigA-Bparsetbondoffset5ptchemfigA-B

A BA B

Trimming bonds

If one bond is followed immediately by another then ChemFig inserts an empty group Around this emptygroup the separation δ is zero

chemfigA-B=-=C A B C

Empty groups

The setbondstylelttikz codegt command sets the style for all the bonds drawn thereafter The lttikz codegtis empty by default To custom a single bond see page 14

setbondstyleline width=1ptredchemfigA-B=Cgt|DltEgtF

A B C D E F

Style of bonds

The spacing δ for just one bond can be speciVed with the character This character must be placed immediatelyafter the bond symbol and has one required argument between parentheses of the form ldquo(ltdim1gtltdim2gt)rdquowhere ltdim1gt is the spacing δ at the beginning of the bond and ltdim2gt is the that at the end If ltdim2gt is omittedthe spacing at the end of the bond takes the value of δ in eUect at that time One can see in the example how theshortening set to 4pt to be more visible is nulliVed for the bond arriving at ldquoBrdquo then for the one leaving ldquoBrdquo andVnally for both

setbondoffset4ptchemfigA-B-CparchemfigA-(0pt)B-CparchemfigA-B-(0pt)CparchemfigA-(0pt)B-(0pt)C

A B CA B CA B CA B C

Fine adjustment of bond shortening

By default all atoms within groups of atoms are typeset in math mode (spaces are ignored) They may thereforecontain math mode speciVc commands such as subscripts or superscripts3

chemfigA_1B^2-C _ 3 ^ 4 A1B2 C43

Math mode

There are settings speciVcally for Cram bonds This syntax is used

setcrambondltdim1gtltdim2gtltdim3gt

Any empty argument takes its default value The three arguments are

bull ltdim1gt is the size of the base of the triangle and is 15pt by defaultbull ltdim2gt is the thickness of the dots and is 1pt by defaultbull ltdim3gt is the spacing between the dots and is 2pt by default

Here is an example where the three dimensions are changed

setcrambond10pt04pt1ptchemfigAgtBgtCgt|D

A B C D

Modified Cram bonds

3There is a problem with the placement of groups of atoms containing exponents or subscripts See page 29

LATEXed by Christian Tellechea the April 24 2011 11

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 13: Chemfig Doc En

ChemFig 3 BOND ANGLE

3 Bond angle

Each bond takes an optional argument in brackets This optional argument can adjust every aspect of a bondand consists of Vve optional Velds separated by commas The Vrst of these Velds deVnes the bond angle Anglesincrease counterclockwise and are relative to the horizontal If the angle Veld is empty the angle takes its defaultvalue of 0 We will see later how to change this default

There are several ways of specifying the bond angle

31 PredeVned angles

When the angle Veld contains an integer this represents the angle the bond makes relative to the horizontal inmultiples of 45 For example [0] speciVes an angle of 0 [1] is 45 and so on up to [7] which speciVes anangle of 315 The integer may lie outside the interval [0 7] in which case the angle is reduced to the interval[0 360)

chemfigA-B-[1]C-[3]-D-[7]E-[6]F

A B

C

D

E

F

Predefined angles

These angles remain valid if the atoms are empty and this is the case for all the features we will see below

chemfig--[1]-[3]--[7]-[6]

Predefined angles with empty groups

32 Absolute angles

If one wishes to specify an angle in degrees relative to the horizontal then the optional angle Veld must take thisform [ltabsolute anglegt] If necessary the ltabsolute anglegt is reduced to the interval [0 360)

chemfigA-[30]B=[-75]C-[10]D-[90]gt|[60]-[-20]E-[0]~[-75]F

A

B

CD

E

F

Absolute angles

33 Relative angles

It is often useful to specify a bond angle relative to the preceding bond This syntax must be then be used[ltrelative anglegt] The sign of the ltrelative anglegt can be omitted if it is a +

Here is a molecule where the Vrst bond has an absolute angle of minus5 and the rest of the bond angles areincremented by 20

chemfigA-[-5]-[+20]-[20]B-[+20]-[20]C-[20]

A

B

C

Result of relative angles

LATEXed by Christian Tellechea the April 24 2011 12

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 14: Chemfig Doc En

ChemFig 4 LENGTH OF A BOND

One can ldquobreakrdquo a chain of relative angles by putting an absolute or predeVned angle where desired Here atomldquoBrdquo is followed by a bond at an absolute angle of 315

chemfigA-[-5]-[20]-[20]B-[7]-[20]C-[20]A

B

C

Result of relative angles followed by absolute

4 Length of a bond

Rather than speaking of length of a bond we should use the term interatomic spacing If eUect only theinteratomic spacing is adjustable with setatomsep as we have seen on page 10 Once this parameter is set thelength of a bond depends on the content of atoms and to a lesser extent the angle the bond makes with thehorizontal It should be obvious that two ldquoslimmerrdquo atoms will have larger edge separations than two which arelarger This can be seen easily in the following example where an ldquoIrdquo atom is narrower than an ldquoMrdquo atom whichmeans that the bond between the ldquoIrdquo atoms is longer than that between the ldquoMrdquo atoms

chemfigI-IparchemfigM-M

I IM M

Influence of the size of atoms

This aspect of the size of atoms becomes particularly acute when the atom involves subscripts or superscripts Inthis example the bond is extremely short to the point of confusion with a negative sign minus

chemfigA^++_2-B^-_3 A++2 Bminus3

Too-short bond

It is important to note that the exponent - is put inside braces If this were not done ChemFig would stop theatom on this character which is a bond character The atom would then be ldquoB^rdquo which would lead to unexpectedresults

We see in the example above that is it sometimes necessary to increase (or perhaps reduce) the interatomic distanceassociated with a bond For this the optional argument to bonds is actually made up of several comma-separatedVelds As we have seen the Vrst Veld speciVes the angle The second Veld if it is not empty is a coeXcient whichmultiplies the default interatomic distance ∆ Thus writing -[2] asks that this bond have the default angle (VrstVeld is empty) and that the atoms it connects be separated by twice the default distance

chemfigA^++_2-[2]B^-_3parchemfigA-B-[2]C=[05]Dparchemfig-=[15]-[075]=[-202]

A++2 Bminus3

A B C D

Modified bond length

We can change the size of molecules by altering the font size or the argument of setatomsep possibly on both 4being careful to conVne these changes within a group if we want to limit the scope

normalsize chemfigH-[30]O-[-30]Hparsetatomsep25emchemfigH-[30]O-[-30]Hparsmall chemfigH-[30]O-[-30]Hparfootnotesize chemfigH-[30]O-[-30]Hparscriptsize chemfigH-[30]O-[-30]Hpartiny chemfigH-[30]O-[-30]H

H

O

H

H

O

H

H

O

H

HO

H

HO

H

HO

H

How to modify the size of molecule

4You can also use the second optional argument of chemfig see page 28

LATEXed by Christian Tellechea the April 24 2011 13

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 15: Chemfig Doc En

ChemFig 6 CUSTOMIZATION OF BONDS

5 Departure and arrival atoms

A group of atoms can contain several atoms Suppose we want to connect the group ldquoABCDrdquo to the groupldquoEFGrdquo with a bond ChemFig calculates which atom of the Vrst group and which of the second group are to beconnected by looking at the angle of bond relative to the horizontal If the angle is between (but not including)minus90 and 90 (modulo 360) then the bond is made between the last atom of the Vrst group and the Vrst atom ofthe second group In all other cases the bond is made between the Vrst atom of the Vrst group and the last atomof the second group

Here are some examples where the bond is in the interval (minus90 90) and where the bond is made between D andE

chemfigABCD-[75]EFGquadchemfigABCD-[-85]EFGquadchemfigABCD-[1]EFG

ABCD

EFG

ABCD

EFG

ABCD

EFG

Default atom connections

In the following examples the angles are in the interval [90 270] and so the bond is made between A and G

chemfigABCD-[100]EFGquadchemfigABCD-[-110]EFGquadchemfigABCD-[5]EFG

ABCD

GFE

ABCD

GFE

ABCD

GFE

Default atom connections

One may sometimes want the bond partners to be atoms other than those determined by ChemFig Thedeparture and arrival atoms can be set with the optional bond argument by writing

[ltinteger 1gtltinteger 2gt]

where ltinteger 1gt and ltinteger 2gt are the numbers of the desired departure and arrival atoms These atomsmust exist otherwise an error message will be given

chemfigABCD-[7523]EFGqquadchemfigABCD-[752]EFGqquadchemfigABCD-[7532]EFG ABCD

GFE

ABCD

FGE

ABCD

FGE

Specified atom connections

6 Customization of bonds

There is a Vfth and last optional argument for bonds which is found after the fourth comma

[lttikz codegt]

This lttikz codegt is passed directly to tikz when the bond is drawn There one can put characteristics such ascolour (red) dash type (dash pattern=on 2pt off 2pt) thickness (line width=2pt) or even decoration if thetikz decoration library has been loaded A bond can be made invisible by writing ldquodraw=nonerdquo To set severalattributes the syntax of tikz is used separating them by a comma

chemfigA-[red]BparchemfigA-[dash pattern=on 2pt off 2pt]BparchemfigA-[line width=2pt]BparchemfigA-[redline width=2pt]B

A BA BA BA B

Passing tikz code

Numerous tikz decoration libraries are available For example one can use the ldquopathmorphingrdquo library by puttingusetikzlibrarydecorationspathmorphing in the preamble in order to draw wavy bonds

chemfigA-[3decoratedecoration=snake]B A B

Wavy bonds

Cram bonds ignore thickness and dash settings

LATEXed by Christian Tellechea the April 24 2011 14

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 16: Chemfig Doc En

ChemFig 8 BRANCHES

7 Default values

At the beginning of each molecule the default values for the optional arguments are initialized They are

bull 0 for the bond anglebull 1 for the length multiplication coeXcientbull ltemptygt for the numbers of the departure and arrival atoms which lets ChemFig calculate these basedon the bond angle

bull ltemptygt for the parameters passed to tikz

These default values can be changed for the whole molecule by beginning the molecule code with

[ltanglegtltcoeffgtltn1gtltn2gtlttikz code]

Thus if the code of a molecule begins with [2015] then all the bonds will be at angle of 20 by default andthe interatomic distances will have a length 15 times the default length These default values can be overriddenat any time by giving an optional argument such as for the bond which follows atom ldquoCrdquo in this example

chemfig[2015]A-B-C-[-8007]D-E-F

A

B

C

D

E

F

Overriding default values

If something odd like [11522redthick] is written then unless otherwise indicated all the bonds will havean angle of 45 the interatomic distances will be 15 times the default distance the bonds will begin and end onthe second atom of each group and the bonds will be red and thick

chemfig[11522redthick]ABC-DEF=GHI

BCA

EFD

HIG

Default values

8 Branches

81 Principle

Up to now all the molecules have been linear which is rare A sub-molecule can be attached to an atom byfollowing the atom with ltcodegt in parentheses This ltcodegt is the code of the submolecule which will be attachedto the atom

In this example the sub-molecule ldquo-[1]W-Xrdquo will be attached to atom ldquoBrdquo

chemfigA-B(-[1]W-X)-CA B

W X

C

A branch

There can be several sub-molecules which are to be attached to the same atom Just have several parenthesescontaining the code for each sub-molecule

chemfigA-B(-[1]W-X)(-[6]Y-[7]Z)-C

A B

W X

Y

Z

C

Multiple branches

LATEXed by Christian Tellechea the April 24 2011 15

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 17: Chemfig Doc En

ChemFig 8 BRANCHES

The code of each sub-molecule can deVne its own default values which will be valid throughout the wholesub-molecule Here a sub-molecule ldquo[60]-D-Erdquo is attached to atom ldquoBrdquo with a default angle of 60 absoluteA second sub-molecule ldquo[-6015]-X-Yrdquo is attached to ldquoBrdquo with a default bond angle 60 less than that ofthe preceding bond (which will be the one between ldquoArdquo and ldquoBrdquo) and with an interatomic distance 15 times thedefault value

chemfigA-B([60]-D-E)([-3015]-X-Y)-C A B

D

E

X

Y

C

Default values in branches

Observe what happens if at the beginning of the main molecule one writes ldquo[-45]rdquo

chemfig[-45]A-B([60]-D-E)([-3015]-X-Y)-C

A

B

D

E

X

Y

C

Effect of the default bond angle

We see that the angle between the bond B-C and the bond B-X stays at 30 because it is a relative angle for thesub-molecule ldquo-X-Yrdquo By contrast the branch ldquo-D-Erdquo stays inclined at 60 to the horizontal and does not followthe rotation given by the minus45 angle at the beginning this is expected because ldquo-D-Erdquo has an absolute angle It isessential that all the angles be relative in order to rotate the whole molecule

82 Nesting

Sub-molecules may be nested and the rules seen in the preceding paragraphs stay in force

chemfigA-B([1]-X([2]-Z)-Y)(-[7]D)-C

A B

X

ZY

D

C

Nested branches

83 Method

Suppose now that we want to draw an acid anhydride molecule R C

O

O

C

O

R

The best way to get this is to Vnd the longest chain Here for example we can draw the chain R-C-O-C-R takinginto account angles and using only relative angles

LATEXed by Christian Tellechea the April 24 2011 16

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 18: Chemfig Doc En

ChemFig 9 CONNECTING DISTANT ATOMS

chemfigR-C-[-60]O-[-60]C-[-60]R

R C

O

CR

Acid anhydride structure

To this structure we just have to add two ldquo=Ordquo sub-molecules to each of the carbon atoms

chemfigR-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R C

O

O

C

O

R

Acid anhydride

Because we used only relative angles we can rotate this molecule by giving a default angle of eg 75

chemfig[75]R-C(=[+60]O)-[-60]O-[-60]C(=[+60]O)-[-60]R

R

C

O

O

CO

R

Rotation of a molecule

9 Connecting distant atoms

We have seen how to connect atoms which are adjacent in the code It is often necessary to connect atoms whichare not next to each other in the code Letrsquos call these particular bonds ldquodistant bondsrdquo

Letrsquos take this molecule

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Branched structure

and suppose that we want to connect the atoms X and C In this case ChemFig allows a ldquohookrdquo to be placedimmediately after the atom of interest The character used for a hook is ldquordquo because of its similarity to a hook Soif one writes X then the atom X will have a hook Later in the code all atoms followed by a will be connected toX

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Distant bond

We could connect other atoms to X by following them with Here itrsquos the atoms C and Z

chemfigA-B(-[1]W-X)(-[7]Y-Z)-C A B

W X

Y Z

C

Several distant bonds

LATEXed by Christian Tellechea the April 24 2011 17

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 19: Chemfig Doc En

ChemFig 10 RINGS

Now imagine if we were to leave the distant bonds X-C and X-Zwhile adding another A-W We must therefore askfor two diUerent hooks one on A and the other on X Fortunately the character has an optional argument

[ltnamegtltbondgtlttikzgt]

where each Veld takes its default value if it is empty

bull The ltnamegt is the name of the hook all alphanumeric characters (a z A Z 0 9) are allowed5 Thename is a by default In the Vrst occurrence of the hook with this name only this Veld is used

bull ltbondgt speciVes how the atom with the current occurrence of the named hook is to be bonded to the atomwith the Vrst occurrence of the hook There are two ways this can be done First this Veld can be aninteger representing the desired bond type 1=single bond 2=double bond etc (See the table on page 5 forthe bond codes)Second the Veld can be one of the bond character codes provided that this character is between braces

bull lttikzgt will be passed directly to tikz as we have seen with regular bonds

Here is our molecule with the required distant bonds then with the bond A-W and X-C customized

chemfigA[a]-B(-[1]W[a]-X[b])(-[7]Y-Z[b])-C[b]parmedskipchemfigA[a]-B(-[1]W[a2red]-X[b])(-[7]Y-Z[b1line width=2pt])-C[bgtblue]

A B

W X

Y Z

C

A B

W X

Y Z

C

Multiple distant bonds

Several diUerent hooks can be written after an atom Suppose that in this unVnished pentagon we wish toconnect A-E A-C and E-C

chemfigA-[-72]B-C-[72]D-[144]E A

B C

D

E

An incomplete ring

Then we must do this

chemfigA[a]-[-72]B-C[a][b]-[72]D-[144]E[a][b] A

B C

D

E

Multiple distant bonds

10 Rings

The preceding example shows how to draw a regular polygon but the method used is tedious because the anglesdepend on the number of sides of the polygon

101 Syntax

ChemFig can easily draw regular polygons The idea is to attach a ring to an ltatomgt outside the ring with thissyntax

ltatomgtltngt(ltcodegt)

ltngt is the number of sides of the polygon and the ltcodegt describes the bonds and groups of atoms which makeup its edges and vertices This code must begin with a bond because the atom is outside the ring

Here is a 5-ring attached to the atom ldquoArdquo

5This is not exactly right Actually all the characters that can be put between csnameendcsname are allowed

LATEXed by Christian Tellechea the April 24 2011 18

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 20: Chemfig Doc En

ChemFig 10 RINGS

chemfigA5(-B=C-D-E=)

AB

C

DE

5-ring

A ring can also be drawn with one several or all the groups of atoms empty as is the case for diagrams outsiderings

chemfig5(-=--=)

5-ring with empty groups

A ring can be incomplete

chemfig5(-B=C-D)

B

C

D

Incomplete 5-ring

If a ring has a code which contains too many bonds and atom groups for the given number of vertices all thebonds and groups over the maximum allowed are ignored

chemfigA5(-B=C-D-E=F-G=H-I)

AB

C

DE

Truncated 5-ring

It is possible to draw a circle or an arc in the inside of a ring To do so the following syntax is used

ltatomgt[ltangle 1gtltangle 2gtlttikzgt]ltngt(ltcodegt)

where each Veld of the optional argument takes its default value if it is empty

bull ltangle 1gt and ltangle 2gt are the absolute angles of the start and Vnish of the arc These default to 0

and 360 respectively so that a circle is drawn by defaultbull lttikzgt is the code that will be passed to tikz for drawing the arc

chemfig6(------)quadchemfig[30330]5(-----)quadchemfig[0270dash pattern=on 2pt off 2pt]4(----)

Rings and arcs

102 Angular position

1021 At the start

As can be seen in the examples above the rule is that the attachment atom ldquoArdquo is always at the south-west of thering Furthermore the ring is always constructed counterclockwise and the last bond descends vertically ontothe attachment atom

chemfigA4(-B-C-D-)qquadchemfigA6(------)

A B

CD

A

Angular position of rings

LATEXed by Christian Tellechea the April 24 2011 19

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 21: Chemfig Doc En

ChemFig 10 RINGS

If this angular position is not convenient it is possible to specify another angle using the optional argument atthe beginning of the molecule Here is a 6-cycle which has been rotated by +30 by minus30 and lastly by +60

chemfig[30]A6(------)qquadchemfig[-30]A6(------)qquadchemfig[60]A6(------) A A A

Rotation of rings

1022 After a bond

When a ring does not begin a molecule and one or more bonds have already been drawn the default angularposition changes the ring is drawn is such a way that the bond ending on the attachment atom bisects the angleformed by the Vrst and last sides of the ring

Here is a simple case

chemfigA-B5(-C-D-E-F-) A B

CD

EF

Bond ending on a ring

The rule remains valid whatever the angle of the preceding bond

chemfigA-[25]B4(----)vskip5ptchemfigA=[-30]6(=-=-=-)

A

B

A

Bonds ending on a ring

103 Branches on a ring

To have branches attached to the vertices of a ring we use the syntax we have already seen

ltatomgt(ltcodegt)

where the ltcodegt is that of the sub-molecule and the ltatomgt is at the vertex Unique to rings the default angle ofthe sub-molecule is not 0 but is calculated so that it will bisect the sides leaving the vertex

chemfigX6(-=-(-A-B=C)=-=-)

X

A

B

C

Branch on a ring

A sub-molecule can be attached to the Vrst vertex of a ring just like the other vertices

LATEXed by Christian Tellechea the April 24 2011 20

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 22: Chemfig Doc En

ChemFig 10 RINGS

chemfig5((-A=B-C)-(-D-E)-(=)-(-F)-(-G=)-)

A

B

C

D

E

F

G

Ring and branches

If one wants the bond leaving a vertex not to be the bisector of its sides one can tinker with the optional globalparameter or the optional bond parameter

chemfig5(---([90]-A-B)--)qquadchemfig5(---(-[90]A-B)--)qquadchemfig5(---([+0]-A-B)--)

A

B

A

B

A

B

Branches at specified angles

It is worth noting that in the third example where a relative angle of 0 was given the bonds of the branch aredrawn in line with the preceding bond in the ring This is the rule on page 12 which speciVed that the referenceangle was that of the bond last drawn

We can now connect together rings with bonds

chemfig6(--(-5(----(-4(----))-))----)

Connected rings

104 Nested rings

To ldquogluerdquo two rings together the syntax is only slightly diUerent the vertex is speciVed where the other ring isgoing to start Simply follow this vertex by the usual syntax for a ring Here for example is a 5-ring which isattached to the second vertex of a 6-ring

chemfigA6(-B5(----)=-=-=) A

B

Nested rings

Note that the ring which is going to be attached to the main ring has an angular position such that two of theringsrsquo sides coincide In addition the 5-ring has only four bonds ldquo----rdquo In eUect the Vfth will be useless becauseit is the second side of the 6-ring which has already been drawn

It is quite possible to glue multiple rings together

LATEXed by Christian Tellechea the April 24 2011 21

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 23: Chemfig Doc En

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

chemfig5(--6(-4(-5(----)--)----)---)

Multiple nested rings

There is a case where a trick must be used It can be seen in this example that the fourth side of the second 5-ringjust passes through the centre of atom ldquoErdquo

chemfigA-B5(-C-D5(-X-Y-Z-)-E-F-) A B

CD

X

Y

ZE

F

Flawed drawing

This is normal because the second 5-ring (which is attached to atom ldquoDrdquo) is drawn before ChemFig knows aboutatom ldquoErdquo In this case it is necessary to use two hooks to draw the bond Z-E

chemfigA-B5(-C-D5(-X-Y-Z)-E-F-) A B

CD

X

Y

ZE

F

Distant bond and ring

We could also use a phantomE at the last vertex of the 5-ring

chemfigA-B5(-C-D5(-X-Y-Z-phantomE)-E-F-) A B

CD

X

Y

ZE

F

Using phantom

105 Rings and groups of atoms

Some care must be taken with rings when one or more vertices are made up of groups of atoms

chemfigAB5(-CDE-F-GH-I-)

ABCDE

F

HGI

Ring and groups of atoms

In order for the ring to have a regular shape it is necessary to override the ChemFig mechanism whichautomatically calculates the departure and arrival atoms of bonds Here C-F and F-G must be connected by usingthe optional argument of these bonds

chemfigAB5(-CDE-[1]F-[1]GH-I-)

ABCDE

F

GHI

Forced departure and arrival atoms

11 Representing electron movements

Starting with ChemFig version 03 we can represent the movement of electrons in mesomeric eUects or reactionmechanisms This is done by marking the departure and arrival points of the electron movement arrow using

LATEXed by Christian Tellechea the April 24 2011 22

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 24: Chemfig Doc En

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

the syntax ldquoltargumentgtrdquo This syntax allows a tikz node to be placed and makes this node accessible outsidethe argument of the chemfig command thanks to the ldquoremember picturerdquo option which is passed to all theldquotikzpicturerdquo environments It is assumed that the viewer supports ldquopicture rememberingrdquo and that the compilationis done twice

Two types of diagrams can arise so we can ask for

bull a zero size node on a bond using the syntax ldquoltnamegtltcoeffgtrdquo placed at the beginning of the optionalargument of the relevant bond without being followed by a comma if there is a Vrst optional argument Inthis case the node takes the name ldquoltnamegtrdquo and the ltcoeffgt which must be between 0 and 1 determineswhere the node is located on the bond If ldquoltnamegtrdquo is used the ltcoeffgt is set to 05 by default whichmeans that the node is placed halfway along the bond

bull a node on an atom using the syntax ldquoltnamegtrdquo immediately before the relevant atom In this case thenode has exactly the same footprint as the atom but may be empty and therefore have zero dimensions

Once the chemfig command has drawn the molecule(s) and has placed the nodes with the syntax describedabove we can connect these nodes to each other with tikz instructions These instructions are placed in theargument of the command chemmove6 and has the following syntax if (for example) we need to connect a nodenamed ldquoltname1gtrdquo to the node named ldquoltname2gtrdquo

chemmove[ltoptgt]draw[lttikz optgt](ltname1gt)lttikz linkgt(ltname2gt)

The optional argument ltoptgt of the chemmove command will be added to the argument of the tikzpictureenvironment in which the links between the nodes will be drawn The lttikz optgt and lttikz linkgt instructionsare describe in detail in the documentation of the tikz package

111 Mesomeric eUects

To make these concepts concrete letrsquos take the example of a mesomeric eUect involving a double bond andnon-bonding lone pair conjugate Letrsquos begin with the possible delocalization of electrons from the double bondWe will place a node named ldquodbrdquo (double bond) in the middle of the double bond and a node named ldquoa1rdquo on theend of the double bond

chemfiga1=_[db30]-[-60]lewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmovedraw[-gt](db) controls +(808mm) and +(1458mm) (a1)

X

Xoplus

Mesomeric effect 1

As noted above there is no comma after the node placed in the optional arguments of a bond we writeldquo=_[db30]rdquo and not ldquo=_[db30]rdquo as one might be tempted to do

To link the nodes ldquodbrdquo and ldquoa1rdquo we have used the following syntax

chemmovedraw[-gt](db)controls +(808mm) and +(1458mm)(a1)

In this example we ask for an arrow ([-gt]) and we use two control points7 These will be located using polarcoordinates at 80 and 8 mm from ldquodbrdquo for the Vrst and at 145 and 8 mm from ldquoa1rdquo for the second Though thissyntax may seem complicated at Vrst reading one need not be alarmed because its use will usually be a matter ofcopying and pasting Only the names and coordinates of the control points need be changed as can be veriVedfrom the example below where an arrow has been added from the lone pair (node ldquodnlrdquo to the single bond (nodeldquosbrdquo)

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-gt](db)controls +(1005mm) and +(1455mm)(a1)draw[-gt](dnl)controls +(904mm) and +(454mm)(sb)

X

Xoplus

Mesomeric effect 2

6Actually the chemmove command puts its argument in a ldquotikzpicturerdquo environment with the options ldquoremember picture overlayrdquo7To Vnd all the ways of connecting two nodes with tikz read the documentation for that package

LATEXed by Christian Tellechea the April 24 2011 23

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 25: Chemfig Doc En

ChemFig 11 REPRESENTING ELECTRON MOVEMENTS

For our new arrow we have set the control points as follows 4 mm at an angle of 90 from ldquodnlrdquo and 4 mm at anangle of 45 from ldquosbrdquo But we are not completely satisVed since we would like the arrow not to touch the linesegment representing the lone pair To do this we will add some options to our arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove[-gt]

draw(db) controls +(1005mm) and +(1455mm) (a1)draw[shorten lt=3ptshorten gt=1pt](dnl) controls +(904mm)

and +(454mm) (sb)

X

Xoplus

Mesomeric effect 3

The option ldquoshorten lt=3ptrdquo indicates that the tail of the arrow is to be shortened by 3 pt just as ldquoshorten gt=2ptrdquomeans that the head of the arrow is shortened by 2 pt

We can use all the power of tikz instructions to modify the style of the arrow Here we change the head of thearrow leaving the double bound writing ldquo-stealthrdquo instead of ldquo-gtrdquo and we draw the arrow with a Vne dashedred line We also add the letter π above the middle of the arrow

chemfiga1=_[db30]-[sb-60]dnllewis2Xchemrellt-gtchemfigchemabovevphantomXominus-[30]=_[-60]chemaboveXscriptstyleopluschemmove

draw[-stealththindash pattern= on 2pt off 2ptred](db) controls +(1005mm) and +(1455mm)node[slopedabove] $pi$ (a1)

draw[-gt shorten lt=3pt shorten gt= 1pt](dnl) controls +(904mm) and +(454mm) (sb)

X

Xoplus

π

Mesomeric effect 4

In the following example wersquoll see how to indicate the position of the departure or arrival anchor points of thearrow If we write

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten gt=4pt]

(x1) controls +(901cm) and +(901cm) (x2)

X X

Departure or arrival anchor point 1

Note that the tail of the arrow does not leave correctly from our electrons it leaves from the middle of the upperedge of the node Indeed we chose a departure angle of 90 and so tikz makes the arrow leave from the anchorldquox190rdquo which corresponds to the intersection of the ray leaving from the centre of node ldquox1rdquo at a 90 angle relativeto the horizontal and of the edge of the rectangular node To get the arrow departure angle that we want wemust specify its position After some trial and error it is ldquox157rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(601cm) and +(1201cm) (x2)

X X

Departure or arrival anchor point 2

In some cases it will be easier to use Cartesian coordinated for the control points Here we use just one controlpoint placed 1 cm to the right of and 15 cm above ldquox1rdquo

chemfigx1lewis1Xhspace2cmchemfigx2lewis2|Xchemmovedraw[-gtshorten lt=4ptshorten gt=4pt]

(x157) controls +(1cm15cm) (x2)

X X

A single control point

All the graphics drawn by means of the command chemmove are superimposed and will not be included in thebounding boxes We can see this in the preceding example

LATEXed by Christian Tellechea the April 24 2011 24

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 26: Chemfig Doc En

ChemFig 12 WRITING A NAME UNDER A MOLECULE

112 Reaction mechanisms

Thanks to the option remenber picture which is passed to all the ldquotikzpicturerdquo environments we can easily drawarrows indicating reaction mechanisms Letrsquos take for example the Vrst step of the esteriVcation reaction

setatomsep7mmsetchemrel5mmchemfigR-dnllewis26O-Hchemsign+chemfigR-atocC([6]-OH)=[db]Ochemrel[chemfigatohchemaboveHscriptstyleoplus]ltgtchemmove[-gtshorten lt=2pt]

draw[shorten gt=2pt](dnl)controls +(901cm)and+(north1cm)(atoc)draw[shorten gt=6pt](db)controls +(north5mm)and+(1001cm)(atoh)

R O H + R C

OH

OHoplus

Esterification step 1

The use of the chemaboveltcodegtltmaterielgt command does not change the dimensions of the boundingbox of ltcodegt For this reason we can run into some diXculty in pointing to the symbol representing the chargecarried (oplus or ) In the example above the solution is to create a control point with an angle of 110 at 1 cm fromldquoatohrdquo and to shorten the arrow by 6pt In the following example the second step of the esteriVcation reaction wecan see that the arrow can take more complicated forms without complicating the code

setatomsep7mmsetchemrel5mmchemfigR-O-C(-[2]R)(-[6]OH)-dnllewis26OHhspace1cmchemfigatohchemaboveHscriptstyleopluschemmove

draw[-gtshorten lt=2pt shorten gt=7pt](dnl) controls +(south1cm) and +(north15cm) (atoh)

R O C

R

OH

OH Hoplus

Esterification step 2

The rest is left as an exercise to the reader

12 Writing a name under a molecule

For convenience ChemFig can write the name of a molecule underneath it with the command

chemname[ltdimgt]chemfigltcode of the moleculegtltnamegt

The ltdimgt which is 15ex by default will be inserted between the baseline of the molecule and the top of theletters of the ltnamegt The ltnamegtwill be centred relative to the molecule but the ltnamegtmay not contain multipleparagraphs As we see in this example H O H

The water molecule H2O

the ltnamegt which is displayed under the molecule is

taken into account only for the vertical size of the bounding box The horizontal size of ltnamegt is always zero

Here is a reaction with the names under the moleculesDisplaying names of molecules

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

R C

OH

O

Carboxylic acid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

There are some limitations to this command Suppose we switch the acid and the alcohol on the left side

Name alignment 1

chemnamechemfigRrsquoOHAlcohol

chemsign+

LATEXed by Christian Tellechea the April 24 2011 25

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 27: Chemfig Doc En

ChemFig 12 WRITING A NAME UNDER A MOLECULE

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

RprimeOH

Alcohol+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

In fact to draw the ltnamegt the command chemname inserts 15ex + the largest of the depths8 of the moleculesthus far below the baseline of each molecule (light grey for the examples in this manual) The commandchenameinitltstuffgt initializes this largest depth with the ltstuffgt Therefore one should

bull write chemnameinitltdeepest moleculegt before using the chemname command in a reaction unlessthe reaction begins with the deepest molecule

bull write chemnameinit after having written all the names in a chemical reaction lest the greatest depth inthis reaction interfere with a future reaction

Thus the correct code uses chemnameinit before and after the reactionName alignment 2

chemnameinitchemfigR-C(-[-30]OH)=[30]O

chemnamechemfigRrsquoOHAlcohol

chemsign+

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylic acid

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

RprimeOH

Alcohol

+ R C

OH

O

Carboxylic acid

R C

ORprime

O

Ester

+ H2O

Water

Finally to write a name on multiple lines the command encountered in a ltnamegt causes a line break9

Name on 2 lines

chemnamechemfigR-C(-[-30]OH)=[30]OCarboxylicacid

chemsign+

chemnamechemfigRrsquoOHAlcohol

chemrel-gt

chemnamechemfigR-C(-[-30]ORrsquo)=[30]OEster

chemsign+

chemnamechemfigH_2OWater

chemnameinit

R C

OH

O

Carboxylicacid

+ RprimeOH

Alcohol

R C

ORprime

O

Ester

+ H2O

Water

8In TEX terms the depth is the dimension which extends vertically below the baseline9Conversely the command par is forbidden and causes a compilation error

LATEXed by Christian Tellechea the April 24 2011 26

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 28: Chemfig Doc En

ChemFig 2 DISPLAYING ATOMS

PART IV

Advanced usage

1 Separating atoms

The separating atom mechanism described previously extends each atom until the next capital letter or one of thecharacters - = ~ ( lt gt

In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagramConsider this example molecule noting that the ldquo(rdquo character is placed between braces so that ChemFig doesnrsquotincorrectly create a branch

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

We Vnd that the bond which arrives at the carbon atom in the upper right is too short This happens becauseif we apply the ChemFig rules for separating atoms to the upper right group the atoms are split in this wayldquoC(rdquo ldquoCrdquo ldquoH_3)_3rdquo We now realize that the Vrst atom contains a parenthesis and thus has too great a depthin math mode we can see this by making the bounding boxes visible

CH3CH2

C

CH3

C

H

C(CH3)3

The character ldquo|rdquo forces splitting of the atom when it is encountered Thus we can write C|(CH_3)_3 to ensurethat ChemFig separates just two atoms here ldquoCrdquo and ldquo(CH_3)_3rdquo The problem of the too-short bond is thussolved

Alkene

chemfigCH_3CH_2-[-603]C(-[-120]H_3C)=C(-[-60]H)-[60]C|(CH_3)_3

CH3CH2

C

CH3

C

H

C(CH3)3

2 Displaying atoms

Once a molecule has been split into atoms the macro printatom is called internally by ChemFig in order todisplay each atom Its sole argument is the code of the atom to be displayed (eg ldquoH_3rdquo) By default this macroenters math mode and displays its argument with the math font family ldquormrdquo It is deVned by the following code

bull newcommandprintatom[1]ensuremathmathrm1 when compiling with LATEX

LATEXed by Christian Tellechea the April 24 2011 27

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 29: Chemfig Doc En

ChemFig 3 OPTIONAL ARGUMENTS

bull defprintatom1ifmmoderm1else$rm1$fi when compiling with εTEX ou ConTEXtX

One can modify the code of this macro to customize how atoms are displayed In the following example weredeVne printatom so that each atom will be enclosed in a rectangular box

fboxsep=1ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigH_3C-C(=[30]O)(-[-30]OH)

H3 C C

O

O H

Redefinition of printatom

Here is how to redeVne it to use the ldquosfrdquo font family of math mode

renewcommandprintatom[1]ensuremathmathsf1chemfigH_3C-C(=[30]O)(-[-30]OH) H3C C

O

OH

Atoms displayed with ldquosfrdquo font family

3 Optional arguments

The chemfig command takes two optional arguments their syntax is as follows

chemfig[ltopt1gt][ltopt2gt]ltmolecule codegt

The Vrst optional argument ltopt1gt contains tikz instructions which will be passed to the tikzpicture environmentin which the molecule is drawn The second optional argument ltopt2gt contains tikz instructions which will beexecuted when each node10 is drawn

With the use of the Vrst optional argument one can for example choose the global colour or thickness of lines

chemfigA-B-[2]Cparmedskipchemfig[line width=15pt]A-B-[2]Cparmedskipchemfig[red]A-B-[2]C

A B

C

A B

C

A B

C

Style choice

With the second optional argument one can choose the colour of nodes drawn by tikz change the angle of thedrawing or its scale

chemfigA-B-[2]Cparmedskipchemfig[][red]A-B-[2]Cparmedskipchemfig[dash pattern=on 1pt off 2pt][red]A-B-[2]Cparmedskipchemfig[][rotate=20]A-B-[2]Cparmedskipchemfig[][scale=05]A-B-[2]C

A B

C

A B

C

A B

C

AB

C

A B

C

Style choices

10These instructions are added to the end of the argument of every nodestyleltargumentgt This argument contains by default thefollowing instructions ldquoanchor=baseinner sep=0ptouter sep=0ptminimum size=0ptrdquo

LATEXed by Christian Tellechea the April 24 2011 28

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 30: Chemfig Doc En

ChemFig 4 VERTICAL ALIGNMENT

4 Vertical alignment

In some cases with condensed structural diagram of molecules having horizontal bonds the placement of groupsof atoms is incorrect

Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline

Vertical placement

Hugesetatomsep2em

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSurprisingly the second atom is correctly aligned while the last two undergo a vertical shift which seems to bethe results of the diUerent height of the bounding box of the atoms ldquoA^1rdquo and ldquoE_1rsquorsquo

In order to understand this phenomenon we need to consider how ChemFig places groups of atoms relativeto each other Let us limit ourselves to the case of horizontal bonds in order to simplify terminology althoughthe algorithm is the same for other bonds A horizontal bond leaves from the middle of the right side of thebounding box of the departure atom of this bond The arrival atom is positioned in such a way that the middle ofthe left side of its bounding box is at the end of the bond It follows that the vertical placement of the arrival atomdepends on the height of the departure atom To limit this phenomenon ChemFig adds to each arrival atom thevphantom of the departure atom but does not include it in the contents of the arrival atom this vphantom isnot intended to aUect the following atoms The atoms remaining in each group are aligned so that their baselinecoincides with the baseline of the preceding atom

The defective alignment can thus be explained The atoms ldquoBrdquo and ldquoFrdquo are aligned correctly as they reWectthe height of the atoms before them because of their vphantom For the atoms ldquoCrdquo and ldquoFrdquo the heights of theimmediately preceding atoms are taken into account but those of the atoms ldquoA^1rdquo and ldquoE_1rdquo are ignored Itfollows that these atoms are a little too high or too low depending on the height of these bonds

We can show this by making visible the bounding boxes of the atoms one sees clearly that the atoms ldquoBrdquo and ldquoFrdquohave bounding boxes that reWect the heights of the immediately preceding atoms

Vertical placement and bounding boxes

Hugesetatomsep2em

fboxsep=0pt

renewcommandprintatom[1]fboxensuremathmathrm1

chemfigA^1-B-C-Dqquad

chemfigE_1-F-G-H

A1 B C D E1 F G HSince there is no satisfactory manual solution this problem can be worked around manually by putting inside thethird atom a vphantom having the same height as the Vrst so that the height aUects the following atoms

Vertical placement workaround

Hugesetatomsep2em

chemfigA^1-B-vphantomA^1C-Dqquad

chemfigE_1-F-vphantomE_1G-H

A1 B C D E1 F G HFor any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thusneutralize the vphantom Simply place the chemskipalign command in the group of atoms the alignment willresume in the following group of atoms as if the group of atoms containing chemskipalign had never existedThe following example shows the eUects of this instruction the reference point of the box containing the Vrstatom is placed at the level of the bond which arrives from the left The bounding boxes of the atoms are drawn inthe second line

LATEXed by Christian Tellechea the April 24 2011 29

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 31: Chemfig Doc En

ChemFig 5 SHIFTED DOUBLE BONDS

largechemfigA--BquadchemfigA-chemskipalign-Bparbigskipfboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA--BquadchemfigA-chemskipalign-B

A B A B

A B A B

Deactivation of the alignment mechanism

This command is to be used with caution lest the alignment of atoms in the next group be disrupted In generalall will be well if the group of atoms featuring chemskipalign contains a single atom whose height and depthare less than those of the preceding and following atoms and if the preceding and following atoms have identicalheights and depths Here is an example of the mess that results when the group of atoms contains two atomshere ldquochemskipalignrdquo and ldquoBrdquo

largefboxsep=0ptrenewcommandprintatom[1]fboxensuremathmathrm1chemfigA-chemskipalignB-C

A B C

Consequence of the chemskipaligncommand

This feature can sometimes be useful Suppose we want to draw the following molecule

A B

We can deVne commands which will draw the empty and full disks with tikz To ensure that these disks are at theright height namely the height of the bond arriving at them we will use the command chemskipalign In thesecond line below the bonds are ldquostuckrdquo to the disks by using the ability to change the bond shortening with theldquordquo character a feature seen on page 11

begingroupdefemptydiskchemskipaligntikzdraw(00)circle(2pt)deffulldiskchemskipaligntikzfill(00)circle(2pt)chemfigA-emptydisk-fulldisk-BparchemfigA-(0pt)emptydisk-(0pt0pt)fulldisk-(0pt)Bendgroup

A BA B

Use of chemskipalign and

5 Shifted double bonds

All double bonds are made up of two line segments and these segments are drawn on either side of the imaginaryline along which a single bond would be drawn It is possible to shift a double bond so that one of the linesegments lies on the imaginary line The other segment is then shifted above or below the bond Actually it ismore correct to say ldquoleftrdquo or ldquorightrdquo of the imaginary line as the bond is traversed in the direction of drawing

To shift the bond to the left write ldquo=^rdquo and to shift it to the right write ldquo=_rdquo

chemfigA-=-BparchemfigA-=^-BparchemfigA-=_-B

A BA BA B

Shifted double bonds

In rings double bonds are automatically shifted to the left However they can be shifted to the right by specifyingit with ldquo=_rdquo

chemfig6(-=-=-=)qquadchemfig6(-=_-=_-=_)

Shifted double bonds and rings

Shifted bonds are particularly useful in drawing skeleton diagrams of molecules consisting of carbon chains withdouble bonds They give a continuous zig-zag path whereas the path will be broken with regular double bonds

LATEXed by Christian Tellechea the April 24 2011 30

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 32: Chemfig Doc En

ChemFig 7 SAVING A SUB-MOLECULE

chemfig-[30]=[-30]-[30]=[-30]-[30]parchemfig-[30]=^[-30]-[30]=^[-30]-[30]parchemfig-[30]=_[-30]-[30]=_[-30]-[30]

Shifted bonds and skeleton diagrams

6 Delocalized double bonds

It is sometimes necessary to draw a double bond so that one line segment is dashed while the other is solid11This feature is not hard-coded into ChemFig instead tikz its ldquodecorationsrdquo library and its programmable stylesmake it possible

First of all after having loaded the ldquodecorationsrdquo library by putting usetikzlibrarydecorations in thepreamble a decoration named ldquoddbondrdquo (for Dashed Double Bond) is deVned (lines 1 to 14) and then two tikzstyles called ldquolddbondrdquo and ldquorddbondrdquo (lines 15 and 16) For the former the dashed line segment is on the leftof the solid middle segment for the latter it is on the right These styles can be called with the Vfth optionalargument of bonds

Custom decorations

pgfdeclaredecorationddbondinitial

stateinitial[width=4pt]

pgfpathlinetopgfpoint4pt0pt

pgfpathmovetopgfpoint2pt2pt

pgfpathlinetopgfpoint4pt2pt

pgfpathmovetopgfpoint4pt0pt

statefinal

pgfpathlinetopgfpointdecoratedpathlast

tikzsetlddbondstyle=decoratedecoration=ddbond

tikzsetrddbondstyle=decoratedecoration=ddbondmirror

setatomsep4em

chemfig[-30]R-C-[60]C(-[60rddbond]O)-[lddbond]N(-[-60]H)-[60]C-R

R

C

C

O

N

H

C

R

7 Saving a sub-molecule

ChemFig is capable of saving a ltcodegt as an alias for reuse in a more compact form in the code of a moleculeThis is particularly useful when the ltcodegt appears several times

To do this one gives the command

definesubmolltnamegtltcodegt

which saves the ltcodegt for recall in the code of the molecule via the shortcut ldquonamerdquo This ltnamegt can be

bull a sequence of characters all the alphanumeric characters able to be between csname and endcsname areaccepted

11Thanks to Andreas Broumlermann who suggested this feature and who gave me the solution to this problem

LATEXed by Christian Tellechea the April 24 2011 31

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 33: Chemfig Doc En

ChemFig 8 DECORATIONS

bull a control sequence

In all cases if the alias is already deVned you should not overwrite it with a new deVnition using definesubmolA warning will be issued to the user that the old alias will be overwritten by the new one To override thedeVnition of an alias made previously use

redefinesubmolltnamegtltcodegt

Here is a code which draws the pentane molecule An alias ldquoxyrdquo was deVned beforehand for the code CH_2

definesubmolxyCH_2chemfigH_3C-xy-xy-xy-CH_3

H3C CH2 CH2 CH2 CH3

Pentane

In this case the technique is not very interesting because ldquoxyrdquo is just as long to type as the code it replaces

But in certain cases this feature saves a lot of space in the code of the molecule and increases readability Inthe following example we draw the complete structural diagram of butane We will deVne an alias with thecontrol sequence ldquoxxrdquo for the sub-molecule CH2 If we use only relative angles it is possible to rotate the entiremolecule to any given angle by using the optional global angle parameter which speciVes the default bond angleof the main molecule It is set to 15 here

definesubmolxxC(-[+90]H)(-[-90]H)chemfig[15]H-xx-xx-xx-xx-H

HC

H

H

C

H

H

C

H

H

C

H

H

H

Butane

The definesubmol command takes an optional argument its syntax is as follows

definesubmolltnamegt[ltcode1gt]code2

When the optional argument is present the alias ldquoltnamegtrdquo will be replaced by ltcode1gt if the bond which arrivesat the alias comes from the right ie if the angle which the arriving bond makes is between but is not equal to90 and 270 For all the other cases where the bond arrives from the left of vertically the alias will be replacedby ltcode2gt

We will deVne a control sequence Me pour ldquomethylrdquo so that the alias ldquoMerdquo will be replaced by ldquoH_3Crdquo when thebond arrives from the right and by ldquoCH_3rdquo when it arrives from the left We can observe in the example that withthis alias we need no longer worry about the angle

definesubmolMe[H_3C]CH_3chemfig6((-Me)=(-Me)-(-Me)=(-Me)-(-Me)=(-Me)-)

CH3

CH3

CH3

CH3

CH3

CH3

Dual alias

8 Decorations

81 Lewis diagrams

The macro lewis allows placement of pairs of electrons of single electrons or of empty slots This syntax isused

lewisltn1gtltn2gtltnigtltatomgt

LATEXed by Christian Tellechea the April 24 2011 32

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 34: Chemfig Doc En

ChemFig 8 DECORATIONS

where the ltn1gt ltnigt represent the desired positions (in multiples of 45) around the ltatomgt These wholenumbers must be between 0 and 7

This command can also be used inside the argument of chemfig

lewis0246Aparmedskiplewis1357BparmedskipchemfigH-lewis26O-S(=[2]lewis13O)(=[6]lewis57O)-lewis26O-H

A

B

H O S

O

O

O H

The lewis macro

If one wishes to draw two electrons instead of a line follow the integer with a ldquordquo If one wishes to draw a singleelectron follow it with a ldquordquo To draw a lacuna follow it with a ldquo|rdquo

lewis0246Cqquadlewis1357Cparbigskiplewis0246Cqquadlewis1357Cparbigskiplewis024|XparbigskipHydronium ion chemfigH-lewis5|7O^+(-[2]H)-H

C C

C C

X

Hydronium ion H O+

H

H

Lewis diagrams

All the decorations drawn by lewis are not included in the bounding box of the atom they are drawn afterwardsA consequence of this is seen in the two examples above where the frame does not appear to be properly Vttedto the drawing of the molecule which extends downward slightly This will be seen more often in this theldquoDecorationsrdquo chapter which presents commands which do not change the bounding box

This can be seen more clearly by drawing an fbox around decorated atoms

fboxsep0ptfboxlewis0246Aparmedskipfboxlewis13B

A

B

Bounding box and the lewis macro

Several parameters can be set with the help of the macro

setlewis[dim1]ltdim2gtltdim3gtlttikz codegt

If an argument is empty it takes its default value

bull ltdim1gt is the width of the rectangle which represents the empty slot obtained whith the character ldquo|rdquobull ltdim2gt is the distance between the bounding box and the decoration It is 02ex by defaultbull ltdim3gt is the length of the line segment representing a pair of electrons It is 15ex by defaultbull ltcode tikzgt is code which is passed directly to tikz This code is empty by default

setlewis4pt15emredchemfigA-lewis26B-Cparbigskipsetlewisline width=04ptchemfigA-lewis2|B-C

A B C

A B C

Parameters for the lewis macro

82 Stacking characters

The macros

chemabove[ltdimgt]ltcodegtltstuffgt

and

chembelow[ltdimgt]ltcodegtltstuffgt

LATEXed by Christian Tellechea the April 24 2011 33

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 35: Chemfig Doc En

ChemFig 8 DECORATIONS

place the ltstuffgt above and below the ltcodegt respectively at a vertical distance ltdimgt without changing thebounding box of ltcodegt The length ltdimgt is 15pt by default

These commands are independent of the macro chemfig and can be used either inside or outside its argument

They are especially useful in rings if care is taken to put braces around the letters A B C and D in order toprevent ChemFig from starting a new atom on these letters

chemfig5(-chembelowAB--chemaboveCD--)

AB

CD

Staking in rings

They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms sothat the bonds do not end up being too short

chemfigH-chemabovelewis5|7Oquadscriptstyle+(-[2]H)-H

H O+

H

H

Hydronium ion

83 Chemical reactions

To write chemical reactions ChemFig provides a command for the signs and a command for the arrows

The command chemsign[ltdimgt]ltsigngt typesets the ltsigngt which is surrounded on both sides by an unbreak-able horizontal space ltdimgt defaulting to 05em

The command chemrel[ltarg1gt][ltarg2gt]ltarrow codegt draws an arrowwhere the optional arguments ltarg1gtand ltarg2gt are placed above and below the arrow respectively without modifying its bounding box Theltarrow codegt is passed directly to tikz except when it involves ldquoltgtrdquo which allows two arrows to be drawn oneabove the other

Achemrel-gtBparAchemrellt-BparAchemrellt-gtBparAchemrelltgtBparAchemrel-gtredthickB

A BA BA BA BA B

Types of arrows

The command setchemrelltdim1gtltdim2gtltdim3gt allows settings of the dimensions used in drawing thearrow

bull ltdim1gt is the vertical spacing between the arrow and the optional text above andor below it If theargument is empty it defaults to 2pt

bull ltdim2gt is the unbreakable horizontal space inserted before and after the arrow If the argument is emptyit defaults to 07em

bull ltdim3gt is the length of the arrow If the argument is empty if defaults to 4em

setchemrel1pt6emAchemrel[footnotesize above][tiny below]lt-gtB

Abelow

aboveB

Text above arrows

Here is an example of a chemical reactionChemical reaction

setchemrel0pt12em6em

chemfig6(------)chemsign+chemfigH_3C-Cl

chemrel[itshapefootnotesize Catalyst]-gt

chemfig6(---(-)---)chemsign+chemfigH-Cl

+ H3C ClCatalyst

+ H Cl

LATEXed by Christian Tellechea the April 24 2011 34

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 36: Chemfig Doc En

ChemFig 10 BEYOND CHEMISTRY

And anotherSynthesis of phenylacetylene

chemfig6(-=6(-(-Br)-(-Br))-=-=)

chemrel[chemfigNaNH_2][chemfigNH_3]-gt

chemfig6(-=(-~)-=-=)

Br

BrNH3

NaNH2

9 Using chemfig in the tikzpicture environment

It is possible to call the chemfig inside a tikzpicture environment

begintikzpicture[help linesstyle=thindraw=black50]draw[help lines] (00) grid (44)draw(00) -- (21)draw(22) circle (05)node at (13) chemfigA=B-[30]Cnode[drawredanchor=base] at(32)chemfigXgt[2blue]Yendtikzpicture

A B

C

X

Y

chemfig inside tikzpicture

10 Beyond chemistry

At heart ChemFig is a tool for drawing graphs and this tool has been programmed to adapt it for chemistryIn some ways it is possible to return ChemFig to its roots to draw organization charts or other diagramsrepresented by graphs

Each atom is contained in a tikz node By default these nodes have an ldquoinner seprdquo and an ldquoouter seprdquo equal to 0ptThey are rectangular as seen on page 10 These defaults can be overwritten with the macro setnodestyle theargument of which is passed to tikz and speciVes the style of the nodes containing the atoms

In this example we specify only ldquodrawinner sep=2ptrdquo which has the eUect of drawing the outline of the nodesand separating the outline and node contents by 2pt We also specify setbondoffset0ptsetbondoffset sothat the bonds touch the edges of the nodes The interatomic spacing is increased to 75pt Finally the commandprintatom is made as simple as possible so that math mode is no longer used and spaces are thus preserved

An organization chart

setnodestyledrawinner sep=2pt

setbondoffset0pt

setatomsep75pt

renewcommandprintatom[1]1

chemfigThe boss-[6]Me(-[4]Them(-[6]The others)(-[72]Group 1))-You(-[-12005]Him)(-[-6005]Her)

LATEXed by Christian Tellechea the April 24 2011 35

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 37: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

The boss

MeThem

The others

Group 1

You

Him Her

Here is another organization chart where the nodes are circular and coloured cyan

Family diagram

setnodestyledrawcirclefill=cyanminimum size=30pt

setbondoffset0pt

setatomsep80pt

renewcommandprintatom[1]textsf1

chemfigMe(-[-5012]Brother)(-[-10]Brother(-[15]Niece)(-[-35]Niece))

(-[-15508]Sister-[-80]Nephew)(-[95125]Father(-[-2508]Uncle)(-[-6508]Aunt))

(-[135]Mother-[-9505]Uncle)

Me

Brother

Brother

Niece

Niece

Sister

Nephew

Father

Uncle

Aunt

Mother

Uncle

11 Annotated examples

In this chapter several molecules will be drawn putting into use the methods previously described The aim hereis to show a logical order for putting together a molecule so that the user unfamiliar with ChemFig will learnhow to construct complex molecules The construction steps will be shown to help with this learning process

In addition several possibilities mdash some intuitive and others less so mdash will be shown which give the same graphicalresults with the objective being to show that ChemFig allows some Wexibility in encoding molecules One cansee how each is put together and adopt the methods with which one is most comfortable

LATEXed by Christian Tellechea the April 24 2011 36

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 38: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

111 Ethanal

Here we will draw the ethanal (or acetaldehyde) molecule H C

H

H

C

H

O

The best method for non-cyclic molecules is to select the longest chain Here one could take ldquoH-C-C=0rdquo forexample The bond C=O is tilted to 45 by using the predeVned angle ldquo[1]rdquo This give a ldquobackbonerdquo of the moleculeto which the branches merely have to be added

chemfigH-C-C=[1]OH C C

O

Backbone of ethanal

The three hydrogen atoms still have to placed at the correct orientation with the help of predeVned angles TheVrst is at 90 with the branch ldquo(-[2]H)rdquo the second at 270 with ldquo(-[6H])rdquo and the one on the right at 315 withldquo(-[7]H)rdquo

chemfigH-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O H C

H

H

C

H

O

Ethanal

112 2-amino-4-oxohexanoic acid

Here is the molecule to be drawn

O NH2

O

OH

As is often the case for most molecules there are several methods and for each several diUerent ways of gettingthe result Here we will look at four diUerent methods

1121 Absolute angles

We will Vrst of all draw the central chain with absolute angles We set the default angle to +30 with the optionalargument and so only the descending bonds need to have their absolute angle set to minus30

chemfig[30]--[-30]--[-30]--[-30]OHOH

Backbone (absolute angles)

The branches ldquo(=[6]O)rdquo ldquo(-[6]NH_2)rdquo and ldquo(=[2]O)rdquo still have to be added to the correct vertices

chemfig[30]--[-30](=[6]O)--[-30](-[6]NH_2)-(=[2]O)-[-30]OH

O NH2

O

OH

Molecule (absolute angles)

LATEXed by Christian Tellechea the April 24 2011 37

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 39: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

1122 Relative angles

A more general approach uses only relative angles in this way

chemfig[30]--[-60]--[-60]--[-60]OHOH

Structure (relative angles)

then

chemfig[30]--[-60](=[-60]O)--[-60](-[-60]NH_2)-(=[60]O)-[-60]OH

O NH2

O

OH

Molecule (relative angles)

1123 Ring

Since the angles between the bonds are 120 it is possible to use a 6-ring although this method is less naturalHere we take advantage of the fact that a ring can be left unVnished The ring must be rotated 120 so that theVrst vertex is to the south-east of the ring

chemfig[120]NH_26(---=O)

H2NO

Backbone (ring)

Now the branches must be added to the right vertices

chemfig[120]NH_26(-(-(=[60]O)-[-60]OH)--(--[60])=O)

H2N

O

OH

O

Molecule (ring)

1124 Nested rings

Delving deeper into the ring method we can also consider nesting incomplete 6-rings We could start with thisbackbone

chemfig6(--6(--=O))

O

Backbone (nested rings)

And then add the bonds which leave the vertices of these rings There are no angles to worry about because thebonds leaving the rings are the bisectors of the sides of the ring exactly what we want here

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)=O))

O NH2

OH

O

Molecule (nested rings)

LATEXed by Christian Tellechea the April 24 2011 38

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 40: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

A close look shows that the second line segment of the double bond to the oxygen atom is inside the incomplete6-ring12 Despite its brevity this code does not give a perfect drawing This can of course be corrected by adding alittle to the code

chemfig6((-)-(=O)-6(-(-NH_2)-(-OH)(=[60]O)))

O NH2

OH

O

Molecule (corrected nested rings)

113 Glucose

The goal here is to represent the glucose molecule according to several diUerent conventions

1131 Skeleton diagram

The code here looks like that of 2-amino-4-oxohexanoic acid This gives almost the same structure with absoluteangles except here the default angle is minus30

chemfig[-30]HO--[30]--[30]--[30]-HHO

H

Backbone

Adding the branches is no problem We use predeVned absolute angles

chemfig[-30]HO--[30](lt[2]OH)-(lt[6]OH)-[30](lt[2]OH)-(lt[6]OH)-[30](=[2]O)-H

HO

OH

OH

OH

OH

O

H

Glucose skeleton diagram

1132 Fisher projection

The goal is to get the molecule below

OH

H OH

H OH

HHO

H OH

O

12This was also true for the preceding method with one ring

LATEXed by Christian Tellechea the April 24 2011 39

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 41: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

The idea is to begin to draw the longest chain vertically by giving a default angle of ldquo[2]rdquo Here is the skeletonwhere we have added lower case letters at the end of each vertical bond

chemfig[2]OH-[3]-a-b-c-d-=[1]O

OH

a

b

c

d

O

Skeleton

Next we deVne two aliases for the horizontal bonds and the atoms at their ends Lets choose ldquoxrdquo which we willput in place of the lower case a c and d and ldquoyrdquo which will replace the letter c Since these alias are just onecharacter we do not need braces and can write ldquoxrdquo instead of ldquoxrdquo

definesubmolx(-[4]H)(-[0]OH)definesubmoly(-[0]H)(-[4]OH)chemfig[2]OH-[3]-x-x-y-x-=[1]O

OH

H OH

H OH

HHO

H OH

O

Glucose (Fisher projection)

1133 ldquoChairrdquo representation

We will depict the α-D-glucose moleculeHO

HO

OHOH

O

OH

To do this we will Vrst of all draw Vve sides of the chair and link the Vrst vertex to the last with a hook ldquordquo Wewill use the following absolute angles running counterclockwise minus50 10 minus10 130 190

chemfig-[-50]-[10]-[-10]-[130]O-[190]O

Structure

Now we simply add the branches inside parentheses The angles are chosen to give the best impression ofperspective and some bonds are shortened by a factor of 07

LATEXed by Christian Tellechea the April 24 2011 40

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 42: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

chemfig(-[190]OH)-[-50](-[170]OH)-[10](-[-5507]OH)-[-10](-[607]OH)-[130]O-[190](-[15007]-[207]OH)

HO

HO

OHOH

O

OH

Chair representation

1134 Haworth projection

The goal is to depict this D-glucopyranose molecule HO

OH

OH

OH

O

HO

First of all we will choose the longest chain which starts at the ldquoHOrdquo group on the left and continues throughVves sides of the ring The ring will be closed with a hook For the vertical bond which leaves from the Vrst ldquoHOrdquogroup we need to specify that it will leave from the second atom using the optional argument Furthermore itwill be shortened with a coeXcient of 05 Its optional argument will thus be ldquo[2052]rdquo

Next to give the impression of perspective to the ring the diagonal bonds will be shortened by a coeXcientof 07 For the bold diagonal lines we will use Cram bonds having redeVned the base of the triangles to be2pt The bold horizontal bond needs to be drawn with a thickness of 2pt and so its optional argument will beldquo[0line width=2pt]rdquo Here is the skeleton of the molecule

setcrambond2ptchemfigHO-[2052]lt[707]-[line width=2pt]gt[107]-[307]O-[4] HO

O

Structure

All that needs to be done now is to add the branches at the correct places giving the right absolute angles andsometimes reducing the length to better give the illusion of perspective

setcrambond2ptchemfigHO-[2052]lt[707](-[205]OH)-[line width=2pt](-[605]OH)gt[107](-[605]OH)-[307]O-[4](-[203]-[305]OH) HO

OH

OH

OH

O

HO

Haworth projection

114 Adrenaline

We want to draw the adrenaline molecule

OH

OH

NH

CH3

OH

We are going to use two diUerent methods

1141 Using one ring

First of all we start with a 6-ring and we draw the start of the branches which leave it

LATEXed by Christian Tellechea the April 24 2011 41

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 43: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

chemfig6((-HO)-=-(-)=-(-HO)=)

OH

OH

Skeleton of adrenaline

The branch on the right still needs to be completed using for example relative angles

chemfig6((-HO)-=-(--[-60]-[-60]HN-[+60]CH_3)=-(-HO)=)

OH

HN

CH3

OH

Adrenaline step two

Then we need to add a Cram-bonded OH and indicate that the bond which arrives at ldquoHNrdquo does so on the secondatom ie ldquoNrdquo We use the fourth optional argument of the bond

chemfig6((-HO)-=-(-(lt[60]OH)-[-60]-[-602]HN-[+60]CH_3)=-(-HO)=)

OH

OH

NH

CH3

OH

Adrenaline

1142 Using two rings

This method is less natural but the goal is to show here how to make a bond invisible

We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-ringsadjacent to each other

chemfig6((-HO)-=6(--HN---)-=-(-HO)=)

OH

HN

OH

Adrenaline two-ring skeleton

Now the Vrst two bonds of the ring on the right need to be made invisible To do this we use the argument that ispassed to tikz specifying ldquodraw=nonerdquo These bonds will thus have this code ldquo-[draw=none]rdquo To keep thecode readable we deVne an alias named ldquoamprdquo for these bonds

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN---)-=-(-HO)=)

OH

HN

OH

Adrenaline step two

The rest becomes easy just add the branches to the right vertices

definesubmolamp-[draw=none]chemfig6((-HO)-=6(ampampHN(-CH_3)--(ltOH)-)-=-(-HO)=)

OH

HN

CH3

OH

OH

Adrenaline step three

LATEXed by Christian Tellechea the April 24 2011 42

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 44: Chemfig Doc En

ChemFig 11 ANNOTATED EXAMPLES

To Vnish we specify that the bonds that arrive at and leave from ldquoHNrdquo must do so at the second atom We thereforedeVne another alias for the invisible bond which arrives at ldquoHNrdquo

definesubmolamp-[draw=none]definesubmolampamp-[2draw=none]chemfig6((-HO)-=6(ampampampHN(-CH_3)-[2]-(ltOH)-)-=-(-HO)=)

OH

NH

CH3

OH

OH

Adrenaline

115 Guanine

We will draw the guanine molecule

NH2 N NH

N

O

NH

First of all letrsquos begin by drawing the nested rings putting just the nitrogen atoms at the vertices

chemfig6(=N-6(-N-=N)=--N-)

N N

NN

Guanine skeleton

Then we can draw the horizontal bond in the right ring with a hook We will also place a hydrogen atom underthe nitrogen atom of the 5-ring with the command chembelowNH We also need to write ldquoHNrdquo instead of ldquoNrdquoat the vertex at the upper left of the molecule

chemfig6(=N-6(-chembelowNH-=N)=--HN-)

N NH

NNH

Guanine step two

We note that one bond leaves from the wrong atom13 The automatic calculation mechanism must be correctedso that the bond leaves from the second atom ldquoNrdquo instead of the Vrst To do this we give an optional argument forthe last bond of the Vrst 6-ring ldquo[2]rdquo

chemfig6(=N-6(-chembelowNH-=N)=--HN-[2])

N NH

NNH

Guanine step three

Simply add the branches to the right vertices Note especially the branch leaving the Vrst vertex of the Vrst 6-ringldquo(-N_2N)rdquo

13This seems illogical because the angle of the bond from the HN group toward the Vrst vertex lies between minus90 and 90 ChemFig

should therefore leave from the second atom To explain this contradiction one must know that in rings the last bond always links thelast vertex to the Vrst ignoring the calculated theoretical angle of this bond (which here is minus90) ChemFig uses this theoretical angle todetermine the departure and arrival atoms but does not use it to draw the bond because the two ends are already deVned The departureatom for the last bond is thus the Vrst atom

LATEXed by Christian Tellechea the April 24 2011 43

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 45: Chemfig Doc En

ChemFig 12 HOW TO

chemfig6((-H_2N)=N-6(-chembelowNH-=N)=-(=O)-HN-[2])

NH2 N NH

N

O

NH

Guanine

We could also draw the same molecule with a regular 5-ring as is sometimes done

chemfig6((-H_2N)=N-5(-chembelowNH-=N-)=-(=O)-HN-[2])

NH2 NNH

N

O

NH

Guanine with 5-ring

12 How to

121 Write a colored atom

Since the package xcolor is loaded by tikz itself loaded by ChemFig we can write color commands in the codeof a molecule mainly color and textcolor The atoms are displayed in tikz nodes which behaves like boxes ofTEX and it is as if these atoms were put in a group Therefore the color change remains local to the atom

chemfigCcolorblueH_3-C(=[1]O)-[7]OcolorredH CH3 C

O

OH

Colors

This code does not work because of the rule used to separate atoms here the Vrst atom sarts at ldquoCrdquo and spreadsto the next uppercase letter Therefore this atom is ldquoCcolorbluerdquo and the color change occurs at the end ofatom and has no eUect We need to force ChemFig to cut the Vrst atom just after ldquoCrdquo with the character ldquo|rdquo andthen include colorblueH_3 between braces so that ChemFig does not stop the atom 2 before the uppercaseldquoHrdquo which would leave the color change alone and therefore ineUective in an atom

chemfigC|colorblueH_3-C(=[1]O)-[7]O|colorredH CH3 C

O

OH

Colors

The same eUect can be obtained with textcolor

chemfigC|textcolorblueH_3-C(=[1]O)-[7]O|textcolorredH CH3 C

O

OH

Colors

The main disadvantage is that we have to do the same for every atom that need to be colored even if they arecontiguous

LATEXed by Christian Tellechea the April 24 2011 44

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 46: Chemfig Doc En

ChemFig 12 HOW TO

122 Add a superscript without modifying a bond

Adding a charge to an atom with a mathematical exponent implies that the box (and therefore the tikz node)containing the atom has its dimensions modiVed It has no importance when the atom is trailing but the alignmentmay be compromised if a bond is attached to the atom The Vrst reaction is to put the charge in a box with nowidth and therefore use the command rlap14 which often gives good results We see here that with rlap thehorizontal alignment of atoms is preserved

chemfigA^+-[2]BqquadchemfigArlap$^+$-[2]B A+

B

A+

B

Charge and bond

If you want to use the command oplus which displays ldquooplusrdquo some could Vnd that the charge is too low Aoplus Inthat case why not use chemabove to put as precisely as you will both vertically and horizontally the charge

chemfigchemabove[05pt]Ascriptstylehspace35mmoplus-[2]Bqquadchemfigchemabove[-05pt]Ascriptstylehspace35mmoplus-[2]B A

oplus

B

Aoplus

B

Charge et chemabove

We notice an additional level of braces for the second molecule Indeed as we specify ldquo-05ptrdquo for the optionalargument of chemabove to lower the charge it is necessary to prevent ChemFig to understand the sign ldquo-rdquo as asingle bond

To add a load near the vertex of a cycle the best method is to attach an invisible bond to this vertex which isdone here with definesubmol with a bond with a length coeXcient equal to 02

definesubmolnobond-[02draw=none]chemfig5(---(nobondscriptstyleoplus)-(nobondscriptstyle-)-)

oplusminus

Charges and cycles

123 Draw a curve bond

We have already seen that with the tikz library ldquodecorationspathmorphingrdquo we can draw a wavy bond

chemfigA-[3decoratedecoration=snake]B

chemfigA-[3decoratedecoration=snakeamplitude=15mmsegment length=25mm]B

A BA B

Wavy bond

For more Wexibility you can also deVne nodes using the character ldquordquo and reuse these nodes after the moleculehas been drawn to connect them with a curved line using chemmove

chemfigaA-[draw=none]bBchemmovedraw[-](a)controls +(457mm) and +(2257mm)(b)bigskip

chemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(2403em)(b)quadchemfig6(a---b---)chemmovedraw[-](a)controls +(603em) and +(301em)

++(202em) controls +(2103em) and +(-1204em) (b)

A B

Curved bonds

14If you have to put the charge at the left of the atom you must use the command llap

LATEXed by Christian Tellechea the April 24 2011 45

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 47: Chemfig Doc En

ChemFig 12 HOW TO

124 Modify the size of a molecule

Two parameters determine the default size of a molecule the font size and the parameter of setatomsep whichis 3em the default We can modify independently these two parameters to change the size of a molecule

definesubmolhhoH-[30]O-[-30]Hchemfighho

setatomsep25emchemfighho

scriptsizechemfighho

tinychemfighhosetatomsep5emchemfighho

H

O

H

H

O

H

HO

H

HO

HH

O

H

Change the size

You can use the optional second argument of chemfig to globally enlarge or reduce a molecule ie the text andlinks will be reduced by the same ratio

definesubmolhhoH-[30]O-[-30]Hchemfighho

chemfig[][scale=075]hho

chemfig[][scale=05]hho

chemfig[][scale=033]hho

H

O

H

H

O

H

H

O

H

H

O

H

Global change of the size

125 Draw a ploymer element

The diXculty lies in the display of delimiters (parentheses or brackets) on bond For this we will again use thecharacter ldquordquo to deVne global nodes that will be used later as anchors for delimiters We will assume that thenode for the location of the opening delimiter is called ldquoopbrrdquo and the one of the closing delimiter ldquoclbrrdquo

We will write a simple macro setpolymerbracket followed by two characters which deVne the opening delimiterand closing delimiter

Then the macro makebraces has an optional argument of the form ldquoltdim upgtltdim downgtrdquo These two dimen-sions are the height and depth of the delimiters from the baseline The mandatory argument of makebraces isthe subscript located at the right bottom of the closing delimiter

Polymers

newcommandsetpolymerdelim[2]

defdelimleft1defdelimright2

defdefinedelimdim12enddefinedelimdefdelimht1defdelimdp2

newcommandmakebraces[2][0pt0pt]

definedelimdim1enddefinedelim

chemmove

node[at=(opbr)yshift=(delimht-delimdp)2]

llap$leftdelimleftstrutvrule heightdelimht depthdelimdp width0pt right$

node[at=(clbr)yshift=(delimht-delimdp)2]

rlap$leftstrutvrule heightdelimht depthdelimdp width0pt rightdelimright_2$

setpolymerdelim()

Polyethylen

chemfigvphantomCH_2-[opbr1]CH_2-CH_2-[clbr0]makebracesn

bigskip

Polyvinyl chloride

chemfigvphantomCH_2-[opbr1]CH_2-CH(-[6]Cl)-[clbr0]

makebraces[0pt15pt]n

bigskip

Nylon 6

LATEXed by Christian Tellechea the April 24 2011 46

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 48: Chemfig Doc En

ChemFig 12 HOW TO

chemfigphantomN-[opbr1]N(-[2]H)-C(=[2]O)-(CH_2)_5-[clbr0]

makebraces[20pt0pt]

bigskip

Polycaprolactamesetatomsep2em

chemfig[-30]-[opbr1]N(-[6]H)-[30](=[2]O)--[30]--[30]--[clbr030]

makebraces[5pt5pt]n

setpolymerdelim[]

Polyphenylen sulfide

chemfigvphantomS-[opbr1]S-(6(---(-[clbr0])---))

makebraces[15pt15pt]

Polyethylen CH2 CH2

( )n

Polyvinyl chloride CH2 CH

Cl

n

Nylon 6 N

H

C

O

(CH2)5

PolycaprolactameN

H

O( )n

Polyphenylen sulVde S

126 Draw the symmetrical of a molecule

The two commands hflipnext and vflipnext allow to draw the symmetrical of the next molecule about ahorizontal or vertical axis If we want to draw more symmetrical molecules we need to write these commandsbefore each molecule involved

chemfigH_3C-C(=[30]O)-[-30]OH original

vflipnextchemfigH_3C-C(=[30]O)-[-30]OHmedskip

chemfigH_3C-C(=[30]O)-[-30]OH originalhflipnextchemfigH_3C-C(=[30]O)-[-30]OH

H3C C

O

OH

H3C C

O

OH

H3C C

O

OH

H3CC

O

OH

Symmetry

127 Add text above bonds and arc to angles

Once we have understood that the character ldquordquo can put a ldquoglobalrdquo tikz node that is to say a node accessible afterthe molecule has been drawn everything that tikz can do with nodes (that is to say a lot of things) becomespossible

To write something above or below a bond we can put two ldquoglobalrdquo nodes on the atoms at the ends of this bondand write midway of them a text raised or lowered so that it falls to just above or below the bond This is doneby the macro bondname in the code below 15

To draw an arc between two bonds three atoms are involved on which we have to put three ldquoglobalrdquo nodes Themacro arcbetweennodes calculates the angle between two lines drawn from a node Then arclabel draws an

15The si command is provided by the siunitx package

LATEXed by Christian Tellechea the April 24 2011 47

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 49: Chemfig Doc En

ChemFig 13 LIST OF COMMANDS

arc between two bonds and writes a text next to the arc the optional argument of this macro is the tikz code usedto custom the arc The second argument is the radius of the arc and the following three arguments are the namesof global nodes between which the arc must be drawn the middle name needs to be the vertex of the angle Thelast argument is the text to write

Arcs and text on bonds

newcommandnamebond[4][5pt]chemmovepath(2)--(3)node[midwayslopedyshift=1]4

newcommandarcbetweennodes[3]

pgfmathanglebetweenpointspgfpointanchor1centerpgfpointanchor2center

let3pgfmathresult

newcommandarclabel[6][stealth-stealthshorten lt=1ptshorten gt=1pt]

chemmove

arcbetweennodes43anglestart arcbetweennodes45angleend

draw[1]([shift=(anglestart2)]4)arc(anglestartangleend2)

pgfmathparse(anglestart+angleend)2letanglestartpgfmathresult

node[shift=(anglestart2+1pt)4anchor=anglestart+180rotate=anglestart+90inner sep=0pt

outer sep=0pt]at(4)6

chemfigaA=[3015]bB-[72]cC-dD

namebondabscriptsize My text

namebond[-35pt]bcsmallcolorred$pi$

namebondcdsmall1siangstrom

medskip

Horizontal water molecule chemfig1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

qquad

Water molecule rorated 30sidegree chemfig[30]1H-[377752]2O-[-75552]3H

namebond12footnotesize09584siangstrom

namebond23footnotesize09584siangstrom

arclabel05cm123footnotesize10445sidegree

A

B

C D

Mytex

t

π

1Aring

Horizontal water molecule H

O

H09584

Aring 09584Aring10445deg

Water molecule rorated 30deg H

OH

09584Aring

09584Aring

10445deg

13 List of commands

The commands created by ChemFig are

Commands Descriptionchemfigltcodegt draws the molecule whose design is described by the ltcodegt

printatom displays the atoms within the molecules It can be redeVned to customize theoutput See page 27

setnodestyleltstyle tikzgt using tikz syntax this macro deVnes the style of nodes containing the atomsSee page 35

setbondestyleltstyle tikzgt with the tikz syntax this macro deVnes the style of the bonds See 11

hflipnext the next molecule will be horizontally Wipped

vflipnext the next molecule will be vertically Wipped

definesubmolltnamegt[code1]ltcode2gt creates an alias ltnomgt which can be put in the code of molecules to be drawnand which will be replaced with ltcode1gt or ltcode2gt depending on the angle ofthe last bond See page 31

LATEXed by Christian Tellechea the April 24 2011 48

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 50: Chemfig Doc En

ChemFig 13 LIST OF COMMANDS

chemskipalign tells the vertical alignment mechanism to ignore the current group of atomsSee page 29

redefinesubmolltnamegtltcodegt replaces a preexisting alias ltnamegt with the new ltcodegt See page 32

setcrambondltdim1gtltdim2gtltdim3gt sets the dimensions of the triangles representing Cram bonds ltdim1gt is the sizeof the base ltdim2gt is the spacing between the dashes and ltdim3gt is the side ofthe dashes See page 11

setatomsepltdimgtgt sets the interatomic distance See page 11

setbondoffsetltdimgt sets the space between bonded atoms and the bond See page 11

setdoublesepltdimgt sets the spacing between the two lines of a double bond See page 5

lewisltcodesgtltatomgt displays the ltatomgt and places Lewis dot decorations as speciVed in the ltcodegtThe dots drawn do not change the bounding box See page 32

setlewisltdim1gtltdim2gtlttikz codegt sets the Lewis dot parameters ltdim1gt is the distance between the atoms andthe decoration ltdim2gt is the length of the line representing the pair of electronsand lttikz codegt is code which is passed directly to tikz See page 33

chemmove[lttikz optionsgt]lttikz codegt Makes a tikzpicture environment adding to it the lttikz optionsgt Uses thelttikz codegt to join the nodes speciVed in the molecules with the help pf theldquordquo character See page 22

chemsign[ltdimgt]ltsigngt draws the ltsigngt placing before and after it an unbreakable space of lengthltdimgt See page 34

chemrel[lttxt1gt][lttxt2gt]ltarrow codegt draws an arrow described by its ltarrow codegt and places the optional textlttxt1gt and lttxt2gt above and below the arrow respectively See page 34

setchemrelltdim1gtltdim2gtltdim3gt sets the dimensions of the arrow drawn with the command chemrel ltdim1gtis the vertical space between the arrow and the optional text ltdim2gt is theunbreakable horizontal space inserted before and after the arrow and ltdim3gt isthe length of the arrow See page 34

chemabove[ltdimgt]lttxt1gttxt2 writes lttxt1gt and places lttxt2gt above leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chembelow[ltdimgt]lttxt1gttxt2 writes txt1 and places lttxt2gt below leaving ltdimgt of vertical space Thiscommand does not change the bounding box of lttxt1gt See page 33

chemname[ltdimgt]ltmoleculegtltnamegt Places ltnamegt under the ltmoleculegt

chemnameinit Initializes the greatest molecule depth to ensure correct alignment of the namesof the following molecules

LATEXed by Christian Tellechea the April 24 2011 49

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 51: Chemfig Doc En

ChemFig

PART V

GalleryThis manual concludes with drawings of molecules of varying complexity

The curious user can look at the ltcodegt of each molecule though it does become less attractive the more complexthe molecule gets Indeed beyond a certain level of complexity though it it is fairly easy to write ltcodegt itbecomes much harder to read the ltcodegt to analyze it afterwards We quickly reached the limits of immediatereadability of the code of a complex drawing

Anyway I hope that this package will help all LATEX users wishing to draw molecules Given the newness of thispackage I hope that you will be forgiving with bugs you encounter and send me an email to let me know of anymalfunctions or suggestions for improvement

Christian Tellechea

2-methylpentane

chemfig[7]H_3C-CH(-[6]CH_3)-[1]CH_2-CH_2-[1]CH_3

H3C

CH

CH3

CH2

CH2

CH3

3-ethyl-2-methylhexane

chemfigH_3C-[7]CH(-[6]CH_3)-[1]CH(-[7]C_3H_7)-[2]CH_2-[3]H_3C

H3C

CH

CH3

CH

C3H7

CH2

CH3

Stearine condensed structural diagram

definesubmol([02]-O-[01]C(=[21]O)-C_17H_33)

chemfig[22]CH_2-CH_phantom 2-CH_2

CH2 O C

O

C17H33

CH O C

O

C17H33

CH2 O C

O

C17H33

LATEXed by Christian Tellechea the April 24 2011 50

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 52: Chemfig Doc En

ChemFig

Stearine skeleton diagram

definesubmolx-[+306]-[-306]

definesubmoly-O-(=[26]O)-xxxxxxxx

chemfig[2]([0]y)-[15]([0]y)-[15]([0]y)

O

O

O

O

O

O

Methyl 2-methylpropanoate

chemfigH_3C-CH_2(-[2]CH_3)-C(=[1]O)-[7]O-CH_3

H3C CH2

CH3

C

O

O CH3

Vanillin

chemfigHC6(-C(-OH)=C(-O-[-60]CH_3)-CH=C(-[2]HC=[-60]O)-HC=[2]) quad or quad

chemfig6(-(-OH)=(-OCH_3)-=(-=[-60]O)-=)

HC

C

OH

C

O

CH3

CH

C

CH

O

CH

or

OH

OCH3

O

Caffeine

chemfig6((=O)-N(-CH_3)-5(-N=-N(-CH_3)-=)--(=O)-N(-H_3C)-)

O N

CH3

N

N

CH3O

N

CH3

Aspirin

chemfig6(-=-(-O-[-60](=[-60]O)-[+60])=(-(=[+60])-[-60]OH)-=)

O

O

OH

LATEXed by Christian Tellechea the April 24 2011 51

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 53: Chemfig Doc En

ChemFig

Aspirin is a registered trademark of Bayer in many countries

Phthalic anhydride

chemfig6(=5(-(=O)-O-(=O)-)-=-=-)

O

O

O

Camphor

chemfig6(-(lt[120](-[-10007])(-[10007]))--(=O)-(-)(lt[120])--)

quad or quad

setcrambond3pt

chemfiglt[10](gt[8518](-[16006])-[2006])

gt[-10]-[60](=[3006]O)-[170](-[3006])-[190]-[240]

O

or

O

Triphenylmethane

chemfig6(-=-6(-(-6(=-=-=-))-6(=-=-=-))=-=)

quad or quad

definesubmol6(=-=-=-)

chemfig(-[-30])(-[90])(-[210])

or

Amygdalin

setcrambond2pt

definesubmolc1-[200]-[120]O-[190]

definesubmolc2-[170](-[20007]HO)lt[300](-[17006]HO)

-[10line width=2pt](-[-4006]OH)gt[-10]

definesubmolcsub-[155065]-[90065]

chemfigO(c1(csubO(c1(csubOH)c2))c2)-[-30](-[-90]CN)-[30]6(=-=-=-)

LATEXed by Christian Tellechea the April 24 2011 52

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 54: Chemfig Doc En

ChemFig

O

O

O

O

OH

OH

OHOH

OH

OHOH

CN

Adenosine triphosphate

setcrambond3pt

definesubmola-P(=[-90075]O)(-[90075]HO)-

chemfig[-54]5((--[60]O([-60]aO([-60]aO([60]aHO))))lt(-OH)

-[line width=2pt](-OH)gt(-N5(-=N-6(-(-NH_2)=N-=N-)=_-))-O-)

OP

O

OH

O

P OOH

OP

O

OH

OH

HO OH

N N

NH2

N

N

O

Viagra

chemfigN6((-H_3C)---N(-S(=[+120]O)(=[+0]O)-[-60]6(-=-(-O-[-60]-[+60]CH_3)

=(-6(=N-5(-(--[-60]-[+60]CH_3)=N-N(-CH_3)-=)--(=O)-N(-H)-))-=))---)

N

CH3

N

S

O O

O

CH3

N

CH3

N

N

CH3O

N

H

Cholesterol ester

chemfig[30]R-(=[+60]O)-[-60]O-6(--6(=--6(-5(---(-(-[+60]Me)

-[-60]-[-60]-[+60]-[-60](-[-60]Me)-[+60]Me)-)-(-[+0]Me)---)--)-(-[+0]Me)---)

R

O

O

Me

Me

Me

Me

Me

LATEXed by Christian Tellechea the April 24 2011 53

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 55: Chemfig Doc En

ChemFig

Porphyrin

chemfig=[+72]5(-N=(-=[-72]5(-[2]HN-[2](=-[-36]5(=N-(=-[-72]5(-NH-[1]=-=))

-=-))-=-))-=-)

N NH

NNH

Manganese 5101520-tetra(N-ethyl-3-carbazolyl) porphyrin

definesubmolA6(=-5(-6(-=-=-)--N(--[-60])-)=-=-)

chemfig([+180]-A)=[+72]5(-N=(-(-[+54]A)=[-72]5(-N(-[-3315draw=none]Mn)

-(=(-[+72]A)-[-36]5(=N-(=(-[+54]A)-[-72]5(-N-(-)=-=))-=-))-=-))-=-)

N

N

N

N

MnN

N

N

N

Penicillin

chemfig[-90]HN(-[-45](-[-45]R)=[+45]O)gt[+45]4(-(=O)-N5(-(lt(=[-60]O)

LATEXed by Christian Tellechea the April 24 2011 54

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 56: Chemfig Doc En

ChemFig

-[+60]OH)-(lt[+0])(lt[-108])-Sgt)--)

HN

R

O

O

N

O

OH

S

LSD

chemfig[150]6(=6(--6(-N(-CH_3)--(lt(=[+60]O)-[-60]N(-[+60]-[-60])

-[-60]-[+60])-=)([-120]ltH)---)-6(-=-=-(-[-301155]chembelowNH)=))

N CH3

O

N

H

NH

Strychnine

chemfig6(=-6(-N6(-(=O)--([-120]ltH)7(-O--=[0]([-25714]-[2][1]))

-6(-[0gt]--(ltN[1][2])-(lt[-90]-[-60][2]))(lt[+0]H)-([+120]ltH))--)=-=-)

N

O

HO

N

H

H

Codeine

chemfig[-30]6(-(-OH)--6(-(-[3]-[22]-[05])6(-(lt[-1501155]O)

-(ltOH)-=-)-(lt[1]H)-(-[2]NCH_3)--)---)

LATEXed by Christian Tellechea the April 24 2011 55

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 57: Chemfig Doc En

ChemFig

HOO

OH

H

NCH3

A dye (red)

chemfig6(--6(-(-NO_2)=-(-lewis26O-[0]H)=(-lewis4N=[0]lewis2N-[0]Ar)-)----)

NO2

O H

N N Ar

Menthone

chemfigCH_3-(-[2]H)(-[-302]-[+60](=[1]lewis20O)

-[-15015](-[20]CH(-[1]CH_3)(-[7]CH_3))(-[6]H)-[-902]-[+60])

CH3

H

O

CH

CH3

CH3

H

Fischer indole synthesis

chemfig6(=-6(-chembelowNH-NH_2)=-=-)

chemsign+

chemfig(=[-150]O)(-[-30]R_2)-[2]-[150]R_1

chemrel[$mathrmH^+$]-stealth

chemfig6(-=5(-chembelowNH-(-R_2)=(-R_1)-)-=-=)

NH

NH2+

O R2

R1

H+

NH

R2

R1

Reaction mechanisms carbonyl group

chemfigC([3]-)([5]-)=[db5]atoolewis06O

chemrelltgt

chemfigchemaboveCscriptstyleoplus([3]-)([5]-)-chemabove

lewis026Ohspace5mmscriptstyleominus

chemmovedraw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(up5mm) and +(up5mm)(atoo)

C O Coplus

O

LATEXed by Christian Tellechea the April 24 2011 56

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 58: Chemfig Doc En

ChemFig

Reaction mechanisms nitro group

chemfigR-chembelowNhspace-5mmscriptstyleoplus([1]=[db]atoo1O)([7]-[sb]atoo2

chemabovelewis157Ohspace7mmscriptstyleominus)

chemrellt-gt

chemfigR-chemaboveNhspace-5mmscriptstyleoplus([1]-chemaboveOscriptstyleominus)([7]=O)

chemmove

draw[-gtshorten lt=2pt shorten gt=2pt](db) controls +(1205mm) and +(1205mm)(atoo1)

draw[-gtshorten lt=3pt shorten gt=2pt](atoo2) controls +(22510mm) and +(22510mm)(sb)

R Noplus

O

O

R Noplus

O

O

Nucleophilic addition Primary amines

chemfigR-atonlewis2NH_2

chemsign+

chemfigatocC([3]-CH_3)([5]-CH_3)=[atoo1]O

hspace1cm

chemfigatoo2chemaboveHscriptstyleoplus

chemmove[-stealthshorten lt=3ptdash pattern= on 1pt off 1ptthin]

draw[shorten gt=2pt](aton) controls +(up10mm) and +(left5mm)(atoc)

draw[shorten gt=8pt](atoo1) controls +(up10mm) and +(north west10mm)(atoo2)

chemrel[tiny addition]ltgt

chemfigR-atonchembelowNscriptstyleoplusH([2]-[sb]H)-C(-[2]CH_3)(-[6]CH_3)-OH

par

chemmove

draw[-stealthdash pattern= on 1pt off 1ptshorten lt=3pt shorten gt=2pt]

(sb)controls +(left5mm) and +(1352mm)(aton)

chemrelltgt

chemfigR-atonlewis2N([6]-[sbh]H)-[sb]C(-[2]CH_3)(-[6]CH_3)-[sbo]atoo

chemaboveOscriptstyleoplus(-[1]H)(-[7]H)

chemmove[-stealthshorten lt=3ptshorten gt=2ptdash pattern= on 1pt off 1ptthin]

draw(aton) controls +(up5mm) and +(up5mm)(sb)

draw(sbh) controls +(left5mm) and +(south west5mm)(aton)

draw(sbo) controls +(up5mm) and +(north west5mm)(atoo)

chemrel[tiny elimination]ltgt

chemfigR-N=C(-[1]CH_3)(-[7]CH_3)

chemsign+

chemfigH_3chemaboveOscriptstyleoplus

R NH2 + C

H3C

H3C

O Hoplus addition

R NoplusH

H

C

CH3

CH3

OH

R N

H

C

CH3

CH3

Ooplus

H

H

elimination

R N C

CH3

CH3

+ H3Ooplus

Reaction mechanism of chlorination

scriptsize

setbondoffset1ptsetatomsep2em

chemfigCl-[4]a0(=[a1120]a2O)-[-120](=[-60]O)-[4]Clchemsign+

chemfig6(-=-=(-oh1OH)-=)chemrel-stealth

chemfig6((-O-[150](-[o0150]o1lewis6O)(-[cl060]cl1Cl)-[240](-[4]Cl)=[6]O)=-=-=-)

chemrel-stealthchemfig6((-O-[150](=[2]O)-[-150](=[6]O)-[150]Cl)=-=-=-)chemsign+

chemfigHClpar

chemfig6(-=6(-O-6(-o2(=[o3]o4O)-Cl)=)-=-=)chemsign+

chemfig6(-=-=(-oh2OH)-=)chemrel-stealth

chemfig6(-=6(-O-(-(-[cl260]cl3Cl)(-[o5-120]o6lewis6O)-O-[-40]6(=-=-=-))=)-=-=)

kern-3em chemrel-stealthchemfig[30]6(=-(-O-[-60](=O)-[-120](=[4]O)-[-60]O-6(=-=-=-))=-=-)

kern-3em chemsign+chemfigHCl

chemmove[line width=02pt-stealthdash pattern = on 2pt off 1pt]

draw[shorten lt=2pt](a1)controls+(2005mm)and+(2005mm)(a2)

LATEXed by Christian Tellechea the April 24 2011 57

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 59: Chemfig Doc En

ChemFig

draw[shorten gt=2pt](oh1west)controls+(18015mm)and+(605mm)(a0)

draw[shorten lt=6ptshorten gt=2pt](o1)controls+(2705mm)and+(2705mm)(o0)

draw[shorten lt=2pt](cl0)controls+(1505mm)and+(1505mm)(cl1150)

draw[shorten lt=2pt](o3)controls +(303mm) and +(305mm)(o4east)

draw[shorten gt=2pt](oh2135) controls +(15010mm) and +(9010mm) (o2)

draw[shorten gt=2ptshorten lt=5pt]([xshift=-15mm]o6315)controls +(3155mm) and +(3155mm)(o5)

draw[shorten lt=2pt](cl2)controls +(1355mm) and +(1355mm)(cl3north west)

Cl

O

O

Cl

+

OH

O

OCl

Cl

O

O

O

O

Cl + HCl

O

O

Cl +

OH

O

Cl

OO

O

O

O

O

+ HCl

Cannizzaro reaction

chemfig[-30]6(=-=(-atocC([6]=[db]atoo1O)-H)-=-)

chemrel[chemfigatoo2chemaboveOscriptstyleominusH]-stealth

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=8pt](atoo2) controls +(up10mm) and +(up10mm)(atoc)

draw[shorten lt=2pt](db) controls +(left5mm) and +(west5mm)(atoo1)

chemfig[-30]6(=-=(-C([6]-[sb1]atoo1chembelowOscriptstyleominus)([2]-OH)-[sb2]H)-=-)

hspace1cm

chemfig[-30]6((-atocC([6]=[db]atoo2O)-[2]H)-=-=-=)

chemmove[-stealthshorten lt=2ptshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw([yshift=-4pt]atoo1270) controls +(05mm) and +(right10mm)(sb1)

draw(sb2) controls +(up10mm) and +(north west10mm)(atoc)

draw(db) controls +(right5mm) and +(east5mm)(atoo2)

vspace1cm

par

chemrel-stealth

chemfig[-30]6(=-=(-C([1]-atoo2O-[sb0]atohH)([6]=O))-=-) hspace1cm

chemfig[-30]6((-C(-[5]H)(-[7]H)-[2]atoo1chemaboveOscriptstyleominus)-=-=-=)

chemmove[-stealthshorten gt=2ptdash pattern=on 1pt off 1ptthin]

draw[shorten lt=7pt](atoo190) controls +(+908mm) and +(up10mm)(atoh)

draw[shorten lt=2pt](sb) controls +(up5mm) and +(up5mm)(atoo2)

C

O

HOH

C

O

OH

H C

O

H

C

O H

O

C

H H

O

Beckmann rearrangement

setbondoffset1pt

setatomsep25em

chemfig(-[-150]Rrsquo)(-[-30]R)=[2]N-[30]OH

kern-1em

chemrel[chemfigchemaboveHkern10ptscriptstyleoplus]ltgt

kern-05em

LATEXed by Christian Tellechea the April 24 2011 58

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 60: Chemfig Doc En

ChemFig

chemfig(-[a0-150]Rrsquo)(-[-30]R)=[2]a1N-[b030]b1chemaboveOscriptstyleoplusH_2

chemmove[red-stealthredshorten lt=2pt]

draw(a0)controls +(1352mm) and +(2154mm) (a1)

draw(b0)controls +(1202mm) and +(1803mm) ([yshift=7pt]b1180)

kern-15em

chemrel[chemfig-H_2O]ltgt

$left[begintabularc

chemfigRrsquo-lewis2N=a1chemaboveCscriptstyleoplus-R

tikzdraw[stealth-stealth](03mm)--(0-3mm)

chemfigRrsquo-chemaboveNscriptstyleoplus~C-R

endtabularright]$

chemrel[chemfigH_2a0lewis02O]ltgtpar

chemmove[red-stealthredshorten lt=3pt]

draw(a0)controls+(9010mm)and+(4510mm)([yshift=6pt]a145)

chemfig6(Rrlap$rsquo$-N=(-R)-chemaboveOscriptstyleoplus H_2)

chemrel[chemfig-chemaboveHkern10ptscriptstyleoplus]ltgt

chemfig6(Rrlap$rsquo$-N=(-R)-OH)

chemrel-stealth

chemfig6(Rrlap$rsquo$-chembelowNH-(-R)(=[2]O))

Rprime R

NOH

Hoplus

Rprime R

N

OoplusH2

minusH2O

Rprime N C

oplusR

Rprime Noplus

C R

H2O

Rprime

N R

OoplusH2

minusHoplus

Rprime

N R

OH

Rprime

NH

R

O

Sulfonation of naphthalene

newcommandputchemnode[1]begintikzpicture[remember picture]node(1)endtikzpicture

definesubmolcycleoplus-[025draw=none]oplus

definesubmolso2ohS(=[90]O)(=[-90]O)-OH

footnotesize

setatomsep25em

begintabularll

ampputchemnodel1chemnamechemfig6(=-6(-=-(cycleoplus)-(-SO_3H)-)=-=-)1-arenium ion

chemrel-stealth

chemnamechemfig6(=-6(-=-=(-so2oh)-)=-=-)1-naphthalenesulfonic acid

chemnamechemfig6(=-6(-=-=-)=-=-)Naphthalene

chemsign+

chemfigH_2SO_4putchemnodeakern1cmamp[-5ex]

ampputchemnodel2chemnamechemfig6(=-6(-=-(-SO_3H)-(cycleoplus)-)=-=-)2-arenium ionkern-3em

chemrel-stealth

chemnamechemfig6(=-6(-=-(-so2oh)=-)=-=-)2-naphthalenesulfonic acid

endtabular

chemmove[-stealthyshift=1cm]

draw(a)--node[slopedabove]80degres C(l1)draw(a)--node[slopedabove]160degres C(l2)

LATEXed by Christian Tellechea the April 24 2011 59

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 61: Chemfig Doc En

ChemFig

oplus

SO3H

1-arenium ion

SO O

OH

1-naphthalenesulfonic acid

Naphthalene

+ H2SO4

SO3Hoplus

2-arenium ion

S

O

O

OH

2-naphthalenesulfonic acid

80 C

160 C

Explanatory diagram

parbox08linewidth

hspace10em

tikz[remember picture]node(n0)chemnameAttacksnucleophilespar

vspace2exhspace15em

chemfigR^2-(-[-60]a0H)-[60]a1(-[120]R^1)(-[1025draw=none]scriptstylecolorreddelta+)

=[a2]a3lewis17O-[105draw=none]scriptstylecolorreddelta-

hspace5em

chemname[-15ex]tikz[remember picture]node(n1)Addition reactionskern1em

chemnametikz[remember picture]node(n2)Basic propertiespar

vspace6exhspace8em

chemnameAcidic properties of hydrogentikz[remember picture]node(n3)

atom in $alpha$ position

chemmove[-stealthline width=08ptgreen60black70]

draw[shorten gt=2pt](n0)controls+(2704em)and+(1802em)(a1)

draw[shorten gt=8pt](n1)controls+(1802em)and+(602em)(a2)

draw[shorten gt=5pt](n2)controls+(1802em)and+(2702em)([xshift=3pt]a3315)

draw[shorten gt=2pt](n3)controls+(02em)and+(2702em)(a0)

Attacksnucleophiles

R2

H

R1

δ+Oδminus

Addition reactions

Basic properties

Acidic properties of hydrogenatom in α position

Crystallography

newcommanddisktikzdraw[fill=blackoverlay](00)circle(2pt)

setatomsep20pt

renewcommandprintatom[1]1

setbondoffset2pt

definesubmolhat-[4015]disk-[-302]disk-[-302]disk-[-1202]disk-[-302]disk

definesubmolmotif-[4015]disk(-[23])-[-302]disk

(-[23])-[-302]disk(-[23])-[-1202]disk(-[23])-[-302]disk

chemfigdisk[a](-[23]disk[b](-[23]disk[c]hat[c])motif[b](-[23]))motif[a](-[23])

qquad

redefinesubmolmotifdisk(-[23])(-[4236draw=none]disk)-[3026]disk

LATEXed by Christian Tellechea the April 24 2011 60

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 62: Chemfig Doc En

ChemFig

(-[23])-[03]disk(-[23])-[-15026]disk(-[43])-[23]-[43]

redefinesubmolhatdisk-[3026]disk-[03]disk-[-15026]disk-[43]

chemfigmotifmotifhat

qquad

redefinesubmolmotif(-[23])(-[25275white]-[215white]disk)-[503]disk

(-[23])-[-503]disk(-[23])-[-1303]disk-[23]-[43]disk

redefinesubmolhat-[503]disk-[-503]disk-[-1303]disk

chemfig-[43]diskmotif(-[25275draw=none]disk[uat][dat](-[0275][uat1][dat1]

-[-9013]disk[uat2][dat2])-[-9013]-[25275])hat[uat3][dat3]-[5015]

(-[615draw=none]disk[datblue][dat1blue][dat2blue][dat3blue])

-[215draw=none]disk[uatred][uat1red][uat2red][uat3red]

Taxotere

chemfig-[-30](-[5])(-[7])-[+60]-[-60]O-[+60](=[-45]O)-[+90]HNgt[-60](-[+60]6(------))

-[-30](lt[2]OH)-[-60](=[6]O)-[+60]Ogt[-60]7(---(lt[-120]OH)-(lt|[1]CH_3)(lt[-90]CH_3)

-(-[1](lt[+80]HO)-[0](=[+60]O)-[7](lt|[+130]CH_3)(-[+75](lt|[2]OH)-[-60]-[-60](lt[+30]O-[-90])

-[-60](lt[+90])(lt[+30]O-[7](-[6]CH_3)=[0]O)-[-60])-[6]-[513](lt[7]O-[5](=[-60]O)

-[6]6(------)))=(-[2]CH_3)-)

OO

NH

OH

O

O

HO

CH3

CH3

OH O

CH3

OH

O

O

CH3

O

O

O

CH3

LATEXed by Christian Tellechea the April 24 2011 61

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 63: Chemfig Doc En

ChemFig INDEX

Index

Symbols see save a molecule( ) see branched molecule see ring see ringinside arc- = ~ see bondtypes=_ =^ see bondshiftedgt lt gt| lt| gt lt see Cram diagram see bonddistant atoms 23 45ndash47 56ndash58 60| see separating atom mechanism 11 30 26

Bbaseline 4 5 25 29bond

angle 5 6 12absolute 6 12 37arc 47predeVned 6 12 37relative 6 12 32 38

branch 37customization 5 14delocalized 31departure and arrival atoms 5 14 22distant atoms 8 17invisible 14 42 45length 5 6 10 13optional argument 5 6 12ndash15 22shifted 7 30types 5 10wavy 45with text 47

bounding box 4 25 33 34branched molecule 6 7 15

Ccatcode 3chair representation 40charge 45

delta 60ominus 9 56 58oplus 9 25 45 56ndash59

chemabove 9 25 33 45 49 56ndash58chembelow 9 33 43 49 55ndash58chemfig 4 5 15 23 28 35 48

optional arguments 28 37 41 42 46chemical reaction 9 25 34chemmove 23ndash25 45 49 56ndash60chemname 25 26 49 59 60chemnameinit 26 49chemrel 9 34 49 56ndash59chemsign 9 34 49 56 57 59chemskipalign 29 30 49

chenameinit 26color 44 60color (atom) 44compilation method 4ConTEXt 4 28control points 23ndash25Cram representation 7 11

Ddefinesubmol 31 32 40 42 43 45 48 50ndash54 59 60dvi mode 4

Eelectron movements 22ndash25εTEX 28

FFisher projection 39

HHaworth projection 41hflipnext 47 48horizontal alignment 45

Iinput 4interatom length see bondlength

LLATEX 4 27lewis 9 32 33 49 56ndash58 60Lewis diagram 7 32

Mmath mode 9 11 27

Ppdf mode 4pgf 4phantom 50picture remembering 23polymer 46printatom 27 28 35 36 48 60

Rredefinesubmol 32 49 60ring 8 18ndash22

angular position 19branch 8 20 38 41charge 34inside arc 19nested 21 38 42 43unVnished 19 38

rlap 45

Ssave a molecule 31 32

LATEXed by Christian Tellechea the April 24 2011 62

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index
Page 64: Chemfig Doc En

ChemFig INDEX

separating atom mechanism 10 27 44setatomsep 11 13 46 49 57ndash60setbondoffset 11 35 49 57 58 60setbondstyle 3 11 48setchemrel 34 49setcrambond 11 41 49 52 53setdoublesep 5 49setlewis 33 49setnodestyle 35 48size of molecules 13 28 46skeleton diagram 7 39symmetrical of a molecule 47

Ttextcolor 44tikz 4 14tikzpicture 4 23 28 35

Uusemodule 4usepackage 4

Vvertical alignment 29vflipnext 47 48vphantom 29

LATEXed by Christian Tellechea the April 24 2011 63

  • I Introduction
    • New in version 04b
    • Foreword
    • Presenting ChemFig
      • II ChemFig for the impatient
        • Syntax
        • The different types of bonds
        • Different types of diagrams
          • Complete structural diagram
          • Condensed structural diagram
          • Cram representation
          • Skeleton diagram
          • Lewis diagrams
            • Branched molecules
            • Rings
            • Ions
            • Chemical equations
              • III Operation of ChemFig
                • Groups of atoms
                • Different types of bonds
                • Bond angle
                  • Predefined angles
                  • Absolute angles
                  • Relative angles
                    • Length of a bond
                    • Departure and arrival atoms
                    • Customization of bonds
                    • Default values
                    • Branches
                      • Principle
                      • Nesting
                      • Method
                        • Connecting distant atoms
                        • Rings
                          • Syntax
                          • Angular position
                            • At the start
                            • After a bond
                              • Branches on a ring
                              • Nested rings
                              • Rings and groups of atoms
                                • Representing electron movements
                                  • Mesomeric effects
                                  • Reaction mechanisms
                                    • Writing a name under a molecule
                                      • IV Advanced usage
                                        • Separating atoms
                                        • Displaying atoms
                                        • Optional arguments
                                        • Vertical alignment
                                        • Shifted double bonds
                                        • Delocalized double bonds
                                        • Saving a sub-molecule
                                        • Decorations
                                          • Lewis diagrams
                                          • Stacking characters
                                          • Chemical reactions
                                            • Using chemfig in the tikzpicture environment
                                            • Beyond chemistry
                                            • Annotated examples
                                              • Ethanal
                                              • 2-amino-4-oxohexanoic acid
                                                • Absolute angles
                                                • Relative angles
                                                • Ring
                                                • Nested rings
                                                  • Glucose
                                                    • Skeleton diagram
                                                    • Fisher projection
                                                    • ``Chair representation
                                                    • Haworth projection
                                                      • Adrenaline
                                                        • Using one ring
                                                        • Using two rings
                                                          • Guanine
                                                            • How to hellip
                                                              • Write a colored atom
                                                              • Add a superscript without modifying a 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
                                                                • List of commands
                                                                  • V Gallery
                                                                  • Index