
我想填充一些官能基或原子(包括鍵)的背景來強調它們。例如,要強調酮中的羰基,請填入 C=O 的背景,如下所示:
我正在使用 chemfig 繪製化學方程式,並且我有一個覆蓋覆蓋(chemmove)的解決方法:
\chemfig{R|_1-@{kc}C(=[:90]O)-R|_2}
\chemmove{
\node[fill=purple!20,anchor=text,inner sep=0.1em]
at (kc.text) {\chemfig{C(=[:90]O)}};
}
然而,我需要更簡單和更聰明的方法,因為透過這種方式,我必須編寫相同的程式碼兩次(如果原子和鍵又長又複雜,這可能會很長)並且它不能時不時地處理錯誤的錨定。
答案1
你可以標記二使用以下語法繪製節點@{<name>}
,然後使用fill opacity=.2
(或最適合您的任何內容)繪製一個矩形:
\documentclass{article}
\usepackage{chemfig,tikz}
\begin{document}
\chemfig{R_1-@{C}C(=[:90]@{O}O)-R_2}
\chemmove{
\draw[
fill=purple,
draw=purple,
fill opacity=.2,
rounded corners=2pt
]
([xshift=-3pt,yshift=-1pt]C.south west)
rectangle
([xshift=3pt,yshift=3pt]O.north east) ;
}
\end{document}