在 Latex 中绘制一个冰霜圆圈

在 Latex 中绘制一个冰霜圆圈

在化学中,弗罗斯特圆是一种快速估计环状化合物中 π 分子轨道的相对能级的方法,然后根据电子位置判断其芳香性。我正在寻找一种在 LaTeX 中创建这些的方法,最好使用和等软件包的功能chemfigtikzorbital但我将只使用一个tikz解决方案。

弗罗斯特圆是通过将环状化合物的多边形(例如苯的正六边形)内接在一个圆内而创建的,多边形的一个顶点朝下。多边形顶点与圆接触的每个位置都是分子轨道,其中最多可以有两个电子(用鱼钩箭头表示)。平分圆的水平线下方的轨道是键合轨道。上方的轨道是反键合轨道。任何位于线上的轨道都是非键合轨道。电子按照某些规则被放入轨道中。

  • 构造原理:轨道按能量增加的顺序填充。
  • 泡利不相容原理:每个轨道只能容纳两个电子,并且它们的自旋(箭头方向)必须相反。
  • 洪特规则:如果两个轨道具有相同的能量,则在它们各自获得第二个电子之前,一个电子会先进入每个轨道。

以下是该方法及其应用的详细描述。

我理想的解决方案是新命令,将环大小和电子数量作为输入,并通过以下示例构建 Frost 环:

  • 绘制圆圈
  • 内接正多边形,边数等于环大小(最多 10 个)
  • 在分子轨道的多边形顶点处绘制水平线段
  • 绘制垂直能量轴
  • 绘制键合/反键合划分的虚线
  • 根据上述规则填充电子数

以下是一些例子:苯(环大小 = 6,电子 = 6)

苯霜圈

环戊二烯基阳离子(环大小 = 5,电子 = 4)

有 5 个原子和 4 个电子的冰霜圆环

环辛四烯(环大小 = 8,电子 = 8)

在此处输入图片描述

答案1

这是一个完全自动化的解决方案。您的三个示例的调用如下

\frost{6}{6}
\frost{5}{4}
\frost{8}{8}

半径大小有一个可选参数。默认值为 1cm。因此frost[2cm]{6}{6}半径为 2cm。

在此处输入图片描述

注意:仅当电子数量为偶数时,此方法才有效(目前)。

\documentclass{article}

\usepackage{tikz}
\usepackage{ifthen}

\usetikzlibrary{decorations.markings}
\tikzset% Define decorations
   {updown/.style={postaction=decorate, decoration={markings, mark=at position .5 with
   {\draw[line join=round] (-2pt,-\arrlen)--++(0pt,2*\arrlen)--(-4pt,1pt);
   \draw[line join=round] (2pt,\arrlen)--++(0pt,-2*\arrlen)--(4pt,-1pt);
   }}},% 2 arrows
   uparr/.style={postaction=decorate, decoration={markings, mark=at position .5 with
   {\draw[line join=round] (0pt,-\arrlen)--++(0pt,2*\arrlen)--(-2pt,1pt);
   }}},% 1 arrow, right side
   dnarr/.style={postaction=decorate, decoration={markings, mark=at position .5 with
   {\draw[line join=round] (0pt,\arrlen)--++(0pt,-2*\arrlen)--(2pt,-1pt);
   }}}% 1 arrow left side (points down since lines will be drawn right to left)
}

\newcommand{\orblen}{.8}% length of horizontal segments as a percentage of main radius
\newcommand{\arrlen}{.25cm}% half length of each arrow

