3

I have two flowcharts in my document with the following code. The problem is that I can compile the flowchart alone but when I repeat the code for a second flowchart it doesn't compile anymore. I get an error in LyX.

! Undefined control sequence.
<argument> ...a \advance \pgf@x by\pgfshapeaspect 
                                                  \pgf@ya \pgf@y =\pgfshapea...
l.84 ...\textsubscript{\textit{it},max,inner}\\*};

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
% Preview source code

%% LyX 2.1.4 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[american,fontsize=11pt,paper=a4,twoside,openright,titlepage,numbers=noenddot,headinclude,BCOR=5mm,footinclude=true,cleardoublepage=empty]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\usepackage{float}
\usepackage[numbers]{natbib}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% Classic Thesis Style loader
\makeatother
\input{classicthesis-config.tex}
\makeatletter
% use Latin Modern instead of Computer Modern sans serif
\renewcommand{\sfdefault}{lmss}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{tikz}

\usepackage{pgf}

\usepackage{setspace}
\usepackage{lipsum}

\makeatother

\usepackage{babel}
\begin{document}
\begin{center}
\begin{figure}[H]
\usetikzlibrary{automata,positioning,shapes.geometric, arrows}



\tikzstyle{io} = [rectangle, rounded corners, minimum width= 3cm, minimum height=1cm,text width=5cm, text centered, draw=black, fill=green!40]
\tikzstyle{process} = [rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!40]
\tikzstyle{NewProcess} = [rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!60]
\tikzstyle{decision} = [diamond, minimum width=2cm,minimum height=1cm,text height=.25cm,text width=2.5cm, text centered, draw=black, fill=red!40]
\tikzstyle{arrow} = [->,>=stealth]


\begin{tikzpicture}[node distance=4cm]     
    \node (Initials) [io] {\footnotesize \setstretch{0.75} Initialization and\\*set iteration values\\*x\textsuperscript{0}, \textit{k} = 0\\*};     
    \node (prc1) [process, below of=Initials,node distance=1.5cm] {\footnotesize \setstretch{0.75} Calculate structural-mechanical  responses via FEM\\* \setstretch{0.5} \textsuperscript{\textit{t}}\textbf{\textit{M}}\textsuperscript{\textit{t}}\textbf{\textit{ü}} +      \textsuperscript{\textit{t}}\textbf{$f$}\textsuperscript{int} = \textsuperscript{\textit{t}}\textbf{$f$}\textsuperscript{ext}\setstretch{0.5}\\*};
    \node (prc2) [process, below of=prc1,node distance=1.55cm] {\footnotesize  Calculate target mass\\*\textit{m}\textsuperscript{$\star$,\textit{k}} =         \textit{m}\textsuperscript{\textit{k}} + $\Delta$\textit{m}\textsuperscript{\text{k}}\setstretch{0.75}\\*where $\Delta$\textit{m} =         \text{$f$\textsubscript{1}}(g)\\*};
    \node (prc3) [process, below of=prc2,node distance=1.5cm] {\footnotesize \setstretch{0.75} Calculate state setpoint based on        responses\\*\setstretch{0.5}\textit{S\textsuperscript{$\star$}} = $f$\textsubscript{2}(\textit{S\textsuperscript{\textit{k}}})\\*};
    \node (prc9) [NewProcess, below of=prc3, node distance=1.55cm,minimum height=1.3cm]{\footnotesize Update Shape variables};
    \node (prc4) [process, below of=prc9,node distance=1.6cm] {\footnotesize \setstretch{0.75} Loop over cells: update size variables by adding \\*         $\Delta$x=$f$\textsubscript{3}(x\textsuperscript{\textit{k}},\textit{S}\textsubscript{\textsubscript{cell}}\textsuperscript{\textsuperscript{\textit{k},(\textit{k}-1,\textit{k}-2)}},\textit{S}\textsubscript{\textsubscript{neigh}}\textsuperscript{\textsuperscript{\textit{k},(\textit{k}-1,\textit{k}-2)}},\textit{S}\textsuperscript{$\star$})\\*};
    \node (prc5) [process, below of=prc4,node distance=1.5cm] {\footnotesize Calculate new mass\\*\textit{m} = $f$\textsubscript{4}(x\textsuperscript{\textit{k}},$\Delta$x)};
    \node (dec1) [decision, below of=prc5, node distance=2.75cm] {\footnotesize \setstretch{0.75} Mass check\\*  $|$\textit{m}\textsuperscript{$\star$} - \textit{m}$|$ $<$ $\varepsilon$\textsubscript{inner}\\*\text{j} $>$ \textit{n}\textsubscript{\textit{it},max,inner}\\*};
    \node (prc6) [process, left of=prc5, node distance=5.5cm] {\footnotesize Update state setpoint\\*\textit{S}\textsuperscript{$\star$}=$f$\textsubscript{5}(\textit{S}\textsuperscript{$\star$},\textit{m},\textit{m}\textsuperscript{$\star$})};
    \node (prc7) [process, below of=dec1, node distance=3cm] {\footnotesize Force size variables to respect limits\\*$\Delta$x = $f$\textsubscript{6}(x\textsuperscript{\textit{k}},\textit{m}\textsuperscript{$\star$},\textit{m} ,x\textsuperscript{\textit{L}},x\textsuperscript{\textit{U}} )};
    \node (dec2) [decision, below of=prc7, node distance=3cm] {\footnotesize \setstretch{0.5} Convergence\\* $\Delta$\textit{m} $<$ $\varepsilon$\textsubscript{outer}\\* \textit{k} $>$ \textit{n}\textsubscript{\textit{it},max}\\*};
    \node (prc8) [io, below of=dec2, node distance=3cm] {\footnotesize Optimum design};




    \draw [arrow] (Initials)--(prc1);
    \draw [arrow] (prc1)--(prc2);
    \draw [arrow] (prc2)--(prc3);
    \draw [arrow] (prc3)--(prc9);
    \draw [arrow] (prc4)--(prc5);
    \draw [arrow] (prc5)--(dec1);
    \draw [arrow] (dec1)-| node[anchor=north] {j=j+$1$}(prc6);
    \draw [arrow] (prc6)|-(prc4);
    \draw [arrow] (dec1)--(prc7);
    \draw [arrow] (prc7)--(dec2);
    \draw [arrow] (dec2)--(prc8);
    \draw [arrow] (dec2)-|node[anchor=north] {k=k+$1$}(4,-1.5)|-(prc1);
    \draw [arrow] (prc9)--(prc4);   




