Text FormattingCurved over-head Arrows connecting Numbers

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
HunterDX77M
Posts: 2
Joined: Tue Jun 19, 2012 6:48 pm

Curved over-head Arrows connecting Numbers

Post by HunterDX77M »

Hello all,

I am going to be teach my student about the FOIL method of multiplication. In order to do that, I thought it would be a nice visual helper if I could draw arrows curving from one number to another and I was wondering if that was possible with LaTeX.

For example if I have (a + b)*(c + d), I want to draw an arrow coming out of "a" going over "b" and terminating at "c". Can that be done with LaTeX?

Thanks for any input! :D
WARNING: You are in the presence of a n00b. Stupid questions can and will be asked.

Operating System: Ubuntu Linux 12.04 LTS
Editor/IDE: TexMaker

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Curved over-head Arrows connecting Numbers

Post by cgnieder »

site moderator & package author
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Curved over-head Arrows connecting Numbers

Post by localghost »

A soluton with pgf/tikZ.

Code: Select all

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}

\begin{document}
  \begin{equation}
    \begin{tikzpicture}[>=stealth,baseline,anchor=base,inner sep=0pt]
      \matrix (foil) [matrix of math nodes,nodes={minimum height=0.5em}] {
        ( & a & + & b & ) & \cdot & ( & c & + & d & ) \\
      };
      \path[->] ($(foil-1-2.north)+(0,1ex)$)   edge[red,bend left=45]    ($(foil-1-8.north)+(0,1ex)$)
                ($(foil-1-2.north)+(0,1ex)$)   edge[green,bend left=60]  ($(foil-1-10.north)+(0,0.5ex)$)
                ($(foil-1-4.north)+(0,0.5ex)$) edge[blue,bend left]      ($(foil-1-8.north)+(0,1ex)$)
                ($(foil-1-4.north)+(0,0.5ex)$) edge[orange,bend left=45] ($(foil-1-10.north)+(0,0.5ex)$);
    \end{tikzpicture}
  \end{equation}
\end{document}

Thorsten
Attachments
The obtained output.
The obtained output.
FOIL.png (7.71 KiB) Viewed 7697 times
Post Reply