10

How do I draw the same picture as a node in figure 1 as with just tikz (to the left)?

enter image description here

This is what I'm trying to do:

enter image description here

\documentclass{article}
\usepackage{float}
\usepackage{tikz}

\tikzset{ remember picture,
SYMBOL/.style = {rectangle,
%line width=1pt,
draw,
semithick,
align=center,
label={below:#1},
label={center:\usebox\symbolI},
minimum size=0.5cm
},
}

\newsavebox\symbolI
\savebox\symbolI{%
\tikz\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,-0.1)ellipse (0.2cm and 0.1cm);
\tikz\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0)ellipse (0.2cm and 0.1cm);%
\tikz\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0.1)ellipse (0.2cm and 0.1cm);%
}
\begin{document}
\begin{tikzpicture}
    \filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,-0.1)ellipse (0.2cm and 0.1cm);
                 \filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0)ellipse (0.2cm and 0.1cm);%
                         \filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0.1)ellipse (0.2cm and 0.1cm);%
\end{tikzpicture}

\begin{figure}[H]
    \centering
        \begin{tikzpicture}
    \node[SYMBOL] {};
\end{tikzpicture}
    \caption{Signs}
\end{figure}

\end{document}
2
  • Do the 3 ellipses have to be placed in a box whose edges are traced?
    – AndréC
    Commented Aug 16, 2020 at 11:23
  • I did not understand your question but I edited the post with what I'm trying to do
    – TheWorker
    Commented Aug 16, 2020 at 11:28

4 Answers 4

10

Instead of using the labels that are used to add a node around the main node, just use the node contents key to fill the node by leaving the braces empty: \node[SYMBOL] {};

screenshot

\documentclass{article}
\usepackage{float}
\usepackage{tikz}

\tikzset{SYMBOL/.style = {%
%line width=1pt,% <-- useless with semithick
draw,
semithick,
inner sep=4pt,% <-- invisible separation space of 4pt inside the shape
node contents={\usebox\symbolI},%<-- sets the contents of the node
%minimum size=0.5cm %<-- useless
}
}

\newsavebox\symbolI
\savebox\symbolI{%
\begin{tikzpicture}%
\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,-0.1)ellipse (0.2cm and 0.1cm);%
\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0)ellipse (0.2cm and 0.1cm);%
\filldraw[line width=0.7pt, fill=cyan, fill opacity=1] (0,0.1)ellipse (0.2cm and 0.1cm);%
%    \path[] (current bounding box.north east)rectangle(current bounding box.south west);%<- uncomment to see the inside box
\end{tikzpicture}%
}
\begin{document}

\begin{figure}[H]
    \centering
        \begin{tikzpicture}
      \node[SYMBOL] {};
\end{tikzpicture}
    \caption{Signs}
\end{figure}

\end{document}
7

A figure like this can be drawn with a double copy shadow from shadows library and the external border with the show background rectangle from backgrounds library.

But the bounding box is not always correct when shadows library is used, therefore another alternative could be to repeat the path with a preaction and postaction options. Now the bounding box is correct and one command is enough to draw the whole figure.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[
    mystyle/.style={line width=.7pt, fill=cyan, draw, fill opacity=1},
    show background rectangle]
\filldraw[mystyle, 
    postaction={mystyle, transform canvas={yshift=0.1cm}}, preaction={mystyle, transform canvas={yshift=-0.1cm}}] (0,0) ellipse (0.2cm and 0.1cm);
\end{tikzpicture}
\caption{Signs}
\end{figure}
\end{document}

enter image description here

4

For the compare purpose with Asymptote.

// name.asy
// output: name.pdf
unitsize(1cm);
transform t=shift(0,0.1);
filldraw(ellipse((0,0),0.2,0.1),blue);
filldraw(t*ellipse((0,0),0.2,0.1),blue);
filldraw(t^2*ellipse((0,0),0.2,0.1),blue);
shipout(bbox(1mm,FillDraw(white,black)));
\documentclass[a4paper]{article}
\usepackage{graphicx}

\newcommand{\SYMBOL}[1][.8\ht\strutbox]{% https://tex.stackexchange.com/a/174662/213378
    \includegraphics[height=#1]{name.pdf}%
}
\begin{document}
    Hello World!    
    \begin{figure}
        \centering
\includegraphics{name.pdf}
\caption{Signs}
    \end{figure}
\begin{itemize}
    \item[\SYMBOL] This is an open folder
    \item This isn't
\end{itemize}
Also a big open folder: \SYMBOL[1cm].
\end{document}

enter image description here

3

This way is plain.

enter image description here

\documentclass{article}
\usepackage{float} 
\usepackage{tikz}
\usepackage{lipsum} % >>> for dummy texts
\begin{document}
\lipsum[1]
\begin{figure}[H]
\centering  
\begin{tikzpicture}
\foreach \i in {-1,0,1}
\draw[fill=cyan,thick,shift={(0,\i*.1)}] (0,0) circle(.2 and .1);
\draw (45:.5) rectangle (-135:.5);
\end{tikzpicture}
\caption{Signs}
\end{figure}
\lipsum[2]
\end{document}

You must log in to answer this question.

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