[Tex/LaTex] Horizontally enlarged hexagon with TikZ

diagramstikz-pgf

I need to draw some nodes for a diagram, but I'm failing to produce a simple horizontally enlarged hexagon.

If I use regular polygon (from shapes.geometric), I cannot enlarge it (first figure in image below). I tried to set shape aspect just to no avail.

A workaround I found in the pgfmanual, is to use the chamfered rectangle (from shapes.misc), but then we must be cautious about the balance between xsep and how much text there is inside the rectangle (second and third figure in image below).

This is the code that produces the figures below:

\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.misc}

\begin{tikzpicture}[node distance=1.5cm]
  \node[regular polygon, regular polygon sides=6, shape aspect=0.5, minimum width=4cm, minimum height=1cm, draw] (reg) {Regular node};
  \node[chamfered rectangle, chamfered rectangle xsep=2cm, draw] (chamf) [right=of reg] {Enlarged node};
  \node[chamfered rectangle, chamfered rectangle xsep=1cm, text width=2cm, draw] (chamfB) [below=of chamf] {Enlarged node with many lines that flow down};
\end{tikzpicture}

Figures

Best Answer

To scale the hexagon horizontally, you can use the xscale option; you can add the text using the label=center:<text> option to the hexagon node:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.misc}

\begin{document}

\begin{tikzpicture}
  \node[regular polygon, regular polygon sides=6, minimum width=2cm,draw,label=center:some text] (reg1) at (0,0){};
  \node[regular polygon, regular polygon sides=6, minimum width=1cm, xscale=3,draw,label=center:some text] (reg2) at (3,0) {};
\end{tikzpicture}

\end{document}

enter image description here

Related Question