# How can you use square brackets in tikz diagram?

I am trying to draw a sequence in TeX with Tikz where the vertices are $[X,Y]$, however I can't seem to get the code to work. Here is the code I am trying to use.

\documentclass[12pt]{amsart}
\begin{document}
\begin{prop}
The retract of an $E$-local spectrum is $E$-local.
\end{prop}
\begin{proof}
Suppose $f:X\to Y$ is a morphism of spectra with $Y$ an $E$-local spectrum so
that $f$ admits a retract. Thus, there is $r:Y\to X$ such that $rf=1$. Then for $Z$ an $E$-acyclic spectrum we get a diagram whose composite is the identity
$\begin{tikzcd} [Z, X]\arrow{r}{f_*}& [Z, Y]\arrow{r}{r_*}& [Z, X] \end{tikzcd}$
but as $Y$ is $E$-local, $[Z, Y]=0$. So, in fact $[Z, X]=0$.
\end{proof}
\end{document}


I get the following error

Package PGF Math Error: Unknown function Z' (in Z').


Does anyone know how to fix this?

Thanks!

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – cfr Nov 17 '14 at 2:28

Something like this. Use of \left [ ... \right ] instead.

Code

\documentclass[12pt]{amsart}
\usepackage{tikz-cd}
\newtheorem{prop}{Proposition}
\begin{document}
\begin{prop}
The retract of an $E$-local spectrum is $E$-local.
\end{prop}
\begin{proof}
Suppose $f:X\to Y$ is a morphism of spectra with $Y$ an $E$-local spectrum so
that $f$ admits a retract. Thus, there is $r:Y\to X$ such that $rf=1$. Then for $Z$ an $E$-acyclic spectrum we get a diagram whose composite is the identity
$\begin{tikzcd} \left [Z, X \right]\arrow{r}{f_*}& \left [Z, Y\right ]\arrow{r}{r_*}&\left [Z, X\right ] \end{tikzcd}$
but as $Y$ is $E$-local, $[Z, Y]=0$. So, in fact $[Z, X]=0$.
\end{proof}
\end{document}

• @user66340 -- You are welcome. – Jesse Nov 17 '14 at 3:11
• Although this method works for the nodes themselves (as in the OP's question here) @user11232's answer works for both nodes and arrow labels. – et_l Apr 28 '18 at 9:06

[ has a special purpose in tikz. The options to tikz commands are enclosed within [..]. You can hide [ (and ]) from tikz parser by enclosing it(them) within braces like {[Z, X]}.

\documentclass[12pt]{amsart}
\usepackage{tikz-cd}
\newtheorem{prop}{Proposition}
\begin{document}
\begin{prop}
The retract of an $E$-local spectrum is $E$-local.
\end{prop}
\begin{proof}
Suppose $f:X\to Y$ is a morphism of spectra with $Y$ an $E$-local spectrum so
that $f$ admits a retract. Thus, there is $r:Y\to X$ such that $rf=1$. Then for $Z$ an $E$-acyclic spectrum we get a diagram whose composite is the identity
$\begin{tikzcd} {[Z, X]}\arrow{r}{f_*}& {[Z, Y]}\arrow{r}{r_*}& {[Z, X]} \end{tikzcd}$
but as $Y$ is $E$-local, $[Z, Y]=0$. So, in fact $[Z, X]=0$.
\end{proof}
\end{document}