I am making a diagram of particles. Each circle at each TikZ node corresponds to a particle. For each particle, there should be the name of the particle (e.g. u) and some of its properties (e.g. charge). I would like the name of the particle to be at the center of its node and to be one font size and its characters to be below the name of the particle and to be at a smaller font size.
When I attempt to change the font size (using \scriptsize
), the font size appears not to change. When I attempt to use a center
environment in the text of nodes that have been set to left-aligned, there is an error.
So, what would be an appropriate way to format text for the nodes? How can multiple alignments and font sizes be used in node text?
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usepackage{siunitx}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{figure}[htbp]
\centering
\tikzstyle{particleblue}=[
circle,
thick,
minimum size=1.5cm,
draw=black,
fill=blue!20
]
\tikzstyle{particlegreen}=[
circle,
thick,
minimum size=1.2cm,
draw=black,
fill=green!20
]
\tikzstyle{particlered}=[
circle,
thick,
minimum size=1.2cm,
draw=black,
fill=red!20
]
\tikzstyle{particleyellow}=[
circle,
thick,
minimum size=1.2cm,
draw=black,
fill=yellow!40
]
\tikzstyle{backgroundblue}=[
rectangle,
fill=blue!10,
inner sep=0.2cm,
rounded corners=5mm
]
\tikzstyle{backgroundgreen}=[
rectangle,
fill=green!10,
inner sep=0.2cm,
rounded corners=5mm
]
\tikzstyle{backgroundred}=[
rectangle,
fill=red!10,
inner sep=0.2cm,
rounded corners=5mm
]
\tikzstyle{backgroundyellow}=[
rectangle,
fill=yellow!40,
inner sep=0.2cm,
rounded corners=5mm
]
\begin{tikzpicture}[>=latex,text depth=0.00ex]
% elements in a matrix
\matrix[row sep=0.5cm,column sep=0.5cm, nodes={align=left}]{
\node (u) [particleblue ]{\begin{center}${\mathbf{u}}$\end{center}\scriptsize\\\\mass: ${2.3}$\,\si{MeV/c^{2}}\\charge: ${2/3}$\\spin: ${1/2}$};&
\node (c) [particleblue ]{${\mathbf{c}}$}; &
\node (t) [particleblue ]{${\mathbf{t}}$}; &
\node (g) [particlered ]{${\mathbf{g}}$}; &
\node (H) [particlegreen ]{${\mathbf{H}}$}; &
\\
\node (d) [particleblue ]{${\mathbf{d}}$}; &
\node (s) [particleblue ]{${\mathbf{s}}$}; &
\node (b) [particleblue ]{${\mathbf{b}}$}; &
\node (gamma) [particlered ]{${\mathbf{\gamma}}$}; &
\\
\node (e) [particleyellow ]{${\mathbf{e}}$}; &
\node (mu) [particleyellow ]{${\mathbf{\mu}}$}; &
\node (tau) [particleyellow ]{${\mathbf{\tau}}$}; &
\node (Z) [particlered ]{${\mathbf{Z}}$}; &
\\
\node (nu_e) [particleyellow ]{${\mathbf{\nu_{e}}}$}; &
\node (nu_mu) [particleyellow ]{${\mathbf{\nu_{\mu}}}$}; &
\node (nu_tau) [particleyellow ]{${\mathbf{\nu_{\tau}}}$}; &
\node (W) [particlered ]{${\mathbf{W}}$}; &
\\
};
% background rectanges
\begin{pgfonlayer}{background}
\node [
backgroundblue,
fit=(u) (b)
]{};
\node [
backgroundyellow,
fit=(e) (nu_tau)
]{};
\node [
backgroundred,
fit=(g) (W)
]{};
\node [
backgroundgreen,
fit=(H)
]{};
\end{pgfonlayer}
\end{tikzpicture}
\end{figure}
\end{document}