I am trying to create a diagram that looks roughly like this picture:

Except that I want it to have rounded corners. It seems that the obvious way to do this would be to use tikz, so I have made an attempt at this:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{braket}
\usetikzlibrary{matrix,fit}
\begin{document}
\newcommand{\objboxthreer}[7]{
\begin{tikzpicture}
\matrix (m) [nodes={inner sep=2pt},matrix of nodes, nodes in empty cells,ampersand replacement=\&, row sep=0pt, column sep=0pt]
{
{#1} \& \& {#2} \& {#4} \& {#6} \& \\
\& \& {#3} \& {#5} \& {#7} \& \\
};
\node [
draw,
rounded corners=.5em,
inner sep=0pt,
outer sep=0pt,
minimum size=0pt,
fit=(m-1-2.north east)
(m-1-2.south east)
(m-1-3.north east)
(m-1-3.south east)
(m-1-4.north east)
(m-1-4.south east)
(m-1-5.north east)
(m-1-5.south east)
(m-1-6.north west)
(m-1-6.south west)] {};
%\draw [rounded corners=.5em] (m-1-2.south east) rectangle (m-3-6.north west);
\draw (m-1-3.north east) -- (m-1-3.south east);
\draw (m-1-4.north east) -- (m-1-4.south east);
\end{tikzpicture}
}
\objboxthreer{d}{$p_s$}{$Y_d$}{$p_d$}{$Y_d'$}{$\{p\}$}{$\Set{ x \in X | x > 5}$}
\end{document}
Which produces the rather unsatisfactory result:

The vertical lines don't reach the top or the bottom of the enclosing box.
The challenge is that the contents of all of the cells of this table are very dynamic in size. Both the height and the width of each element may change significantly (complex formulas, etc), so I cannot simply specify the height and width of each row and column. How can I emulate the first table but with rounded corners?
Here is an additional testcase that has taller elements: \documentclass{standalone} \usepackage{tikz} \usepackage{braket} \usetikzlibrary{matrix,fit}
\begin{document}
\newcommand{\objboxthreer}[7]{
\begin{tikzpicture}
\matrix (m) [nodes={inner sep=2pt},matrix of nodes, nodes in empty cells,ampersand replacement=\&, row sep=0pt, column sep=0pt]
{
{#1} \& \& {#2} \& {#4} \& {#6} \& \\
\& \& {#3} \& {#5} \& {#7} \& \\
};
\node [
draw,
rounded corners=.5em,
inner sep=0pt,
outer sep=0pt,
minimum size=0pt,
fit=(m-1-2.north east)
(m-1-2.south east)
(m-1-3.north east)
(m-1-3.south east)
(m-1-4.north east)
(m-1-4.south east)
(m-1-5.north east)
(m-1-5.south east)
(m-1-6.north west)
(m-1-6.south west)] {};
%\draw [rounded corners=.5em] (m-1-2.south east) rectangle (m-3-6.north west);
\draw (m-1-3.north east) -- (m-1-3.south east);
\draw (m-1-4.north east) -- (m-1-4.south east);
\end{tikzpicture}
}
\objboxthreer{d}{$p_s$}{$Y_d$}{$\left\{\frac{p}{q}\right\}$}{$Y_d'$}{$\{p\}$}{$\Set{ x \in X | x > 5}$}
\end{document}
The output of this has similar problems but cannot be solved by using \strut:



\{p\}, such as\left\{ \frac{p}{q} \right\}. I am hoping for some method that will grow all heights to the tallest height. – Arlen Cox May 21 '13 at 06:23\MyStrutallnon empty cellswill have same height and you can save some typing withfit=(m-1-2.east|-m-1-3.north) (m-1-6.west|-m-1-3.south)instead of enumerating all corners. – Ignasi May 21 '13 at 07:29\vphantom. That's actually fairly elegant. @Ignasi: I think you're right and, in fact, I was looking for how to specify coordinates like that. Thanks! – Arlen Cox May 21 '13 at 14:25