I have the following code (which I found somewhere around this page) to make polymer figure
\usepackage{chemfig}
\usepackage{mhchem}
\makeatletter
\newcommand*\setpolymerdelim[2]{\def\polymer@delimleft{#1}\def\polymer@delimright{#2}}
\newcommand*\makepolymerbraces[5]{%
\edef\polymer@delimhalfdim{\the\dimexpr(#1+#2)/2}%
\edef\polymer@delimvshift{\the\dimexpr(#1-#2)/2}%
\chemmove{
\node[at=(#4),yshift=(\polymer@delimvshift)]
{$
\left\polymer@delimleft
\vrule height\polymer@delimhalfdim depth\polymer@delimhalfdim width0pt
\right.
$};
\node[at=(#5),yshift=(\polymer@delimvshift)]
{$
\left.
\vrule height\polymer@delimhalfdim depth\polymer@delimhalfdim width0pt
\right\polymer@delimright_{\rlap{#3}}
$};
}%
}
\makeatother
%
\begin{document}
\setpolymerdelim[]
\chemfig{-[@{b1},1.5]C(-[2]H)(-[6]H)-C(-[2]Cl)(-[6]H)-[@{b2},1.5]}
\makepolymerbraces{40pt}{40pt}{$n$}{b1}{b2}
\end{document}
No matter what I try it always gives me this error: !Missing $ inserted. !Extra } !pacakage PFG math error: unknown function '@b1 !pacakage PFG math error: unknown function '@b2
Everything in the line where the command \chemfig{-[@{b1},1.5]C(-[2]H)(-[6]H)-C(-[2]Cl)(-[6]H)-[@{b2},1.5]} Can anyone help me and tell me what I'm doing wrong? I'm using Texmaker and I just took any basic polymer as an example. I would appreciate any help.