I wish to draw a picture like this with an arbitrary shape around a few points with arrows between them. I am using the circle command in tikzpicture but the result is very different. Could someone guide me? enter image description here

  • 2
    Welcome to TeX.SX. When you post a question, please provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output.
    – Sandy G
    Apr 9 at 19:56

1 Answer 1


This is a job for ... tikzmark!

enter image description here

Basic idea: make your tikzcd as usual. But place a tikzmark in the middle. I placed one on an invisible (phantom) arrow from a to f and called it middleL.

Then leave some space and make your tikzpicture as usual. But place a tikzmark in the middle. I put one at (0,0) and called it middleR.

Then start a new tikzpicture using \begin{tikzpicture}[remember picture, overlay]. Draw big puffy cloud nodes (using shapes.symbols) and place them at coordinates using the syntax (pic cs:middleL) and (pic cs:middleR) (which is how to refer to previous tikzmarks). Then just treat them like ordinary nodes—label them and \draw an arrow between them with bend left.

Note: You must compile twice when using tikzmark.

Here is the code:


\tikzset{elnode/.style={draw, ellipse, dotted, minimum height=1cm, label distance=-2mm},
    cloudnode/.style={draw, dashed, black!80, inner sep=1.75cm, cloud, cloud puffs=20, cloud puff arc=120}}


\begin{tikzcd}[arrows={-latex, outer sep=-1.5pt},row sep=1cm, column sep=2cm]
 & b\arrow[dd,bend left=20,"f"{name=F}]\\
a\arrow[ur,bend left,"g_1"]\arrow[ur,"g_2"]\arrow[ur,bend right,"g_3"]
    \arrow[dr,bend left=20,"h_1"']\arrow[dr,bend right=20,"h_2"'] 
    \arrow[to=F,phantom,"{}\tikzmark{middleL}"] \\
 & c
\node[elnode,label={above:$C(a,b)$}] at(0,1){$g_1\quad g_2\quad g_3$};
\node[elnode,label={below:$C(a,c)$}] at (0,-1){$h_1\quad h_2$};
\node at (0,0){\tikzmark{middleR}{}};

\begin{tikzpicture}[remember picture, overlay]
\node[cloudnode, label={above:$C$}](lft) at (pic cs:middleL){};
\node[cloudnode, label={above:\textbf{Set}}](rgt) at (pic cs:middleR){};
\draw[-latex](lft)to[bend left]node[above]{$C(a,-)$}(rgt);

  • And incidently, you managed to do all the work for OP, that's very nice of you ;)
    – SebGlav
    Apr 10 at 9:08
  • Thanks a lot! Follow up question: how to ensure that each of the diagrams gets a cloud? When I write a similar code for a few diagrams on the same page, only the last one gets the clouds when typeset.
    – concordepi
    Apr 10 at 10:17
  • @concordepi: Did you give each tikzmark a different name? Did you try compiling again? If those aren't the issues you may want to post a new question with your code. Please remember, on this site you should always post a complete MWE. You will rarely get help if you just post a picture and ask for assistance without providing your code. You can also reference this earlier question when you post your new one.
    – Sandy G
    Apr 10 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.