I need to draw a generic tri bloc copolymer such as presented in this MWE and figure. The problem I have is with the left and right sides of the molecule. I want them to end with "(" and ")" only and no chemical bond represented. If I keep the "-" then I get the results on the left side of the image with a chemical bond. If I do not include it I get the results presented on the right hand side of the image with an error in the placement of the ")" and some junk characters.
I'm using chemfig 1.2e from the Ubuntu 18.04 archive. Meaning that I do not have the new features introduced in newer versions of the package.
Thanks !
edit : also bonus point if the chemical bonds are made shorter :)
\documentclass{article}
\usepackage{mwe}
\usepackage{chemfig}
\begin{document}
% Define a function to draw polymer structures
\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{
-[@{opa,.75}]A-[@{cla,0.25}]
-[@{opb,.75}]B-[@{clb,0.25}]
-[@{opc,.75}]A\ [@{clc,0.25}]
}
\makebraces[5pt,5pt]{\!\!n_{i}}{opa}{cla}
\makebraces[5pt,5pt]{\!\!n_{i+1}}{opb}{clb}
\makebraces[5pt,5pt]{\!\!n_{i+2}}{opc}{clc}
\end{document}
chemfig
received major updates for the past year, including altered syntax, so if you plan to use it extensively, it might be a good idea to keep your LaTeX installation bleeding edge. By the way, if you are on Ubuntu LTS branch, you can give MiKTeX a try, which is basically a rolling release.tlmgr
. Also, to be frank, it is only the second time that I usedchemfig
since I started using LaTeX almost 10 years ago. I will no the using it extensively any time soon.