2

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?

1 Answer 1

1

Note that chemfig package has been recently updated, and version 1.33 includes \polymerdelim macro with the following syntax:

\polymerdelim[<keys>=<values>]{<node1>}{<node2>}

For more detailed info on usage refer to section 12.4 Draw a ploymer element on p. 43 of the chemfig manual. I'm not sure whether Overleaf has already updated the package on their side or not, but I'd stick to the new syntax anyway. I also wouldn't use scaling; instead, make the bonds a bit shorter.

So, in your case for the structure of polyethylene terephthalate I suggest the following (I also adjusted angles a bit):

\documentclass{article}
\usepackage{chemfig}
    \setchemfig{
        atom sep = 1.75em,
        double bond sep = 0.3em,
        bond join = true,
    }
\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}

\begin{document}

\chemfig{
    -[@{op, 0.5}]O-[:60](=[:120]O)-*6(-=-(-(=[:60]O)-[:-60]O--[:60]-[@{cl, 0.5}])=-=)
}
\polymerdelim[height = 32pt, depth = 4pt, indice = \!\!n]{op}{cl}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .