2

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?

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

1 Answer 1

3

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.
1
  • Found this 6 years later ... \setatomsep is obsolet now, use \setchemfig{atom sep=4em} instead. Mar 27, 2020 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .