I want to make polymer structures with chemfig like this:
\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[][scale=0.5]{-[@{op, 0.75}]O-[:30](=[:120]O)-*6(-=-(-(=[:60]O)-[:-30]O--[:30]-[@{cl, 0.25}])=-=)}
\makebraces[8pt, 8pt]{\!\!n}{op}{cl}\\
\end{document}
Overleaf makes the polymer structures and also the brackets, but gives me a lot of error messages:
Illegal parameter number in definition of \makebraces.
l.70 \edef\delimvshift{\the\dimexpr(#1#
You meant to type ## instead of #, right? Or maybe a } was forgotten somewhere earlier, and things are all screwed up? I'm going to assume that you meant ##.
Does anyone know, what I did wrong?