\end{tikzpicture}

\caption{Flowchart of Knowledge Based Rule Method }
\end{figure}

\par\end{center}



\begin{center}
\begin{figure}[H]
\usetikzlibrary{automata,positioning,shapes.geometric, arrows}



\tikzstyle{io} = [rectangle, rounded corners, minimum width= 3cm, minimum height=1cm,text width=5cm, text centered, draw=black, fill=green!40]
\tikzstyle{process} = [rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!40]
\tikzstyle{NewProcess} = [rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!60]
\tikzstyle{decision} = [diamond, minimum width=2cm,minimum height=1cm,text height=.25cm,text width=2.5cm, text centered, draw=black, fill=red!40]
\tikzstyle{arrow} = [->,>=stealth]


\begin{tikzpicture}[node distance=4cm]     
    \node (Initials) [io] {\footnotesize \setstretch{0.75} Initialization and\\*set iteration values\\*x\textsuperscript{0}, \textit{k} = 0\\*};     
    \node (prc1) [process, below of=Initials,node distance=1.5cm] {\footnotesize \setstretch{0.75} Calculate structural-mechanical  responses via FEM\\* \setstretch{0.5} \textsuperscript{\textit{t}}\textbf{\textit{M}}\textsuperscript{\textit{t}}\textbf{\textit{ü}} +      \textsuperscript{\textit{t}}\textbf{$f$}\textsuperscript{int} = \textsuperscript{\textit{t}}\textbf{$f$}\textsuperscript{ext}\setstretch{0.5}\\*};
    \node (prc2) [process, below of=prc1,node distance=1.55cm] {\footnotesize  Calculate target mass\\*\textit{m}\textsuperscript{$\star$,\textit{k}} =         \textit{m}\textsuperscript{\textit{k}} + $\Delta$\textit{m}\textsuperscript{\text{k}}\setstretch{0.75}\\*where $\Delta$\textit{m} =         \text{$f$\textsubscript{1}}(g)\\*};
    \node (prc3) [process, below of=prc2,node distance=1.5cm] {\footnotesize \setstretch{0.75} Calculate state setpoint based on        responses\\*\setstretch{0.5}\textit{S\textsuperscript{$\star$}} = $f$\textsubscript{2}(\textit{S\textsuperscript{\textit{k}}})\\*};
    \node (prc9) [NewProcess, below of=prc3, node distance=1.55cm,minimum height=1.3cm]{\footnotesize Update Shape variables};
    \node (prc4) [process, below of=prc9,node distance=1.6cm] {\footnotesize \setstretch{0.75} Loop over cells: update size variables by adding \\*         $\Delta$x=$f$\textsubscript{3}(x\textsuperscript{\textit{k}},\textit{S}\textsubscript{\textsubscript{cell}}\textsuperscript{\textsuperscript{\textit{k},(\textit{k}-1,\textit{k}-2)}},\textit{S}\textsubscript{\textsubscript{neigh}}\textsuperscript{\textsuperscript{\textit{k},(\textit{k}-1,\textit{k}-2)}},\textit{S}\textsuperscript{$\star$})\\*};
    \node (prc5) [process, below of=prc4,node distance=1.5cm] {\footnotesize Calculate new mass\\*\textit{m} = $f$\textsubscript{4}(x\textsuperscript{\textit{k}},$\Delta$x)};
    \node (dec1) [decision, below of=prc5, node distance=2.75cm] {\footnotesize \setstretch{0.75} Mass check\\*  $|$\textit{m}\textsuperscript{$\star$} - \textit{m}$|$ $<$ $\varepsilon$\textsubscript{inner}\\*\text{j} $>$ \textit{n}\textsubscript{\textit{it},max,inner}\\*};
    \node (prc6) [process, left of=prc5, node distance=5.5cm] {\footnotesize Update state setpoint\\*\textit{S}\textsuperscript{$\star$}=$f$\textsubscript{5}(\textit{S}\textsuperscript{$\star$},\textit{m},\textit{m}\textsuperscript{$\star$})};
    \node (prc7) [process, below of=dec1, node distance=3cm] {\footnotesize Force size variables to respect limits\\*$\Delta$x = $f$\textsubscript{6}(x\textsuperscript{\textit{k}},\textit{m}\textsuperscript{$\star$},\textit{m} ,x\textsuperscript{\textit{L}},x\textsuperscript{\textit{U}} )};
    \node (dec2) [decision, below of=prc7, node distance=3cm] {\footnotesize \setstretch{0.5} Convergence\\* $\Delta$\textit{m} $<$ $\varepsilon$\textsubscript{outer}\\* \textit{k} $>$ \textit{n}\textsubscript{\textit{it},max}\\*};
    \node (prc8) [io, below of=dec2, node distance=3cm] {\footnotesize Optimum design};




    \draw [arrow] (Initials)--(prc1);
    \draw [arrow] (prc1)--(prc2);
    \draw [arrow] (prc2)--(prc3);
    \draw [arrow] (prc3)--(prc9);
    \draw [arrow] (prc4)--(prc5);
    \draw [arrow] (prc5)--(dec1);
    \draw [arrow] (dec1)-| node[anchor=north] {j=j+$1$}(prc6);
    \draw [arrow] (prc6)|-(prc4);
    \draw [arrow] (dec1)--(prc7);
    \draw [arrow] (prc7)--(dec2);
    \draw [arrow] (dec2)--(prc8);
    \draw [arrow] (dec2)-|node[anchor=north] {k=k+$1$}(4,-1.5)|-(prc1);
    \draw [arrow] (prc9)--(prc4);   




