[Tex/LaTex] Painting an ellipse that fits a row of node but is not narrow and long

fittikz-pgf

I want to draw a Tikz diagram, in which an ellipse contains a row of smaller ellipses. I tried doing so using the fitting library:

\begin{tikzpicture}[
  every node/.style={inner sep=1pt},
  proc/.style={shape=ellipse, draw}
]
\path node[proc] (q) {q} -- ++(2cm,0) 
      node[proc] (p1) {p$_1$} -- ++(1.5cm,0)
      node (d) {\ldots} -- ++(1.5cm,0)
      node[proc] (pn) {p$_n$};
\node[fit=(q)(p1)(d)(pn), proc] {};
\end{tikzpicture}

The result is a long and narrow ellipse:

bad ellipse

I would prefer the surrounding ellipse to be shorter and taller, i.e., end closer to the q and pn nodes, and also have slightly more height. What is the right configuration for this?

Best Answer

My original answer is below the line. Here's a slightly improved version, which uses two "strategically-placed" pegs to distort the ellipse. I think this approach will need less manual fine tuning (of envel/inner sep and peg/node distance).

\begin{tikzpicture}[
  every node/.style={inner sep=1pt},
  proc/.style={shape=ellipse, draw},
  peg/.style={draw=none,color=black!0,node distance=1cm},
  envel/.style={shape=ellipse, draw, inner sep=-0.5cm}
]
\path node[proc] (q) {q} -- ++(2cm,0) 
      node[proc] (p1) {p$_1$} -- ++(1.5cm,0)
      node (d) {\ldots} -- ++(1.5cm,0)
      node[proc] (pn) {p$_n$};
\node  [peg,above of=p1] (c1) {+}; 
\node  [peg,below of=d] (c2) {+};
\node[fit=(q)(p1)(d)(pn)(c1)(c2), envel] {};
\end{tikzpicture}

Here's a slightly exaggerated answer. I suggest you play with the envel construction's inner sep and minimum height parameters to find what suits you best.

\begin{tikzpicture}[
  every node/.style={inner sep=1pt},
  proc/.style={shape=ellipse, draw},
  envel/.style={shape=ellipse, draw, inner sep=-0.5cm, minimum height=4.5cm}
]
\path node[proc] (q) {q} -- ++(2cm,0) 
      node[proc] (p1) {p$_1$} -- ++(1.5cm,0)
      node (d) {\ldots} -- ++(1.5cm,0)
      node[proc] (pn) {p$_n$};
\node[fit=(q)(p1)(d)(pn), envel] {};
\end{tikzpicture}