我正在尝试使用创建节点tikzmark
,但由于某种原因,它生成了一个错误,据说我正在从包提供的手册示例中复制。
客观的
\documentclass[a5paper,twoside,openany]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[11names,table,dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,tikzmark}
%\newcommand{\tikzmark}[3][]{\tikz[overlay,remember picture,baseline] \node [anchor=base,#1](#2) {#3};}
\begin{document}
\begin{frame}
\textcolor{blue}{function} (\tikzmark{a} argument0, \tikzmark{b} argument1, \tikzmark{c} argument2, \tikzmark{d}argument3, \tikzmark{e}argument4 )
\begin{itemize}
\item \tikzmark{e} Argument0 Note
\item \tikzmark{f} Argument1 Note
\item \tikzmark{g} Argument2 Note
\item \tikzmark{h} Argument3 Note
\end{itemize}
\begin{tikzpicture}[remember picture, overlay]
\draw[->] (a) -- (e);
\draw[->] (b) -- (f);
\draw[->] (c) -- (g);
\draw[->] (d) -- (h);
\end{tikzpicture}
\end{frame}
\end{document}
错误
>l.97 \tikzmark
{a}argument0, \tikzmark{b}argument1, \tikzmark{c}argument2, \tikzmark{d}argument3 ...
Dimensions can be in units of em, ex, in, pt, pc,
cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one!
I'll assume that you meant to say pt, for printer's points.
To recover gracefully from this error, it's best to
delete the erroneous units; e.g., type `2' to delete
two letters. (See Chapter 27 of The TeXbook.)
! Argument of \language@active@arg> has an extra }.
<inserted text>
\par
l.107 \draw[->]
(a) -- (e);
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.
Runaway argument?
! Paragraph ended before \language@active@arg> was complete.
<to be read again>
\par
l.107 \draw[->]
(a) -- (e);
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
! TeX capacity exceeded, sorry [input stack size=5000].
\@restorepar ->\def \par
{\@par }
l.107 \draw[->]
(a) -- (e);
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
是否有类似的包来创建这些类型的节点?
答案1
主要问题在于您对框架环境的使用。如果这是基于文档中的示例,那么我怀疑它是基于使用 beamer 的示例(我能找到的最接近的示例是其首次使用的历史部分中的示例,这不是一个有效示例,但作为其历史的一部分存在)。由于您没有使用 beamer,因此您应该删除框架环境。
那么,关于如何使用 tikmark,还存在第二个问题。当引用使用 tikzmarks 定义的位置时,您需要使用语法pic cs:mark
。
\documentclass[a5paper,twoside,openany]{book}
%\url{https://tex.stackexchange.com/q/604923/86}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[11names,table,dvipsnames,svgnames]{xcolor}
\usepackage[scale=.8]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,tikzmark}
\begin{document}
\noindent\textcolor{blue}{function} (\tikzmarknode{a}{argument0}, \tikzmarknode{b}{argument1}, \tikzmarknode{c}{argument2}, \tikzmarknode{d}{argument3}, \tikzmarknode{e}{argument4})
\vspace*{\baselineskip}
\begin{itemize}
\item \tikzmark{f} Argument0 Note
\item \tikzmark{g} Argument1 Note
\item \tikzmark{h} Argument2 Note
\item \tikzmark{i} Argument3 Note
\item \tikzmark{j} Argument4 Note
\end{itemize}
\begin{tikzpicture}[remember picture, overlay]
\draw[->] (a.south) -- ++(0,-.2) -| ($(pic cs:f)+(-.7,3pt)$) -- ++(.2,0);
\draw[->] (b.south) -- ++(0,-.3) -| ($(pic cs:g)+(-.8,3pt)$) -- ++(.3,0);
\draw[->] (c.south) -- ++(0,-.4) -| ($(pic cs:h)+(-.9,3pt)$) -- ++(.4,0);
\draw[->] (d.south) -- ++(0,-.5) -| ($(pic cs:i)+(-1,3pt)$) -- ++(.5,0);
\draw[->] (e.south) -- ++(0,-.6) -| ($(pic cs:j)+(-1.1,3pt)$) -- ++(.6,0);
\end{tikzpicture}
\end{document}
(我添加了该geometry
包,因为文本宽度对于初始行来说不够function
。)
答案2
为了好玩,获得该图形的方法是pstricks
:
\documentclass[a5paper,twoside,openany]{book}
\usepackage[T1]{fontenc}
\usepackage[11names,table,dvipsnames,svgnames]{xcolor}
\usepackage{pst-node}
\begin{document}
\textcolor{blue}{function} (\rnode{a}{argument0}, \rnode{b}{argument1}, \rnode{c}{argument2}, \rnode{d}{argument3}, \rnode{e}{argument4})\vskip 8ex
\begin{itemize}
\item \pnode[0,0.5ex]{f} Argument0 Note
\item \pnode[0,0.5ex]{g} Argument1 Note
\item \pnode[0,0.5ex]{h} Argument2 Note
\item \pnode[0,0.5ex]{i} Argument3 Note
\item \pnode[0,0.5ex]{j} Argument4 Note
\end{itemize}
\psset{linewidth=0.6pt, linearc=0.08, angleA=-90,angleB=180, nodesepB=0.5\leftmargini}
\foreach \s/\t/\arm in {a/f/1em, b/g/1.5em, c/h/2em, d/i/2.5em, e/j/3em}{\ncangles[ arm=\arm]{\s}{\t}}
\end{document}