2

I'm want to create a flowchart in Latex(sharelatex.com). But to try out what i need to do i start with creating a copy from the manual. The example is shown on Page 147 in tikzpgfmanual.pdf. First start a copy where i figured out that i was missing some packages and libraries. After fixing these packages i still get errors on some lines. Basically on every path(i left one open). The errors i got are

Missing \endcsname inserted.
<to be read again> \OT1\textquoteright 

and

Package xcolor Error: Undefined color `latex\OT1\textquoteright '.
See the xcolor package documentation for explanation.

My tikz script so far.

\documentclass{article}
%\documentclass[tikz,margin=3mm]{standalone}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage[utf8]{inputenc}

\begin{document}
    \begin{tikzpicture}[auto]
    \tikzstyle{decision} = [diamond, draw=blue, thick, fill=blue!20, text width=4.5em, text badly centered, inner sep=1pt]
    \tikzstyle{block} = [rectangle, draw=blue, thick, fill=blue!20,text width=5em, text centered, rounded corners, minimum height=4em]
    \tikzstyle{line} = [draw, thick, -latex’,shorten >=2pt];
    \tikzstyle{cloud} = [draw=red, thick, ellipse,fill=red!20, minimum height=2em];
    \matrix [column sep=5mm,row sep=7mm]
    {
    % row 1
    \node [cloud] (expert) {expert}; &
    \node [block] (init) {initialize model}; &
    \node [cloud] (system) {system}; \\
    % row 2
    & \node [block] (identify) {identify candidate model}; & \\
    % row 3
    \node [block] (update) {update model}; &
    \node [block] (evaluate) {evaluate candidate models}; & \\
    % row 4
    & \node [decision] (decide) {is best candidate}; & \\
    % row 5
    & \node [block] (stop) {stop}; & \\
    };
    \tikzstyle{every path}=[line]
    \path (init) -- (identify);
    %\path (identify) -- (evaluate);
    %\path (evaluate) -- (decide);
    %\path (update) |- (identify);
    %\path (decide) -| node [near start] {yes} (update);
    %\path (decide) -- node [midway] {no} (stop);
    %\path [dashed] (expert) -- (init);
    %\path [dashed] (system) -- (init);
    %\path [dashed] (system) |- (evaluate);
    \end{tikzpicture}
\end{document}

I have the idea i'm missing some package but i'm unable to figure out which one. If i'm don't miss a package can somebody explain what's wrong?

  • 3
    You have curly quotes where you need straight ones: not -latex’ but -latex'. Better still, use arrows.meta. – cfr Sep 13 '17 at 14:01
  • 3
    Don't copy text from PDF and paste it into your code. Rewrite the quotes and dashes, for example. When you copy/paste usually you have problems. So it is better to avoid. – Sigur Sep 13 '17 at 14:01
  • You need the library \usetikzlibrary{arrows,arrows.meta,shapes} – AndréC Sep 13 '17 at 14:16
  • 1
    Don't read that specific manual though, it's ancient. The current version of pgf/TikZ is 3.0.1a, a lot has happened since 1.18. Look at CTAN, or texdoc.net instead. – Torbjørn T. Sep 14 '17 at 11:26
  • 1
    @cfr Do you want to answer? – Torbjørn T. Dec 23 '17 at 19:17
3

There are two problems. The first is that the curly closing quotation mark is not part of TikZ syntax, so -latex’ gives an error. It is presumably the straight quotation mark which you want in the arrow specification -latex'.

The second problem is that the arrow tip kind latex is not defined by default. To use it, you must load the arrows library. However, this is deprecated, so it would be better to use arrows.meta instead.

\tikzstyle is also deprecated, so it would also be better to update this syntax, too.

Recommended code:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows.meta}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}
  [
    auto,
    decision/.style={diamond, draw=blue, thick, fill=blue!20, text width=4.5em, text badly centered, inner sep=1pt},
    block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5em, text centered, rounded corners, minimum height=4em},
    line/.style={draw, thick, -Latex,shorten >=2pt},
    cloud/.style={draw=red, thick, ellipse,fill=red!20, minimum height=2em},
  ]
  \matrix [column sep=5mm,row sep=7mm]
  {
    \node [cloud] (expert) {expert}; &
    \node [block] (init) {initialize model}; &
    \node [cloud] (system) {system}; \\
    & \node [block] (identify) {identify candidate model}; & \\
    \node [block] (update) {update model}; &
    \node [block] (evaluate) {evaluate candidate models}; & \\
    & \node [decision] (decide) {is best candidate}; & \\
    & \node [block] (stop) {stop}; & \\
  };
  \tikzset{every path/.style={line}}
  \path (init) -- (identify);
\end{tikzpicture}
\end{document}

compiled output

Minimally amended code in case you don't want to use the recommendation above for some reason:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{tikzpicture}[auto]
  \tikzstyle{decision} = [diamond, draw=blue, thick, fill=blue!20, text width=4.5em, text badly centered, inner sep=1pt]
  \tikzstyle{block} = [rectangle, draw=blue, thick, fill=blue!20,text width=5em, text centered, rounded corners, minimum height=4em]
  \tikzstyle{line} = [draw, thick, -latex',shorten >=2pt];
  \tikzstyle{cloud} = [draw=red, thick, ellipse,fill=red!20, minimum height=2em];
  \matrix [column sep=5mm,row sep=7mm]
  {
    \node [cloud] (expert) {expert}; &
    \node [block] (init) {initialize model}; &
    \node [cloud] (system) {system}; \\
    & \node [block] (identify) {identify candidate model}; & \\
    \node [block] (update) {update model}; &
    \node [block] (evaluate) {evaluate candidate models}; & \\
    & \node [decision] (decide) {is best candidate}; & \\
    & \node [block] (stop) {stop}; & \\
  };
  \tikzstyle{every path}=[line]
  \path (init) -- (identify);
\end{tikzpicture}
\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.