13

When I try to put an = symbol into a TikZ node label specified as an option (using label=), I get an error:

Extra }, or forgotten $.

Is there a way to specify = in such cases that I'm missing?


\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node(x){$X$};
  \path(x)[late options={label=right:=$A$}];     % Works but doesn't display anything
  \path(x)[late options={label=above:$\neq B$}]; % Works 
  \path(x)[late options={label=below:$C$}];      % Works 
  \path(x)[late options={label=left:$=D$}];      % Fails! 
\end{tikzpicture}
\end{document}
1

1 Answer 1

15

Key-value systems look for =, and can't 'tell' that the = here is part of the 'value'. You therefore need braces:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
  \node(x){$X$};
  \path(x)[late options={label={right:=$A$}}];
  \path(x)[late options={label=above:$\neq B$}]; 
  \path(x)[late options={label=below:$C$}]; 
  \path(x)[late options={label={left:$=D$}}]; 
\end{tikzpicture}
\end{document}

(You get an error as the = inside math mode leaves to grouping issues, which don't happen in the first case.)

2
  • Thanks! I thought I tried that too, but must have put the braces around the wrong thing.
    – orome
    Jun 27, 2012 at 19:32
  • 1
    An answer is in the pgfmanual : /tikz/late options=⟨options⟩ with an example : \path (a) [late options={label=above:world}]; Jun 28, 2012 at 7:51

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.