如何使用“chemfig”包绘制羧酸离子?

如何使用“chemfig”包绘制羧酸离子?

我不确定如何画虚线,如能得到任何帮助我将非常感激。 像这样

答案1

混合债券

\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{chemfig}
\usetikzlibrary{decorations.pathmorphing}
\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}}}
\begin{document}

\chemfig{\charge{30:7pt=$\ominus$}{C}(-[:210]R)(-[2,,,,rddbond]O)(-[:330,,,,lddbond]O)}

\end{document}

在此处输入图片描述

答案2

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

\catcode`\_=11 % manual p. 28
\tikzset{
    ddbond/.style args={#1}{
        draw=none,
        decoration={%
            markings,
            mark=at position 0 with {
                \coordinate (CF@startdeloc) at (0,\dimexpr#1\CF_doublesep/2)
                coordinate (CF@startaxis) at (0,\dimexpr-#1\CF_doublesep/2);
            },
            mark=at position 1 with {
                \coordinate (CF@enddeloc) at (0,\dimexpr#1\CF_doublesep/2)
                coordinate (CF@endaxis) at (0,\dimexpr-#1\CF_doublesep/2);
                \draw[dash pattern=on 2pt off 1.5pt] (CF@startdeloc)--(CF@enddeloc);
                \draw (CF@startaxis)--(CF@endaxis);
            }
        },
        postaction={decorate}
    }
}
\catcode`\_=8

\begin{document}
    
    \chemfig{\charge{30:5pt=$\ominus$}{C}(-[:210]R)(-[:330,,,,ddbond={+}]O)(-[2,,,,ddbond={-}]O)}
    
\end{document}

在此处输入图片描述

相关内容