You can use \node also
, which is described on p. 250 of the pgfmanual, for that.
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,10}
{
\node at (\i,0) [rectangle,label={above:$ \i $}] (v\i) {$i$};
}
\foreach \i in {3,6,8}{
\node also [label={[fill=white]above:$ \varnothing $}] (v\i);
}
\end{tikzpicture}
\end{document}
BIG THANKS TO MAX for the edit.
Just in case you ever have wider labels: give the labels names and use their width for Max' fill=white
trick.
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,2,...,10}
{
\node at (\i,0) [rectangle,label={[name=lab\i]above:$\i\i$}] (v\i) {$i$};
}
\foreach \i in {3,6,10}{
\path let \p1=($(lab\i.north east)-(lab\i.south west)$) in node also
[label={[fill=white,minimum width=\x1,minimum height=\y1]above:$ \varnothing $}] (v\i);
}
\end{tikzpicture}
\end{document}
ADDENDUM: Just for curiosity I was wondering if there is a simple way to make Max' nice answer work with lists. I am sure there is and leave it to others to use some xparse
or other magic. Here I just want to report an irony of fate. If one goes for the built-in LaTeX check whether or not something is an element of a list, then my naive attempt fails for two digits, precisely where the simplest version of the above also starts to go wrong. Rather funny and ironic, I'd say. ;-)
\documentclass[tikz]{standalone}
\makeatletter
% https://tex.stackexchange.com/a/260921/121799 and https://tex.stackexchange.com/a/287094/121799
\newcommand\ifmember[2]{%
\in@{#1}{#2}%
\ifin@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
\usepackage{amssymb}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,10}
{
\edef\temp{\noexpand\ifmember{\i}{3,6,9}{\varnothing}{\i}}
\node at (\i,0) [rectangle,label=above:$\temp$] (v\i) {$ i $};
}
\end{tikzpicture}
\end{document}