\newcommand{\frost}[3][1cm]% optional argument is circle radius, #2=edges, #3=electrons
{\begin{tikzpicture}[line width=1pt]
\draw(0,0)circle[radius=#1];% main circle
\ifthenelse{#3 = 0}{\draw(-.5*#1*\orblen,-#1)--(.5*#1*\orblen,-#1);}% draw bottom line segment...
    {\draw[updown](-.5*#1*\orblen,-#1)--(.5*#1*\orblen,-#1);}% ...with arrows if >0 electrons
\foreach \k [evaluate=\k as \r using .5*#2+1,% point right if k<r, point left if k>r, top if k=r
    evaluate=\k as \t using (\k-1)*360/#2-90,% angles of polygon vertices. k=1 is bottom.
    evaluate=\k as \n using -4*\k+6+#3,% who gets 2 electrons (right)?
    evaluate=\k as \m using -4*(#2+2-\k)+6+#3,% who gets 2 electrons (left)?
    evaluate=\k as \j using 2*#2] in {1,...,#2}% electrons for top if #3=2*#2
    {\draw(\t:#1)--(\t+360/#2:#1);
    \ifthenelse{\k>1}% already did bottom line.
    {\ifthenelse{\lengthtest{\k pt < \r pt}}% right side
        {\ifthenelse{3 < \n}{\draw[updown](\t:#1)--+(#1*\orblen,0);}% 2 arrows
        {\ifthenelse{1 < \n}{\draw[uparr](\t:#1)--+(#1*\orblen,0);}% 1 arrow
        {\draw(\t:#1)--+(#1*\orblen,0);}}}% no arrows
    {\ifthenelse{\lengthtest{\k pt > \r pt}}% left side
        {\ifthenelse{3 < \m}{\draw[updown](\t:#1)--+(-#1*\orblen,0);}% 2arrows
        {\ifthenelse{1 < \m}{\draw[dnarr](\t:#1)--+(-#1*\orblen,0);}% 1 arrow
        {\draw(\t:#1)--+(-#1*\orblen,0);}}}%no arrows
        {\ifthenelse{#3 = \j}{\draw[updown](-.5*#1*\orblen,#1)--(.5*#1*\orblen,#1);}% 2 arrows on top
        {\draw(-.5*#1*\orblen,#1)--(.5*#1*\orblen,#1);}}} % no arrows on top
    }{} % do nothing if k=1 (bottom)
}
\draw[dotted](-2*#1,0)--(3*#1,0)node[below]{bonding\phantom{anti}}node[above]{antibonding};
\draw[-latex](-2.2*#1,-#1)--node[sloped,above,pos=.4]{Energy}(-2.2*#1,1.8*#1);
\end{tikzpicture}
}

\begin{document}

\frost{6}{6}

\frost{5}{4}

\frost{8}{8}

\end{document}

答案2

老实说,这需要花费一些精力,但你的身材很有趣,而且让我学到了新的东西所以一切都很好。

基本上我创建了一个\newcommand名称\Frostcircle,它有 2 个参数,选项和电子。

目前[options]有:

  • radius= 圆的半径,请注意,如果半径太大,周围的图形目前不会调整。我以后可能会研究一下。目前只需要一个数字(in cm),使用长度会破坏它,我还不知道为什么。欢迎提出建议。
  • ring size= 这指的是多边形的边数。边数从 5 到 10 都经过了测试。正如您所料,它接受一个数字作为参数
  • frost label= 这是顶部的标签,默认为空。确保用花括号括住文本,例如frost label={My label here}

另一个参数是电子,我能找到的最简单的方法是将它们以逆时针方式设置,从顶部开始,如下图所示:

命令如何工作

它需要值012:按顺序,无电子、一个电子、两个电子。您可以将其作为列表提供,这样给出{0,0,2,2,2,0}就会给出您的benzene冰霜圈。这听起来可能违反直觉,但一旦您尝试一下,它实际上就很简单。

如果您提供的列表中的元素数量小于环大小,您将收到错误,并且代码将无法编译。如果您不想要电子,只需键入0即可解决此问题。

笔记

电子“箭头”的方向在另一侧是反转的,不确定这对您的图表是否重要。如果它很重要,我可以改天再研究一下。 固定的

我还添加了与塞巴斯蒂亚诺的回答来获取数学字体,但是命令运行不需要它们。

输出

霜圈示例

代码

\documentclass[margin=10pt]{article}
\usepackage{tikz}
\usepackage{newtxtext}
\usepackage{amssymb}
\usepackage{bm}

\usetikzlibrary{arrows.meta,decorations.markings,shapes.geometric}

\tikzset{%
    electron/.style={%
        postaction={decorate,
            decoration={%
            markings,
            mark=at position .5 with
            {%   
            \ifnum#1=1\relax% 
                \draw[-{Straight Barb[left,angle=60:2pt 3]}] (0,-6pt) --(0,6pt);
            \else
            \ifnum#1=2\relax%
                \draw[-{Straight Barb[left,angle=60:2pt 3]}] (-1pt,-6pt) -- (-1pt,6pt);
                \draw[{Straight Barb[left,angle=60:2pt 3]}-] (1pt,-6pt) -- (1pt,6pt);
            \else
            \fi\fi
            }}
        }
    },
    mlbl/.style={anchor=south, align=center, midway, sloped},
}

\pgfkeys{/tikz/.cd,% to set the path
    radius/.initial=.8, % initial value
    radius/.get=\circleradius, % to get the value from a macro
    radius/.store in=\circleradius, % to store the value into a macro
    ring size/.initial=5,
    ring size/.get=\numbersides,
    ring size/.store in=\numbersides,
    frost label/.initial=,
    frost label/.get=\frostlabel,
    frost label/.store in=\frostlabel,
}

\newcommand\Frostcircle[2][]{%
    \tikzset{radius=.8,ring size=5,frost label=,#1}
    \begin{tikzpicture}[line width=1pt]
    \draw[-{Stealth[scale=1.5]}] (0,0) -- (0,3cm) 
    node[mlbl] {Energy}
    node[anchor=north west, xshift=2mm] {\frostlabel};
\draw[dotted, shorten >=-1cm] (.5,1) -- (4,1)
    node[anchor=south west] {antibonding}
    node[anchor=north west] {bonding};
\draw (2,1) circle (\circleradius);
\node[%
    regular polygon, 
    rotate=360/\numbersides/2,
    regular polygon sides=\numbersides,
    minimum size=\circleradius*2 cm, 
    draw, 
    outer sep=0pt
] at (2,1) (FrostCircle) {};

\def\electronarrow{{#2}}
\foreach \polycorner [count=\findex starting from 0] in {1,...,\numbersides}{%
    \pgfmathtruncatemacro\maximumhalf{\numbersides/2+1}
    \pgfmathsetmacro\Findex{\electronarrow[\findex]}
    \ifnum\polycorner=1\relax%
        \draw[electron=\Findex] (FrostCircle.corner \polycorner)++(-.8,0) --++ (1.6,0);
    \else
    \ifnum\polycorner=\maximumhalf\relax%
        \draw[electron=\Findex] (FrostCircle.corner \polycorner)++(-.8,0) --++ (1.6,0);
    \else
    \ifnum\polycorner<\maximumhalf\relax%
        \draw[electron=\Findex] (FrostCircle.corner \polycorner)++ (-.8,0) -- (FrostCircle.corner \polycorner);
    \else
        \draw[electron=\Findex] (FrostCircle.corner \polycorner) --++ (.8,0);
    \fi\fi\fi
}%
    \end{tikzpicture}%
}

\begin{document}

\Frostcircle[%
    ring size=6, 
    radius=1,
    frost label={benzene (ring size = 6, electrons = 6)}
    ]{0,0,2,2,2,0}

\vspace{1cm}

\Frostcircle[%
    ring size=5, 
    radius=1,
    frost label={cyclopentadienyl cation (ring size = 5, electrons = 4)}
    ]{0,1,2,1,0}

\vspace{1cm}

\Frostcircle[%
    ring size=8, 
    radius=1,
    frost label={cyclooctatetraene (ring size = 8, electrons = 8)}
    ]{0,0,1,2,2,2,1,0}

\end{document}

1:pgfkeys

答案3

我已经完成了马查第一个例子。依我拙见,它们看起来非常相似...但有一句拉丁格言:“de gustibus non disputandum est”。

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage{newtxtext}
\usepackage{amssymb}
\usepackage{bm}


\begin{document}


\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300

%Shape: Regular Polygon [id:dp9024119328579219] 
\draw  [line width=1.5]  (203,184) -- (161.86,160.25) -- (161.86,112.75) -- (203,89) -- (244.14,112.75) -- (244.14,160.25) -- cycle ;
%Shape: Circle [id:dp3742321630799761] 
\draw  [line width=1.5]  (155.5,136.5) .. controls (155.5,110.27) and (176.77,89) .. (203,89) .. controls (229.23,89) and (250.5,110.27) .. (250.5,136.5) .. controls (250.5,162.73) and (229.23,184) .. (203,184) .. controls (176.77,184) and (155.5,162.73) .. (155.5,136.5) -- cycle ;
%Straight Lines [id:da6431705906977057] 
\draw [line width=1.5]    (101,185) -- (101,31.71) ;
\draw [shift={(101,27.71)}, rotate = 450] [fill={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.08]  [draw opacity=0] (13.4,-6.43) -- (0,0) -- (13.4,6.44) -- (8.9,0) -- cycle    ;
%Straight Lines [id:da03628267423150655] 
\draw [line width=1.5]    (176.75,89) -- (229.25,89) ;
%Straight Lines [id:da6999074691962319] 
\draw [line width=1.5]    (244.14,112.75) -- (285.5,112.75) ;
%Straight Lines [id:da6267867712352968] 
\draw [line width=1.5]    (120.5,112.75) -- (161.86,112.75) ;
%Straight Lines [id:da4603867099439829] 
\draw [line width=1.5]    (244.14,160.25) -- (285.5,160.25) ;
%Straight Lines [id:da018369347304083128] 
\draw [line width=1.5]    (120.5,160.25) -- (161.86,160.25) ;
%Straight Lines [id:da7545009709936943] 
\draw [line width=1.5]    (176.75,184) -- (229.25,184) ;
%Straight Lines [id:da42526907269791137] 
\draw [line width=1.5]  [dash pattern={on 1.69pt off 2.76pt}]  (120.5,136.5) -- (346.5,136.5) ;

% Text Node
\draw (126,149.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\upharpoonleft }$};
% Text Node
\draw (249,149.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\upharpoonleft }$};
% Text Node
\draw (195,173.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\upharpoonleft }$};
% Text Node
\draw (130,149.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\downharpoonright }$};
% Text Node
\draw (253,149.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\downharpoonright }$};
% Text Node
\draw (200,173.4) node [anchor=north west][inner sep=0.75pt]  [font=\large]  {$\bm{\downharpoonright }$};
% Text Node
\draw (74,149) node [anchor=north west][inner sep=0.75pt]  [font=\large,rotate=-270] [align=left] {Energy};
% Text Node
\draw (288,103) node [anchor=north west][inner sep=0.75pt]  [font=\large] [align=left] {Antibonding};
% Text Node
\draw (288,150) node [anchor=north west][inner sep=0.75pt]  [font=\large] [align=left] {Bonding};
% Text Node
\draw (120,36) node [anchor=north west][inner sep=0.75pt]   [align=left] {\large benzene (6 atoms, 6 electrons)};


\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容