I am working on a simple graph, using TikZ.

The code I have so far is:



\graph[clockwise, n=3, V={i,j,k}, edge={bend left=45, -stealth}] { subgraph C_n };


The output I receive while compiling the code above is:

enter image description here

The only change I want to make is to display $\mathbf{i}$ instead of i, $\mathbf{j}$ instead of j and $\mathbf{k}$ instead of k. When I try to do so, compiling doesn't work and I receive the following error message:

Undefined control sequence.
  • 1
    Please show what When I try to do so means.
    – daleif
    Sep 22, 2022 at 15:06
  • 4
    Is \graph[clockwise, n=3, V={i,j,k}, typeset=$\mathbf{\tikzgraphnodename}$, edge={bend left=45, -stealth}] { subgraph C_n }; what you want? With V you specify the name of the nodes. These can't have names that include \mathbf. Sep 22, 2022 at 15:08

1 Answer 1


The list of names you specify for the key V is used for the names of the nodes. These kind of names don't allow “special” macros like \mathbf. (Node names are used as macro names internally by PGF and these need to be fully expandable to text. \mathbf is not and all hell breaks loose because of that.)

However, the graphs library provides the typeset key where you have access to certain macros, mainly the \tikzgraphnodename and the \tikzgraphnodetext macros (which are the same in this simple case):

  edge={bend left=45, -stealth},
  typeset=$\mathbf{\tikzgraphnodetext}$ % !or $\mathbf{\tikzgraphnodename}$
] { subgraph C_n };


\tikz\graph[clockwise, n=3, V={i,j,k}, edge={bend left=45, -stealth}, % no typeset
  ] { subgraph C_n };
\tikz\graph[clockwise, n=3, V={i,j,k}, edge={bend left=45, -stealth}, % typeset with text
  typeset=$\mathbf{\tikzgraphnodetext}$] { subgraph C_n };
\tikz\graph[clockwise, n=3, V={i,j,k}, edge={bend left=45, -stealth}, % typeset with name
  typeset=$\mathbf{\tikzgraphnodename}$] { subgraph C_n };
\tikz\graph[clockwise, n=3, edge={bend left=45, -stealth}, % for fun
] { subgraph C_n };

Thanks to the comment of Henri Menke, a small fix to the subgraph I_n (which is used internally by subgraph C_n) enables you to use the full power of the \graph way of specifying a vertex.

However, as it uses a \foreach loop you need to protect , when they're used the node text or in the options (or in the node name but that's not a good idea to begin with).

V={ i / $\mathbf{i}$, j / $\mathbf{j}$, k / $\mathbf{k}$ [{red, fill=green}]}


V={ i / $\mathbf{i}$, j / $\mathbf{j}$, {k / $\mathbf{k}$ [red, fill=green]}}


  declare={subgraph I_n}{
    \foreach \tikz@lib@graph@node@num in \tikzgraphV
      {[parse/.expand once=\tikz@lib@graph@node@num]}}}
\tikz\graph[clockwise, n=3,
  V={ i / $\mathbf{i}$, j / $\mathbf{j}$, k / $\mathbf{k}$ },
  edge={bend left=45, -stealth}] { subgraph C_n };
  • 1
    It should be possible to do V={ i / $\mathbf{i}$, j / $\mathbf{j}$, k / $\mathbf{k}$ }, but that is currently prevented by a bug. The loop variable \tikz@lib@graph@node@num is not expanded in the definition of subgraph I_n which results in all of i / $\mathbf{i}$ being parsed as the node name. Sep 22, 2022 at 15:38
  • @HenriMenke I've tried that as an alternative but when it failed I went with the best next thing I know worked. The manual actually states that Vs value is used for the vertex names which I understood to be plain node names but even better … I've added a "fix" for that bug in my updated answer. Sep 22, 2022 at 16:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .