2

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}

MWE

2
  • Out of curiosity, why do you prefer TeXLive from the Ubuntu repos? The majority of Linux distros have an outdated version of TeXLive in the repositories, so it might be a better idea to install it from an *.iso. 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. – andselisk Dec 9 '19 at 14:25
  • I am aware that the TeXLive version in the Ubuntu repository is "outdated" but I usually don't need bleeding edge packages. It is easier for me to simply install all the packages from the repository with apt then to deal with them through an independent tool such as tlmgr. Also, to be frank, it is only the second time that I used chemfig since I started using LaTeX almost 10 years ago. I will no the using it extensively any time soon. – DBrassard Dec 10 '19 at 15:36
4

Welcome! Here is one way: set the opacity of these bonds to zero.

\documentclass{article}
\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},,,,opacity=0]A-[@{cla,0.25}]
    -[@{opb,.75}]B-[@{clb,0.25}]
    -[@{opc,.75}]A-[@{clc,0.25},,,,opacity=0]
}
\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}

enter image description here

Please note that there might well be better ways. Yet this is a way to get rid of these bonds.

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.