3

I have a predefined geometry \big_area and want to fill it out cutting another predefined piece \cut_this_out from it. And I want to cut a whole "scope" from it and not an explicit definition of a shape.

\def \cutout {(0,0) --++ (3.5,0) --++ (0,7) --++ (-3.5,0) --++(0,-7)}

\def \mycircle {(0,0) circle (10)}


\begin{tikzpicture}


%This works
\fill[even odd rule] \mycircle \cutout;

%This doesn't work
%\fill[even odd rule] \mycircle \begin{scope}[xshift=1cm] \cutout \end{scope};


\end{tikzpicture}

How do I do this?

6
  • 1
    'And' we want a complete minimal working example. :) – CroCo Dec 12 '15 at 22:23
  • That may be what you want but I strongly suspect that you cannot have it. A complete minimal example might enable somebody to suggest an alternative. Without that, I doubt anybody can be of much help. – cfr Dec 12 '15 at 22:37
  • I added a working minimal code – Caniko Dec 12 '15 at 22:49
  • That's not a minimal example. Please provide a minimal example which can be used to reproduce the problem you want help with i.e. copy-paste-compile and get a problem to work on. Your code will not compile, so cannot possibly count as a suitable minimal example. (Nor will it produce an error you are asking about when an attempt is made to compile it.) – cfr Dec 13 '15 at 2:19
  • Well, I guess you can put a scope in the middle of a path, after all. I didn't realise that \draw[fill, even odd rule] (0,0) circle (3) {[shift={(1cm,1cm)}](0,0) circle (1)}; would work. Interesting. But then I don't see why this doesn't answer the question. – cfr Dec 13 '15 at 2:24
4

One option with scopes library

%\usetikzlibrary{scopes} %<---- Somewhere in the preamble

\begin{tikzpicture}
\def\big_area{(0,0) circle (3)}
\def\cut_this_out{(0,0) circle (1)}
%\draw[fill, even odd rule] \big_area \cut_this_out;

\draw[fill, even odd rule] \big_area {[shift={(3cm,2cm)}]\cut_this_out};
\end{tikzpicture}

For your own sanity, don't use underscores in TeX macro names.

5
  • you mean \draw[fill, even odd rule] \big_area [shift={(3cm,2cm)}]\cut_this_out}; – Caniko Dec 12 '15 at 22:54
  • Still I don't love this solution...I want to make another stuff with it. Scale..anchor..styles...I would love to have a fully working scope.. – Caniko Dec 12 '15 at 22:56
  • @Caniko No brace starts before [shift... and if you don't ask what you want you don't get it. Not my problem what you love. – percusse Dec 12 '15 at 23:36
  • I clearly asked to cut a whole "scope". and not to shift anything. What you suggested is a workaround for my minimal example. But the question is clearly asked I think. I upvoted your post. But it's not the solution I imagine. If there's no solution the way I imagine, it's absolutely ok. – Caniko Dec 12 '15 at 23:48
  • @Caniko Which exactly does that. Did you add the scopes library and compiled what I wrote? You changed your question with the shift. I don't get what you are trying to do. – percusse Dec 13 '15 at 0:21
3

Why can't you just do this? That is, why do you need a scope at all? It certainly isn't required for the examples you've given.

\documentclass[tikz,border=10pt,multi]{standalone}
\begin{document}
\begin{tikzpicture}
  \draw[fill, even odd rule] (0,0) circle (3) [shift={(1cm,1cm)}](0,0) circle (1);
\end{tikzpicture}
\def \cutout {(0,0) --++ (3.5,0) --++ (0,7) --++ (-3.5,0) --++(0,-7)}
\def \mycircle {(0,0) circle (10)}
\begin{tikzpicture}
  \fill[even odd rule] \mycircle [xshift=1cm]\cutout;
\end{tikzpicture}
\end{document}

cut out circle

cut out rectangle

1
  • 1
    @CroCo I don't think it is originally. I think I copied it from the question ;). – cfr Dec 13 '15 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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