Why my Tikz can not show color in standalone document class ? But the color do show in article class.
Here is the code which I follow from Example: Rusting Iron
% Rusting Iron
% Author: Jason Waskiewicz
% A "jazzy" picture of the stages of rust (presented for a high school level).
% Iron is red, oxygen is blue and electrons are black. At the left you see
% iron atoms with two oxygen molecules, then the electrons go to the oxygen molecules
% leaving oxygen ions and iron ions which then disolve.
\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{standalone}
% Load all packages needed for all sub−files:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
>=stealth,
iron/.style={shade, ball color=red},
electron/.style={shade, ball color=green},
oxygen/.style={shade, ball color=blue},
droplet/.style={ball color=blue!20, opacity=0.4},
]
\begin{scope} % Energy levels
\draw (0,0) node[left] {$y=0$} --
++(10.8,0) ;%node[right] {$0,108$}
\draw (0,1.6) node[left] {$y=16$} --
++(10.8,0) ; %node[right] {$16,108$}
\end{scope}
\foreach \x in {0.200000, 0.500000, 0.800000, 1.100000, 2.900000, 3.200000, 3.500000, 3.800000, 5.600000, 5.900000, 6.200000, 6.500000, 8.300000, 8.600000, 8.900000, 9.200000}
\draw [iron] (\x,0,0) circle (0.2cm);
\foreach \x in {1.400000, 4.100000, 6.800000, 9.500000}
\draw [electron] (\x,0,0) circle (0.2cm);
\foreach \x in {1.700000, 2.000000, 2.300000, 2.600000, 4.400000, 4.700000, 5.000000, 5.300000, 7.100000, 7.400000, 7.700000, 8.000000, 9.800000, 10.100000, 10.400000, 10.700000}
\draw [oxygen] (\x,0,0) circle (0.2cm);
\end{tikzpicture}
\end{document}
The result is like this:
But if I change the class into standalone ,the code is below:
% Rusting Iron
% Author: Jason Waskiewicz
% A "jazzy" picture of the stages of rust (presented for a high school level).
% Iron is red, oxygen is blue and electrons are black. At the left you see
% iron atoms with two oxygen molecules, then the electrons go to the oxygen molecules
% leaving oxygen ions and iron ions which then disolve.
\documentclass{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
% Load all packages needed for all sub−files:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
>=stealth,
iron/.style={shade, ball color=red},
electron/.style={shade, ball color=green},
oxygen/.style={shade, ball color=blue},
droplet/.style={ball color=blue!20, opacity=0.4},
]
\begin{scope} % Energy levels
\draw (0,0) node[left] {$y=0$} --
++(10.8,0) ;%node[right] {$0,108$}
\draw (0,1.6) node[left] {$y=16$} --
++(10.8,0) ; %node[right] {$16,108$}
\end{scope}
\foreach \x in {0.200000, 0.500000, 0.800000, 1.100000, 2.900000, 3.200000, 3.500000, 3.800000, 5.600000, 5.900000, 6.200000, 6.500000, 8.300000, 8.600000, 8.900000, 9.200000}
\draw [iron] (\x,0,0) circle (0.2cm);
\foreach \x in {1.400000, 4.100000, 6.800000, 9.500000}
\draw [electron] (\x,0,0) circle (0.2cm);
\foreach \x in {1.700000, 2.000000, 2.300000, 2.600000, 4.400000, 4.700000, 5.000000, 5.300000, 7.100000, 7.400000, 7.700000, 8.000000, 9.800000, 10.100000, 10.400000, 10.700000}
\draw [oxygen] (\x,0,0) circle (0.2cm);
\end{tikzpicture}
\end{document}
the result is like this,without any color:
So how can I adjust this to show the color in standalone class?
Because I need to insert the picture as a standalone picture into my latex document for uploading pictures later.



XeLaTeXintoPDFLaTeX– sikisis Sep 22 '15 at 03:40standaloneand worked fine – Very23 Sep 22 '15 at 03:41XeLaTeXdefault forGummibut maybePDFLaTeXcan do better. – sikisis Sep 22 '15 at 03:43