如果你能帮我在 LaTeX 中绘制 NO2,那就太好了。该图应该看起来像示例图像。
在这网站提供了一些有关 chemfig/chemmakro 包的信息。我的代码现在只显示了一个 NO2 分子。现在我只需要添加箭头和节点(原始图像上的红色区域)。怎么做呢?首先我要感谢 @Sigur(他让 chemfig 代码工作)和 @ajeh 纠正了我的角度。我还要感谢德国 Texwelt(德国 LaTeX 帮助论坛)。在该网站上,名为“Clemens”的用户帮助(20 Jul,05:27)用户“goldsonne23”完成了此分离键合网站。所以所有 Tikz 部分都是从 Clemns “偷”来的。代码如下:
\documentclass[a4paper, 12pt, twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{chemfig, chemmacros}
\usetikzlibrary{decorations}
%delocated bondings
\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},
rddbond/.style={decorate,decoration={ddbond,mirror}},
elmove/.style={->,red,shorten >=3pt, shorten <=3pt}
}
\begin{document}
%\chemfig{<atom1><bond type>[<angle>,<coeff>,<tikz code>]<atom2>}
\chemfig{O-[:22.85,,,,rddbond]N-[:-22.85,,,,rddbond]O}
\end{document}
有谁能帮忙? 谨致问候,巴西利乌斯
答案1
我使用包中的示例chemfig
(第 12.7 节)将其拼凑在一起。
编辑:我还在键旁边添加了一个普通标签(没有箭头)。我认为这看起来更好,因为带箭头的线与指示键的线不太平行。
\documentclass[a4paper, 12pt, twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{chemfig, chemmacros}
\setatomsep{5em}
\usepackage{siunitx}
\usetikzlibrary{calc,decorations}
%delocated bondings
\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},
rddbond/.style={decorate,decoration={ddbond,mirror}},
elmove/.style={->,red,shorten >=2pt, shorten <=2pt}
}
\begin{document}
%\chemfig{<atom1><bond type>[<angle>,<coeff>,<tikz code>]<atom2>}
\chemfig{O-[:22.85,,,,rddbond]N-[:-22.85,,,,rddbond]O}
\newcommand\namebond[4][5pt]{\chemmove{\path(#2)--(#3)
node[midway,sloped,yshift=#1]{\color{red}#4};
}}
\newcommand\bondlengtharrows[4][9pt]{\chemmove{\path(#2)--(#3)
node(p1)[above,at end]{}
node(p2)[above,at start]{}
node[midway,sloped,yshift=#1]{\color{red}#4};
\draw[red,stealth-stealth](p1)--(p2);
}}
\newcommand\arcbetweennodes[3]{%
\pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{\pgfpointanchor{#2}{center}}%
\let#3\pgfmathresult}
\newcommand\arclabel[6][red,thick,shorten <=2pt,shorten >=2pt]{%
\chemmove{%
\arcbetweennodes{#4}{#3}\anglestart \arcbetweennodes{#4}{#5}\angleend \draw[#1]([shift=(\anglestart:#2)]#4)arc(\anglestart:\angleend:#2); \pgfmathparse{(\anglestart+\angleend)/2}\let\anglestart\pgfmathresult \node[shift=(\anglestart:#2+1pt)#4,anchor=\anglestart+180,rotate=\anglestart+90,inner sep=0pt,outer sep=0pt]at(#4){\color{red}#6};}}
\chemfig[scale=2]{@{1}O-[:22.85,,,,rddbond]@{2}N-[:-22.85,,,,rddbond]@{3}O}
\namebond{1}{2}{\footnotesize\SI{119.7}{\pico\meter}}
\bondlengtharrows{2}{3}{\footnotesize\SI{119.7}{\pico\meter}}
\arclabel{5mm}{1}{2}{3}{\footnotesize104.45\si\degree}
\end{document}