# Difficulty in making the big square braces with n at bottom right end

I have made the code for following using \chemfig. But I am having issue making the final [D] at the end of the equation. Can anyone please help me how to define this and the final output. I have copied the following code from Chemfig but this gives error, I have tried putting the defining code both in preamble and in body of the program but nothing works!

My MWE is here:

\documentclass{article}
\usepackage{mhchem}
\usepackage{chemmacros}
\usepackage{amsmath}
\usepackage{rotating}
\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{*6(----(=[:90]NOH)--)} \schemestart \arrow(start.mid east--.mid west){->[\ce{H^{+}}]} $C$  \arrow(start.mid east--.mid west){->[Polymerisation]}[,1.85]  \schemestop
\chemfig{\vphantom{CH_2}[@{op,.75}]CH_2CH_2[@{cl,0.25}]}
\makebraces[5pt,5pt]{}{left}{right}

\end{document}

• Defining \makebraces is not necessary when using chemmacros and it's polymers module – clemens Jul 28 '17 at 6:59

This should work as you want. Maybe tweak the lengths and spaces.

\documentclass{article}
\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}
\schemestart
\chemfig{*6(----(=[:90]NOH)--)}
\arrow(.(-35)--.west){->[H$^+$]}
\chemfig{C}
\arrow{->[Polymerisation]}[,2pt]
\setpolymerdelim[]
\chemfig{{\ast}-[@{op,0.7}]D-[@{cl,0.4}]-[,0.2,,,draw=none]{\ast}} \makebraces[4pt,10pt]{n}{op}{cl}
\schemestop

\end{document}