2

I'm a new latex user. I don't understand why the text I write is written in the space where my tikz picture is displayed on the document. In my source code document the text is written below the code for the tikz picture, yet when the document is compiled the text is displayed on the tikz picture. I want the text of my document to be displayed below the tikz picture not in the same place as the picture.

Here is my code:


\usepackage{tikz}

\usetikzlibrary{arrows.meta, positioning, shadows , calc ,shapes}

\tikzstyle{rec style2}=[draw , shape = rectangle , fill = white , drop shadow , rounded corners , align = center , minimum height = 1cm , minimum width = 2cm]

\tikzstyle{diamond style} = [diamond, draw, minimum height = 0.8cm , minimum width = 0.8cm , font=\bfseries]

\newcommand*{\Shift}{1.5ex}

\begin{document}

%%%%% Tikz picture %%%%

\begin{figure}[h!]

\centering

\begin{tikzpicture}[transform canvas={scale=0.6}]

\nodedraw , rec style2{Get \ tractor \ ready};

\nodedraw , diamond style, below of = n1 , node distance = 3cm{};

\draw [line width=1mm] ($(n2.north) - (0,\Shift)$) -- ($(n2.south) + (0,\Shift)$) ($(n2.west) + (\Shift,0)$) -- ($(n2.east) - (\Shift,0)$);

% Let's draw the invisible coordinates;

\nodeleft of = n2, coordinate, node distance = 3cm {};

\noderight of = n2, coordinate, node distance = 3cm {};

\noderight of = n2, coordinate, node distance = 6cm {};

% Second level of nodes;

\nodebelow of = cor1 , draw , rec style2 , node distance = 3cm{Driver \ coordination};

\nodebelow of = cor2 , draw , rec style2 , node distance = 3cm{Book \ equipment};

\nodebelow of = cor3 , draw , rec style2 , node distance = 3cm{Workers \ board \ tractor};

% Second level of invisible nodes;

\nodebelow of = n3, coordinate, node distance = 3cm {};

\nodebelow of = n4, coordinate, node distance = 3cm {};

\nodebelow of = n5, coordinate, node distance = 3cm {};

\nodedraw , diamond style, below of = n2 , node distance = 6cm{};

\draw [line width=1mm] ($(n6.north) - (0,\Shift)$) -- ($(n6.south) + (0,\Shift)$) ($(n6.west) + (\Shift,0)$) -- ($(n6.east) - (\Shift,0)$);

% Last nodes;

\nodebelow of = n6 , draw , rec style2 , node distance = 3cm{Drive to \ job site};

\nodebelow of = n7 , draw , rec style2 , node distance = 3cm{Clock at \ job site};

\nodebelow of = n8 , draw , rec style2 , node distance = 3cm{Walk to \ job site};

\nodebelow of = n9 , draw , rec style2 , node distance = 3cm{Start work };

% Let's start drawing the arrows and lines;

\draw[-{Latex[length=4.5mm]}] (n1) -- (n2);

\draw (n2) -- (cor1);

\draw[-{Latex[length=4.5mm]}] (cor1) -- (n3);

\draw (n2) -- (cor3);

\draw[-{Latex[length=4.5mm]}] (cor2) -- (n4);

\draw[-{Latex[length=4.5mm]}] (cor3) -- (n5);

\draw (n3) -- (cor4);

\draw[-{Latex[length=4.5mm]}] (cor4) -- (n6);

\draw (n4) -- (cor5);

\draw (n5) -- (cor6);

\draw[-{Latex[length=4.5mm]}] (cor6) -- (n6);

\draw [-{Latex[length=4.5mm]}] (n6) -- (n7);

\draw [-{Latex[length=4.5mm]}] (n7) -- (n8);

\draw [-{Latex[length=4.5mm]}] (n8) -- (n9);

\draw [-{Latex[length=4.5mm]}] (n9) -- (n10);

\end{tikzpicture}

\end{figure}

The transport system needs to be designed to incorporate all encompassing cases that relates to worker transportation. Firstly, workers need to be transported at the start of working days and between the working breaks to job sites. This is referred to as the transport process during non-operating hours. Secondly, workers often need to move from one block location to another block location. This process is known as the transport process during operating hours.

\end{document}

2 Answers2

