tikz-cd 中的弯曲箭头不起作用

tikz-cd 中的弯曲箭头不起作用

我正在使用 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

在此处输入图片描述

答案2

我不知道该怎么做curve,但是为什么不使用简单的弯道(左弯道或右弯道)?

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

\begin{document}
\begin{tikzcd}[ampersand replacement=\&,column sep=2.25em]
    A \& B
    \arrow[bend right, from=1-1, to=1-2]
\end{tikzcd}
\end{document}

在此处输入图片描述

相关内容