3

image image source: https://opentextbc.ca/

I write the electron configurations like 1s2 2s2 2p6, but not able to draw the box and arrow notations.

$\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$

I tried something like this using \fbox{} or \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}$

2 Answers2

8

I have collected a few command definitions in a separate style file electrons.sty, see below. It essentially uses \upharpoonleft, \downharpoonright, \fboxes, and loops to iterate over shell specifications.

Then you can achieve what you want by

\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}

enter image description here

Package electrons: Copy the following code into a file electrons.sty. For the documentation see below.

\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

enter image description here

\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}

gernot
  • 49,614
2

A possible solution: boxes are drawn by use of the tikz package:

\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}

enter image description here

Bernard
  • 271,350
Zarko
  • 296,517