2

pgf/tikz: I am trying to create a hexagon with a fixed height . Using the chamfered Rectangle. I can turn the rectangle into a hexagon, but when I try to apply the minimum height option it seems to interfere with setting the xsep.

Does anyone know a way around this?

This is the macro I'm trying to make.

\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}

Thankyou.

12
  • Please post a full but minimal example for your question. Also, your command doesn't output anything because this: {|[ is not a proper Tikz command. Maybe you meant {\node[?
    – Alenanno
    Feb 19 '16 at 18:41
  • @Alenanno done. The { | [ is a valid command. Using matrix means you do not need to constantly write node.
    – Adriala
    Feb 19 '16 at 19:08
  • @Zarko hmmm I was under the impression that regular polygon creates one with equal sides? I may be mistaken. I want more of a rectangle with the angled edges. I know I could apply scaling to squish the polygon to the height I'm after, but then the points become over exaggerated.
    – Adriala
    Feb 19 '16 at 19:18
  • Only if we know it's supposed to go in a matrix.
    – Alenanno
    Feb 19 '16 at 19:18
  • @Alenanno I admit I should have included a complete example. However, flat out assuming it was incorrect was still a mistake. By the same strand I could argue \node is invalid because you didn't say I had to put it in tikz environment.
    – Adriala
    Feb 19 '16 at 19:24
1

If I understand what you like to have as final shape form, than this is easier to obtain by signal shape than with chamfered rectangle. It provide hexagon independent from desired text height:

enter image description here

For above picture I expand your matrix and change the way to define its cells:

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.