4

Can you suggest an easy way to draw these atoms?

enter image description here

enter image description here

\documentclass{standalone}
\usepackage{tikz,graphicx}
\usetikzlibrary{shadings}
\usetikzlibrary{decorations.markings}
\definecolor{myyellow}{RGB}{254,241,24}
\definecolor{myorange}{RGB}{234,125,1}
\begin{document}

\begin{tikzpicture}
\def\proton(#1,#2){%
    \fill[shade=ball,ball color=myyellow] (#1,#2) circle (10pt);
    \node at (#1,#2) {\texttt{+}};
}
\def\neutron(#1,#2){%
    \fill[shade=ball,ball color=myorange] (#1,#2) circle (10pt);
}
\def\electron{%
    \fill[shade=ball,ball color=gray!30] (0,0) circle (5pt);
    \node at (0,0) {\texttt{-}};
}
\def\sorbit(#1,#2){%
  \draw[
  color=violet,
  rotate=#1,
  postaction=decorate,
  decoration={markings,
  mark=at position #2 with {\electron},
}]
  (0,0) ellipse (1.5 and 3.5);
}
\def\porbit(#1,#2){%
  \draw[
  color=violet,
  rotate=#1,
  postaction=decorate,
  decoration={markings,
  mark=at position #2 with {\electron},
}]
  (0,0) ellipse (4 and 6);
}
%%Nucleons
\neutron(0.8,0.2)
\proton(0.5,-0.5)
\neutron(-0.25,-0.5)
\neutron(0.55,0.8)
\proton(-0.5,0.2)
\proton(-0.1,0.8)
\proton(0.5,0)
\proton(0.12,0.6)
\proton(0.12,-0.6)
\neutron(-0.25,0)
\neutron(-0.5,0.6)
\neutron(0.5,-0.3)
%%orbits
\porbit(-20,.15)
\porbit(15,.45)
\sorbit(40,.9)
\porbit(65,.6)
\sorbit(100,.3)
\porbit(125,.75)

\end{tikzpicture}

\end{document}
5
  • 1
    Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Jan 5, 2016 at 15:21
  • If someone has drown a similar athom I can try to change the code.
    – ryuk
    Jan 5, 2016 at 15:23
  • take a look at this answer tex.stackexchange.com/a/281814/23166 for drawing atoms and lines ;)
    – Davide
    Jan 5, 2016 at 15:23
  • yes. But when I compile there is an error :(
    – ryuk
    Jan 5, 2016 at 15:48
  • This is clearly a duplicate of the question linked to in Chris's answer. If your question is about a particular problem you have with the code there, then rework your question to be much more focused on the code itself.
    – Alan Munn
    Jan 5, 2016 at 15:48

1 Answer 1

4

The answers to Draw Bohr atomic model with electron shells in TeX? have some examples that could serve as a starting point. The code of some examples there will not compile out of the box on recent TeX distributions. You have to replace shade=ball with shading=ball on several lines. I guess this is because the TikZ syntax changed over time.

4
  • there is this error ! Package pgfkeys Error: Choice 'ball' unknown in choice key '/tikz/shade'. I a m going to ignore this key. See the pgfkeys package documentation for explanation. Type H <return> for immediate help. I have updated the packages with ubuntu
    – ryuk
    Jan 5, 2016 at 15:30
  • 1
    Try adding \usetikzlibrary{shadings} after the first \usetikzlibrary.
    – Chris
    Jan 5, 2016 at 15:41
  • there is an error :( i post the code.
    – ryuk
    Jan 5, 2016 at 15:44
  • 1
    Replace shade=ball with shading=ball in the orginal code. \usetikzlibrary{shadings} should not be needed.
    – Chris
    Jan 5, 2016 at 15:49

Not the answer you're looking for? Browse other questions tagged .