带小盒子的原子电子配置

带小盒子的原子电子配置

我需要为原子的电子分布(轨道 S、P、D、F)创建一个新命令,类似于下面链接中显示的命令,但电子对周围有方框。有人能帮我吗?

电子配置图

答案1

我改编了附件链接中的解决方案,绘制了一个\fbox而不是\underline。此外,我还必须添加\mathord以使\fbox定义中的 -es 具有相同的宽度。(虽然我不确定我是否做对了)

\documentclass[border=2mm]{standalone}
\usepackage{amssymb} % for harpoons
\newcommand{\electron}[2]{{%
        \newcommand*\up{\fbox{$\mathord\upharpoonleft\phantom{\downharpoonright}$}}%
        \newcommand*\dwn{\fbox{$\mathord\downharpoonleft\phantom{\upharpoonright}$}}%
        \newcommand*\updwn{\fbox{$\upharpoonleft\downharpoonright$}}%
        \newcommand*\emp{\fbox{$\phantom{\downharpoonright}\phantom{\downharpoonright}$}}%
        \setlength\tabcolsep{0pt}% remove extra horizontal space from tabular
        \begin{tabular}{c}#2\\[2pt]#1\end{tabular}%
}}
\begin{document}
    \electron{2s}{\updwn}\quad \electron{2p}{\up\ \dwn\ \emp}
\end{document}

盒装

命令:

  • \up:仅向上自旋电子
  • \dwn:仅向下自旋电子
  • \updwn:上自旋电子和下自旋电子(已填充)
  • \emp:无电子(未填充)

编辑:

更新了代码,使框彼此连接,线宽相等。用法仍然与上面相同。现在线条更粗了,因为 fbox-es 正在绘制。如果您想保留旧的fbox线宽,请取消注释该\setlength\fboxrule{0.2pt}行。

\documentclass[border=2mm]{standalone}
\usepackage{amssymb} % for harpoons
\newcommand*\up{\fbox{$\mathord\upharpoonleft\phantom{\downharpoonright}$}}%
\newcommand*\dwn{\fbox{$\mathord\downharpoonleft\phantom{\upharpoonright}$}}%
\newcommand*\updwn{\fbox{$\upharpoonleft\downharpoonright$}}%
\newcommand*\emp{\fbox{$\phantom{\downharpoonright}\phantom{\downharpoonright}$}}%
\newcommand{\electron}[2]{{%
        \setlength\tabcolsep{0pt}% remove extra horizontal space from tabular
%       \setlength\fboxrule{0.2pt}% uncomment for original line width
        \begin{tabular}{c}
            \fboxsep=0pt\fbox{\fboxsep=3pt#2}\\[2pt]
            #1
        \end{tabular}%
}}
\begin{document}
    \electron{2s}{\updwn}\quad \electron{2p}{\up\dwn\emp}
\end{document}

更新框

答案2

为什么要重新发明轮子?使用modiagram

\documentclass{article}
\usepackage{modiagram}
\begin{document}

\begin{MOdiagram}[style=square]
  \AO{s}[label={2s}]{0}
  \AO(30pt){p}[label[y]={2p}]{0;up,up,up}
\end{MOdiagram}

\end{document}

在此处输入图片描述

或无style=square

在此处输入图片描述

答案3

以下是我的答案的改编,以适应两种样式(方框或下划线):

\documentclass{article}
\usepackage{amssymb}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\electron}{smm}
 { % #2 = level, #3 = electron schemes
  \IfBooleanTF{#1}
   { \jm_electron:Nnn \underline { #2 } { #3 } }
   { \jm_electron:Nnn \fbox { #2 } { #3 } }
 }

\seq_new:N \l_jm_electron_schemes_seq
\seq_new:N \l__jm_electron_schemes_print_seq

\cs_new_protected:Nn \jm_electron:Nnn
 {
  \cs_set_eq:NN \__jm_electron_highlight:n #1
  \seq_clear:N \l__jm_electron_schemes_print_seq
  \seq_set_split:Nnn \l_jm_electron_schemes_seq { | } { #3 }
  \seq_map_function:NN \l_jm_electron_schemes_seq \__jm_electron_do_scheme:n
  % print the schemes
  \group_begin:
  \setlength{\tabcolsep}{.2em}
  \begin{tabular}{ * { \seq_count:N \l_jm_electron_schemes_seq } { c } }
  \seq_use:Nn \l__jm_electron_schemes_print_seq { & } \\
  \multicolumn { \seq_count:N \l_jm_electron_schemes_seq } { c } { #2 }
  \end{tabular}
  \group_end:
 }

\cs_new_protected:Nn \__jm_electron_do_scheme:n
 {
  \seq_put_right:Nn \l__jm_electron_schemes_print_seq
   {
    \__jm_electron_highlight:n
     {
      \clist_map_inline:nn { #1 }
       {
        \int_case:nn { ##1 }
         {
          {1}{$\scriptstyle\upharpoonleft$}
          {0}{\phantom{$\scriptstyle\upharpoonleft$}}
          {-1}{$\scriptstyle\downharpoonright$}
         }
       }
     }
   }
 }
\ExplSyntaxOff

\begin{document}

\electron{2s}{1,-1}\quad\electron{2p}{1,0 | 1,0 | 1,0}

\electron*{2s}{1,-1}\quad\electron*{2p}{1,0 | 1,0 | 1,0}

\end{document}

在此处输入图片描述

相关内容