4
  • your ain problem is solved by @ Qrrbrbirlbel comments: don't use transform canvas for scaling tikzpicture.
  • If possible, avoid scaling of picture. Rather design it such, that their width will be smaller or equal to \textwidth.
  • Beside this, your images has other issues:
    • If you define nodes' styles don't repeat its parts locally in nodes
    • You load positioning library. Why you than not use its syntax. By it is positioning of nodes simpler and define relative to each other.
    • in main branch of flowchart nodes are in chain. This can be exploited by their positioning in chan using chains library and its macro join=by ... (see MWE below) and make it much more concise and clear.
    • Your construct of diamonds with pus can be integrated with this nodes style, i.e. instead of
\node[draw , diamond style, below of = n2 , node distance = 6cm](n6){};
\draw [line width=1mm]%
            ($(n6.north) - (0,\Shift)$)-- ($(n6.south) + (0,\Shift)$)
            ($(n6.west)  + (\Shift,0)$)-- ($(n6.east)  - (\Shift,0)$);

you can define for example:

diamond plus/.style = {diamond, draw, minimum size=8mm , font=\bfseries,
                       path picture={\draw[line width=1mm,shorten <=2mm,shorten >=2mm]
                                (\ppbb.north) edge (\ppbb.south)
                                (\ppbb.west)  edge (\ppbb.east);
                                    },% end of path picture /node content/
                       node contents={}},

where command \ppbb is shortiness for path picture bounding box and you can be defined in document preamble is is done in my MWE. Using it your construct can be replaced by:

\node (n2) [diamond plus, below = of n1];

Considered aforementioned the complete MWE (Minimal Working Example) is:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, 
                calc, chains,
                positioning, 
                shadows, shapes}
\tikzset{FC/.append style = {% FC: FlowChart
         arr/.style = {-{Latex[scale=1.2]}, semithick},
  rec style2/.style = {draw, rounded corners, fill=white, drop shadow, 
                       minimum height=1cm, text width=22mm, align=center},
diamond plus/.style = {diamond, draw, minimum size=8mm , font=\bfseries,
                       path picture={\draw[line width=1mm,shorten <=2mm,shorten >=2mm]
                                (\ppbb.north) edge (\ppbb.south)
                                (\ppbb.west)  edge (\ppbb.east);
                                    },% end of path picture /node content/
                       node contents={}},
                            }
        }
\newcommand\ppbb{path picture bounding box} % new

\begin{document} %%%%% Tikz picture %%%% \begin{figure}[ht] \centering \begin{tikzpicture}[FC, node distance = 8mm and 12mm, start chain = going below ] \node (n1) [rec style2] {Get tractor ready}; \node (n2) [diamond plus, below = of n1]; % Second level of nodes; \node (n3) [rec style2, below left=of n2] {Driver coordination}; \node (n4) [rec style2, below right=of n2] {Book equipment}; \node (n5) [rec style2, right= of n4] {Workers board tractor}; % chain of nodes \begin{scope}[nodes={on chain, join = by arr}] \node (n6) [diamond plus, below=of n2.south |- n3]; % Last nodes; \node (n7) [rec style2] {Drive to job site}; \node (n8) [rec style2] {Clock at job site}; \node (n9) [rec style2] {Walk to job site}; \node (n10)[rec style2] {Start work }; \end{scope} % drawing arrows and lines out of chain; \draw[arr] (n1) -- (n2); \draw[arr] (n2.west) -| (n3); \draw[arr] (n2.east) -| (n4) coordinate[pos=0.5] (aux1); \draw[arr] (aux1) -| (n5); % \draw[arr] (n3) |- (n6); \draw[arr] (n4) |- (n6) coordinate[pos=0.5] (aux2); \draw[arr] (n5) |- (aux2); \end{tikzpicture} \end{figure}

The transport system needs to be designed to incorporate all encompassing cases that relates to worker transportation. Firstly, workers need to be transported at the start of working days and between the working breaks to job sites. This is referred to as the transport process during non-operating hours. Secondly, workers often need to move from one block location to another block location. This process is known as the transport process during operating hours. \end{document}

and produce:

enter image description here

Zarko
  • 296,517
1

The tikzpicture is too large for one page -- commenting out the last few nodes of the code will show just how much is acceptable on a single page with the text following the picture- the text also gets divided- you will either need to shorten the arrows in the picture or break the picture across two pages or reduce the size of the nodes and the text inside the nodes to make it fit one page

    \documentclass[11pt]{article}
