`edge quotes mid` TikZ 问题

`edge quotes mid` TikZ 问题

当我使用 LuaLaTex 渲染它时:

\documentclass[border=4mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{graphdrawing,graphs} 
\usegdlibrary{layered,trees,circular,force}

\begin{document}

\tikz \graph [spring layout,
edge quotes mid,
edges={nodes={font=\scriptsize, fill=white, sloped, inner sep=1pt}}]
 {
1 ->["Das"] 2 ->["ist"] 3 ->["das"] 4 ->["Haus"]
 2 ->["vom" near start] 5 ->["Ni"] 4 ->["ko" near start]
 1 ->["laus", orient=right] 5;
 };

\end{document}

我收到此错误:

第 8 行:软件包 pgfkeys 错误:我不知道密钥“/tikz/"{Das}"”,我将忽略它。也许您拼错了。

为什么?

答案1

您需要添加tikzlibrary调用quotes才能使用该语法。

\documentclass[border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{graphdrawing,graphs,quotes} % <-- new library added
\usegdlibrary{layered,trees,circular,force}

\begin{document}

\tikz \graph [spring layout,
edge quotes mid,
edges={nodes={font=\scriptsize, fill=white, sloped, inner sep=1pt}}]
 {
1 ->["Das"] 2 ->["ist"] 3 ->["das"] 4 ->["Haus"]
 2 ->["vom" near start] 5 ->["Ni"] 4 ->["ko" near start]
 1 ->["laus", orient=right] 5;
 };

\end{document}

在此处输入图片描述

相关内容