# How to draw differential geometry diagrams like the one below?

I am making notes on the subject and I have to make too many figures of the following kind. How do I do this? An alternative tool is Metapost with lualatex and the luamplib package. Here's a routine to draw manifolds as general randomised ellipses. Drawing labels, arrows, and boxes, etc is covered in the manuals and tutorials linked above. As a bonus I've added the torus hole too.

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
vardef manifold(expr a,b,rho) =
(for t=0 upto 7:
right scaled (a+rho*normaldeviate) rotated 45t ..
endfor cycle) yscaled (b/a)
enddef;
randomseed:=1855.10574;

beginfig(1);
path M, N, torus_edge_lower, torus_edge_upper, torus_hole;

M = manifold(90,60,10);
N = manifold(80,80,3) shifted 240 right rotated 10;

torus_edge_lower = quartercircle scaled 80 rotated 225 shifted center M shifted (-25,15);
torus_edge_upper = point 1/3 of torus_edge_lower
{direction 1/3 of torus_edge_lower rotated 80}
.. point 5/3 of torus_edge_lower;
torus_hole = buildcycle(torus_edge_lower,torus_edge_upper);

fill M withcolor .9[blue,white];
unfill torus_hole;
draw M;
draw torus_edge_lower;
draw torus_edge_upper;
label(btex $M$ etex, point 7 of M shifted (-6,16));

fill N withcolor .9[green,white];
draw N;
label(btex $N$ etex, point 7 of N shifted (-6,16));
endfig;
\end{mplibcode}
\end{document}


To draw a manifold you can use plot coordinates with smooth option, and you can play with the tension parameter. Or you can use the hobby package.

To draw a hole you can use the arc command.

Here is a starting example :

\documentclass[tikz,border=7mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[smooth cycle,tension=.7] plot coordinates{(-1,0) (0.5,2) (2,2) (4,3) (4.5,0)};
\coordinate (A) at (1,1);
\draw (A) arc(140:40:1) (A) arc(-140:-20:1) (A) arc(-140:-160:1);
\end{tikzpicture}
\end{document} 