Short question
After a \clip
and a \pgfresetboundingbox
, the bounding box is permanently (0,0)rectangle(0,0)
. How can I turn on the bounding-box calculation and obtain a fairly small bounding box?
The story
The example below
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz{
\clip circle(10);
\pgfresetboundingbox
\fill circle(10);
% \useasboundingbox(-10,-10)(10,10); % makes no difference
}
\end{document}
results in
where the rectangle is the US-letter paper from article
and the center of the circle is approximately the starting point of normal documents. This shows that \pgfresetboundingbox
resets the bounding box, as expected. However, a normal path does not repair it. Neither does an explicit \useasboundingbox
.
The question is:
After a
\clip
and a\pgfresetboundingbox
,
How can I turn on the calculation of bounding box?
Recall that in everyday usage, the code with \pgfresetboundingbox
will always give a smaller or equal bounding box than that without \pgfresetboundingbox
. In the case above, it does give me a smaller bounding box. (just too small)
Therefore I expect that if somehow we can turn the calculation on, it should not give a bounding box that is larger than that without \pgfresetboundingbox
.
In other words,
After a
\clip
and a\pgfresetboundingbox
,
How can I turn on the calculation of bounding box
such that it is the smallest but contains everything visible?
\tikz{
\clip(5,0)--(-4,-4)--(0,5)--cycle;
\pgfresetboundingbox
\fill(-5,0)--(4,4)--(0,-5)--cycle;
}
should give me
where the hidden parts are
Possible application
The following code generate bad right border. (beacuse of the control point)
\tikz{
\fill(0,-1)..controls(10,0)..(0,1);
}
It would be good if we can apply some clipping only on right border.
% Caution! imaginary code
\tikz[clip right at x=7]{
\fill(0,-1)..controls(10,0)..(0,1);
}
which is implemented by inserting
\clip(-\maxdimen,-\maxdimen)rectangle(7,\maxdimen);
\pgfresetboundingbox
Remark
If two clippings are issued consecutively, the bounding box should be even smaller.