I was trying to use an equal sign within a TikZ picture as a subcaption of an inner TikZ picture for comparing two images.

Here is my code:





        \coordinate (p1) at (0,0);
        \coordinate (p2) at (-3,0);

        \node[label=below:$\mathcal{L}(B)$] (left) 
                \draw (p1) -- (p2);
        \node[label=below:$\mathcal{L}^*(B)\text{$=$}\mathcal{L}(D)$,right=of left]
                \draw (p2) -- (p1);


My workaround was to use \text{$=$}. A plain equal sign instead of this will produce and error. I think TikZ recognizes this equal sign a separator of a key-value-pair of an attribute. Is there a right way to produce a plain equal-sign without this workaround?


2 Answers 2


As already pointed out by Jake, the = is detected by TikZ that parses the options based on , and =.

This works:


As well as that:


If you want to include a : in the label but do not specify a direction (here: below), then you will need to protect the colon, too:

\tikzset{label position=below}
\node[label=here's{:} a colon]

The same bracing is needed if you use , (in a label and elsewhere), for example:

\tikzset{nodes={draw, fill, font=\tiny}}

Defining a macro \equal as


hides the = from the parser, too, but may not be the favorite way to input formulas.


At least the spacing is correct as opposed to that work-around of \text{$=$} where the braces { } from \text hides = from the parser as well. Note that $L{=}L$ still produces wrong spacing and isn’t an option here.


this works nicely in my case

\documentclass {standalone}
     for tree={l+=1cm} % increase level distance
        [ $X_n  \mapsto {\lim_{n=\infty} X_n=X^*} $
        [left[lleft $a+b$ ][lright]]

The trick is to apply {} barackets.

  • The question already has this answer. -I do not see that your code is relevant for the problem other than { and }. Jan 2, 2021 at 13:35

You must log in to answer this question.

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