我刚刚升级到tikz-cd
0.9(pgf
3.0.0)。以下代码现在中断:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-cd}
\begin{document}
\[
\begin{gathered}
\begin{tikzcd}
1 & 2 \\
3 & 4
\end{tikzcd}
\\
\begin{tikzcd}
5 & 6 \\
7 & 8
\end{tikzcd}
\end{gathered}
\]
\end{document}
Runaway argument?
! Forbidden control sequence found while scanning use of \pgfutil@ifnextchar.
<inserted text>
\par
l.11 \begin{tikzcd}
如果我注释掉gathered
环境(以及\\
图表之间的),或者将旧的文件tikz-cd.sty
放在文件目录中,它就会起作用.tex
。它确实不是努力做到这一点:
\begin{gathered}
\begin{tikzcd}[ampersand replacement=\&]
1 \& 2 \\
3 \& 4
\end{tikzcd}
\\
\begin{tikzcd}[ampersand replacement=\&]
5 \& 6 \\
7 \& 8
\end{tikzcd}
\end{gathered}
这甚至没有改变错误:
Runaway argument?
! Forbidden control sequence found while scanning use of \pgfutil@ifnextchar.
<inserted text>
\par
l.11 \begin{tikzcd}
[ampersand replacement=\&]
事实上,我最初遇到这个问题是因为我使用的一些代码ampersand replacement
损坏了。
答案1
如果有疑问,请添加
ifnum0=`}
团体
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-cd}
\let\oldtikzcd\tikzcd
\def\tikzcd{{\ifnum0=`}\fi\oldtikzcd}
\let\oldendtikzcd\endtikzcd
\def\endtikzcd{\oldendtikzcd\ifnum0=`{\fi}}
\begin{document}
\[
\begin{gathered}
{\begin{tikzcd}
1 & 2 \\
3 & 4
\end{tikzcd}}
\\
\begin{tikzcd}
5 & 6 \\
7 & 8
\end{tikzcd}
\end{gathered}
\]
\end{document}