0

I am trying to draw some polymer structures with brackets ()n, but I don't really get the instructions of the chemfig manual...

Here an example which gives me weird braces at the wrong place:

\documentclass{article}
%
\usepackage[utf8]{inputenc}
\usepackage[square,numbers]{natbib}
%\bibliographystyle{plainnat}
\bibliographystyle{abbrvnat}

\usepackage{siunitx}
\usepackage{textgreek}
%
\usepackage{caption}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}%showframe 
nachher löschen
\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\vruleheight\delimhalfdim depth\delimhalfdimwidth0pt\right.$};%
        \node[at=(#5),yshift=(\delimvshift)]{$\left.\vrule height\delimhalfdimdepth\delimhalfdimwidth0pt\right\delimright_{\rlap{$\scriptstyle#3$}}$};
    }
}

\begin{document}

\chemfig{-[@{op, 0.75}:30](-[:90])-[:-30](=[:-90]O)-[:30]O-[@{cl, 0.25}:-30]} \makebraces[5pt,25pt]{\!\!\!n}{op}{cl}
\bigskip \\

\end{document}

enter image description here

2

The chemfig package now provides the \polymerdelim macro:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{-[@{op, 0.75}:30](-[:90])-[:-30](=[:-90]O)-[:30]O-[@{cl, 0.25}:-30]}
\polymerdelim[indice=n]{op}{cl}
\end{document}

enter image description here

  • that doesn't make brackets at all any more :/ with this command it says "undefined control sequence" – Maj-Britt ter Hell Nov 19 '18 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.