TikZ 中箭头的方向

TikZ 中箭头的方向

以下 TikZ 代码用于准备流程图。

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,shadows,arrows}
\usepackage{lscape}
\begin{document}
\tikzstyle{decision} = [diamond, draw, fill=blue!50]
\tikzstyle{line} = [draw, -stealth, thick]
\tikzstyle{block} = [draw, rectangle, fill=red!25, text width=12em, text centered, minimum height=14mm, node distance=10em]
\begin{center}
\begin{tikzpicture}
\node [block] (start) {Vacuum Drying of LiCl-KCl Eutectic+H$_2$O Mixtures};
\node [block, left of=start, xshift=-5em] (process1) {Vacuum Drying of LiCl-KCl Eutectic};
\node [block, above of=start, yshift=0.1em] (user) {Purification of LiCl-KCl Eutectic};
\node [block, right of=start, xshift=5em] (process2) {Redox Behaviour of H$_2$O in LiCl-KCl Eutectic Melt};
\node [block, below of=start, yshift=0.1em] (process5) {Pre-Electrolysis of LiCl-KCl Eutectic + H$_2$O Melts};
\node [block, below of=process1, yshift=0.1em] (process4) {Pre-Electrolysis of LiCl-KCl Eutectic Melts};
\node [block, below of=process4, yshift=0.1em] (process6) {Demonstration of Vacuum Drying in 2 kg};
\node [block, below of=process6, yshift=0.1em] (process7) {Scale Up};
\path [line] (user) -- (start);
\path [line] (user) -| node[yshift=0.1em, xshift=-5em] {} (process1);
\path [line] (user) -| node[yshift=0.1em, xshift=5em] {} (process2);
\path [line] (process1) -- (process4);
\path [line] (start) -- (process5);
\path [line] (process2) -- (start);
\path [line] (process4) -- (process6);
\path [line] (process6) -- (process7);
\path [line] (process1) -- (start);
\path [line] (process4) -- (process5);
\path [line] (process5.south) -- (process6.east);
\path [line] (process2.south) -- (process5.east);
\end{tikzpicture}
\end{center}
\end{document}

流程图看起来不错,但使用最后两个命令绘制的两个箭头

\path [line] (process5.south) -- (process6.east);
\path [line] (process2.south) -- (process5.east);

我希望块通过垂直 \& 水平线连接起来,类似于命令

\path [line] (user) -| node[yshift=0.1em, xshift=-5em] {} (process1);
\path [line] (user) -| node[yshift=0.1em, xshift=5em] {} (process2);

我尝试了各种选项,但箭头被遮盖/与块重叠。还有其他解决方案吗?谢谢,

答案1

像这样?

在此处输入图片描述

对于连接线,我部分考虑@ferahfeza 的评论。我建议将您的流程图的代码重新组织如下:

  • 画出三个分支:中间、左边、右边
  • 链中分支链接中的节点
  • 对于链内的节点连接使用join
  • 用于暂停分支之间的连接使用代码suspend join(其定义可以在许多类似的答案中找到)
  • 为了编写化学公式,我使用了以下mhchem软件包

姆韦上述考虑的是:

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                shapes, shadows}
\makeatletter
\tikzset{suspend join/.code={\def\tikz@after@path{}}}
\makeatother
\usepackage[version=4]{mhchem}

\begin{document}
    \begin{center}
\begin{tikzpicture}[
node distance = 8mm and 4mm,
  start chain = going below,
 block/.style = {draw, fill=red!25, text width=12em, minimum height=14mm,
                 font=\linespread{0.84}\selectfont, align=center,
                 on chain, join=by line},
  line/.style = {-Stealth, semithick}
                    ]
    \begin{scope}[every node/.style = {block}]
 % midle branch
\node   (user)      {Purification of \ce{LiCl-KCl} Eutectic};
\node   (start)     {Vacuum Drying of \ce{LiCl-KCl} Eutectic + \ce{H2O} Mixtures};
\node   (process5)  {Pre-Electrolysis of \ce{LiCl}-\ce{KCl} Eutectic + \ce{H2O}  Melts};
% left branch
\node   (process1)  [left=of start, suspend join]
                    {Vacuum Drying of \ce{LiCl-KCl} Eutectic};
\node   (process4)  {Pre-Electrolysis of \ce{LiCl}-\ce{KCl} Eutectic Melts};
\node   (process6)  {Demonstration of Vacuum Drying in 2 kg};
\node   (process7)  {Scale Up};
% right branch
\node   (process2)  [right=of start, suspend join]
                    {Redox Behaviour of \ce{H2O} in LiCl-KCl Eutectic Melt};
    \end{scope}
% connection not considered by join macro
\draw[line] (user) -| (process1);
\draw[line] (user) -| (process2);
%
\draw[line] (process5) |- (process6);
\draw[line] (process2) |- (process5);
\end{tikzpicture}
\end{center}
\end{document}

注意:用于\tikstyle定义节点样式的 已经过时,它被 取代 \tikzset。由于在您的流程图中仅使用block来自所有定义的样式,我只考虑它并将其重新定义为 的选项tikzpicture

相关内容