3

Is it possible to put math with commands that require curly braces inside graph nodes (and edges)? My attempt (see MNWE below, must be compiled with LuaLaTeX) does not seem the way to do it.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[thick]
\graph [tree layout] {
    root -> "Child $C_\text{text}$"};
\end{tikzpicture}
\end{document}

This causes an error:

! Undefined control sequence.
\tikzgraphnodetext ->Child $C_\text 
                                    {text} $
l.14        $"}

1 Answer 1

6

unrelated to tikz you need

\usepackage{amsmath}

to define \text

Also unrelated to tikz but it is much better to use the standard markup C_{\text{text}} rather rely on the weird artefact of the implementation of \text that allows the braces to be omitted.

2
  • Thanks a lot! It did not cross my mind to include amsmath in my tikz sandbox...
    – FlorianL
    Feb 26, 2017 at 20:37
  • @FlorianL undefined command \text should have been a clue;-) Feb 26, 2017 at 20:39

You must log in to answer this question.

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