TikZ in XeLaTeX can't label arrows if they contain square brackets

23 Views Asked by At

I'm trying to create a commutative diagram in LaTeX and it creates dozens of errors in the editor. Here's the code of the diagram:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}


\setmainfont{Times New Roman}


\setdefaultlanguage{english}
\setotherlanguage{greek}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{cancel}
\usepackage{centernot}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{biblatex}
\usepackage{listings}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{csquotes}
\usepackage{tikz-cd}

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\Ob}{Ob}
\DeclareMathOperator{\Id}{Id}

\begin{document}
\section{Main Results}
\begin{lemma}
\[
\begin{tikzcd}
{[h_Y,F]} \arrow[rr, ''{[\beta_*,F]}''] \arrow[dd, ''\xi^Y''] && {[h_{Y'},F]} \arrow[dd, ''\xi^{Y'}'']\\{}
\\{}
{[h_Y,h_X]} \arrow[rr, ''{[\beta_*,h_X]}'']                  && {[h_{Y'},h_X]}
\end{tikzcd}
\]
\end{lemma}
\end{document}

I've tried to add curly braces and it didn't work. I'm using TeXnicCenter. The errors state:

xelatex> ! Missing \endcsname inserted.
xelatex> <to be read again>
xelatex>                    \beta
xelatex> 1.71 \end{tikzcd}
xelatex>

Over and over again then suddenly:

xelatex> ! Package xcolor Error: Undefined color `''{[\beta_*,F]}'''.
xelatex> See the xcolor package documentation for explanation.
xelatex> Type H <return> for immediate help
xelatex> ...
xelatex> 1.68 I think the culprit is a tikzcd arrow in cell 1-1.
xelatex> \errmessage ...currentrow -\tikzcd@currentcolumn }

Also:

xelatex> ! Argument of \@secondoffive has an extra }.
xelatex> <inserted text>
xelatex>                 \par
xelatex> 1.71 \end{tikzcd}
xelatex>
xelatex> Runaway argument?
xelatex> ! Paragraph ended before \@secondoffive was complete.
xelatex> <to be read again>
xelatex>                   \par
xelatex> 1.71 \end{tikzcd}
xelatex>

Similar errors appear for other characters, like \xi and \xi^Y, and another arrow.

1

There are 1 best solutions below

0
samcarter_is_at_topanswers.xyz On

You need to use " and not '' to delimitate the labels:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\[
\begin{tikzcd}
{[h_Y,F]} \arrow[rr, "{[\beta_*,F]}"] \arrow[dd, "\xi^Y"] && {[h_{Y'},F]} \arrow[dd, "\xi^{Y'}"]\\{}
\\{}
{[h_Y,h_X]} \arrow[rr, "{[\beta_*,h_X]}"]                  && {[h_{Y'},h_X]}
\end{tikzcd}
\]
\end{document}

enter image description here