书写电子构型的方框和箭头符号

书写电子构型的方框和箭头符号

图像 图片来源:https://opentextbc.ca/

我写出了像 1s 2 2s 2 2p 6这样的电子配置,但无法画出盒子和箭头符号。

$\mathrm{N} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{3} \quad$
$\mathrm{O} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{4} \quad$
$\mathrm{F} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{5} \quad$
$\mathrm{Ne} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{6} \quad$

我尝试过这样的\fbox{}方法\boxed{}

$\mathrm{N} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{3} \quad$ $\boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow} \boxed{\uparrow|\uparrow|\uparrow}$

$\mathrm{O} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{4} \quad$ $\boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow|\uparrow|\uparrow}$

$\mathrm{F} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{5} \quad$ $\boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow|\uparrow \downarrow|\uparrow}$

$\mathrm{Ne} \quad 1 s^{2} 2 \mathrm{~s}^{2} 2 p^{6} \quad$ $\boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow} \boxed{\uparrow \downarrow|\uparrow \downarrow|\uparrow \downarrow}$

答案1

我在一个单独的样式文件中收集了一些命令定义electrons.sty,如下所示。它本质上使用\upharpoonleft、、\downharpoonrightes\fbox和循环来迭代 shell 规范。

然后你可以通过以下方式实现你想要的

\documentclass{article}
\usepackage{array}% only needed for injecting commands at the beginning of columns in the tabular below
\usepackage{electrons}
\begin{document}
\sffamily
\begin{tabular}{l>{\TextShells}l>{\BoxedShells}l}
  N  & \subshells{{1s:2}{2s:2}{2p:111}} & \subshells{{1s:2}{2s:2}{2p:111}} \\
  O  & \subshells{{1s:2}{2s:2}{2p:211}} & \subshells{{1s:2}{2s:2}{2p:211}} \\
  F  & \subshells{{1s:2}{2s:2}{2p:221}} & \subshells{{1s:2}{2s:2}{2p:221}} \\
  Ne & \subshells{{1s:2}{2s:2}{2p:222}} & \subshells{{1s:2}{2s:2}{2p:222}} \\
\end{tabular}
\end{document}

在此处输入图片描述

封装电子:将以下代码复制到文件中electrons.sty。有关文档,请参阅下文。

\RequirePackage{amssymb}

\newcommand\spinup{$\upharpoonleft$}
\newcommand\spindown{$\downharpoonright$}

