左右图 Latex TikZ

左右图 Latex TikZ

我已经使用 Tikz 创建了以下内容。

\begin{document}
\pagestyle{empty}


% Define block styles

\tikzstyle{block} = [rectangle, draw, fill=white, rounded corners,
                 minimum height=2em, minimum width =7em, text width=5em]
\tikzstyle{line} = [draw, -latex']


\begin{tikzpicture}[node distance = 2cm, auto]
 % Place nodes

\node [block] (strategy) {\footnotesize Multimedia RSs};
\node [block, right of=strategy, node distance=3cm] (content) {\footnotesize Multimedia Content};

% Draw edges

\path [line] (strategy) -- (content);

\end{tikzpicture}
\end{document}

输出如下:

在此处输入图片描述

我希望“多媒体内容”框出现在“东北”另一个盒子'东南'箭头不倾斜(IE的组合水平的垂直的箭头)。我对 tikzz 还很陌生,因此非常欢迎您的建议。

附言:正如您所见,尽管文本大小很大\footnotesize

答案1

有几种方法可以做到这一点。有chainsTi 库Z 适用于这种绘图,但我认为它适用于斜连接。您也可以matrix像这样使用该库:有没有更简单的方法在 tikz 中绘制大量箭头?、使用positioning图书馆等等。

无论如何,下面是使用 MWE,matrix因为它更容易拥有-||-(水平和垂直线的组合)并且也是您正在做的事情的延续。

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,calc}
\tikzset{block/.style={ rectangle,
                        draw,
                        fill=white,
                        rounded corners,
                        minimum height=2em,
                        minimum width =7em,
                        text width=5em},
         >=latex}

\begin{document}
\begin{tikzpicture}
% Using the matrix library
  % Make the grid
  \matrix (Media)[matrix of nodes, nodes in empty cells, column sep=2cm]
  {
                           &                                    &          & Subsubblock \\
                           &                                    & Subblock & \\
                           &                                    &          & Subsubblock \\
                           & |[block]| Multimedia content       &          & \\
                           &                                    &          & Subsubblock \\
                           &                                    & Subblock & \\
                           &                                    &          & Subsubblock \\
  |[block]| Multimedia RSs &                                    &          & \\
                           &                                    &          & Subsubblock \\
                           &                                    & Subblock & \\
                           &                                    &          & Subsubblock \\
                           & |[block]| Other Multimedia content &          & \\
                           &                                    &          & Subsubblock \\
                           &                                    & Subblock & \\
                           &                                    &          & Subsubblock \\
  };

  % Draw the lines
  \draw[->] (Media-2-1) -| +(2cm,0) |- (Media-1-2);
  \draw[->] (Media-2-1) -| +(2cm,0) |- (Media-3-2);

% Somewhat what you were doing - needs positioning and calc libraries
  \begin{scope}[xshift=6cm] %the scope here is just so graphics don't overlap in this example
  \node [block] (strategy) {\footnotesize Multimedia RSs};
  \node [block, above right=1cm of strategy] (content) {\footnotesize Multimedia Content};
  \node [block, below right=1cm of strategy] (content2) {\footnotesize Multimedia Content};

  \draw[->] (strategy) -| ($(strategy)!.5!(content)$) |- (content);
  \draw[->] (strategy) -| ($(strategy)!.5!(content2)$) |- (content2);
  \end{scope}
\end{tikzpicture}
\end{document}

顺便说一句,对我来说,que 似乎\footnotesize运行正常。

在此处输入图片描述

答案2

看起来你实际上画了一棵树。借助tikztrees或使用包 可以相对简单地绘制树forest

\documentclass[tikz,
               border=3mm]{standalone}
\usetikzlibrary{arrows,trees}
\usepackage[edges]{forest}

\begin{document}
    \begin{tikzpicture}[
    node distance = 2cm, 
every node/.style = {rectangle, draw, semithick, rounded corners,
                     inner sep=3mm, font=\footnotesize,
                     align=center},
  level distance = 33mm,
            grow = right,
edge from parent fork right,
edge from parent/.style = {draw, semithick, -stealth},
                        ]
\node {Multimedia\\ RSs}
    child { node {Multimedia\\ Content}}
    child { node {Multimedia\\ Content}}
    ;
    \end{tikzpicture}

  \begin{forest}
    for tree={
      font=\footnotesize,
      draw, semithick, rounded corners,
      align=center,
        inner sep = 3mm,
             edge = {draw, semithick, -stealth},
             grow = east,
    parent anchor = east,
     child anchor = west,
             grow = east,
      forked edge,
             l sep = 12mm% level distance
          fork sep = 6mm,
                }
    [Multimedia\\ RSs
      [Multimedia\\ Content]
      [Multimedia\\ Content]
    ]
  \end{forest}
\end{document}

结果为trees

在此处输入图片描述

结果forest

在此处输入图片描述

编辑: 在@cfr 的帮助下,使用 的解决方案forest得到了改进,增加了fork sep = 6mmfor tree现在分支点位于节点之间水平距离的中间。

相关内容