4

How can I draw an edge from (ab) to ($a^3$$b$)?

I tried using \Edge(ab)($a^3$$b$) like I did for drawing an edge from (b) to (e) but the same method didn't work.

I think it has something to do with using dollar signs.

\documentclass[a4paper]{article}
\usepackage[english]{babel}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}

\usepackage[colorinlistoftodos]{todonotes}

\usepackage{tkz-graph}

\usetikzlibrary{arrows}

\title{Your Paper}
\author{You}
\date{\today}

\begin{document}
\maketitle

\begin{center}
\begin{tikzpicture}

\Vertex[x=-1 ,y=-1]{e}

\Vertex[x=1 ,y=1]{$a^2$}

\Vertex[x=-1,y=1]{a}

\Vertex[x=1 ,y=-1]{$a^3$}

\Vertex[x=-3 ,y=-3]{b}

\Vertex[x=3 ,y=3]{$a^2$$b$}

\Vertex[x=-3 ,y=3]{$a^3$$b$}

\Vertex[x=3 ,y=-3]{ab}

\Edge(e)(b)

\Edge(ab)($a^3$)

\end{tikzpicture}

\end{center}

\end{document}
3
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – jub0bs
    Nov 17 '14 at 14:41
  • @Jubobs sure, sorry its my first post, thanks for the comment
    – Peter A
    Nov 17 '14 at 14:54
  • 1
    The answer is easily found in Tkz-graph documentation, page 21. You already have this document in your system: type texdoc tkz-graph from command line
    – Ignasi
    Nov 17 '14 at 15:29
4

If you add \SetVertexMath right after \begin{tikzpicture} you don't need to use $ in the vertices. This should allow you to reference them as you would other vertices.

\documentclass[border=2mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tkz-graph}
\usetikzlibrary{arrows,calc}
\begin{document}
\begin{tikzpicture}
\SetVertexMath
\Vertex[x=-1 ,y=-1]{e}
\Vertex[x=1 ,y=1]{a^2}
\Vertex[x=-1,y=1]{a}
\Vertex[x=1 ,y=-1]{a^3}
\Vertex[x=-3 ,y=-3]{b}
\Vertex[x=3 ,y=3]{a^2b}
\Vertex[x=-3 ,y=3]{a^3b}
\Vertex[x=3 ,y=-3]{ab}
\Edge(e)(b)
\Edge(ab)(a^3)
\end{tikzpicture}
\end{document}

enter image description here

By the way, when using math you don't need $ around each variable. You can use $ once to enter math mode, then once again to exit. So, rather than $a^2$$b$, you would have $a^{2}b$. The {} is to identify the argument in the exponent.

1
  • Ah amazing thanks for the reply and solution!
    – Peter A
    Nov 17 '14 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.