2

我正在使用 tikz 在乳胶文档中排版图表。

我有一个“网格图”网格,每个网格图都绘制为单独的 tikz 图片,然后作为节点排列到网格中。

我想在每个网格图的右下角绘制一个圆形节点(最终将包含一个标签)。

我为每个网格图使用完全相同的代码,但每次都在不同的位置绘制圆圈。

我做错了什么,或者这是 tikz 中的错误?特别是,我包含子图片的方法是否允许/标准/良好做法?

请参阅此处获取图像。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\begin{tikzpicture}[scale=1, node distance = .5cm]
  \node (a) at (0,0) {
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.25, -1.25) [fill=white, shape=circle, draw=black] {};
   \end{tikzpicture}
    };
    \node[right=of a] (b) {
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.25, -1.25) [fill=white, shape=circle, draw=black] {};
     \end{tikzpicture}
    };
    \node[below=of a] (c) {
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.25, -1.25) [fill=white, shape=circle, draw=black] {};
     \end{tikzpicture}
    };
    \node[right=of b] (d){
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.2, -1.5) [fill=white, shape=circle, draw=black] {};
     \end{tikzpicture}
    };
    \node[below=of b] (e){
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.25, -1.25) [fill=white, shape=circle, draw=black] {};
     \end{tikzpicture}
    };
    \node[below = of c] (f) {
    \begin{tikzpicture}
     \draw[step=.5cm,gray,very thin] (-0.1,-1.6) grid (1.6, 0.1);
      \node at (1.25, -1.25) [fill=white, shape=circle, draw=black] {};
      \end{tikzpicture}
    };
\end{tikzpicture}
\end{document}
4

1 回答 1

0

我不确定为什么您的示例中的圆圈没有对齐,但这可能与使用of.

我不知道这是否是最佳实践,但您可以使用它foreach来自动化网格构建:

\begin{document}
\begin{tikzpicture}[scale=1]
  \foreach \x in {-0.01cm,2.99cm,5.99cm}
    \foreach \y in {-0.01cm,2.99cm,5.99cm} {
      \draw[step=.5cm,gray,thin] (\x,\y) grid +(1.52cm,1.52cm);
      \draw[fill=white, draw=black] (\x,\y) +(1.255cm,0.25cm) circle (0.2cm);
    }
\end{tikzpicture}
\end{document}

替代文字

于 2010-09-27T19:46:25.113 回答