# Creating delocalized double bonds in chemfig without tikzset?

I'm trying to create a delocalized double bond, similar to the example given in the chemfig documentation. They suggest using the tikz library package {decorations} to implement this. Before running the actual chemfig code for the molecule, the documentation suggests this setup code:

\pgfdeclaredecoration{ddbond}{initial}
{
\state{initial}[width=4pt]
{
\pgfpathlineto{\pgfpoint{4pt}{0pt}}
\pgfpathmoveto{\pgfpoint{2pt}{2pt}}
\pgfpathlineto{\pgfpoint{4pt}{2pt}}
\pgfpathmoveto{\pgfpoint{4pt}{0pt}}
}
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}


}

\tikzset{lddbond/ .style={decorate, decoration=ddbond}}
\tikzset{rddbond/ .style={decorate, decoration={ddbond, mirror}}}
\setatomsep{4em}


After which, the standard chemfig syntax comes in:

\chemfig{[:-30]R-C-[::60]C(-[::60,,,,,rddbond]O)-[,,,,lddbond]N(-[::-60]C-R}


My problem: I Have no idea how to use tikz, or even what it is. I run this above code and get errors from my compiler saying ! Package pgfkeys Error: I do not know the key /tikz/lddbond/ .style' and I am going to ignore it. Perhaps you misspelled it. How do I implement tikz to create these delocalized double bonds; or, how do I create a double bond without tikz?

-
Welcome to TeX.SX! Did you try removing the space between / and .? –  Claudio Fiandrino Jan 22 at 14:57
You just probably forgot to include \usetikzlibrary{decorations} at the preamble. –  pisoir Jan 29 at 17:08

This worked for me:

\documentclass{article}
\usepackage{chemfig}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{ddbond}{initial}{
\state{initial}[width=4pt]{
\pgfpathlineto{\pgfpoint{4pt}{0pt}}
\pgfpathmoveto{\pgfpoint{2pt}{2pt}}
\pgfpathlineto{\pgfpoint{4pt}{2pt}}
\pgfpathmoveto{\pgfpoint{4pt}{0pt}}
}
\state{final}{
\pgfpathlineto{\pgfpointdecoratedpathlast}
}
}
\tikzset{lddbond/.style={decorate, decoration=ddbond}}
\tikzset{rddbond/.style={decorate, decoration={ddbond, mirror}}}
\setatomsep{4em}
\begin{document}
\chemfig{
[:-30]R-C-[::60]C(
-[::60,,,,,rddbond]O
)-[,,,,lddbond]N(
-[::-60]H
)-[::60]C-[::-60]R
}
\end{document}


• The space between / and .style was removed as stated in Claudio's comment.
• \usetikzlibrary{decorations} was added as stated in pisoir's comment.
• Syntax for \chemfig was corrected.
-