tikz-cd 的问题

tikz-cd 的问题

我有以下一行代码:

\documentclass[a4paper]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{tikz-cd}

\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\id}{id}

\begin{document}
\[
\begin{tikzcd}
\Hom(Fz,y)\otimes G(y')
\arrow[r,"\Hom (Fz,\id )\otimes G(f)"]
\arrow[d,"\Hom (Fz,f)\otimes G(\id )"']&
\Hom(Fz,y)\otimes G(y)\dar["\rho_y"] \\
\Hom(Fz,y')\otimes G(y')\rar["\rho_{y'}"]&
d.
\end{tikzcd}
\]
\end{document}

我原本以为会有一个简单的正方形图。但是,编译时出现了很多错误;我尝试删除一些代码行,似乎问题出在左上角。但是,我不知道哪里出了问题。

确切的错误信息是:

! Argument of \XC@definec@lor has an extra }.
<inserted text>
\par
l.263 \end{tikzcd}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

答案1

这里的问题是,传递给的选项\arrow是一个逗号分隔的列表,其中一个条目有一个逗号。

例如,你有

\arrow[d,"\Hom (Fz,f)\otimes G(\id )"']

应该是

\arrow[d,"{\Hom (Fz,f)\otimes G(\id )}"']

添加了{},它需要位于 内""。这会“隐藏”标签中的逗号,使解析选项列表的解析器无法看到。

我还在yshift其中一个标签上添加了,以避免重叠。

在此处输入图片描述

\documentclass[a4paper]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{tikz-cd}

\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\id}{id}

\begin{document}
\[
\begin{tikzcd}
\Hom(Fz,y)\otimes G(y')
\arrow[r,"{\Hom (Fz,\id )\otimes G(f)}"yshift=4pt]
\arrow[d,"{\Hom (Fz,f)\otimes G(\id )}"']
&
\Hom(Fz,y)\otimes G(y)
\dar["\rho_y"] 
\\
\Hom(Fz,y')\otimes G(y')
\rar["\rho_{y'}"]
&
d.
\end{tikzcd}
\]
\end{document}

答案2

如果箭头标签包含逗号,则标签应该用括号括起来。

我不会混淆\arrow和。另外\rar\dar您需要更多空间来放置顶部标签。

\documentclass[a4paper]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{tikz-cd}

\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\id}{id}

\begin{document}
\[
\begin{tikzcd}
\Hom(Fz,y)\otimes G(y')
  \arrow[r,"{\Hom (Fz,\id )\otimes G(f)}"]
  \arrow[d,"{\Hom (Fz,f)\otimes G(\id )}"']
&[6em]
\Hom(Fz,y)\otimes G(y) \arrow[d,"\rho_y"]
\\
\Hom(Fz,y')\otimes G(y') \arrow[r,"\rho_{y'}"]
&
d.
\end{tikzcd}
\]
\end{document}

在此处输入图片描述

相关内容