Chemfig Package

Preview:

Citation preview

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Chemfig Package

Zachary Morseth

Minnesota State University-Moorhead

May 3, 2011

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Outline

1 Introduction

2 Syntax

3 Drawing Molecules

4 Drawing Rings

5 Chemical Reactions

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Chemfig is a package written for drawing molecules and otherimportant aspects of chemistry using the LATEXcode.

To add the package, type:

\usepackage{chemfig}

into the preamble of your document. This will also automaticallyload the tikz package (a very powerful graphics representationprogram).

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Chemfig is a package written for drawing molecules and otherimportant aspects of chemistry using the LATEXcode.

To add the package, type:

\usepackage{chemfig}

into the preamble of your document. This will also automaticallyload the tikz package (a very powerful graphics representationprogram).

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Outline

1 Introduction

2 Syntax

3 Drawing Molecules

4 Drawing Rings

5 Chemical Reactions

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

The syntax for drawing figures using Chemfig is

\chemfig{<code>}

The code will describe the atoms to draw and their spatialarrangment (angles, distance, bond type, etc.).

A more detailed example of the code is:

\chemfig{<atom1><bond type>

[<angle>,<coeff>,<n1>,<n2>,<tikz code>]<atom2>}

With this code in hand, it is possible to draw an infinite number ofdifferent molecules.

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

The syntax for drawing figures using Chemfig is

\chemfig{<code>}

The code will describe the atoms to draw and their spatialarrangment (angles, distance, bond type, etc.).

A more detailed example of the code is:

\chemfig{<atom1><bond type>

[<angle>,<coeff>,<n1>,<n2>,<tikz code>]<atom2>}

With this code in hand, it is possible to draw an infinite number ofdifferent molecules.

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Outline

1 Introduction

2 Syntax

3 Drawing Molecules

4 Drawing Rings

5 Chemical Reactions

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Water Molecule

To draw a water molecule, we will use Chemfig to specify thearrangement of the atoms.

The code is:

\chemfig{H-O-H}

H O H

We can also change the distance of the bond using the command

\setatomsep{2em}

H O H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Water Molecule

To draw a water molecule, we will use Chemfig to specify thearrangement of the atoms.

The code is:

\chemfig{H-O-H}

H O H

We can also change the distance of the bond using the command

\setatomsep{2em}

H O H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Water Molecule

To draw a water molecule, we will use Chemfig to specify thearrangement of the atoms.

The code is:

\chemfig{H-O-H}

H O H

We can also change the distance of the bond using the command

\setatomsep{2em}

H O H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Water Molecule

To draw a water molecule, we will use Chemfig to specify thearrangement of the atoms.

The code is:

\chemfig{H-O-H}

H O H

We can also change the distance of the bond using the command

\setatomsep{2em}

H O H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Specifying Angles

In Chemfig, predefined angles are specified in multiples of 45degrees.

For example, to specify an angle measure of 90 degrees,we input [2] in the optional argument. The default value for noinput is 0 degrees.There is also a way to introduce absolute angles in the interval[0, 360). The code for this is:

[:<absolute angle>]

Additionally, angles can be defined relative to the preceding bond.The code for this is:

[::<relative angle>]

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Specifying Angles

In Chemfig, predefined angles are specified in multiples of 45degrees. For example, to specify an angle measure of 90 degrees,we input [2] in the optional argument. The default value for noinput is 0 degrees.

There is also a way to introduce absolute angles in the interval[0, 360). The code for this is:

[:<absolute angle>]

Additionally, angles can be defined relative to the preceding bond.The code for this is:

[::<relative angle>]

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Specifying Angles

In Chemfig, predefined angles are specified in multiples of 45degrees. For example, to specify an angle measure of 90 degrees,we input [2] in the optional argument. The default value for noinput is 0 degrees.There is also a way to introduce absolute angles in the interval[0, 360). The code for this is:

[:<absolute angle>]

Additionally, angles can be defined relative to the preceding bond.The code for this is:

[::<relative angle>]

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Specifying Angles

In Chemfig, predefined angles are specified in multiples of 45degrees. For example, to specify an angle measure of 90 degrees,we input [2] in the optional argument. The default value for noinput is 0 degrees.There is also a way to introduce absolute angles in the interval[0, 360). The code for this is:

[:<absolute angle>]

Additionally, angles can be defined relative to the preceding bond.The code for this is:

[::<relative angle>]

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Ethane Molecule

To draw the ethane molecule, the code is:

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-H)(-[2]H)(-[6]H)}

C

H

H

H

C H

H

H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Ethane Molecule

To draw the ethane molecule, the code is:

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-H)(-[2]H)(-[6]H)}

C

H

H

H

C H

H

H

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Outline

1 Introduction

2 Syntax

3 Drawing Molecules

4 Drawing Rings

5 Chemical Reactions

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Rings

In addition to drawing linear and branched molecules, Chemfig canalso construct a variety of different molecules containing rings.The code for drawing a ring is:

\chemfig{*n(<code for the molecule>)}

To draw rings composed of 6 carbon atoms, we will use the code:

\chemfig{*6(------)}, \chemfig{*6(--(-Cl)-=-=)}

Cl

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Rings

In addition to drawing linear and branched molecules, Chemfig canalso construct a variety of different molecules containing rings.The code for drawing a ring is:

\chemfig{*n(<code for the molecule>)}

To draw rings composed of 6 carbon atoms, we will use the code:

\chemfig{*6(------)}, \chemfig{*6(--(-Cl)-=-=)}

Cl

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Rings

To combine multiple rings together, as in the case of phtalicanhydride, we use the code:

\chemfig{*6(=*5(-(=O)-O-(=O)-)-=-=-)}

O

O

O

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

The code for the benzene ring is

\chemfig{*6(=-=-=-)}

