我有一个 tikz 绘图,其中有三条平行线和一个大箭头。我希望这三条线在开头合并到大线中。有人能建议我怎么做吗?
\begin{center}
\begin{figure}[t!]
\resizebox{0.7\textwidth}{!}{
\begin{tikzpicture}[font=\sffamily]
\node[draw=none, fill=none] (sender) {};
\node[draw=none, fill=none, right =6cm of sender] (provider) {};
\coordinate (wall) at ([xshift=-2.5cm]provider.west);
\draw[transform canvas={yshift=4.5ex}, line width = 2pt] (sender) -- node [text width=2.5cm,midway,above] {Line 1} (wall);
\draw[transform canvas=, line width = 2pt] (sender) --node [text width=2.5cm,midway,above] {Line 2} (wall);
\draw[transform canvas={yshift=-4.5ex}, line width = 2pt] (sender) -- node [text width=2.5cm,midway,above] {Line 3} (wall);
\draw[transform canvas=,->, line width = 5pt] (wall) -- node [text width=2.5cm,midway,above=1em] {Large line} (provider);
\end{tikzpicture}
}
\end{figure}
\end{center}
答案1
像这样?
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, positioning, shapes.arrows}
\begin{document}
\begin{tikzpicture}[
node distance=2mm and 12mm,
A/.style = {single arrow, draw=gray, fill=gray,
single arrow head extend=1.5mm,
minimum height=12mm, minimum width=12mm,
outer sep=0mm},
box/.style = {rectangle, draw, minimum size=12mm},
]
\node (s) [box] {sender};
\node (a) [A,right=of s] {};
\node (r) [box,right=0mm of a]{receiver};
%
\coordinate[above=of s.east] (sa);
\coordinate[below=of s.east] (sb);
%
\draw[very thick]
(sa) -- (a.tail |- sa)
(s.east) -- (a)
(sb) -- (a.tail |- sb);
\end{tikzpicture}
\end{document}
笔记:
- 切勿将浮动环境置于
\begin{center}
和之间\end{center}
- 请不要只发送代码片段。始终提供最小的工作示例(姆韦),一个很小但很完整的文档,以 开头
\documentclass{...}
,以 结尾\end{document}
。在序言中,只加载与您的问题相关的软件包。
答案2
你想要这样的东西吗?
正如 Zarko 告诉你的那样,我已经使用了\centering
环境center
。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes.arrows}
\begin{document}
\begin{figure}[t!]
\centering
\resizebox{0.7\textwidth}{!}{%
\begin{tikzpicture}[font=\sffamily]
\node[draw=none, fill=none] (sender) {};
\node[draw=none, fill=none, right =6cm of sender] (provider) {};
\coordinate (prewall) at ([xshift=-3cm]provider.west);
\coordinate (wall) at ([xshift=-2.5cm]provider.west);
\draw[line width = 2pt] ([yshift=4.5ex]sender.east) -- node [text width=2.5cm,midway,above] {Line 1} ([yshift=4.5ex]prewall) -- ([shift={(1pt,1pt)}]wall.west);
\draw[transform canvas=, line width = 2pt] (sender) --node [text width=2.5cm,midway,above] {Line 2} (prewall) -- (wall.west);
\draw[line width = 2pt] ([yshift=-4.5ex]sender.east) -- node [text width=2.5cm,midway,above] {Line 3} ([yshift=-4.5ex]prewall) -- ([shift={(1pt,-1pt)}]wall.west);
\draw[transform canvas=,->, line width = 5pt] (wall) -- node [text width=2.5cm,midway,above=1em] {Large line} (provider);
\end{tikzpicture}
}
\end{figure}
\end{document}