TeXblog

 Typography with TeX and LaTeX

Math formulas and arrows with TikZ

Januar 19th, 2009 by Stefan Kottwitz

In the Art of Problem Solving Forum somebody asked for help in creating a construction for proofs and demonstrations in Logic by LaTeX commands. Math expressions should be aligned, some connected by arrows going vertically and horizontally.
Regarding arrows I would use tikz and also its matrix library for math nodes. The nodes could be connected by -| or |- path construction operations, like

\draw (node1) -| (node2) |- (node3);

For creation of the example given in the thread on AoPS I’ve used a matrix of math nodes, some empty nodes for alignment and |- -| arrows, here’s the compilable example code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[every node/.style={anchor=west}]
  \matrix (m) [matrix of math nodes,
    nodes in empty cells]{
    \quad & 1.\quad (x)(Q\supset Fx) & \\
    & 2.\quad Q\supset Fx & \textrm{I,\textbf{UI}} & \\
    & 3.\quad Q \\
    & 4.\quad Fx & 2, 3, \textrm{ M.P.}\\
    & 5.\quad (x)Fx & 4, \textrm{ \textbf{UG}} \\
    & 6.\quad Q\supset(x)Fx & 3-5, \textrm{ C.P.} \\
    & 7.\quad \parbox[t]{2.9cm}{%
             $(x)(Q\supset(x)Fx)\supset$\\
             $[Q\supset(x)Fx]$} & 1-6, \textrm{ C.P.}\\};
  \draw[-stealth] (m-7-2.north east)
               -| (m-1-1.west) |- (m-1-2);
  \draw[-stealth] (m-6-2.north east)
               -| (m-3-1.east) |- (m-3-2);
\end{tikzpicture}
\end{document}

Output:

logic diagram with TikZ

This entry was posted on Montag, Januar 19th, 2009 at 19:53 and is filed under pgf/TikZ, Mathematics. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

1 response about “Math formulas and arrows with TikZ”

  1. math tutoring said:

    math tutoring…

    […]Math formulas and arrows with TikZ - TeXblog - Typography with TeX and LaTeX[…]…

Leave a Reply