2

I am drawing a flow chart. Diamond-shaped nodes don't come out right. My minimal working example is below. There are no problems with ShareLaTeX, but it doesn't work on my computer.

\usepackage{tikz}

\usetikzlibrary{shapes.geometric, arrows, fit}

\tikzstyle{decision} = [diamond, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black, inner sep=1pt, fill=green!10]
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered,text width=5cm, draw=black, fill=orange!30]
\tikzstyle{endloop} = [ellipse, minimum width=2cm, minimum height=1cm, text centered, text width=3cm, draw=black, inner sep=1pt]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\tikzstyle{arrow} = [thick,->,>=stealth]

\begin{document}

    \begin{tikzpicture} [node distance=2cm]

        \node [input, name=input] {};
        \node(dec1)[decision, below of=input]{$Round <= Limit$};

    \end{tikzpicture}

\end{document}

Output on my computer:

with TeXstudio

Output from ShareLaTeX:

with sharelatex

3
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarise yourself further with our format. A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). – ChrisS Jun 27 '18 at 5:51
  • Sorry and thanks. Error message for Texstudio is : Undefined control sequence. ...ision, below of=input]{$Round <= Limit$}; – Aaron Jun 27 '18 at 5:56
  • see my answer on question tex.stackexchange.com/questions/300759. – Zarko Jun 27 '18 at 6:05
0
  • i can't reproduce your problem, after completing your mwe, it works fine
  • you use one old definition (with obsolete tizstyle syntax) of nodes style for flow charts. i suggest to renew it as is used in mwe below (copied from my here):

\documentclass[border=3mm,
                tikz]{standalone}
\usetikzlibrary{arrows.meta,
                calc, chains,
                quotes,
                positioning,
                shapes.geometric}

\begin{document}
%---------------------------------------------------------------%
\begin{tikzpicture}[
    node distance = 8mm and 16mm,
      start chain = A going below,
      base/.style = {draw, minimum width=32mm, minimum height=8mm,
                     align=center, on chain=A},
 startstop/.style = {base, rectangle, rounded corners, fill=red!30},
   process/.style = {base, rectangle, fill=orange!30},
        io/.style = {base, trapezium,
                     trapezium left angle=70, trapezium right angle=110,
                     fill=blue!30},
  decision/.style = {base, diamond, fill=green!30},
  every edge quotes/.style = {auto=right}]
                    ]
\node (dec1) [decision] {$Round <= Limit$};
    \end{tikzpicture}
\end{document}

enter image description here

  • in the case, that you like to have flowchart's nodes style in preamble (for more flowcharts, than you can do this on the following way:

    \documentclass[border=3mm,
                    tikz]{standalone}
    \usetikzlibrary{arrows.meta,
                    calc, chains,
                    quotes,
                    positioning,
                    shapes.geometric}
    
    \tikzset{FlowChart/.style={     % <---
          start chain = A going below,
          base/.style = {draw, minimum width=32mm, minimum height=8mm,
                         align=center, on chain=A},
     startstop/.style = {base, rectangle, rounded corners, fill=red!30},
       process/.style = {base, rectangle, fill=orange!30},
            io/.style = {base, trapezium,
                         trapezium left angle=70, trapezium right angle=110,
                         fill=blue!30},
      decision/.style = {base, diamond, fill=green!30},
      every edge quotes/.style = {auto=right}
                            }% end of FlowChart styles
      }
    
    
    \begin{document}
    %---------------------------------------------------------------%
    \begin{tikzpicture}[FlowChart,  % <---
        node distance = 8mm and 16mm,
                        ]
    \node(dec1)[decision]{$Round <= Limit$};
        \end{tikzpicture}
    \end{document}
    
  • note: i don't see any befits for declaring nodes as coordinates (for input and output). for this purposes you can simply use \coordinate, if you really need it.

  • an example of code for relatively simple flowchart you can find here.

addendum:

  • above document examples also works with any other document class, not only with standalone. for example:

    \documentclass[ pdftex, oneside,    
                    Einseitiger Druck. 12pt,    
                    Schriftgroesse parskip=half,    
                    topmargin = 10pt,   headheight = 33pt,  headsepline,    footsepline,    
                    footheight = 16pt,  abstracton, DIV=calc,   
                    Satzspiegel berechnen BCOR=8mm, headinclude=false, footinclude=false, listof=totoc, toc=bibliography,   
                    ]{scrreprt}
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta,
                    calc, chains,
                    quotes,
                    positioning,
                    shapes.geometric}
    
    \tikzset{FlowChart/.style={     % <---
          start chain = A going below,
          base/.style = {draw, minimum width=32mm, minimum height=8mm,
                         align=center, on chain=A},
     startstop/.style = {base, rectangle, rounded corners, fill=red!30},
       process/.style = {base, rectangle, fill=orange!30},
            io/.style = {base, trapezium,
                         trapezium left angle=70, trapezium right angle=110,
                         fill=blue!30},
      decision/.style = {base, diamond, fill=green!30},
      every edge quotes/.style = {auto=right}
                            }% end of FlowChart styles
      }
    
    \begin{document}
    %---------------------------------------------------------------%
    \begin{tikzpicture}[FlowChart,  % <---
        node distance = 8mm and 16mm,
                        ]
    \node(dec1)[decision]{$Round <= Limit$};
        \end{tikzpicture}
    \end{document}
    

gives the same result as both mwe before.

8
  • hmm, if I start a new project, your example works. But when I add exact the same think at my actual project: Undefined control sequence. \node (dec1) [decision] {$Round <= Limit$}; – Aaron Jun 27 '18 at 6:57
  • @Aaron, this means that your actual project is corrupted (probably it has missing tikz libraries, etc. without knowing its preamble, i can't say what is going wrong in your document (sorry, my crystal ball is on vacation :-( ). – Zarko Jun 27 '18 at 7:15
  • I searched a little bit and I think it is because I have another class.{\documentclass[% pdftex, oneside, % Einseitiger Druck. 12pt, % Schriftgroesse parskip=half, %topmargin = 10pt, headheight = 33pt, headsepline, footsepline, %footheight = 16pt, abstracton, DIV=calc, % Satzspiegel berechnen BCOR=8mm, headinclude=false, footinclude=false, listof=totoc, toc=bibliography, ]{scrreprt} – Aaron Jun 27 '18 at 7:20
  • I think your example is working because of the {standalone} environment. – Aaron Jun 27 '18 at 7:22
  • no, it also work with any other document class. you only need to add package tikz, which is in my mwe included in option of standalone. please, edit your question and add your code in comment to your code snippet. – Zarko Jun 27 '18 at 7:33

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.