PGF decorations not working

by scorpionwars   Last Updated September 20, 2019 18:23 PM

I am trying to use the following custom pgfdecoration to draw bonds with varying length of the double bond while using chemfig. The code was obtained from the following link: How to alter the bond length of a double bond in chemfig?. However, I am unable to run the code after recently installing MikTeX and executing the code throws the following error message: Undefined control sequence. ...]--[::-60,,,,,rsdbond={120}{120}]-[::-60]}. I have tried updating pgf and chemfig from the MikTeX console but to no avail.

Does someone know what package I am missing and how to successfully execute this code (see below).

\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}%
  }
}
\setchemfig{
    double bond sep=0.4em,
    atom sep=2em,
}
\makeatother
\begin{document}
\chemfig{[:60]--[::-60,,,,,rsdbond={120}{120}]-[::-60]}
\chemfig{[:90]--[::-90,,,,,rsdbond={90}{60}]-[::-120]}
\end{document}



Related Questions


How can I create this ornament section?

Updated November 21, 2017 23:23 PM

Tikz: Text along top and bottom of arrow path

Updated June 03, 2017 16:23 PM


Additional parallel paths and "shorten"

Updated May 29, 2015 00:10 AM

Position arrow decoration by center, not by tip

Updated April 19, 2017 11:23 AM