\usepackage{tikz}

\usetikzlibrary{arrows.meta, positioning, shadows , calc ,shapes}

\tikzstyle{rec style2}=[% draw, shape = rectangle , fill = white ,
drop shadow , rounded corners , align = center , minimum height = 1cm , minimum width = 2cm] \tikzstyle{diamond style} = [% diamond, draw, minimum height = 0.8cm , minimum width = 0.8cm , font=\bfseries] \newcommand*{\Shift}{1.5ex}

\begin{document}

%%%%% Tikz picture %%%%

% \begin{figure}[h!]
% \centering \begin{tikzpicture} \nodedraw , rec style2{Get \ tractor \ ready}; \nodedraw , diamond style, below of = n1 , node distance = 3cm{};

        \draw [line width=1mm]%
        ($(n2.north) - (0,\Shift)$)-- ($(n2.south) + (0,\Shift)$)
        ($(n2.west)  + (\Shift,0)$)-- ($(n2.east)  - (\Shift,0)$);

        % Let's draw the invisible coordinates;

        \node[left of = n2, coordinate, node distance = 3cm](cor1) {};
        \node[right of = n2, coordinate, node distance = 3cm](cor2) {};
        \node[right of = n2, coordinate, node distance = 6cm](cor3) {};

        % Second level of nodes;

        \node[below of = cor1 , draw , rec style2 , node distance = 3cm](n3){Driver \\ coordination};
        \node[below of = cor2 , draw , rec style2 , node distance = 3cm](n4){Book \\ equipment};
        \node[below of = cor3 , draw , rec style2 , node distance = 3cm](n5){Workers \\ board \\ tractor};

        % Second level of invisible nodes;

        \node[below of = n3, coordinate, node distance = 3cm](cor4) {};
        \node[below of = n4, coordinate, node distance = 3cm](cor5) {};
        \node[below of = n5, coordinate, node distance = 3cm](cor6) {};
        \node[draw , diamond style, below of = n2 , node distance = 6cm](n6){};

        \draw [line width=1mm]%
        ($(n6.north) - (0,\Shift)$)-- ($(n6.south) + (0,\Shift)$)
        ($(n6.west)  + (\Shift,0)$)-- ($(n6.east)  - (\Shift,0)$);

        % Last nodes;

        \node[below of = n6 , draw , rec style2 , node distance = 3cm](n7){Drive to \\ job site};
        \node[below of = n7 , draw , rec style2 , node distance = 3cm](n8){Clock at \\ job site};

%
% \nodebelow of = n8 , draw , rec style2 , node distance = 3cm{Walk to \ job site}; %
% \nodebelow of = n9 , draw , rec style2 , node distance = 3cm{Start work }; %
% % Let's start drawing the arrows and lines; %
% \draw[-{Latex[length=4.5mm]}] (n1) -- (n2); %
% \draw (n2) -- (cor1); %
% \draw[-{Latex[length=4.5mm]}] (cor1) -- (n3); %
% \draw (n2) -- (cor3); %
% \draw[-{Latex[length=4.5mm]}] (cor2) -- (n4); %
% \draw[-{Latex[length=4.5mm]}] (cor3) -- (n5); %
% \draw (n3) -- (cor4); %
% \draw[-{Latex[length=4.5mm]}] (cor4) -- (n6); %
% \draw (n4) -- (cor5); %
% \draw (n5) -- (cor6); %
% \draw[-{Latex[length=4.5mm]}] (cor6) -- (n6); %
% \draw [-{Latex[length=4.5mm]}] (n6) -- (n7); %
% \draw [-{Latex[length=4.5mm]}] (n7) -- (n8); %
% \draw [-{Latex[length=4.5mm]}] (n8) -- (n9); %
% \draw [-{Latex[length=4.5mm]}] (n9) -- (n10); %
\end{tikzpicture}

% \end{figure} \vspace*{2em}

The transport system needs to be designed to incorporate all encompassing cases that relates to worker transportation. Firstly, workers need to be transported at the start of working days and between the working breaks to job sites. This is referred to as the transport process during non-operating hours. Secondly, workers often need to move from one block location to another block location. This process is known as the transport process during operating hours.



\end{document}

enter image description here

js bibra
  • 21,280