1

I have a problem inserting an equation into a tikz node. I'm used to insert successive equations that are separated with 'align', but with my equation (succesive lines, put together with two braces), I does not work, I cannot seem to find the answer to this. I'm using: tikz, tikzlibrary, amsmath, amssymb and amsmath. I think the problem is with the two braces, and the encapsulated equation...

\begin{equation}

if \;  

  \left\{  
      \begin{aligned}
        x_{ref}=x_1+1\\
        x_{ref}=x_2+1\\
        x_{ref}=x_3+1\\
      \end{aligned}
    \right\rbrace 
\end{equation}
  • Can you complete your example code so that it's compilable? Just the minimum to make it work. – Alenanno Apr 5 '16 at 18:01
  • Welcome to TeX.SX! I don't think you can insert equation in a node; but if $\left\{\begin{aligned}...\end{aligned}\right\}$ should do. – egreg Apr 5 '16 at 18:05
  • Thank you #egreg, it worked. I think it was a problem with the dollar signs!! – Josh.h Apr 5 '16 at 18:15
3

There are several possible problems. The only obvious problem in your snippet is that you have empty lines inside the equation environment, which is not permitted.

That said, egreg is correct in saying that you cannot have an equation environment inside a node, unless you set the text width of the node. That makes the node a minipage like box, and makes it possible to use equation. You could of course also add a minipage inside the node, but that is more messy, I think.

In the code below I also added egreg's suggestion of inline math.

enter image description here

\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{tikzpicture}
\node [text width=5cm]  {\begin{equation*}
\text{if }  
  \left\lbrace
      \begin{aligned}
        x_{\mathrm{ref}}=x_1+1\\
        x_{\mathrm{ref}}=x_2+1\\
        x_{\mathrm{ref}}=x_3+1\\
      \end{aligned}
    \right\rbrace 
\end{equation*}};

\node at (6,0) {if $ \left\lbrace
      \begin{aligned}
        x_{\mathrm{ref}}=x_1+1\\
        x_{\mathrm{ref}}=x_2+1\\
        x_{\mathrm{ref}}=x_3+1\\
      \end{aligned}
    \right\rbrace$};
\end{tikzpicture}
\end{document} 

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.