0

How am I supposed to write an overarrow between two symbols in formula?

I am currently doing a report with relational algebra and normalization for databases, and what I need to do is representing a dependency between to elements in the same table, something like this:

enter image description here

Note that this arrow could be from a to d too, or they could be multiples ones in the same expression, like a to e and a to d and c to e.

Is there a way to do this?

QVignaud
  • 3
  • 1

3 Answers3

3

A pure TikZ solution:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newcommand{\mypoint}[2]{\tikz[remember picture]{\node[inner sep=0pt](#1){$#2$};}}

\begin{document}
    \[
    T_{3,1}(d,\mypoint{tohere}{e},\mypoint{fromhere}{a},c)
    \]

    \tikz[overlay, remember picture]{\draw[-{Stealth[round]}] ([yshift=2pt]fromhere.north) -- ++(0,7pt) -| ([yshift=2pt]tohere.north);}

\end{document}

enter image description here

CarLaTeX
  • 62,716
2

If you only want to put an arrow over two neighbouring letters, you could use \overset. But this won’t work, if one of the letters is part of an underlined section.

Another approach (but quite similar to these) using tikzmarks could be:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

$T_{3,1}(d,\overset{\curvearrowleft}{e,a},c)$

\bigskip

$T_{3,1}(\underline{d,e\tikzmark{e}},a\tikzmark{a},c)$
\tikz[overlay,remember picture]{ \draw[<-] ([xshift=-.5ex,yshift=1.5ex]pic cs:e) to[bend left=60] ([xshift=-.5ex,yshift=1.5ex]pic cs:a); }

\bigskip

$T_{3,1}(\underline{d\tikzmark{d},e},a\tikzmark{aa},c)$
\tikz[overlay,remember picture]{ \draw[<-] ([xshift=-.5ex,yshift=2ex]pic cs:d) to[bend left] ([xshift=-.5ex,yshift=2ex]pic cs:aa); }


\end{document}

enter image description here

1

A solution with pstricks: the elements to be linked are defined as nodes, and I add node connections:

 \documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

    \begin{document}

\[ \begin{pspicture}
 T_{3,1}(\Rnode{d}{d}, \Rnode{e}{e}, \Rnode{a}{a}, \Rnode{c}{c})
 \psset{linewidth=0.4pt, linejoin=1, arrows=->, arrowinset=0.15, angle=90, nodesep=1pt, arm=1.1ex}
 \ncbar[offsetA=1pt]{a}{e} \ncbar[offsetA=-1pt, arm=1.3ex, nodesepB=-1pt]{a}{d}\ncbar[angle=-90]{c}{e}
 \end{pspicture} \]

  \end{document} 

enter image description here

Bernard
  • 271,350