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?


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.

| improve this answer | |

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.