为什么这两个矩形不重合?

为什么这两个矩形不重合?

以下是 tikz 的代码:

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

\begin{document}
\begin{tikzpicture}[x=.8mm, y=30mm][remember picture]
\tikzstyle{reverseclip}=[insert path={
  (current page.north east) --
  (current page.south east) --
  (current page.south west) --
  (current page.north west) --
  (current page.north east)}
]
\coordinate (lowerleft) at (-2mm, 2mm);
\coordinate (upperright) at (120, 2.6);

    % \input{pts}
% \path [fill=orange, draw=orange] (lowerleft) rectangle (upperright);
\fill [orange] (lowerleft) rectangle (upperright);

\begin{pgfinterruptboundingbox}
\path  [clip] (20, 1) circle [radius=2mm] [reverseclip];
\path  [clip] (30, 1.5) circle [radius=2mm] [reverseclip];
\path  [clip] (40, 1.3) circle [radius=2mm] [reverseclip];
\end{pgfinterruptboundingbox}

% \path [fill=white, draw=white] (lowerleft) rectangle (upperright);
\fill [white] (lowerleft) rectangle (upperright);
% \draw [help lines, opacity=.2] (lowerleft) grid (upperright);
    \end{tikzpicture}
\end{document}

结果:

在此处输入图片描述

我希望第二个矩形能够完全覆盖第一个矩形(除了 3 个圆形点以外)。

答案1

[remember picture]选项仅对环境有效tikzpicture。因此,您必须将其放在环境的选项中tikzpicture

\begin{tikzpicture}[x=.8mm, y=30mm,remember picture]

结果(之后汇编):

在此处输入图片描述

完整代码:

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

\begin{document}
\begin{tikzpicture}[x=.8mm, y=30mm,remember picture]
\tikzstyle{reverseclip}=[insert path={
  (current page.north east) --
  (current page.south east) --
  (current page.south west) --
  (current page.north west) --
  (current page.north east)}
]
\coordinate (lowerleft) at (-2mm, 2mm);
\coordinate (upperright) at (120, 2.6);

    % \input{pts}
% \path [fill=orange, draw=orange] (lowerleft) rectangle (upperright);
\fill [orange] (lowerleft) rectangle (upperright);

\begin{pgfinterruptboundingbox}
\path  [clip] (20, 1) circle [radius=2mm] [reverseclip];
\path  [clip] (30, 1.5) circle [radius=2mm] [reverseclip];
\path  [clip] (40, 1.3) circle [radius=2mm] [reverseclip];
\end{pgfinterruptboundingbox}

% \path [fill=white, draw=white] (lowerleft) rectangle (upperright);
\fill [white] (lowerleft) rectangle (upperright);
% \draw [help lines, opacity=.2] (lowerleft) grid (upperright);
    \end{tikzpicture}
\end{document}

相关内容