I have made two figures using TikZ that I would like to place side by side. This is done in this MWE:
\documentclass{memoir}
\usepackage{graphicx}
\usepackage{tikz}
\newsubfloat{figure}
\begin{document}
\begin{figure}[htbp]
\centering
\subbottom[Convex set]{
\begin{tikzpicture}
\draw[rotate=-45,fill=gray!30] (0,0) ellipse (30pt and 45pt);
\end{tikzpicture}
}
\hspace{1cm}
\subbottom[Non-convex set]{
\begin{tikzpicture}
\draw[fill=gray!30] (0,0) to [out=140,in=90] (-1,-1)
to [out=-90,in=240] (0.8,-0.6)
to [out=60,in=-60] (1.2,1.2)
to [out=120,in=90] (0.3,0.7)
to [out=-90,in=20] (0.3,0)
to [out=200,in=-40] (0,0);
\draw (-0.5,-0.5) -- (0.7,0.7);
\fill (-0.5,-0.5) circle[radius=1.5pt];
\fill (0.7,0.7) circle[radius=1.5pt];
\end{tikzpicture}
}
\caption{Graphical interpretation of convex sets.}
\label{fig:convexSet}
\end{figure}
\end{document}
The problem is that neither the top, center, or bottom of the subfigures are aligned. How is this resolved? And what causes this misalignment? A faulty use of the TikZ coordinate system?
\begin{tikzpicture}[baseline,remember picture]
for both tikzpictureshelp lines
helps (pun intended), as you give both pictures dimensions from(-2,-2)
to(2,2)
. If you don't want them, an easy solution can be to add\path (-2,-2) grid (2,2);
to both pictures. But there's bound to be a more elegant way, I believe.