tikz 图片上书写的文字

tikz 图片上书写的文字

我是新来的 latex 用户。我不明白为什么我写的文本写在文档中显示我的 tikz 图片的空间中。在我的源代码文档中,文本写在 tikz 图片的代码下方,但当文档编译时,文本显示在 tikz 图片上。我希望我的文档的文本显示在 tikz 图片下方,而不是与图片显示在同一个位置。

这是我的代码:


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


\node[draw , rec style2](n1){Get \\ tractor \\ ready};


\node[draw , diamond style, below of = n1 , node distance = 3cm](n2){};

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

\node[below of = n8 , draw , rec style2 , node distance = 3cm](n9){Walk to \\ job site};

\node[below of = n9 , draw , rec style2 , node distance = 3cm](n10){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}

答案1

  • 您的自身问题已由@Qrrbrbirlbel 评论解决:不要用于transform canvas缩放 tikzpicture。
  • 如果可能的话,避免缩放图片。最好设计成宽度小于或等于\textwidth
  • 除此之外,您的图像还存在其他问题:
    • 如果你定义节点的样式,请不要在节点中本地重复其部分
    • 您加载positioning库。为什么不使用它的语法呢?因为它使节点的定位更简单,并且相互之间可以相互定义。
    • 流程图主分支中的节点处于链中。这可以通过使用chains库及其宏join=by ...(参见下面的 MWE)将它们定位在 chan 中来利用,并使其更加简洁明了。
    • 您构建的带有脓液的钻石可以与此节点样式集成,即
\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)$);

例如你可以定义:

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={}},

其中命令\ppbb是简短的path picture bounding box,您可以在文档序言中定义,这在我的 MWE 中完成。使用它,您的构造可以替换为:

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

考虑到上述情况,完整的 MWE (最小工作示例) 是:

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

并产生:

在此处输入图片描述

答案2

对于一页来说太大tikzpicture了——注释掉nodes代码的最后几部分将显示在一页上可以接受多少图片——text图片text也会被分割——你要么需要shorten the arrows在图片中,要么在两页之间,或者在break图片reduce the size of the nodes里面,以使其适合一页textnodes

    \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}
            \node[draw , rec style2](n1){Get \\ tractor \\ ready};
            \node[draw , diamond style, below of = n1 , node distance = 3cm](n2){};

            \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};
%           
%           \node[below of = n8 , draw , rec style2 , node distance = 3cm](n9){Walk to \\ job site};
%           
%           \node[below of = n9 , draw , rec style2 , node distance = 3cm](n10){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}

在此处输入图片描述

相关内容