The context
I know how to display a cross inside a rectangle (see minimal working example and image below)
\documentclass[border = 2]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc, fit}
\tikzset{
mystyle1/.style = {
rectangle,
draw,
append after command={
node [
fit = (\tikzlastnode),
inner sep = -\pgflinewidth,
cross out,
draw = blue,
] {}
}
}
}
\begin{document}
\begin{tikzpicture}
\node [mystyle1] {a};
\end{tikzpicture}
\end{document}
I also know how to display a rectangle inside a rectangle (see minimal working example and image below)
\documentclass[border = 2]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc, fit}
\tikzset{
mystyle2/.style = {
rectangle,
draw,
append after command={
node [
fit = (\tikzlastnode),
inner sep = -\pgflinewidth,
draw = blue,
scale = 0.6
] {}
}
}
}
\begin{document}
\begin{tikzpicture}
\node [mystyle2] {a};
\end{tikzpicture}
\end{document}
The problem
I wanted to merge the two previously explained concepts, so that I can draw a node that contains both the cross and the small rectangle. For this reason, I wrote the following document (mystyle1
and mystyle2
are the same styles that were showed above)
\documentclass[border = 2]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc, fit}
\tikzset{
mystyle1/.style = {
rectangle,
draw,
append after command={
node [
fit = (\tikzlastnode),
inner sep = -\pgflinewidth,
cross out,
draw = blue,
] {}
}
},
mystyle2/.style = {
rectangle,
draw,
append after command={
node [
fit = (\tikzlastnode),
inner sep = -\pgflinewidth,
draw = blue,
scale = 0.6
] {}
}
}
}
\begin{document}
\begin{tikzpicture}
\node [mystyle1, mystyle2] {a};
\end{tikzpicture}
\end{document}
However, when compiling the document using pdflatex
from TeX Live 2020. I get the following error
! Package pgf Error: No shape named `' is known.
See the pgf package documentation for explanation.
Type H <return> for immediate help.
...
l.40 \node [mystyle1, mystyle2] {a};
?
The question
In a tikzpicture
environment, how can I draw a node that contains a cross and a smaller rectangle (similar to the ones showed in the images above)?