如何在 LaTeX 中创建简单的漏斗?

如何在 LaTeX 中创建简单的漏斗?

我在尝试创建一个简单的漏斗时遇到了问题,如附件中所示: 在此处输入图片描述

我曾尝试查看互联网,尝试写出这些线条,但不起作用。我正在使用 TikZ。该图的基本思想是向读者展示我做了一个界定。

如果有人可以帮助我或者有更好的选择,我会很高兴听到。

答案1

概括性不是很好,但是...

\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}[x=4cm,y=.5cm, >=stealth]
\foreach \i [evaluate={%
  \x=\i<4 ? \i : (\i<16 ?    1 : (\i<22 ?     2 : 3));
  \y=\i<4 ?  1 : (\i<16 ? 2-\i : (\i<22 ? 11-\i : 15-\i));
}] in {1,...,23}
  \node (text-\i) at (\x,\y) {Text \i};
\draw [->] ( text-4.north west -| text-15.west)++(0,1)  -- (text-22.north east);
\draw [->] (text-15.south west)++(0,-1) -- (text-23.south east);
\end{tikzpicture}

在此处输入图片描述

答案2

PSTricks 解决方案:

\documentclass{article}

\usepackage{pstricks}
\usepackage{multido}


\begin{document}

\begin{pspicture}(8,8.1)
  \psline{->}(0,0)(8,3)
  \psline{->}(0,7)(8,4)
  \multido{\iA = 1+3, \iB = 1+1}{3}{\rput(\iA,8){Text~\iB}}
  \multido{\r = 5.975+-0.45, \i = 4+1}{12}{\rput(1,\r){Text~\i}}
  \multido{\r = 4.625+-0.45, \i = 16+1}{6}{\rput(4,\r){Text~\i}}
  \multido{\r = 3.725+-0.45, \i = 22+1}{2}{\rput(7,\r){Text~\i}}
\end{pspicture}

\end{document}

输出

答案3

像这样吗?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
% Line of Text
\node at (0,7) {Text 1};
\node at (4,7) {Text 2};
\node at (8,7) {Text 3};
% First column of Text
\node at (0,5.5) {Text 4};
\node at (0,5) {Text 5};
\node at (0,4.5) {Text 6};
\node at (0,4) {Text 7};
\node at (0,3.5) {Text 8};
\node at (0,3) {Text 9};
\node at (0,2.5) {Text 10};
\node at (0,2) {Text 11};
\node at (0,1.5) {Text 12};
\node at (0,1) {Text 13};
\node at (0,0.5) {Text 14};
\node at (0,0) {Text 15};
% Second column of Text
\node at (4,4) {Text 16};
\node at (4,3.5) {Text 17};
\node at (4,3) {Text 18};
\node at (4,2.5) {Text 19};
\node at (4,2) {Text 20};
\node at (4,1.5) {Text 21};
% Third column of Text
\node at (8,3) {Text 22};
\node at (8,2.5) {Text 23};
% Arrows
\draw[-triangle 60] (-1,6.5)--(9,3.5);
\draw[-triangle 60] (-1,-1)--(9,2);
\end{tikzpicture}

\end{document}

得到如下结果:

在此处输入图片描述

编辑:调整为更短的代码,但对于每个特定“文本”的位置的控制较少:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\begin{document}

\begin{tikzpicture}
% Line of Text
\foreach \x in {1,2,3}{\node at ($(0,7)+(\x*4-4,0)$) {Text \x};}
% First column of Text
\foreach \x in {4,...,15}{\node at ($(0,6)+(0,\x*-.5+1.5)$) {Text \x};}
% Second column of Text
\foreach \x in {16,...,21}{\node at ($(4,4)+(0,\x*-.5+8)$) {Text \x};}
% Third column of Text
\foreach \x in {22,23}{\node at ($(8,3)+(0,\x*-.5+11)$) {Text \x};}
% Arrows
\draw[-triangle 60] (-1,6.5)--(9,3.5);
\draw[-triangle 60] (-1,-1)--(9,2);
\end{tikzpicture}

\end{document}

相关内容