% Looping over a list of tokens with separator
% \electronLoop{processor}{separator}{list}
\newcommand\electronLoop[3]{%
  \bgroup
  \def\electronLoopProcessor{#1}%
  \def\electronLoopSeparator{\def\electronLoopSeparator{#2}}%
  \electronLoopDo#3\relax
  \egroup
}
\newcommand\electronLoopDo[1]{%
  \ifx\relax#1\else
    \electronLoopSeparator
    \electronLoopProcessor{#1}%
    \expandafter
    \electronLoopDo
  \fi
}

% \orbital{#electrons: 0,1,2}
\newcommand\orbital[1]{%
  \fbox{%
    \ifcase#1
      \phantom\spinup\!\phantom\spindown
    \or
      \spinup\!\phantom\spindown
    \or
      \spinup\!\spindown
    \else
      \bfseries**\strut
    \fi
  }%
}

% \orbitals{list of #electrons}
\newcommand\orbitals[1]{\electronLoop\orbital{\hspace{-\fboxrule}}{#1}}

% \subshell{name:list of #electrons}
\newcommand\subshell[1]{%
  \subshellX#1\endOfShell
}
\newcommand\subshellX{}
\def\subshellX#1:#2\endOfShell{\doSubShell{#1}{#2}}

\newcommand\subshellBox[2]{%
  \begin{tabular}[t]{@{}c@{}}
    \orbitals{#2}\\[-2pt]
    \scriptsize#1%
  \end{tabular}%
}

\newcounter{electrons}
\newcommand\subshellText[2]{%
  \setcounter{electrons}{0}%
  \electronLoop{\addtocounter{electrons}}{}{#2}%
  #1$^\arabic{electrons}$%
}

% \subshells{list of shells}
\newcommand\subshells[1]{\electronLoop\subshell\SubShellSep{#1}}

\newcommand\BoxedShells{%
  \def\SubShellSep{ }%
  \let\doSubShell\subshellBox
}

\newcommand\TextShells{%
  \def\SubShellSep{}%
  \let\doSubShell\subshellText
}

\BoxedShells

在此处输入图片描述

\documentclass{article}
\usepackage{electrons}
\parindent0pt
\begin{document}

\title{The package \texttt{electrons}}
\author{gernot}
\date{2021}
\maketitle

\paragraph{Spins:} \verb"\spinup" gives \spinup, \verb"\spindown" gives
\spindown.

\paragraph{Single orbitals:}
\verb"\orbital{0} \orbital{1} \orbital{2}" gives \orbital{0}
\orbital{1} \orbital{2}.

\paragraph{Multiple orbitals:} \verb"\orbitals{012}" gives \orbitals{012}.

\bigskip
\verb"\BoxedShells" (the default) represents shells as boxes.

\paragraph{Subshell:} \verb"\subshell{2p:221}" gives \subshell{2p:221}.

\paragraph{Multiple subshells:}
\verb"\subshells{{1s:2}{2s:2}{2p:221}}" gives \subshells{{1s:2}{2s:2}{2p:221}}.

\bigskip
\verb"\TextShells" represents shells as text.
\TextShells

\paragraph{Subshell:} Now \verb"\subshell{2p:221}" results in \subshell{2p:221}.

\paragraph{Multiple subshells:} Now
\verb"\subshells{{1s:2}{2s:2}{2p:221}}" results in
\subshells{{1s:2}{2s:2}{2p:221}}.

\end{document}

答案2

一个可能的解决方案:使用包绘制盒子tikz

\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}                                            
\usetikzlibrary{chains,
                positioning,
                shapes.multipart}
\tikzset{chem/.style = {%
     baseline = -1ex,
node distance = 1em,
  start chain = going right,
M/.style = {draw, on chain},
N/.style = {rectangle split, rectangle split parts=3, rectangle split horizontal,
            draw, on chain}
        }}

\usepackage[version=4]{mhchem}
\usepackage{array}

\begin{document}                                         
    \begin{table}                         
\begin{tabular}{l >{$}l<{$} c}
\ce{N}  &   1 s^{2} 2s^{2} 2p^{3}   
            &   \tikz[chem]{%
            \node[M,label=below:1s] {$\upharpoonleft\downharpoonright$};
            \node[M,label=below:2s] {$\upharpoonleft\downharpoonright$};
            \node[N,label=below:2p] {\nodepart{one}~$\upharpoonleft$~
                                     \nodepart{two}~$\upharpoonleft$~
                                     \nodepart{three}~$\upharpoonleft$~};}
            \\[5ex]
\ce{O}  &   1 s^{2} 2s^{2} 2p^{4}   
            &   \tikz[chem]{%
            \node[M,label=below:1s] {$\upharpoonleft\downharpoonright$};
            \node[M,label=below:2s] {$\upharpoonleft\downharpoonright$};
            \node[N,label=below:2p] {\nodepart{one}$\upharpoonleft\downharpoonright$
                                     \nodepart{two}~$\upharpoonleft$~
                                     \nodepart{three}~$\upharpoonleft$~};}
            \\[5ex]
\ce{F}  &   1 s^{2} 2s^{2} 2p^{5}
            &   \tikz[chem]{%
            \node[M,label=below:1s] {$\upharpoonleft\downharpoonright$};
            \node[M,label=below:2s] {$\upharpoonleft\downharpoonright$};
            \node[N,label=below:2p] {\nodepart{one}$\upharpoonleft\downharpoonright$
                                     \nodepart{two}$\upharpoonleft\downharpoonright$
                                     \nodepart{three}~$\upharpoonleft$~};}
            \\[5ex]
\ce{Ne} &   1 s^{2} 2s^{2} 2p^{6}
            &   \tikz[chem]{%
            \node[M,label=below:1s] {$\upharpoonleft\downharpoonright$};
            \node[M,label=below:2s] {$\upharpoonleft\downharpoonright$};
            \node[N,label=below:2p] {\nodepart{one}$\upharpoonleft\downharpoonright$
                         \nodepart{two}$\upharpoonleft\downharpoonright$
                         \nodepart{three}$\upharpoonleft\downharpoonright$};}
\end{tabular}
    \end{table}
\end{document}

在此处输入图片描述

相关内容