\end{tikzpicture}

\caption{Flowchart of Knowledge Based Rule Method }
\end{figure}

\par\end{center}


\end{document}
4
  • The error I get from testing your code is No shape named dec1 is known. because you don't have any nodes called dec. Edit: dec2 is also missing. Sep 14, 2016 at 16:03
  • I have put the complete code now. if you repeat the code twice in two sections of the same document it doesn't compile! @TorbjørnT.
    – memari
    Sep 14, 2016 at 16:11
  • That code works fine, repeated or not, so something else is wrong. You're using LyX as the tag suggested? Then can you do this: Take a copy of the document that doesn't work. Remove as much of the content from it as you can, without removing the error. Then in the source pane (View->Source Pane) select Complete source on the right, and copy everything from \documentclass to \end{document}. Add that to your question. Sep 14, 2016 at 16:20
  • @TorbjørnT. Thank you for helping. I have done it as you said.
    – memari
    Sep 14, 2016 at 16:28

1 Answer 1

3

You shouldn't use \usetikzlibrary in the document itself. Remove the line

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

from both places in your document, and place it in the preamble instead (Document --> Settings --> LaTeX preamble), after \usepackage{tikz}.

I think you can also move all the style declarations to the preamble, and there is no need to repeat them. So, remove all the \tikzstyle declarations, and instead add

\tikzset{
  io/.style={rectangle, rounded corners, minimum width= 3cm, minimum height=1cm,text width=5cm, text centered, draw=black, fill=green!40},
  process/.style={rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!40},
  NewProcess/.style={rectangle, minimum width= 3cm, minimum height=1cm, text width=5cm, text centered, draw=black, fill=blue!60},
  decision/.style={diamond, minimum width=2cm,minimum height=1cm,text height=.25cm,text width=2.5cm, text centered, draw=black, fill=red!40},
  arrow/.style={->,>=stealth}
}

to the preamble.

2
  • I might edit the answer later with some other comments, will ping you when/if I do. Sep 14, 2016 at 16:38
  • Thank you a lot!!! Saved me! the problem was the library was not in the main document it was in the preamble of the chapter I was using it.
    – memari
    Sep 14, 2016 at 16:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .