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.



\usetikzlibrary{shapes.geometric, arrows}

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



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



But when I run it, I get the followingCommand is bigger then Login Credentials 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.


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:

enter image description here

\usetikzlibrary{arrows, positioning, shapes.geometric, }

\tikzset{flowchart/.style = {
     base/.style = {draw=black, 
                    inner sep=1mm, outer sep=0mm,
                    text width=3cm, minimum height=1cm,
                    align=flush center},
startstop/.style = {base, fill=red!30},
  process/.style = {base, fill=orange!30},
 decision/.style = {base, diamond, aspect=1.2, fill=green!30},
       io/.style = {base, trapezium,
                    trapezium left angle=70, trapezium right angle=-70,
                    trapezium stretches=true, %%%% <-- added
     arrow/.style = {thick, -stealth}

    node distance=0.5cm, auto
\node (n1) [io] {Login Credentials};
\node (n2) [io, below=of n1]        {Command};
\node (n3) [io, below=of n2]        {Command Command Command};
\node (n4) [process, below=of n3]   {Validate Credentials};
    (n4.north west) -- ++ (0,5)
    (n4.north east) -- ++ (0,5);

Off-topic: above MWE has in comparison to your MWE the following changes:

  • instead \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 the tikzpictures with flowchart, had to call this settings with its name (see MWE above)
  • in positioning is (directly) used syntax determined in positioning library
  • defined is common base style, which is then used in all other node's styles
  • Thank you! I'm new to Tikz and I found the layout I posted on a ShareLatex forum for flowcharts. – Alex Dec 4 '16 at 2:27

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.