[Tex/LaTex] Periodic table with electron counts in shells

chemistrytikz-pgf

Expectations

I would like to make my own periodic table in LaTeX. It should (…)

  • have a space between the orbital groups (s, p, d, f)
  • every group should have rounded corners
  • the different "categories" (earth alkali metal and so on) should be colored

Each element should have this information

  • Atomic Weight
  • Atomic Number
  • Chemical Symbol
  • Chemical Name
  • Count of electrons in the orbitals

Here an image how I thought it should look like
Sketch of periodic table design

And here an image what I meant with electron counts in orbitals
Electron counts.

Source Code
I have tried something myself. I thought I could "borrow" some of the code from here. Some of the information in the link is wrong. So I thought of making a new code using a list of all need information. Sirius3 helped me in a German Python Forum:

\documentclass{article}
\usepackage{tikz}

\newcommand{\CommonElementTextFormat}[4]
{
 \begin{minipage}{2.2cm}
   \centering
     {\textbf{#1} \hfill #2}%
      \linebreak \linebreak
      {\textbf{#3}}%
      \linebreak \linebreak
      {{#4}}
 \end{minipage}
}

\newcommand{\NaturalElementTextFormat}[4]
{
 \CommonElementTextFormat{#1}{#2}{\LARGE {#3}}{#4}
}


\newread\linereader
\def\foreachline#1#2{\openin\linereader=#1\nextline#2}
\def\nextline#1{\read\linereader to \line\ifeof\linereader\closein\linereader\else\expandafter#1\line\end\expandafter\nextline\expandafter#1\fi}

\def\element#1 #2 #3 #4 #5\end{\node[name=#2, Element]{\NaturalElementTextFormat{#1}{#4}{#2}{#3}};}

\begin{document}
\section{Elemente}
\begin{tikzpicture}[font=\sffamily, scale=0.45, transform shape]

\tikzstyle{ElementFill} = [fill=yellow!15]
\tikzstyle{Element} = [draw=black, ElementFill,
   minimum width=2.75cm, minimum height=2.75cm, node distance=2.75cm]

\foreachline{elements.txt}\element
\end{tikzpicture}
\end{document}

And here is the elements.txt data:

AN      Symb    Name            AU              Notes
1       H       Hydrogen        1.008   3, 6
2       He      Helium          4.002602(2)     1, 2
3       Li      Lithium         6.94    3, 6
4       Be      Beryllium       9.0121831(5)
5       B       Boron   10.81   3, 6
6       C       Carbon  12.011  6
7       N       Nitrogen        14.007  6
8       O       Oxygen  15.999  6
9       F       Fluorine        18.998403163(6)
10      Ne      Neon    20.1797(6)      1, 3
11      Na      Sodium  22.98976928(2)    
12      Mg      Magnesium       24.305  6
13      Al      Aluminium       26.9815385(7)
14      Si      Silicon 28.085  6
15      P       Phosphorus      30.973761998(5)
16      S       Sulfur  32.06   6
17      Cl      Chlorine        35.45   3, 6
18      Ar      Argon   39.948(1)       1, 2
19      K       Potassium       39.0983(1)     
20      Ca      Calcium 40.078(4)      
21      Sc      Scandium        44.955908(5)
22      Ti      Titanium        47.867(1)
23      V       Vanadium        50.9415(1)
24      Cr      Chromium        51.9961(6)
25      Mn      Manganese       54.938044(3)
26      Fe      Iron    55.845(2)
27      Co      Cobalt  58.933194(4)
28      Ni      Nickel  58.6934(4)      2
29      Cu      Copper  63.546(3)       2
30      Zn      Zinc    65.38(2)        2
31      Ga      Gallium 69.723(1)
32      Ge      Germanium       72.630(8)
33      As      Arsenic 74.921595(6)
34      Se      Selenium        78.971(8)
35      Br      Bromine 79.904  6
36      Kr      Krypton 83.798(2)       1, 3
37      Rb      Rubidium        85.4678(3)      1
38      Sr      Strontium       87.62(1)        1, 2
39      Y       Yttrium 88.90584(2)
40      Zr      Zirconium       91.224(2)       1
41      Nb      Niobium 92.90637(2)
42      Mo      Molybdenum      95.95(1)        1
43      Tc      Technetium      97      4
44      Ru      Ruthenium       101.07(2)       1
45      Rh      Rhodium 102.90550(2)
46      Pd      Palladium       106.42(1)       1
47      Ag      Silver  107.8682(2)     1
48      Cd      Cadmium 112.414(4)      1
49      In      Indium  114.818(1)
50      Sn      Tin     118.710(7)      1
51      Sb      Antimony        121.760(1)      1
52      Te      Tellurium       127.60(3)       1
53      I       Iodine  126.90447(3)
54      Xe      Xenon   131.293(6)      1, 3
55      Cs      Caesium 132.90545196(6)
56      Ba      Barium  137.327(7)
57      La      Lanthanum       138.90547(7)    1
58      Ce      Cerium  140.116(1)      1
59      Pr      Praseodymium            140.90766(2)
60      Nd      Neodymium       144.242(3)      1
61      Pm      Promethium      145     5
62      Sm      Samarium        150.36(2)       1
63      Eu      Europium        151.964(1)      1
64      Gd      Gadolinium      157.25(3)       1
65      Tb      Terbium 158.92535(2)
66      Dy      Dysprosium      162.500(1)      1
67      Ho      Holmium 164.93033(2)
68      Er      Erbium  167.259(3)      1
69      Tm      Thulium 168.93422(2)
70      Yb      Ytterbium       173.054(5)      1
71      Lu      Lutetium        174.9668(1)     1
72      Hf      Hafnium 178.49(2)
73      Ta      Tantalum        180.94788(2)
74      W       Tungsten        183.84(1)
75      Re      Rhenium 186.207(1)
76      Os      Osmium  190.23(3)       1
77      Ir      Iridium 192.217(3)
78      Pt      Platinum        195.084(9)
79      Au      Gold    196.966569(5)
80      Hg      Mercury 200.592(3)
81      Tl      Thallium        204.38  6
82      Pb      Lead    207.2(1)        1, 2
83      Bi      Bismuth 208.98040(1)
84      Po      Polonium        209     4
85      At      Astatine        210     4
86      Rn      Radon   222     4
87      Fr      Francium        223     4
88      Ra      Radium  226     4
89      Ac      Actinium        227     4
90      Th      Thorium 232.0377(4)     1, 4
91      Pa      Protactinium    231.03588(2)    4
92      U       Uranium 238.02891(3)    1, 3, 4
93      Np      Neptunium       237     4
94      Pu      Plutonium       244     4
95      Am      Americium       243     4
96      Cm      Curium  247     4
97      Bk      Berkelium       247     4
98      Cf      Californium     251     4
99      Es      Einsteinium     252     4
100     Fm      Fermium 257     4
101     Md      Mendelevium     258     4
102     No      Nobelium        259     4
103     Lr      Lawrencium      262     4
104     Rf      Rutherfordium   267     4
105     Db      Dubnium 270     4
106     Sg      Seaborgium      271     4
107     Bh      Bohrium 270     4
108     Hs      Hassium 277     4
109     Mt      Meitnerium      276     4
110     Ds      Darmstadtium    281     4
111     Rg      Roentgenium     282     4
112     Cn      Copernicium     285     4
113     Uut     Ununtrium       285     4, 5
114     Fl      Flerovium       289     4, 5
115     Uup     Ununpentium     289     4, 5
116     Lv      Livermorium     293     4, 5
117     Uus     Ununseptium     294     4, 5
118     Uuo     Ununoctium      294     4, 5

Problems

  • Arranging all elements (all 118 elements are behind each other)
  • Make round corners for each group of orbitals
  • Give every group a color (Alkali Metal, Alkali Earth Metal …)
  • Writing the electron count from the Aufbau principle for each element
  • Writing the number of period/groups for each period/group

I know it is much, but it would be nice if you could help me a little further 🙂 … I am just stuck :/

Thank you very much in advance! Kind regards!

Best Answer

So far I got this

  • You need to delete the first line from your elements.txt.
  • Aufbau principle may fail. I did not handle it.
  • It is badly colored because the rules vary.
  • Please add labels yourself.
  • Some sequences are hard-coded such as 1/30,34/24,66/24,98/14,130/14 and 2,2,6,2,6,2,10,6,2,10,6,2,14,10,6,2,14,10,6,2. Perhaps they are encoded in a most efficient manner.

Code

\documentclass[tikz,border=9]{standalone}
\begin{document}

% Draw the Contour of Groups
\def\DrawGroup;{
    \draw[rounded corners=10pt,fill=red!10   ](15in,0)|-+(-1in,1in)|-+(1in,-6in)|-cycle;
    \draw[rounded corners=10pt,fill=yellow!50](17in,-2in)rectangle+(10in,-4in);
    \draw[rounded corners=10pt,fill=green!10 ](17in,-7in)rectangle+(14in,-2in);
    \draw[rounded corners=10pt,fill=blue!10  ](33in,-0in)-|+(-5in,-6in)-|+(1in,1in)-|cycle;
    \clip[rounded corners=10pt]               (15in,0)|-+(-1in,1in)|-+(1in,-6in)|-cycle
                                              (17in,-2in)rectangle+(10in,-4in)
                                              (17in,-7in)rectangle+(14in,-2in)
                                              (33in,-0in)-|+(-5in,-6in)-|+(1in,1in)-|cycle;
}

% Atomic Number \PNn => Coordinate (\PNx,\PNy)
\def\PositionByNumber;{
    \pgfmathtruncatemacro\PNn{\n}
    \foreach\PNa/\PNb in{1/30,34/24,66/24,98/14,130/14}{
        \ifnum\PNn>\PNa
            \pgfmathtruncatemacro\PNn{\PNn+\PNb}\xdef\PNn{\PNn}
        \fi
    }
}

% Coordinate (\PNx,\PNy) => Move and Group
\def\GroupByPosition;{
    \pgfmathtruncatemacro\PNx{mod(\PNn-.5,32)+.5}
    \pgfmathtruncatemacro\PNy{(\PNn-\PNx)/32}
    \ifnum\PNx>2\ifnum\PNx<17
        \pgfmathtruncatemacro\PNy{\PNy+3}
        \pgfmathtruncatemacro\PNx{\PNx+14}
    \fi\fi
    \ifnum\PNx<3
        \pgfmathtruncatemacro\PNx{\PNx+13}
    \fi
    \ifnum\PNx>26\ifnum\PNy<8
        \pgfmathtruncatemacro\PNx{\PNx+1}
    \fi\fi
    \pgftransformreset;\pgftransformxshift{\PNx in};\pgftransformyshift{-\PNy in};
}

% Atomic Number \APn => Electron Configuration \APe1 \APe2 \APe3 ...
\def\AufbauPrinciple;{
    \pgfmathtruncatemacro\APn{\n}
    \xdef\APi{0}
    \foreach\APa in{2,2,6,2,6,2,10,6,2,10,6,2,14,10,6,2,14,10,6,2}{
        \pgfmathtruncatemacro\APi{\APi+1}\xdef\APi{\APi}
        \ifnum\APn>\APa
            \expandafter\xdef\csname APe\APi\endcsname{$\bullet$}
            \pgfmathtruncatemacro\APn{\APn-\APa}\xdef\APn{\APn}
        \else\ifnum\APn>0
            \expandafter\xdef\csname APe\APi\endcsname{\APn}
            \pgfmathtruncatemacro\APn{\APn-\APn}\xdef\APn{\APn}
        \else
            \expandafter\xdef\csname APe\APi\endcsname{}
        \fi\fi
    }
}

% Print the Configuration 
\def\DrawConfiguration;{
    \xdef\DCi{0}
    \foreach\DCa/\DCb in{1/1,1/2,2/2,1/3,2/3,1/4,3/3,2/4,1/5,3/4,2/5,1/6,4/4,3/5,2/6,1/7,4/5,3/6,2/7,1/8}{
        \pgfmathtruncatemacro\DCi{\DCi+1}\xdef\DCi{\DCi}
        \path[scale=.2](\DCa,\DCb)node{\csname APe\DCi\endcsname};
    }
}

\newread\linereader
\def\foreachline#1#2{\openin\linereader=#1\nextline#2}
\def\nextline#1{\read\linereader to \line\ifeof\linereader\closein\linereader\else\expandafter#1\line\end\expandafter\nextline\expandafter#1\fi}
\def\element#1 #2 #3 #4 #5\end{
    \xdef\n{#1}
    \PositionByNumber;
    \GroupByPosition;
    \draw[black](0,0)rectangle(1in,1in)
        (0,1in)node[below right]{#1}(1in,1in)node[below left]{#4}(.5in,.5in)node{\Large #2}(.5in,.1in)node{#3};
    \AufbauPrinciple;
    \DrawConfiguration;
    \message{[\n]}
}

\scriptsize
\begin{tikzpicture}
    \DrawGroup;
    \foreachline{elements.txt}\element
\end{tikzpicture}
\end{document}