The code for the oxalane-2,5-dione is

\chemfig{*5(-(=O)-O-(=O)--)}

O

O

O

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Caffeine

O N

CH3

N

N

CH3O

NCH3

The code for caffeine is:

\chemfig{*6((=O)-N(-CH_3)-*5(-N=-

N(-CH_3)-=)--(=O)-N(-H_3C)-)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Caffeine

O N

CH3

N

N

CH3O

NCH3

The code for caffeine is:

\chemfig{*6((=O)-N(-CH_3)-*5(-N=-

N(-CH_3)-=)--(=O)-N(-H_3C)-)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Adrenaline

Now, let’s take a look at how to construct the chemical structurefor adrenaline piece by piece.

OH

OH

NH

CH3

OH

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Draw the skeleton structure:

\chemfig{*6(-=-=-=)}

Add hydroxyl substituents to skeleton stucture:

OH

OH

\chemfig{*6((-HO)-=-=-(-HO)=}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Draw the skeleton structure:

\chemfig{*6(-=-=-=)}

Add hydroxyl substituents to skeleton stucture:

OH

OH

\chemfig{*6((-HO)-=-=-(-HO)=}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Draw the skeleton structure:

\chemfig{*6(-=-=-=)}

Add hydroxyl substituents to skeleton stucture:

OH

OH

\chemfig{*6((-HO)-=-=-(-HO)=}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Draw the skeleton structure:

\chemfig{*6(-=-=-=)}

Add hydroxyl substituents to skeleton stucture:

OH

OH

\chemfig{*6((-HO)-=-=-(-HO)=}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Next, we must add the branched chain to our structure (usingrelative angles for ease):

OHHN

CH3

OH

The code for this step is:

\chemfig{*6((-HO)-=-(--[::-60]-

[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Next, we must add the branched chain to our structure (usingrelative angles for ease):

OHHN

CH3

OH

The code for this step is:

\chemfig{*6((-HO)-=-(--[::-60]-

[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Lastly, we must add in the ”cram” bond for the added hydroxylsubstituent.

To illustrate the use of cram bonds: The code forA B is

\chemfig{A<B}

OH

OH

HNCH3

OH

Th final code for the structure is:

\chemfig{*6((-HO)-=-(-(<[::60]OH)-

[::-60]-[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Lastly, we must add in the ”cram” bond for the added hydroxylsubstituent. To illustrate the use of cram bonds: The code forA B is

\chemfig{A<B}

OH

OH

HNCH3

OH

Th final code for the structure is:

\chemfig{*6((-HO)-=-(-(<[::60]OH)-

[::-60]-[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Lastly, we must add in the ”cram” bond for the added hydroxylsubstituent. To illustrate the use of cram bonds: The code forA B is

\chemfig{A<B}

OH

OH

HNCH3

OH

Th final code for the structure is:

\chemfig{*6((-HO)-=-(-(<[::60]OH)-

[::-60]-[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Adrenaline

Lastly, we must add in the ”cram” bond for the added hydroxylsubstituent. To illustrate the use of cram bonds: The code forA B is

\chemfig{A<B}

OH

OH

HNCH3

OH

Th final code for the structure is:

\chemfig{*6((-HO)-=-(-(<[::60]OH)-

[::-60]-[::-60]HN-[::+60]CH_3)=-(-HO)=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Acetylsalicylic Acid (Aspirin)

O

O

OH

\chemfig{*6(-=-(-O-[::-60](=[::-60]O)-

[::+60])=(-(=[::+60])-[::-60]OH)-=)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Camphor

O

Here is the code for drawing camphor:

\quad \setcrambond{3pt}{}{}

\chemfig{<[:10](>[:85,1.8]?(-[:160,0.6])-[:20,0.6])>[:-10]

-[:60](=[:30,0.6]O)-[:170]?(-[:30,0.6])-[:190]-[:240]}

Note: The ? character is used to create a hook between an atomand a distant atom.

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Camphor

O

Here is the code for drawing camphor:

\quad \setcrambond{3pt}{}{}

\chemfig{<[:10](>[:85,1.8]?(-[:160,0.6])-[:20,0.6])>[:-10]

-[:60](=[:30,0.6]O)-[:170]?(-[:30,0.6])-[:190]-[:240]}

Note: The ? character is used to create a hook between an atomand a distant atom.

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Outline

1 Introduction

2 Syntax

3 Drawing Molecules

4 Drawing Rings

5 Chemical Reactions

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Chemical Reactions

Another important feature of chemfig is the ability to writechemical reactions, which show how a set of reactants reaches afinal product.

As an example, consider the reaction

+ H3C ClAlCl3−−−−→ + HCl

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Chemical Reactions

Another important feature of chemfig is the ability to writechemical reactions, which show how a set of reactants reaches afinal product. As an example, consider the reaction

+ H3C ClAlCl3−−−−→ + HCl

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

The code for the previous chemical reaction (the alkylation ofbenzene) is:

\setatomsep{2em}\chemfig{**6(------)} \hspace{.2cm} +

\hspace{.2cm} \chemfig{H_3C-Cl}

\hspace{.2cm} $\xrightarrow{\chemfig{AlCl_3}}$

\hspace{.2cm} \chemfig{**6(-(-)-----)} \hspace{.1cm} +

\hspace{.1cm} \chemfig{HCl}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Drawing Viagara

NCH3

NS

O O

O

CH3

N

CH3

N

N

CH3O

NH

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

The code for the drug Viagara is:

\setatomsep{2.2em}

\chemfig{N*6((-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)-))-=))---)}

Zachary Morseth MSUM

Chemfig Package

Introduction Syntax Drawing Molecules Drawing Rings Chemical Reactions

Thank You!

Zachary Morseth MSUM

Chemfig Package

Recommended