我怎样才能使用 tikz(左侧)绘制与图 1 中的节点相同的图片?
这就是我想做的事情:
\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}
答案1
不要使用在主节点周围添加节点的标签,而是只需使用键node contents
来填充节点,并将括号留空:\node[SYMBOL] {};
\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}
答案2
double copy shadow
可以使用库来绘制这样的图形,并使用库来shadows
绘制外部边框。show background rectangle
backgrounds
但是使用库时边界框并不总是正确的,因此另一种选择是使用和选项shadows
重复路径。现在边界框是正确的,一个命令就足以绘制整个图形。preaction
postaction
\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}
答案3
为了比较渐近线。
// 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}
答案4
這條路很簡單。
\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}