Text along bent arrows in TikZ

I would do something like this:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}

    \begin{frame}{}
    \tikzstyle{leaf}=[shape=circle,draw=black,fill=green!20,minimum size=0.01cm]
    \tikzstyle{pool}=[shape=rectangle,draw=black,fill=blue!20,minimum width=4cm,minimum height=1cm]
    \begin{figure}[t]
        \begin{tikzpicture}[overlay,remember picture]
        \node[pool] (biomass_pool) at (0,-2) {Pool};
        \node[leaf] (leaf_1) at (-5.5,1.5) {$x_1$};
        \draw [{Latex[length=1.5mm]}-] (leaf_1) to [bend right=30] node [above, sloped] (TextNode1) {$q_1$} (biomass_pool);
        \draw [-{Latex[length=1.5mm]},dotted] (leaf_1) to [bend left=30]  node [above, sloped]  (TextNode2) {$d_1$} (biomass_pool);
        \end{tikzpicture}
    \end{figure}
\end{frame}

\end{document}

enter image description here


When using to, the node has to be placed right after to, not after the next coordinate, i.e. (a) to node{foo} (b) instead of (a) to (b) node[midway]{foo};.

\tikzstyle is I believe considered deprecated by the way. It still works, but the recommended method is \tikzset{style A/.style={...}, style B/.style={...}}.

output of code

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{frame}{}
  \tikzset{
      leaf/.style={shape=circle,draw=black,fill=green!20,minimum size=0.01cm},
      pool/.style={shape=rectangle,draw=black,fill=blue!20,minimum width=4cm,minimum height=1cm}
  }
  \begin{figure}[t]
    \begin{tikzpicture}[overlay,remember picture]
      \node[pool] (biomass_pool) at (0,-2) {Pool};
      \node[leaf] (leaf_1) at (-5.5,1.5) {$x_1$};
      \draw [{Latex[length=1.5mm]}-] (leaf_1) -- (biomass_pool) node [pos=.5, above, sloped] (TextNode1) {$q_1$};
      \draw [-{Latex[length=1.5mm]},dotted] (leaf_1) to[bend left=5] node [below, sloped] (TextNode2) {$d_1$} (biomass_pool);
    \end{tikzpicture}
  \end{figure}
\end{frame}

\end{document}

  • do you really need named nodes for edge labels?
  • is it necessary that tikzpicture has options overlay,remember picture?
  • is necessary that the image is in figure environment (i don't see caption)?

if answers are no, than i would rather use the following solution:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, quotes}

\begin{document}

\begin{frame}
\frametitle{My image}
\centering
    \begin{tikzpicture}[%overlay,remember picture, % do you really need this?
%
    auto,
    leaf/.style={circle,draw,fill=green!20,minimum size=1mm},
    pool/.style={draw,fill=blue!20,minimum width=4cm,minimum height=1cm},
     Arr/.style={-{Latex[length=1.5mm]}},
                        ]
    \node[pool] (biomass_pool)  at (0,-2) {Pool};
    \node[leaf] (leaf_1)        at (-5.5,1.5) {$x_1$};
    \draw[Arr] (biomass_pool)   to [bend left=30,"$q_1$"] (leaf_1);
    \draw[Arr,dotted] (leaf_1)  to [bend left=30,"$d_1$"]   (biomass_pool);
    \end{tikzpicture}
\end{frame}

\end{document}

enter image description here