3

The code is

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

\begin{document}
\begin{tikzcd}
    \hom(A, A) \arrow[d, "\hom(A, f)"] \arrow[r, "\hom(h, B)"] & \hom(A', B) \arrow[d, "\hom(A', f)"] \\
    \hom(A, B') \arrow[r, "\hom(h, B')"] & \hom(A', B')
\end{tikzcd}
\end{document}

and it gives a lot of errors, the first one being

Package pgfkeys Error: I do not know the key '/tikz/f)"' and I am going to ignore it. Perhaps you misspelled it.

What am I doing wrong?

4
  • 4
    Welcome to TeX.SE! Try adding braces, e.g. "{\hom(A, f)}".
    – user121799
    Feb 20, 2019 at 20:01
  • I confirm that @marmot suggestion solves the problem. But insert braces in all arrow labels.
    – Sigur
    Feb 20, 2019 at 20:03
  • @marmot Thanks, that fixed it! So why is that necessary here? In the other diagrams I've made it was not, even if I used \times or something like that.
    – user388557
    Feb 20, 2019 at 20:04
  • 2
    Also, you could want to use \begin{tikzcd}[column sep=2cm] to change the columns space.
    – Sigur
    Feb 20, 2019 at 20:05

1 Answer 1

5

The problem comes from the commas inside \hom, which interfere with the commas separating the arguments of \arrow . Just add a pair of braces:

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

\begin{document}

\begin{tikzcd}[row sep=large, column sep=huge]%[column sep=3em]
    \hom(A, A) \arrow[d, "{\hom(A, f)}"] \arrow[r, "{\hom(h, B)}"] & \hom(A', B) \arrow[d, "{\hom(A', f)}"] \\%
    \hom(A, B') \arrow[r, "{\hom(h, B')}"] & \hom(A', B')%
\end{tikzcd}

\end{document} 

enter image description here

You must log in to answer this question.

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