0

I'm trying to use TikZ to draw the following figure, I'm sure that the commands are correct but I obtain the following error:

"! Package pgfkeys Error: I do not know the key '/tikz/closed' and I am going to ignore it. Perhaps you misspelled it."

Can anyone help me with this problem?

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,shapes.geometric}
\colorlet{myred}{red!60!black}
\colorlet{mygreen}{green!40!black}
\usetikzlibrary{shapes,arrows}
\usepackage{pgfplots}
\usepgfplotslibrary{units}


\begin{document}

\begin{tikzpicture}
\draw[thick,->] (52,0) -- (60,0) node[anchor=north west] {$x'$};
\draw[thick,->] (56,-03) -- (56,03) node[anchor=south east] {$x_N$};
\node[draw=red,dashed,thick,semicircle,minimum width=4cm] (n) at (56,0.8) {};
\node[draw=blue, dashed,thick,semicircle,minimum width=2cm] (n2) at (56,0.4) {};
\node[draw=green,circle,minimum width=4cm] (n3) at (56,0) {};


\draw (56,0) node[below right] {$O$} node{$\bullet$};
\draw (58,0) node[below right] {\color{red} $1$} node{};
\draw (54,0) node[below left] {\color{red} -$1$} node{};
\draw (56.8,0) node[below right] {\color{blue} $r$} node{};
\draw (55.3,0) node[below left] {\color{blue} -$r$} node{};


\draw[red, ->] (n.400) -- +(0.7,0.3) node[pos=1.7]{\color{red} $I^{+}(1)$};
\draw[green, ->] (n3.300) -- +(0.7,-0.3) node[pos=1.5]{\color{green}$I(1)$};
\draw[red, ->] (n.210) -- +(-0.7,-2.3) node[pos=1.2]{\color{red}$\Gamma_1$};
\draw[blue, ->] (n2.320) -- +(0.2,-0.5) node[pos=1.5]{\color{blue}$\Gamma_{r}$};



\node[draw,circle,minimum width=2cm] (n1) at (50,3) {};
\begin{scope}
\clip[draw](48,1) to[closed,curve through={(50,3) -- (52,4) -- (51,6) -- (47,6) -- (46.6,5) -- (45,3.8) }] (48,1);
\node[draw,circle,fill=magenta,minimum width=2cm] (n1) at (50,3) {};
\end{scope}
\node[inner sep=1pt,fill,circle,label={below right: $x_0$}] at (50,3){};
\draw[->,shorten <= -4mm] (n1.90) -- +(0.7,0.7) node[pos=1.3]{$\Omega_1 \cap \Omega$};
\draw[->] (51,6) -- +(0.7,0.3) node[pos=1.3]{$\Omega$};
\draw[->] (n1.300) -- +(0.7,-0.3) node[pos=1.3]{$\Omega_1$};
\draw[->] (n1.10) to[bend left] node[midway,below]{$\tau$} (n.120);
\end{tikzpicture}

\end{document}
10
  • 1
    If you are sure the commands are right, why are you asking us? In that case, it would presumably mean something screwed up with your TeX installation. But why are you so sure they are right?
    – cfr
    Commented Jul 4, 2016 at 19:43
  • Where you find option closed? If it exist, than in your MWE is missing some library
    – Zarko
    Commented Jul 4, 2016 at 19:44
  • \clip[draw](48,1) to[closed,curve through={(50,3) -- (52,4) -- (51,6) -- (47,6) -- (46.6,5) -- (45,3.8) }] (48,1); I use the closed here, and i'm sure that it is correct because use the same command with the same figure but with less details. and you can find it here tex.stackexchange.com/questions/197094/…
    – Student
    Commented Jul 4, 2016 at 19:45
  • Do you use LuaLateX?
    – Zarko
    Commented Jul 4, 2016 at 19:48
  • No, i'm using Texmaker
    – Student
    Commented Jul 4, 2016 at 19:49

1 Answer 1

7

After answering this, I discovered that the OP already got an answer to this question in the follow-up comments on Harish Kumar's answer to an earlier question. In fact, my answer below was perfectly well known to the OP. I'm not certain what the real question here is, but I'm sure it is not the one asked and which I answered.

[Perhaps the question should be, how can this be done without Hobby? Or perhaps it should be, how can I install Hobby? The second would be a duplicate unless there's some specific further problem, of course.]

There are two problems. The first is that you have not loaded the hobby library but are trying to use its options. The second is that you cannot use -- in curve through. See the Hobby manual for details.

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{shapes.geometric,hobby}
\begin{document}
\begin{tikzpicture}
  \draw[thick,->] (52,0) -- (60,0) node[anchor=north west] {$x'$};
  \draw[thick,->] (56,-03) -- (56,03) node[anchor=south east] {$x_N$};
  \node[draw=red,dashed,thick,semicircle,minimum width=4cm] (n) at (56,0.8) {};
  \node[draw=blue, dashed,thick,semicircle,minimum width=2cm] (n2) at (56,0.4) {};
  \node[draw=green,circle,minimum width=4cm] (n3) at (56,0) {};

  \draw (56,0) node[below right] {$O$} node{$\bullet$};
  \draw (58,0) node[below right] {\color{red} $1$} node{};
  \draw (54,0) node[below left] {\color{red} -$1$} node{};
  \draw (56.8,0) node[below right] {\color{blue} $r$} node{};
  \draw (55.3,0) node[below left] {\color{blue} -$r$} node{};

  \draw[red, ->] (n.400) -- +(0.7,0.3) node[pos=1.7]{\color{red} $I^{+}(1)$};
  \draw[green, ->] (n3.300) -- +(0.7,-0.3) node[pos=1.5]{\color{green}$I(1)$};
  \draw[red, ->] (n.210) -- +(-0.7,-2.3) node[pos=1.2]{\color{red}$\Gamma_1$};
  \draw[blue, ->] (n2.320) -- +(0.2,-0.5) node[pos=1.5]{\color{blue}$\Gamma_{r}$};

  \node[draw,circle,minimum width=2cm] (n1) at (50,3) {};
  \begin{scope}
    \clip[draw](48,1) to[closed,curve through={(50,3) .. (52,4) .. (51,6) .. (47,6) .. (46.6,5) .. (45,3.8) }] (48,1);
    \node[draw,circle,fill=magenta,minimum width=2cm] (n1) at (50,3) {};
  \end{scope}
  \node[inner sep=1pt,fill,circle,label={below right: $x_0$}] at (50,3){};
  \draw[->,shorten <= -4mm] (n1.90) -- +(0.7,0.7) node[pos=1.3]{$\Omega_1 \cap \Omega$};
  \draw[->] (51,6) -- +(0.7,0.3) node[pos=1.3]{$\Omega$};
  \draw[->] (n1.300) -- +(0.7,-0.3) node[pos=1.3]{$\Omega_1$};
  \draw[->] (n1.10) to[bend left] node[midway,below]{$\tau$} (n.120);
\end{tikzpicture}
\end{document}

hobby code

9
  • Ok, thank you, but i have a problem in how to use the hobby, when i use hobby i have error.
    – Student
    Commented Jul 4, 2016 at 19:54
  • when i use the Hobby i get the ollowing error ! Package tikz Error: I did not find the tikz library 'hobby'. I looked for fil es named tikzlibraryhobby.code.tex and pgflibraryhobby.code.tex, but neither co uld be found in the current texmf trees.. @cfr
    – Student
    Commented Jul 4, 2016 at 19:56
  • So you undid your upvote because my answer points out what you already knew when you asked this question from Harish Kumar i.e. that this depends on Hobby? What did you expect? I now realise that answering this question was pointless because it was not a question to which you wanted to know the answer.
    – cfr
    Commented Jul 4, 2016 at 19:59
  • As I say above, Hobby is a third-party library. Use the package manager provided by your TeX distribution or by your OS if you need to install it. This is just the same for any other package.
    – cfr
    Commented Jul 4, 2016 at 20:01
  • 1
    If you do not have expl3.sty then there are 2 possibilities. One is that your installation of TeX is very outdated. (This file is present in TeX Live 2011.) Or you have a quite partial installation of TeX and you've not configured MikTeX for on-the-fly package installation. [A third possibility is that your installation is screwed up, but I'm guessing the very-partial is more likely.] I recommend asking for help with MikTeX in chat because this is not something I know really anything about. Even if it were TeX Live, I'd be pretty lost on Windows. Unix-like I get. Windows is Mystery Itself.
    – cfr
    Commented Jul 5, 2016 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .