8

I am trying to reproduce this:

enter image description here

So far I have:

\documentclass{memoir}
\usepackage{tikz}
\usepackage{chemfig}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}

\chemfig{*5(5-1-2(-((-[:90,1,,,decorate,decoration=snake])-[:-90,1,,,decorate,decoration=snake]))-3-4*6(-6-7-8-9-5-)-)}

\end{document}

But the wavy line really doesn't look very good. Can someone think of a better way of doing that? Also, looking at the number 5 there is something strange going on there. What's wrong with that? enter image description here

jonalv
  • 11,466

1 Answers1

8

You might want to use the decoration complete sines from Nicer wavy line with TikZ as I've used in a blog post of mine a while ago:

enter image description here

\documentclass{article}
\usepackage{tikz}
\usepackage{chemfig}
\usetikzlibrary{decorations.pathmorphing}

\pgfdeclaredecoration{complete sines}{initial}{
  \state{initial}[
    width=+0pt,
    next state=sine,
    persistent precomputation={
      \pgfmathsetmacro\matchinglength{
        \pgfdecoratedinputsegmentlength /
        int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)
      }
      \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
    }]{}
  \state{sine}[width=\pgfdecorationsegmentlength]{
      \pgfpathsine{
        \pgfpoint
          {0.25\pgfdecorationsegmentlength}
          {0.5\pgfdecorationsegmentamplitude}
      }
      \pgfpathcosine{
        \pgfpoint
          {0.25\pgfdecorationsegmentlength}
          {-0.5\pgfdecorationsegmentamplitude}
      }
      \pgfpathsine{
        \pgfpoint
          {0.25\pgfdecorationsegmentlength}
          {-0.5\pgfdecorationsegmentamplitude}
      }
      \pgfpathcosine{
        \pgfpoint
          {0.25\pgfdecorationsegmentlength}
          {0.5\pgfdecorationsegmentamplitude}
      }
  }
  \state{final}{}
}

\tikzset{wv/.style={decorate,decoration=complete sines}}

\begin{document}

\chemfig{*5(5-1-2(-((-[:90,1,,,wv])-[:-90,1,,,wv]))-3-4*6(-6-7-8-9-5-))}

\end{document}

For reproducing the picture I'd probably also define a submol:

\tikzset{wv/.style={decorate,decoration=complete sines}}
\definesubmol{R}{-[,.5]((-[::90,.5,,,wv])-[::-90,.5,,,wv])}

and then:

\chemfig{*5(9-1-2(!R)-3(!R)-4*6(-5-6-7-8-9-))}

enter image description here

For more customization of the wavy bond you might be interested in this blog post by Joseph Wright: Exploring ChemFig: Going further

cgnieder
  • 66,645
  • This is a very helpful and the code provided works well. However, if you decrease the atom seperation below 20 pt (i.e. using \setchemfig{atom sep=19pt}), pgf throws a division by zero error. I assume this is connected to the complete sines declaration, but I do not have the skill to fix it. Any idea, how the code could be amended to also work with more ACS style like chemfig structures? – tosogoso Feb 04 '23 at 09:09