[Tex/LaTex] Vertex labelling in TikZ

tikz-pgftikz-styles

I want to be able to label the vertices of a graph arbitrarily, i.e., not just by letters or numbers, but by whole formulas. For example, I can't be bothered to rename the vertices in the text, so I want to label each vertex thusly: ab = A (see code). All I get are error messages. Are there any ways to use arbitrary labels on vertices, using the TikZ package?

For example, this doesn't work:

\node (1) [label=above: $ab = A$] at (-2,0) {};

Best Answer

Put braces around the label text.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (1) [label=above:{$ab = A$}] at (-2,0) {node label};
\end{tikzpicture}
\end{document}
Related Question