I want to place two tikz pictures next to each other, both of them should be figures I can reference to. Please consider the following MWE:
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
\draw [fill=black] (0,0) rectangle (1,1);
\end{tikzpicture}
\captionof{figure}{a square}
\label{fig:square}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
\draw [fill=black] (0,0) rectangle (1,3);
\end{tikzpicture}
\captionof{figure}{a rectangle}
\label{fig:rect}
\end{minipage}%
\end{figure}
Figures \ref{fig:square} and \ref{fig:rect} demonstrate the difference
between a square and a rectangle.
\end{document}
which looks like
I need both pictures to be aligned at the top, but the captions to be on the same height as well:
Can you please tell me how those alignments can be realized without loosing the ability to reference the single pictures?