我目前正在使用Latex制作流程图,我发现箭头会像这样穿过标签:
当然有代码:
%!TEX program = xelatex UTF8
\documentclass[UTF8]{ctexart}
\usepackage{tikz,mathpazo}
\usepackage{graphicx,amssymb,amstext,amsmath,newtxmath}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\thispagestyle{empty}
\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=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
\tikzstyle{arrow} = [->,>=stealth]
\begin{tikzpicture}[node distance=2cm]
\node (start) [startstop] {Start};
\node (in1) [io, below of=start] {Input 1};
\node (pro1) [process, below of=in1] {Process 1};
\node (dec1) [decision, below of=pro1, yshift=-0.5cm] {Decision 1};
\node (out1) [io, left of=dec1,xshift=-2cm,yshift=-2cm] {Out 1};
\node (stop) [startstop, below of=out1] {Stop};
\node (dec2) [decision,right of=dec1,xshift=2cm,yshift=-2cm] {Decision 2};
\node (pro2) [process, right of=dec2, xshift=2cm] {Process 2};
\node (pro3) [process, below of=dec2, yshift=-0.5cm] {Process 3};
\draw [arrow](start) -- (in1);
\draw [arrow](in1) -- (pro1);
\draw [arrow](pro1) -- (dec1);
\draw [arrow](dec1) -| node[anchor=north] {Doch} (out1);
\draw [arrow](out1) -- (stop);
\draw [arrow](dec1) |- node[anchor=east] {Nein} (dec2);
\draw [arrow](dec2) -- node[anchor=east] {Nein} (pro3);
\draw [arrow](dec2) -- node[anchor=south] {Ja} (pro2);
\draw [arrow](pro2) |- (dec1);
\end{tikzpicture}
\end{document}
如何将标签Doch移动到两侧的空白处?
答案 0 :(得分:2)
使用其他left
或above
属性:
\draw [arrow](dec1) -| node[anchor=north, left] {Doch} (out1);
或
\draw [arrow](dec1) -| node[anchor=north, above] {Doch} (out1);
应该做到这一点。