I have a code that generates a flow chart. It's not entirely complete, it just needs arrows which is besides everything. This issue I have is the process nodes, trapeziums, aren't the same size even though I pre defined them.
Code:
\documentclass{article}
%----------------------------------------------------------------------------------------
% PACKAGES
%----------------------------------------------------------------------------------------
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{positioning}
\tikzstyle{startstop} = [rectangle, text centered, rounded corners, minimum width=3cm, minimum height=1cm, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=-70,text centered,text width = 2cm,minimum height=1cm, minimum width=2cm, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, text centered, minimum width=3cm, minimum height=1cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, text badly centered, text width=4.5em, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=stealth]
% Does Node distance by sides instead of centers.
\tikzstyle{my below of} = [below=of #1.south]
\tikzstyle{my right of} = [right=of #1.east]
\tikzstyle{my left of} = [left=of #1.west]
\tikzstyle{my above of} = [above=of #1.north]
%----------------------------------------------------------------------------------------
% DOCUMENT INFO
%----------------------------------------------------------------------------------------
\begin{document}
\begin{tikzpicture}[node distance=0.1cm,auto]
\node (Start) [startstop] {Program Startup};
\node (UsrStat) [decision, my below of=Start] {New or Returning User?};
\node (CrtUsr) [process, my right of=UsrStat] {Create User};
\node (LogCred) [io, my below of=UsrStat] {Login Credentials};
\node (ValCred) [process, my below of=LogCred] {Validate Credentials};
\node (ValRes) [decision, my below of=ValCred] {Valid or Invalid Credentials?};
\node (Login) [process, my below of=ValRes] {Login};
\node (ConUI) [process, my below of=Login] {Contact UI};
\node (Com) [io, my below of=ConUI, text width = 2.1cm] {Command};
\node (ExDec) [decision, my below of=Com] {Exit Command?};
\node (ComPros) [process, my right of=Com] {Command Process};
\node (Exit) [startstop, my below of=ExDec] {Exit Program};
\end{tikzpicture}
\end{document}
But when I run it, I get the following I have played with changing the text width, minimum height and width and cant seem to get it right. I would like them to have a minimum width of 2cm as the others.
Best Answer
On the first sight this looks as bug, however reading documentation an link provided in percusse comment show, that in such a cases the option
trapezium stretches=true
should be added to node style definition:Off-topic: above MWE has in comparison to your MWE the following changes:
\tikzstyle
, which is considered obsolete the\tikzset
is used\tikzset
, containing definitions of nodes used in flowcharts is named "flowchart" (if you not liked this, just erase this part of\tikzset
). Consequently thetikzpicture
s with flowchart, had to call this settings with its name (see MWE above)positioning
librarybase
style, which is then used in all other node's styles