![如何使用“chemfig”包绘制羧酸离子?](https://linux22.com/image/458197/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E2%80%9Cchemfig%E2%80%9D%E5%8C%85%E7%BB%98%E5%88%B6%E7%BE%A7%E9%85%B8%E7%A6%BB%E5%AD%90%EF%BC%9F.png)
答案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}