TransWikia.com

Multiple Brackets in Chemfig Polymer - Cannot Get Rid of Errors

TeX - LaTeX Asked by Timon on August 18, 2020

I am struggling to get a Reaktion showing a Polymerisation Process using chemfig right.

This is the code I am using:

begin{figure}[htb!]
centering
schemestart
chemfig{R-C(-[2])(-[6])-C(-[2])(-[6])-C(-[2])(-[6])-lewis{0.,C}(-[2])(-[6])}
+
chemfig{[@{left,0.5}]C(-[2])(-[6])=C(-[2])(-[6])[@{right,0.5}]}
%polymerdelim[delimiters ={[]}, height = 40pt, indice = n]{left}{right}
arrow
chemfig{R-C(-[2])(-[6])-C(-[2])(-[6])-[@{left,0.5}]C(-[2])(-[6])-C(-[2])(-[6])-[@{right,0.5}]C(-[2])(-[6])-lewis{0.,C}(-[2])(-[6])}
polymerdelim[delimiters ={[]}, height = 40pt, indice = n]{left}{right}
schemestop
caption{}
label{}
end{figure}

This is the current result:

enter image description here

For some reason the second bracket is the way I want it, but the first one is not. It seems as if it is not getting the specifications made by polymerdelim, so I thought I might need to add the line also to the chemfig above.

If I activate the line

%polymerdelim[delimiters ={[]}, height = 40pt, indice = n]{left}{right}

I get this error message:

! Package pgf Error: No shape named left is known.See the pgf package documentation for explanation.Type H <return> for immediate help.... chemfig

Can someone help me out?

Thank you!

One Answer

From the documentation of chemfig, Section 13, the syntax @{<name>, <coeff>} can only be used at the beginning of the optional argument of a bond. In the second chemfig of your example

chemfig{[@{left,0.5}]C(-[2])(-[6])=C(-[2])(-[6])[@{right,0.5}]}

optional arguments [@{left,0.5}] and [@{right,0.5}] has no corresponding bonds, hence the nodes left and right are never created.

Option 1

If you are ok with beginning and ending bonds, then use

chemfig{C(-[2])(-[6])(-[@{left,0.5}4])=C(-[2])(-[6])-[@{right,0.5}]}
polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n]{left}{right}

enter image description here

Option 2

If you want to keep the bond-less style, you can use @{<name>}<atom> to add a node to an atom, and use polymerdelim options open xshift and close xshift to adjust the position of delimiters. Note in this case, the left and right space is not auto-adjusted.

chemfig{@{left}C(-[2])(-[6])=@{right}C(-[2])(-[6])}
polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n, 
  open xshift=-8pt, close xshift=]{left}{right}

enter image description here

Option 3

This is a variant of option 1, in which the beginning and ending bonds are specified but not drawn (by bond option [,,,draw=none]). To get better horizontal spacing, those two bonds are also shortened (by bond option [,0.5,,,]) and the position of nodes are adjusted (from @{left, 0.5}to@{left, 1}`).

chemfig{C(-[2])(-[6])(-[@{left,1}4,.5,,,draw=none])=C(-[2])(-[6])-[@{right,1},.5,,,draw=none]}
polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n]{left}{right}

enter image description here

Full example:

documentclass[margin=20pt]{standalone}
usepackage{chemfig}

begin{document}

schemestart
  chemfig{R-C(-[2])(-[6])-C(-[2])(-[6])-C(-[2])(-[6])-lewis{0.,C}(-[2])(-[6])}
  +
  %% option 1
  % chemfig{C(-[2])(-[6])(-[@{left,0.5}4])=C(-[2])(-[6])-[@{right,0.5}]}
  % polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n]{left}{right}
  %
  %% option 2
  % chemfig{@{left}C(-[2])(-[6])=@{right}C(-[2])(-[6])}
  % polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n, 
  %   open xshift=-8pt, close xshift=]{left}{right}
  %% option 3
  chemfig{C(-[2])(-[6])(-[@{left,1}4,.5,,,draw=none])=C(-[2])(-[6])-[@{right,1},.5,,,draw=none]}
  polymerdelim[delimiters={[]}, height=40pt, depth=, indice=n]{left}{right}
  arrow
  chemfig{R-C(-[2])(-[6])-C(-[2])(-[6])-[@{left,0.5}]C(-[2])(-[6])-C(-[2])(-[6])-[@{right,0.5}]C(-[2])(-[6])-lewis{0.,C}(-[2])(-[6])}
  polymerdelim[delimiters ={[]}, height=40pt, depth=, indice=n]{left}{right}
schemestop

end{document}

enter image description here

Correct answer by muzimuzhi Z on August 18, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP