My chemical reaction latex codes look like this



\chemname{\chemfig{R-H}}{Alkane} \arrow(.{5.5}--){->[light,heat or catalyst]}[0,2,] \chemname{\chemfig{R-X}}{Haloalkane} \+ \chemfig{HX}

\chemfig{CH_4} \+ \chemfig{Cl_2} \arrow(.{5.5}--){->[light]}[0,2,] \chemfig{CH_3Cl} \+ \chemfig{HCl}

\chemfig{CH_3Cl}  \+ \chemfig{Cl_2} \arrow(.{5.5}--){->[light]}[0,2,] \chemfig{CH_2Cl_2} \+ \chemfig{HCl}

\chemfig{CH_2Cl_2}  \+ \chemfig{Cl_2} \arrow(.{5.5}--){->[light]}[0,2,] \chemfig{CHCl_3} \+ \chemfig{HCl}

\chemfig{CH_3Cl}  \+ \chemfig{Cl_2} \arrow(.{5.5}--){->[light]}[0,2,] \chemfig{CCl_4} \+ \chemfig{HCl}


It looks like this on compiling enter image description here

I thought adding \arrow{0}[,0] will fix it but it didn't actually i don't' know why :( . But i think it works for reaction containing benzene etc :(

  • +How to i balance the position of arrow of chemical reaction ?
  • How to i give blue color to Cl_2 atoms ? i thought of adding \colors but dont' know how it works :(
  • How do i show all arrow of same length ?
  • How to i show these reaction with arrow center so it looks very nice ?
  • How to i reduce the distance between names of compound and their names?

Thank you .

  • 1
    I'd do those kind of reactions either with the chemformula or the mhchem package. Both \ch (chemformula) and \ce (mhchem) can be used in amsmath's align environment for alignment – cgnieder Jun 23 '15 at 13:39
  • @clemens Thanks clemens . I am learning chemfig as many people recommended. Is it good to learn chemformula or mhchem? – aftershock Jun 23 '15 at 13:43
  • chemformula and mhchem are alternatives to each other but both can be used quite well together with chemfig – cgnieder Jun 23 '15 at 13:44
  • @clemens thanks can chemformula and mhchem works like chemfig . I mean for example drawing benzene ? – aftershock Jun 23 '15 at 13:45
  • No but they do other things very well where chemfig is not the ideal soultion. Why don't you have a look at them and decide for yourself? – cgnieder Jun 23 '15 at 13:49

Basically the answer is: have a look at TikZ anchors and how to use them with chemfig's \arrow:

\arrow(<node name>.<anchor>--<node name>.<anchor>)

All node names and anchors are optional. Those can be used with an invisible downarrow (angle: -90) to achieve alignment, e.g., by aligning the lower right-hand edge of the upper compound (south west) with the upper right-hand edge of the lower compound (north west):

\arrow(@c1.south east--.north east)

Here is an example alignment:

% \schemedebug{true} % shows (not only) the node names
  % line one
  A + B \arrow C + D
  \arrow(@c1.south east--.north east){0}[-90,.15]
  % line two:
  E + F \arrow G + H
  \arrow(@c3.south east--.north east){0}[-90,.15]
  % line three:
  I + J \arrow K + L

enter image description here

or with \schemedebug{true}:

enter image description here

Coloring can be done by placing braces around the atom and adding \color{blue}


As for the distance between compounds and names: I supsect you have used \chemname not in a group somewhere and have forgotten to reset it. Have a look at Placement of caption in \chemfig via \chemname command - how to reset spacing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.