4

I'm using this code to generate chemical structure with chemfig package:

\documentclass[12pt,a4paper]{standalone}
\usepackage{chemfig}
\begin{document}
\setatomsep{2.5em}
\chemfig{B(-[:35]N*5(=(-*6(=-=(-OH)-(-NO_2)=-))-=(-Ph)-(=N?[o])-))(-[:145]N*5(-?[o]=(-Ph)-=(-*6(=-=(-O-[7]-[1](=[:65]O)(-[:15]NH(-{(CH_2CH_2O)_nH})))-=-))-))(<[:225]F)(<:[:-45]F)}
\end{document}

enter image description here

I am not happy how chemfig makes connection, which is crossed with red. I need to have bond going from Nto first C atom, not to the second one.

How the code should be changed to avoid this problem.

2 Answers 2

3

Here is another idea: if you place each of the parentheses between braces ({(} and {)}) they are treated like an atom (i.e. like C or H) and you can use the optional argument of the bonds to determine where the bond arrives:

<bond>[<angle>,<length factor>,<departure atom>,<arrival atom>,<TikZ options>]

Where <departure atom> and<arrival atom> are the position numbers of the atoms where the bond should start or end, respectively.

In your case the following fragment (the rest of the MWE unchanged)

-[,,,2]{(}CH_2CH_2O{)}_nH

gives

enter image description here

2

It can be done like this:

\documentclass[12pt,a4paper]{standalone}
\usepackage{chemfig}
\newcommand\setpolymerdelim[2]{\def\delimleft{#1}\def\delimright{#2}}
\def\makebraces[#1,#2]#3#4#5{%
\edef\delimhalfdim{\the\dimexpr(#1+#2)/2}%
\edef\delimvshift{\the\dimexpr(#1-#2)/2}%
\chemmove{%
\node[at=(#4),yshift=(\delimvshift)]
{$\left\delimleft\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right.$};%
\node[at=(#5),yshift=(\delimvshift)]
{$\left.\vrule height\delimhalfdim depth\delimhalfdim
width0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};}}
\begin{document}
\setpolymerdelim()
\setatomsep{2.5em}
\chemfig{B(-[:35]N*5(=(-*6(=-=(-OH)-(-NO_2)=-))-=(-Ph)-(=N?[o])-))(-[:145]N*5(-?[o]=(-Ph)-=(-*6(=-=(-O-[:-45]-[:10](=[:65]O)(-[:-15]NH(-[@{op,.85}:1]CH_2CH_2O-[@{cl,0.15}:0,.7]H)(-[5,0.5,,,white])))-=-))-))(<[:225]F)(<:[:-45]F)}
\makebraces[5pt,5pt]{\!n}{op}{cl}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .