I'd like to draw the following copolymer structure using \chemfig.
But it turns out that I can't put the right bracket and the next left one within the same bond. All I found on the internet were some workarounds which I quite didn't understand.
The closest I got was
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\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$}}$};}}
\setpolymerdelim()
\chemfig{H_2N-[:30](-[:90])-[:-30]-[@{L1,.75}:30]O-[:-30]-[:30](-[:90])-[@{R1}:-30]O(@{L2})-[:30]-[:-30]-[@{R2}:30]@{L3}O-[:-30]-[:30](-[:90])-[@{R3}:-30]NH_2}
\makebraces[20pt,20pt]{\!\!\!x}{L1}{R1}
\makebraces[20pt,20pt]{\!\!\!y}{L2}{R2}
\makebraces[20pt,20pt]{\!\!\!z}{L3}{R3}
\end{document}
which gives
As you see I can't displace the brackets that are on the Oxygen atom. I'd care to get everything lined up as well.
Thanks for any help!
EDIT
After checking How to draw parentheses inside chemfig as Bobyandbob told me so, I adapted the code a bit and got closer to what I want, but now I need the brackets to be bigger.
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\def\L1{\llap{$\left(\strut\right.$\kern2pt }}
\def\Rx{\rlap{$\kern60pt \left.\strut\right)_x$}}
\def\Ry{\rlap{$\kern60pt \left.\strut\right)_y$}}
\def\Rz{\rlap{$\kern60pt \left.\strut\right)_z$}}
\chemfig{H_2N-[:30](-[:90])-[:-30]-[:30] \L1 \Rx O-[:-30]-[:30](-[:90])-[:-30] \L1 \Ry O-[:30]-[:-30]-[:30] \L1 \Rz O-[:-30]-[:30](-[:90])-[:-30]NH_2}
\end{document}
Any suggestions?




