考虑这个例子:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\tikzset{
rect/.style={
font=\small,
rectangle,
rounded corners,
minimum width=1em,
text width=2em,
%draw=blue!75,
very thick,
align=center,
}%
}%
\begin{tikzpicture}
\draw [draw=black] (0.0, 0.0) rectangle (4.0, 4.0);
%\tikz\draw[rect] (0.0, 0.0) rectangle (4.0, 4.0);
\node[single arrow, draw=blue,
minimum width = 1.0cm, single arrow head extend=1cm,
minimum height = 2cm] at (2.0, 2.0)[anchor = center] {};
\end{tikzpicture}
\end{document}
结果是:
然而,当我评论时
\draw [draw=black] (0.0, 0.0) rectangle (4.0, 4.0);
并取消注释
%\tikz\draw[rect] (0.0, 0.0) rectangle (4.0, 4.0);
粗箭头的形状消失了:
怎么了?
答案1
正如您在评论中看到的那样,在环境\tikz
中包含它不是一个好主意tikzpicture
。您正在嵌套tikzpictures
,这必然会产生错误。因此,只需删除该\tikz
命令即可。
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\begin{document}
\tikzset{
rect/.style={
font=\small,
rectangle,
rounded corners,
minimum width=1em,
text width=2em,
%draw=blue!75,
very thick,
align=center,
}%
}%
\begin{tikzpicture}
% \draw [draw=black] (0.0, 0.0) rectangle (4.0, 4.0);
\draw[rect] (0.0, 0.0) rectangle (4.0, 4.0);
\node[single arrow, draw=blue,
minimum width = 1.0cm, single arrow head extend=1cm,
minimum height = 2cm] at (2.0, 2.0)[anchor = center] {};
\end{tikzpicture}
\end{document}
答案2
大部分都是题外话(你的问题已经由@Juan Castaño 的回答解决了,+1)...
绘制矩形路径时使用的样式有点不寻常,而这通常用于节点。因此,我看到了两种绘制图片的可能方法:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit,
shapes.arrows}
\tikzset{
rect/.style = {rounded corners, very thick},
SA/.style = {single arrow, draw=blue, thin, sharp corners,
minimum width=1.0cm, minimum height = 2cm,
single arrow head extend=1cm},
%%
FIT/.style = {draw, rounded corners, very thick, inner sep=1cm,
fit=#1},
}
\begin{document}
% draw rectangle
\begin{tikzpicture}
\draw[rect] (0,0) rectangle (4, 4) node[SA, midway] {};
\end{tikzpicture}
or
% use of nodes
\begin{tikzpicture}
\node[SA] (n1) {};
\node[FIT=(n1)] {};
\end{tikzpicture}
\end{document}