![tikz-cd 中的弯曲箭头不起作用](https://linux22.com/image/476130/tikz-cd%20%E4%B8%AD%E7%9A%84%E5%BC%AF%E6%9B%B2%E7%AE%AD%E5%A4%B4%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我正在使用 Quiver,但在制作带有弯曲箭头的图表时遇到了麻烦。例如,它建议我将以下内容放在我的文档中:
\begin{tikzcd}[ampersand replacement=\&,column sep=2.25em]
A \& B
\arrow[curve={height=-12pt}, from=1-1, to=1-2]
\end{tikzcd}
但是,它无法编译。TexMaker 告诉我:软件包 tikz 错误:预期为 + 或 -,并且 \tikz@curveCdot 的使用与其定义不匹配。
我在序言中同时使用了tikz
和。tikz-cd
分数维:
\documentclass{article}
\usepackage[french,english]{babel}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
% A TikZ style for curved arrows of a fixed height, due to AndréC.
\tikzset{curve/.style={settings={#1},to path={(\tikztostart)
.. controls ($(\tikztostart)!\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
and ($(\tikztostart)!1-\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes}},
settings/.code={\tikzset{quiver/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/quiver/##1}}},
quiver/.cd,pos/.initial=0.35,height/.initial=0}
\begin{document}
\begin{tikzcd}[ampersand replacement=\&]
A \& B
\arrow[curve={height=-12pt}, from=1-1, to=1-2]
\end{tikzcd}
\end{document}
答案1
您忘记加载babel
库了。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french,english]{babel}
\usepackage{tikz-cd}
\usetikzlibrary{calc,babel} % <--- IMPORTANT!
% A TikZ style for curved arrows of a fixed height, due to AndréC.
\tikzset{
curve/.style={
settings={#1},
to path={
(\tikztostart)
.. controls ($(\tikztostart)!\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
and ($(\tikztostart)!1-\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
.. (\tikztotarget)\tikztonodes
},
},
settings/.code={%
\tikzset{quiver/.cd,#1}%
\def\pv##1{\pgfkeysvalueof{/tikz/quiver/##1}}%
},
quiver/.cd,
pos/.initial=0.35,
height/.initial=0,
}
\begin{document}
\begin{tikzcd}[ampersand replacement=\&]
A \& B
\arrow[curve={height=-12pt}, from=1-1, to=1-2]
\end{tikzcd}
\begin{tikzcd}
A & B
\arrow[curve={height=-12pt}, from=1-1, to=1-2]
\end{tikzcd}
\end{document}
不需要ampersand replacement
。