我有以下内容
\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usepackage[margin=0cm,nohead]{geometry}
\usepackage[active,tightpage]{preview}
\usetikzlibrary{shapes,arrows}
% needed for BB
\usetikzlibrary{calc}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.pathreplacing}
\pgfdeclarepatternformonly[\GridSize]{MyCircleGrid}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{\GridSize}{\GridSize}}{\pgfqpoint{\GridSize}{\GridSize}}%
{
\pgfsetlinewidth{0.5pt}
\pgfsetstrokecolor{blue!80!black}
%\pgfpathqcircle{7pt}
\pgfpathcircle\pgfpointorigin{7pt}
%\pgfusepath{stroke}
\pgfusepathqstroke
}
\newdimen\GridSize
\tikzset{
GridSize/.code={\GridSize=#1},
GridSize=3pt
}
\begin{document}
\begin{tikzpicture}
\draw [GridSize=10 pt,pattern=MyCircleGrid] (0,-4.5) rectangle (-7.5,-1.5);
\draw [thick] (-7.5,-3) -- (0,-3);
\draw (-7.5,3.5) rectangle (0,-1.5);
\begin{scope}
\clip (-7.5,3.5) rectangle (0,-1.5);
\draw (-7.5,-1) ellipse (0.5 and 0.5);
\draw (0,-1) ellipse (0.5 and 0.5);
\draw (-7,-1) ellipse (0.5 and 0.5);
\draw (-6,-1) ellipse (0.5 and 0.5);
\draw (-4,-1) ellipse (0.5 and 0.5);
\draw (-3,-1) ellipse (0.5 and 0.5);
\draw (-5,-1) ellipse (0.5 and 0.5);
\draw (-2,-1) ellipse (0.5 and 0.5);
\draw (-1,-1) ellipse (0.5 and 0.5);
\draw (-7.5,2) ellipse (1.5 and 1.5);
\draw (-3.5,2.5) ellipse (2 and 2);
\draw (-5.5,2.5) ellipse (2 and 2);
\draw (-1,2.5) ellipse (2 and 2);
\draw (-5.5,0) ellipse (1 and 1);
\draw (-7,0) ellipse (1 and 1);
\draw (-4,0) ellipse (1 and 1);
\draw (-0.5,0) ellipse (1 and 1);
\draw (-2.5,0) ellipse (1 and 1);
\draw (-1,0) ellipse (1 and 1);
\end{scope}
\draw (-6.5,-1.5) ellipse (0.5 and 0.5);
\draw (-7,-1.5) ellipse (0.5 and 0.5);
\draw (-5,-1.5) ellipse (0.5 and 0.5);
\draw (-4.5,-1.5) ellipse (0.5 and 0.5);
\draw (-4,-1.5) ellipse (0.5 and 0.5);
\draw (-3.5,-1.5) ellipse (0.5 and 0.5);
\draw (-3,-1.5) ellipse (0.5 and 0.5);
\draw (-6,-1.5) ellipse (0.5 and 0.5);
\draw (-5.5,-1.5) ellipse (0.5 and 0.5);
\draw (-1,-1.5) ellipse (0.5 and 0.5);
\draw (-2,-1.5) ellipse (0.5 and 0.5);
\draw (-0.5,-1.5) ellipse (0.5 and 0.5);
\draw (-2.5,-1.5) ellipse (0.5 and 0.5);
\draw (-1.5,-1.5) ellipse (0.5 and 0.5);
\draw [decorate,decoration={brace,amplitude=10pt}] (0.5,3.5) -- (0.5,-1.5) node [black,midway,xshift=25pt] {\footnotesize
$X\setminus Z$};
\draw [decorate,decoration={brace,amplitude=10pt}] (-8,-4.5) -- (-8,-1.5) node [black,midway,xshift=-25pt] {\footnotesize
$N_\rho(Z)$};
\draw [decorate,decoration={brace,amplitude=10pt}] (0.5,-3) -- (0.5,-4.5) node [black,midway,xshift=17pt] {\footnotesize
$Z$};
\end{tikzpicture}
\end{document}
我期望它产生这样的结果:
但在生成的 pdf 中我得到了这个
我究竟做错了什么?
答案1
该图块由一个位于原点的圆组成,半径为 7 pt,线宽为 0.5 pt。这将形成一个边界框“(-7.25 pt, -7.25 pt) 矩形 (7.25 pt, 7.25 pt)”。
但论点是:
\pgfdeclarepatternformonly[\GridSize]{MyCircleGrid}
{\pgfqpoint{-1pt}{-1pt}}% Lower left corner of the bounding box
{\pgfqpoint{\GridSize}{\GridSize}}% Upper right corner of the bounding box
{\pgfqpoint{\GridSize}{\GridSize}}% Tile size
如果\GridSize
大于 7.25 pt(示例中使用 10 pt),那么您将获得圆的右上象限(左侧和底部稍微多 1pt)。
如果你想拥有满的圆,需要指定一个覆盖整个圆的边界框。
但是图块尺寸可以更小。这样,局限于边界框的图块将部分打印在图块外部。
圆的总宽度和高度为 14.5 pt。使用 10 pt 的图块大小将导致圆重叠:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\newdimen\GridSize
\tikzset{
GridSize/.code={\GridSize=#1},
GridSize=3pt
}
\pgfdeclarepatternformonly[\GridSize]{MyCircleGrid}
{\pgfqpoint{-7.25pt}{-7.25pt}}% Lower left corner of bounding box
{\pgfqpoint{7.25pt}{7.25pt}}% Upper right corner of bounding box
{\pgfqpoint{\GridSize}{\GridSize}}% Tile size
{
\pgfsetlinewidth{0.5pt}
\pgfsetstrokecolor{blue!80!black}
%\pgfpathqcircle{7pt}
\pgfpathcircle\pgfpointorigin{7pt}
%\pgfusepath{stroke}
\pgfusepathqstroke
}
\begin{document}
\begin{tikzpicture}
\draw [GridSize=10 pt,pattern=MyCircleGrid] (0,-4.5) rectangle (-7.5,-1.5);
\end{tikzpicture}
\end{document}