Is there a way to crop everything outside the bounding box?

I made some periodic pattern in TikZ but I wanna crop it outside some box. Just making a bounding box helps for the alignment but the pattern still repeats outside the box.

up vote 14 down vote accepted

Simply use the \clip macro or \path [clip] and draw your bounding box, e.g. using \clip (lower left coordinate) rectangle (upper right coordinate). You can access the bounding box of everything drawn so far using the current bounding box shape: \clip (current bounding box.south west) rectangle (current bounding box.north east);. You need to do so before you apply the pattern, I think. If you already use \useasboundingbox or the equivalent \path [use as bounding box] then you can simply add the clip option to it.

If you only want to clip some drawing commands place them with the \clip into a scope environment. 

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.