大家早安。其實這是我第一次在這裡寫文章,所以我感謝所有願意回覆的人。我正在寫本科論文,目前正致力於繪製圖靈機。我想做的是這樣的:
除了我想讓第一個節點的左側(只有左側,而不是所有 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=b 的最左邊節點 {1};
我還可以問你如何獲得那種“電鋸”(這個術語存在嗎?)的磁帶末端?謝謝,乾杯;)來源:1 2
編輯按照 moospit 的建議,我解決了「厚度問題」。現在只剩下我來創造那條特殊的鋸齒線了;)
EDIT2 我剛剛看到你的回覆。我以稍微不同的方式解決了這個問題。
\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
在下面描述的路徑的一部分上使用了 -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}