I've defined the following command that just draws four colored rectangles with some text inside them:
\newcommand{\fourcards}[4]{
\begin{figure}
\centering
\begin{tabular}{cccc}
\centering
\tikz \draw[fill=green!50] (0,0) rectangle (1,1) node[pos=.5] {#1}; &
\tikz \draw[fill=magenta] (0, 0) rectangle(1, 1) node[pos=.5]{#2}; &
\tikz \draw[fill=orange] (0, 0) rectangle(1, 1) node[pos=.5]{#3}; &
\tikz \draw[fill=yellow] (0, 0) rectangle(1, 1) node[pos=.5]{#4};
\end{tabular}
\end{figure}
}
I was wondering if there was some way to change the dimensions of the rectangles dynamically, such that they accommodate the text inside them. I have found this thread discussing something similar, but the OP there requires that the rectangle follows constraints imposed outside the rectangle: I want the rectangle to adjust itself to constraints inside it.
tabular
for this