3

I'm using chemfig to draw chemical figures. However, when drawing double bonds as side group onto a carbon chain, I get a little gap. This behaviour is different e.g. in chemdraw, where it looks better in my opinion.

enter image description here

This is my mwe:

\documentclass[border=2pt]{standalone}
\usepackage{chemfig}

\usepackage{mathpazo}
\renewcommand*{\familydefault}{\sfdefault}
\renewcommand*{\printatom}[1]{\ensuremath{\mathsf{#1}}}

\setdoublesep{0.35700 em}  % 'Bond Spacing'
\setatomsep{1.478500 em}    % 'Fixed Length'
\setbondoffset{0.18265 em} % 'Margin Width'
\setbondstyle{line width = 0.06642 em}
\setbondstyle{thick,cap=round}

\begin{document}
    \chemfig{
        -[:30](=[2]O)-[:-30]
    }
\end{document}

How can I remove this gap and "attach" the boule-bond onto the backbone? Drawing Carbon-Atoms is not the desired solution in this case.

2

With some help I found a solution:

 -[:30](=[2,,,,shorten <=-1pt]O)-[:-30]

So what is going on here? The fifth argument is tikz-code. shortenis a tikzcommand for e.g. lines in a \draw commands and will shorten one end of line by the specified amount. As we specify the amount to be negative, it will make the line(s) longer. With the <= part we are able to select one of the two lines end, which should be shortened (or in this case prolonged).


or another code, a little shorter:

-[:30](=#(-1pt)[2]O)-[:-30]

This one is explained in the chemfig-manual. Bond-spacing can be altered directly with the #()-command (see manual section 2, Different types of bonds). Keep in mind: if used within a macro, #can make problems.


A little more manual-digging could have helped me :-)

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.