Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local bounding box seems to ignore overlay option #858

Closed
ghost opened this issue May 23, 2020 · 5 comments
Closed

Local bounding box seems to ignore overlay option #858

ghost opened this issue May 23, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented May 23, 2020

I hope that this is just me seeing ghosts, or there is a reason for this behavior. According to what I find, the local bounding box now includes paths that are drawn in the overlay mode. I believe that this was not the case before version 3.1.5.

Let us look at the example

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
 \begin{scope}[local bounding box=test]
  \draw (0,0) circle[radius=1cm];
  \draw[overlay] (1,2) circle[radius=1cm];
 \end{scope}
 %\draw (test.south west) rectangle (test.north east);
\end{tikzpicture}
\end{document}

Screen Shot 2020-05-22 at 9 56 27 PM

The result is as expected. The overlay circle at (1,2) gets (partially) clipped away.

However, when I draw the boundary of the local bounding box, i.e. when I uncomment

\draw (test.south west) rectangle (test.north east);

I get

Screen Shot 2020-05-22 at 9 58 49 PM

and with

\draw[overlay] (test.south west) rectangle (test.north east);

Screen Shot 2020-05-22 at 9 59 47 PM

That is, the local bounding box captures the second circle even though it is drawn in the overlay mode.

I do see that this behavior can make sense, yet it seems to be different from the previous behavior. So if this is now the new "correct" behavior one may want to add this information to the manual.

@hmenke
Copy link
Member

hmenke commented May 23, 2020

This is a documented breaking change of PGF 3.1.5. Quoting from the release notes:

It turned out that in \pgf@protocolsizes the \pgf@path@size@hook was executed only if the picture was actually to be placed. This led to the problem that the local bounding box was not updated correctly (#795). To correct this, the hook is now executed unconditionally.

@hmenke
Copy link
Member

hmenke commented May 23, 2020

Try this:

\makeatletter
\tikzset{
  overlay/true/.code={%
    \pgf@relevantforpicturesizefalse
    \pgf@size@hookedfalse
  },
  overlay/false/.code={%
    \pgf@relevantforpicturesizetrue
    \pgf@size@hookedtrue
  },
}
\makeatother

@ghost
Copy link
Author

ghost commented May 23, 2020

@hmenke Thanks! I think it would make sense to add this information also to the manual. One could write just above the code example before section 107.5 Declaring New Shapes

Note that the local bounding box also includes paths that are created in the overlay mode, i.e. paths that are excluded from bounding box of the tikzpicture. This can lead to the curious effect that the bounding box of the picture changes when one just uses nodes of the local bounding box in a path.

@hmenke
Copy link
Member

hmenke commented May 23, 2020

It would make a lot more sense to revert 03b8912 and fix #795 properly.

@hmenke hmenke closed this as completed May 23, 2020
@hmenke
Copy link
Member

hmenke commented May 23, 2020

Fixed in ca1f30e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant