# How to alter the bond length of a double bond in chemfig?

With the chemfig package, is it possible to alter the bond length of the pi-bond in a double-bond? I know about the \setbondoffset{}-command, but in this case, this does not work. Hope the below example clarifies what i want to accomplish.

Input:

\documentclass{scrartcl}
\usepackage{chemfig}

\begin{document}
\chemfig{-[:120]=^[:180]-[:240]}
\end{document}


Output:

Desired ouput:

-
IIRC there is no option to customize the second bond separately. You could define a TikZ-decoration that looks like it and use that instead. Or you can »cheat«: \chemfig{*6(-=-)} –  cgnieder Dec 4 '13 at 12:56
It would be better if the length of second/third bond can be customized as this is the standard drawing of molecular structure involving unsaturated bond for linear molecule, according to IUPAC –  bingung Dec 30 '13 at 16:15
@jc2254 really? This is interesting! Where does IUPAC say this? –  cgnieder Feb 1 at 18:14
@cgnieder Before I was wondering if there is some 'general rules' for representing chemical structure, and I found the 'Graphical representation standards for chemical structure diagrams' from IUPAC very useful (iupac.org/publications/pac/80/2/0277). GR-1.10 talks about the above issue. I don't know this is regarded as very 'official' or not, but it is sometimes great to have consistent representation. And there are many other recommendations! But the point is to represent clear structure. –  bingung Feb 2 at 23:15
@jc2254 Thanks! –  cgnieder Feb 2 at 23:25

I defined TikZ decorations:

\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{decorations}
\makeatletter
\newdimen\mystartshorten
\newdimen\myendshorten
\mystartshorten0pt
\myendshorten0pt
\pgfdeclaredecoration{sdbond}{initial}{
\state{initial}[width=\pgfdecoratedremainingdistance,next state=final]
{
{
\pgftransformyshift{\CF@double@sep}
\pgfpathmoveto{\pgfqpoint{\mystartshorten}{0pt}}
{
\pgftransformxshift{\pgfdecoratedremainingdistance}
\pgfpathlineto{\pgfqpoint{-\myendshorten}{0pt}}
}
}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfqpoint{\pgfdecoratedremainingdistance}{0pt}}
}
\state{final}
{}
}
\tikzset{
lsdbond/.code 2 args={%
\tikzset{decorate, decoration=sdbond}%
\pgfmathsetlength\mystartshorten{\CF@double@sep*cot((#1)/2)}%
\pgfmathsetlength\myendshorten{\CF@double@sep*cot((#2)/2}%
},
rsdbond/.code 2 args={%
\tikzset{decorate, decoration={sdbond, mirror}}%
\pgfmathsetlength\mystartshorten{\CF@double@sep*cot((#1)/2)}%
\pgfmathsetlength\myendshorten{\CF@double@sep*cot((#2)/2}%
}
}
\setdoublesep{0.4em}
\setatomsep{2em}
\makeatother
\begin{document}
\chemfig{[:60]--[::-60,,,,,rsdbond={120}{120}]-[::-60]}
\chemfig{[:90]--[::-90,,,,,rsdbond={90}{60}]-[::-120]}
\end{document}


Two decorations lsdbond (left short double bond) and rsdbond (right short double bond) are defined. lsdbond puts the shortened (pi) bond on the left of the middle (sigma) bond, and rsdbond on the right. They take two arguments: the first is the bond angle on the departure atom of the bond; the second on the arrival atom. The angles are in degrees and should be in the range of (0,180].

-