![左右图 Latex TikZ](https://linux22.com/image/342152/%E5%B7%A6%E5%8F%B3%E5%9B%BE%20Latex%20TikZ.png)
我已经使用 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
有几种方法可以做到这一点。有chains
Ti 库钾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
看起来你实际上画了一棵树。借助tikz
库trees
或使用包 可以相对简单地绘制树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 = 6mm
。for tree
现在分支点位于节点之间水平距离的中间。