Math & ScienceAdd connecting Arrows over Parts of an Equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
luftbahnfahrer
Posts: 2
Joined: Tue Jul 31, 2012 11:15 am

Add connecting Arrows over Parts of an Equation

Post by luftbahnfahrer »

Is there a way to add arrows over (or under) different elements of an equation that would denote "swapping" those two parts?

Here's an example I created with a graphics editor (Inkscape) showing about what I am looking for:
equation-arrows.png
equation-arrows.png (4.56 KiB) Viewed 7167 times
Thanks for any help!
Last edited by localghost on Tue Jul 31, 2012 11:27 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10359
Joined: Mon Mar 10, 2008 9:44 pm

Add connecting Arrows over Parts of an Equation

Post by Stefan Kottwitz »

Hi,

welcome to the board!

With TikZ, you can define some pieces of the formula as nodes, and draw arrows between those nodes. Here's a complete compilable example, with comments what I'm doing:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}% For nice arrow tips
% One style for all TikZ pictures for working with overlays:
\tikzset{every picture/.style=remember picture}
% Define a TikZ node for math content:
\newcommand{\mathnode}[1]{%
  \mathord{\tikz[baseline=(#1.base), inner sep = 0pt]{\node (#1) {$#1$};}}}
\begin{document}
\[
  \mathnode{A} \otimes B \otimes \mathnode{C} \otimes \mathnode{D}
    = C \otimes B \otimes A \otimes \mathnode{D}
\]
% Now we draw connections between defined nodes:
\begin{tikzpicture}[overlay]
  \path [>=stealth, <->, shorten <= 3pt, shorten >=3 pt]
    (A) edge [bend left=60] (C);
\end{tikzpicture}
\end{document}
math-nodes.png
math-nodes.png (2.72 KiB) Viewed 7161 times
Stefan
LaTeX.org admin
luftbahnfahrer
Posts: 2
Joined: Tue Jul 31, 2012 11:15 am

Re: Add connecting Arrows over Parts of an Equation

Post by luftbahnfahrer »

Thanks! Exactly what I was looking for.
Post Reply