4

I'm trying to draw a graph which node text should be in a math environment. For instance consider the following :

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{graphs}

\begin{document}
\begin{tikzpicture}
\graph{
    A0 -> A1;
};
\end{tikzpicture}
\end{document}

I'd the text of A0 and A1 to be \(A^0\) and \(A^1\) (or using $...$ even if it is a bad practise, at this point I don't really care).

Outside graphs, I have no problem to have such nodes, and I read from tikz doc that graph vertices are just regular nodes, but yet, I don't know how to do what I want.

If that is relevant, I'm using lualatex, because I need the \usegdlibrary for the rest of the graph.

3

enter image description here

look in manual, page 259:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{graphs}

\begin{document}
\begin{tikzpicture}
\graph {
A0/$A^0$ -> A1/$A^1$;
};
When you wish to use a node\end{tikzpicture}
\end{document}

or longer version:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{graphs}

\begin{document}
\begin{tikzpicture}
\graph {
A0/[as=$A^0$] -> A1/[as=$A^1$];
};
\end{tikzpicture}
\end{document}
4
  • Thanks, I was obviously not searching at the right place. I though I'd find it in part IV. (that being said, I don't think we have the same version of the manual, p.159 is section 14.10 in mine, which is drawing sine/cosine)
    – Bromind
    Jan 12 '18 at 11:54
  • ups, correct page number is 259 (corrected now). sorry for typing error
    – Zarko
    Jan 12 '18 at 11:56
  • Yep, got it. It's 265 on my version (3.0.1 CVS version). For the sake of completeness, I just saw it is equivalent to do A0/[as=$A^0$] ....
    – Bromind
    Jan 12 '18 at 12:05
  • i have 3.0.1a . and yes, i will ad your finding (i left out it because i was lazy to write long version ... :-) . now i will add this possibilities to answer.
    – Zarko
    Jan 12 '18 at 12:09

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.