Implementation of "clouds" for notes in the text

With tikz and tikzmark you can do such things.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 0.95 step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate}}
\begin{document}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$
\begin{tikzpicture}[overlay,remember picture]
\path[thought dots] (n) -- ++(0.5,-1) node[below,cloud,draw,align=center,aspect=2,inner sep=0pt]{study structure\\
of sets by studying\\ maps between them};
\end{tikzpicture}
\end{document}

enter image description here

You can address the alignment problem with either shapepar or wrapfig or something along those lines. Which of these options suits you best may only be gauged once you provide us with an MWE, from which we can see which packages you are using and so on. The following is to give you an idea.

\documentclass{article}
\usepackage{amsmath}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 0.95 step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate},iCloud/.style={cloud,draw,align=center,aspect=2,inner sep=0pt}}
\begin{document}
\setcounter{section}{3}
\section{Measurable maps}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$

\begin{wrapfigure}[10]{r}[10pt]{6cm}
\tikzmarknode[iCloud]{nn}{study structure\\
of sets by studying\\ maps between them}
\begin{tikzpicture}[overlay,remember picture]
\path[thought dots] (n) -- (nn);
\end{tikzpicture}
\end{wrapfigure}
$\triangleright$ measurable maps

a map $f:M\to N$ is called measurable if \dots \lipsum[1]

\end{document}

enter image description here

If you want them in the margin, then I'd use tikzpagenodes.

\documentclass{article}
\usepackage[left=1in,top=1.5in,bottom=1.5in,right=2in]{geometry}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{tikzmark,shapes.symbols,decorations.markings}
\tikzset{thought dots/.style={decoration={markings,
      mark=between positions 4pt and 1-4pt step 9pt
      with
      {
        \draw (0,0) circle[radius=2pt];
      }
},decorate},iCloud/.style={cloud,draw,align=center,aspect=2,inner sep=0pt}}
\newcounter{clouds}
\newcommand{\AddThought}[3][]{\begin{tikzpicture}[overlay,remember picture]
\stepcounter{clouds}
\node[iCloud,anchor=west,#1] (cloud-\number\value{clouds}) at 
(#2.south-|current page text area.east)
{#3};
\path[thought dots] (#2) -- (cloud-\number\value{clouds});
\end{tikzpicture}}
\begin{document}
\setcounter{section}{3}
\section{Measurable maps}
Standard philosophy $\displaystyle (M,\sigma_M)
\xrightarrow[\tikzmarknode{n}{\mathrm{nervously}}]{\mathrm{study}}(M,\sigma_M)$
\AddThought{n}{study structure\\
of sets by studying\\ maps between them}

$\triangleright$ measurable maps

a map $f:M\to N$ is called measurable if \dots \lipsum[1]

Something about \tikzmarknode{d}{ducks}
\AddThought[yshift=-1cm]{d}{Why always\\
ducks? Don't we\\ have enough\\ ducks?}

\end{document}

enter image description here


Note: SUPPLEMENT added at end for twoside version.

Unless you want to spend all your time manually placing text so as to wrap around your clouds, I suggest combining it with a \marginpar mechanism. The only change to the layout I did was to decrease the \textwidth to leave room for the clouds.

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}

\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{%
    \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}%
    \rule[-\dp\strutbox]{\dimexpr\textwidth-\TabPrevPos\relax}{.5pt}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}

\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

enter image description here

At the OP's request, a version with dotted connectors:

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1{\cleaders\hbox to #1{\scalebox{1.4}{.}}\hfill}
\newcommand\dotline[2][.5em]{\leavevmode\hbox to #2{\dotfill{#1}\hfil}}
\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{\raisebox{-\dp\strutbox}{%
    \dotline{\dimexpr\textwidth-\TabPrevPos\relax}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\dotline[.7em]{60pt}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}
\sloppy
\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

enter image description here

Better yet, a version with bubbles:

\documentclass{article}
\textwidth=\dimexpr\textwidth-1in\relax
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1#2{\cleaders\hbox to #1{\scalebox{#2}{$\circ$}}\hfill}
\newcommand\dotline[3][.6em]{\leavevmode\hbox to #2{\dotfill{#1}{#3}\hfil}}
\newcommand\margincloud[1]{{%
  \tabto{\textwidth}%
  \llap{\raisebox{-\dp\strutbox}{%
    \dotline{\dimexpr\textwidth-\TabPrevPos\relax}{.6}%
    \kern-3pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\dotline[.8em]{60pt}{1}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}%
}}
\sloppy
\begin{document}
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

enter image description here

SUPPLEMENT twoside version (using lines, per OP request)

\documentclass[twoside]{book}
%\usepackage[left=2.5in,right=2.5in]{geometry}
\usepackage{tikz,tabto,lipsum}
\usetikzlibrary{shapes}
\def\dotfill#1#2{\xleaders\hbox to #1{\scalebox{#2}{$\circ$}}\hfill}
\newcommand\dotline[3][.6em]{\leavevmode\hbox to #2{\dotfill{#1}{#3}\hfil}}
\newcommand\margincloud{\ifodd\thepage\relax\expandafter\rmargincloud
  \else\expandafter\lmargincloud\fi}
\newcommand\lmargincloud[1]{{%
  \tabto*{0pt}%
  \smash{\rlap{%
    \smash{\llap{\rotatebox[origin=rb]{-45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}%
    \kern-2.5pt
    \rule[-\dp\strutbox]{\TabPrevPos}{.5pt}%
        \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}}}%
  \tabto{\TabPrevPos}%
  \marginpar{%
    \smash{\makebox[\marginparwidth][r]{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}}%
}}
\newcommand\rmargincloud[1]{{%
  \tabto{\textwidth}%
  \smash{\llap{%
    \rule[-\dp\strutbox]{.5pt}{\dp\strutbox}%
    \rule[-\dp\strutbox]{\dimexpr\textwidth-\TabPrevPos\relax}{.5pt}%
    \kern-2.5pt
    \smash{\rlap{\rotatebox[origin=lb]{45}{\rule[-\dp\strutbox]{60pt}{.5pt}}}}}}%
  \tabto*{\TabPrevPos}%
  \marginpar{%
    \smash{\makebox[\marginparwidth][l]{\begin{tikzpicture}
    \node [cloud, fill=blue!5, draw,cloud puffs=10,cloud puff arc=120, 
       aspect=1.5, inner ysep=1em]{\parbox{1in}{\raggedright#1}};
    \end{tikzpicture}%
  }}}%
}}
\sloppy
\begin{document}

This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]

\clearpage
This is a test\margincloud{My marginnote of some length} of a cloudy
marginpar.  I will continue to write so as to make sure that the line
is appropriately set at the right height. \lipsum[1]

Now I get to try it again, to see if it still works.  Let us do it here%
\margincloud{I would like a longer marginnote to see how this works}
and see. \lipsum[2]

Finally, we get to try it one last time on the page.  I will work
my way a bit into the paragraph, in order to see if that makes any
difference at all.  Ok, we prepare for this final test of the page.
Here goes...\margincloud{Boo!} \lipsum[3]
 \end{document}

enter image description here