chemfig,如何做出这些波浪形标记?

chemfig,如何做出这些波浪形标记?

我正在尝试重现这一点:

在此处输入图片描述

到目前为止我已经:

\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}

但是波浪线看起来确实不太好。有人能想出更好的方法吗?另外,看看数字 5,那里有些奇怪。这有什么问题吗? 在此处输入图片描述

答案1

你可能想要使用complete sines来自使用 TikZ 绘制更漂亮的波浪线正如我所用在我之前的一篇博客文章中

在此处输入图片描述

\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}

为了重现图片我可能还会定义一个子模型:

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

进而:

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

在此处输入图片描述

如果想了解更多关于波浪键的定制,你可能会对 Joseph Wright 的这篇博客文章感兴趣:探索 ChemFig:更进一步

相关内容