pgf/tikz:我正在尝试创建一个具有固定高度的六边形。使用倒角矩形。我可以将矩形变成六边形,但是当我尝试应用最小高度选项时,它似乎会干扰 xsep 的设置。
有人知道解决这个问题的方法吗?
这是我正在尝试制作的宏。
\documentclass[a4paper, 12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{matrix}
\newcommand{\Task}[2]{|[chamfered rectangle, chamfered rectangle angle=50, thick, draw, text centered, text width=1.5cm, minimum width=3cm, minimum height=1.3cm, chamfered rectangle xsep=5cm, scale=0.5](#1)|{#2}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix (grlplay) [matrix of nodes, row sep = 0mm] %grlFlow-row-column
{
&\Task{label}{name} & \\
};
\end{tikzpicture}
\end{figure}
\end{document}
谢谢。
答案1
如果我理解你想要的最终形状形式,那么通过signal
形状比通过更容易获得chamfered rectangle
。它提供与所需文本高度无关的六边形:
对于上图,我扩展了矩阵并改变了定义其单元格的方式:
\documentclass[a4paper, 12pt]{report}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,shapes.symbols}
% for show only figure
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[
task/.style = {signal, draw, thick,
signal to=west and east,
text width=22mm, minimum height=9mm, align=center}
]
\matrix (grlplay) [matrix of nodes, row sep = 1mm] %grlFlow-row-column
{
left & \node[task] {name}; & right \\
left & \node[task] {name}; & right \\
};
%\draw[red,->] (grlplay-1-1) -- (grlplay-1-3);
\end{tikzpicture}
\end{figure}
\end{document}