大家早上好。这实际上是我第一次在这里写文章,所以感谢所有回复的人。我正在写我的本科论文,目前我被困在画一台图灵机上。我想做的事情是这样的:
除了我希望第一个节点的左侧(仅左侧,而不是所有 4 条边)非常厚之外。到目前为止,我所做的如下:
\begin{tikzpicture}
\edef\turingtapesize{0.7cm}
\tikzstyle{tape}=[draw,minimum size=\turingtapesize]
\tikzset{
leftmostnode/.style={
draw,minimum size=\turingtapesize,
append after command={% <= for the leftside line of the leftward node
\pgfextra{%
\begin{pgfinterruptpath}
\begin{pgfonlayer}[foreground]
\draw[verythick] (\tikzlastnode.south west)--(\tikzlastnode.north west);
\end{pgfonlayer}
\end{pgfinterruptpath}
}
}
}
}
% Drawing the tape itself
\begin{scope}[start chain=0 going right,node distance=0mm]
\node[on chain=0,tape] (b) {0};
\node[left=of b,leftmostnode](a){1};
\node[on chain=0,tape] (c) {1};
\node[on chain=0,tape] (d) {0};
\node[on chain=0,tape] (e) {1};
\node[on chain=0,tape] (f) {0};
\node[on chain=0,tape] (g) {0};
\node[on chain=0,tape] (h) {1};
\node[on chain=0,tape] (i) {1};
\node[on chain=0,tape] (l) {$\sqcup$};
\node[on chain=0,tape] (l) {$\sqcup$};
\node[on chain=0,tape] (l) {$\sqcup$};
\end{scope}
\end{tikzpicture}
但是我收到一个错误:
抱歉,无法找到请求的层“[”。也许您拼错了?。
\nodeleft=of b,最左边的节点{1};
我是否也可以问你如何得到那种“电锯”般的结尾(这个词真的存在吗?)?谢谢,干杯 ;) 资料来源:1 2
编辑 根据 moospit 的建议,我解决了“厚度问题”。现在我只需要创建那条特殊的锯齿线 ;)
EDIT2 我刚刚看到你的回复。我用一种稍微不同的方法解决了这个问题。我在下面发布了整个 tikz-image 的代码;)
\begin{tikzpicture}
\edef\turingtapesize{0.7cm}
\tikzstyle{tape}=[draw,minimum size=\turingtapesize]
% Drawing the tape itself
\begin{scope}[start chain=0 going right,node distance=0mm]
\node[on chain=0,tape] (a) {1} ;
\node[on chain=0,tape] (b) {0} ;
\node[on chain=0,tape] (c) {1} ;
\node[on chain=0,tape] (d) {0} ;
\node[on chain=0,tape] (e) {1} ;
\node[on chain=0,tape] (f) {0} ;
\node[on chain=0,tape] (g) {0} ;
\node[on chain=0,tape] (h) {1} ;
\node[on chain=0,tape] (i) {1} ;
\node[on chain=0,tape] (l) {$\sqcup$};
\node[on chain=0,tape] (l) {$\sqcup$};
\node[on chain=0,tape] (l) {$\sqcup$};
\node[on chain=0,tape,draw=none](m) {} ;
\node[on chain=0,tape,draw=none](n) {$\ldots$};
% Coordinates
\coordinate(snake1) at ($ (l.north east)!0.5cm!(m.north east) $);
\coordinate(snake2) at ($ (l.south east)!.5cm!(m.south east) $) ;
\draw [-] (l.north east) -- (snake1);
\draw [-] (l.south east) -- (snake2);
\draw[snake=snake,
segment amplitude=.4mm,
segment length=1.75mm,
line after snake=0mm] (snake1) -- (snake2);
\end{scope}
\draw[ultra thick] (a.south west) -- (a.north west) ;
\node[draw,above=0.75cm of e,minimum size=\turingtapesize] (Q) {$q_3$};
\draw[-latex] (Q) -- (e) ;
\end{tikzpicture}
编辑3
\begin{tikzpicture}
\tikzset{tape/.style={minimum size=.7cm, draw}}
\begin{scope}[start chain=0 going right, node distance=0mm]
\foreach \x [count=\i] in {1,0,1,0,1,0,0,1,1,$\sqcup$,$\sqcup$,$\sqcup$} {
\ifnum\i=12 % if last node reset outer sep to 0pt
\node [on chain=0, tape, outer sep=0pt] (n\i) {\x};
\draw (n\i.north east) -- ++(.1,0) decorate [decoration={zigzag, segment length=.12cm, amplitude=.02cm}] {-- ($(n\i.south east)+(+.1,0)$)} -- (n\i.south east) -- cycle;
\else
\node [on chain=0, tape] (n\i) {\x};
\fi
\ifnum\i=1 % if first node draw a thick line at the left
\draw [line width=.1cm] (n\i.north west) -- (n\i.south west);
\fi
}
\node [right=.25cm of n12] {$\cdots$};
\node [tape, above left=.25cm and 1cm of n1] (q3) {$q_3$};
\draw [>=latex, ->] (q3) -| (n5);
\end{scope}
\end{tikzpicture}
最终结果如下:
答案1
那么如何使用你的tape
节点样式a
并在链代码后添加它:
\draw [very thick] (a.south west) -- (a.north west);
或者
\draw [line width=.1cm] (a.south west) -- (a.north west);
这样,您就可以在节点上方添加一条额外的线a
。
编辑:更新链末端的锯齿节点 (MWE)
这里还有一些关于 zigzag-node 的信息。我zigzag
在下面描述的路径的一部分上使用了 -decoration。只需zigzag
segment length
根据您的需要调整和振幅即可。
注意将outer sep
链节点的设置为0
,否则曲折路径将与north east
和south east
坐标产生一些偏移。
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{decorations.pathmorphing, calc}
\begin{document}
\begin{tikzpicture}
\node [draw, outer sep=0pt] (n) {n};
\draw (n.north east) -- ++(.1,0) decorate [decoration={zigzag, segment length=.12cm, amplitude=.02cm}] {-- ($(n.south east)+(+.1,0)$)} -- (n.south east) -- cycle;
\end{tikzpicture}
\end{document}
仅剩一个编辑:无法抗拒 ;)。稍微重写一下代码,让链可以扩展到更多元素:
如果您还有更多问题,请直接提问。如果您愿意,可以轻松更改zigzag
一些内容。snakes
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{calc, chains, decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\tikzset{tape/.style={minimum size=.7cm, draw}}
\begin{scope}[start chain=0 going right, node distance=0mm]
\foreach \x [count=\i] in {1,0,1,10,1,1,1,1,$\sqcup$,$\sqcup$,$\sqcup$} {
\ifnum\i=11 % if last node reset outer sep to 0pt
\node [on chain=0, tape, outer sep=0pt] (n\i) {\x};
\draw (n\i.north east) -- ++(.1,0) decorate [decoration={zigzag, segment length=.12cm, amplitude=.02cm}] {-- ($(n\i.south east)+(+.1,0)$)} -- (n\i.south east) -- cycle;
\else
\node [on chain=0, tape] (n\i) {\x};
\fi
\ifnum\i=1 % if first node draw a thick line at the left
\draw [line width=.1cm] (n\i.north west) -- (n\i.south west);
\fi
}
\node [right=.25cm of n11] {$\cdots$};
\node [tape, above left=.25cm and 1cm of n1] (q7) {$q_7$};
\draw [>=latex, ->] (q7) -| (n5);
\end{scope}
\end{tikzpicture}
\end{document}