我怎样才能使路径图片变大?

我怎样才能使路径图片变大?

可能重复:
我应该如何绘制单/双链表?

我目前正在尝试创建一个链接列表像这个: 在此处输入图片描述

这是我目前的尝试:

在此处输入图片描述

我错过的是箭头起始处的点和每个列表元素的第二个框。

这是我的尝试:

\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}

\usepackage{tikz}
\usetikzlibrary{trees,arrows,positioning, calc} 

\tikzset{
    squarecross/.style={
        draw, fill=black!20, rectangle,minimum size=18pt,
        inner sep=0pt, text=black,
        path picture = {
            \draw[black]
            (path picture bounding box.north west) -- 
            (path picture bounding box.south east) --
            (path picture bounding box.south west) -- 
            (path picture bounding box.north east);
        }
    },
    listelement/.style={
        draw, fill=black!20, rectangle,minimum size=18pt,
        inner sep=0pt, text=black,
        path picture = {% 
            \draw[black]
            ($(path picture bounding box.north west)$) --
            ($(path picture bounding box.north west)+(1,0)$) --
            ($(path picture bounding box.south west)+(1,0)$) -- 
            ($(path picture bounding box.south west)$);
        }
    }
}

\usetikzlibrary{trees,arrows,positioning, calc}

\begin{document}
\begin{preview}
\begin{tikzpicture}[font=\sffamily,very thick]
\node [listelement] (a) {12};
\node [listelement] (b) [right=of a] {99};
\node [listelement] (c) [right=of b] {37};
\node [squarecross] (d) [right=of c] {};
\draw [->] (a) -- (b);
\draw [->] (b) -- (c);
\draw [->] (c) -- (d);
\end{tikzpicture}
\end{preview}
\end{document}

我该如何让它工作?为什么以下部分不起作用?

path picture = {% 
    \draw[black]
    ($(path picture bounding box.north west)$) --
    ($(path picture bounding box.north west)+(1,0)$) --
    ($(path picture bounding box.south west)+(1,0)$) -- 
    ($(path picture bounding box.south west)$);
}

答案1

路径图片用于将图片放在路径区域内,因此当您在路径区域外绘制某些内容时,它们会被剪裁掉。只是为了说明缩放

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc} 

\tikzset{
    listelement/.style={
        draw, fill=black!20, rectangle,minimum size=5mm,
        inner sep=0pt, text=black,
        path picture = {%
        \pgftransformscale{3}
            \draw[black]
            ($(path picture bounding box.north west)$) rectangle ++(1mm,-1mm);
        }
    }
}
\begin{document}
\begin{tikzpicture}[font=\sffamily,very thick]
\node [listelement] (a) {12};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容