具有包含文本和图像的节点的福雷斯特树

具有包含文本和图像的节点的福雷斯特树

在这里找到了我需要的答案……真是一个及时、乐于助人的社区!谢谢大家。

我正在尝试用 MS Word 重新创建这个情节 在此处输入图片描述

如何创建一个带有换行文本和其下方图像的节点?

尝试1)

\begin{figure*}[ht]
\centering
\tikzset{edge from parent/.style=
{draw, edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}},
blank/.style={draw=none}}
\begin{tikzpicture}
\matrix
{
\node{\Tree 
 [.{Gaps and overlaps due to manufacturing process variation} 
    [.
    {Tape position variation } 
        [.{\includegraphics[width=0.25\linewidth]{manuscript/src/figures/incorrectgeometry.jpg}}  {Robot inaccuracy}  {Tape lateral movement on the roller} ] 
    ]
    [.
    {Tape position variation} 
        [.{\includegraphics[width=0.25\linewidth]{manuscript/src/figures/incorrectgeometry.jpg}}  {Robot inaccuracy}  {Tape lateral movement on the roller} ] 
    ]
    ]};\\
};           
\end{tikzpicture}
    \caption{Breakdown of AFP manufacturing process variations which cause gap and overlap defects.}
    \label{fig:breakdown}
\end{figure*}

在此处输入图片描述

尝试 2(无法弄清楚文本部分):

> \usepackage[edges]{forest} \begin{document} \forestset{   declare
> toks={graphics}{}, } \begin{forest}   before typesetting nodes={
>     for tree={
>       content/.wrap 2 pgfmath args={\includegraphics[#2]{#1}}{content()}{graphics()},
>     },
>     where={isodd(n_children())}{calign=child, calign child/.wrap pgfmath arg={#1}{int((n_children()+1)/2)}}{},   },   forked edges,  
> for tree={
>     parent anchor=children,
>     child anchor=parent,
>     l sep'+=3mm,
>     s sep'+=1mm,
>     fork sep'+=1mm,
>     edge={line width=1.5pt},   },   [incorrectgeometry.jpg, graphics={scale=0.1}
>     [incorrectgeometry.jpg, graphics={scale=0.1}
>       [incorrectgeometry.jpg, graphics={scale=0.1}]
>       [incorrectgeometry.jpg, graphics={scale=0.1}]
>       [incorrectgeometry.jpg, graphics={scale=0.1}]
>     ]
>     [incorrectgeometry.jpg, graphics={scale=0.1}
>       [incorrectgeometry.jpg, graphics={scale=0.1}]
>     ]   ] \end{forest}

在此处输入图片描述

答案1

您可以在 es 中设置文本\parbox,并将图像作为一行添加到框后面。

在此处输入图片描述

\documentclass{article}

\usepackage{forest, graphicx, duckuments}
\useforestlibrary{edges}

\begin{document}

\begin{forest}
for tree={align=center, s sep=5mm, forked edge}
[Gaps and overlaps due to manufacturing process variation
    [Tape position variation\\{\includegraphics[width=4cm, height=1cm]{example-image-a}}
        [{\parbox[c][12mm]{32.5mm}{\centering Robot inaccuracy}}\\{\includegraphics[width=3cm]{example-image-duck}}]
        [{\parbox[c][12mm]{32.5mm}{\centering Tape lateral movement on the roller}}\\{\includegraphics[width=3cm]{example-image-duck}}]
    ]
    [Tape position variation\\{\includegraphics[width=4cm, height=1cm]{example-image-b}}
        [{\parbox[c][12mm]{32.5mm}{\centering Tape width variation}}\\{\includegraphics[width=3cm]{example-image-duck}}]
        [{\parbox[c][12mm]{32.5mm}{\centering Tape compaction under roller}}\\{\includegraphics[width=3cm]{example-image-duck}}]
    ]
]
\end{forest}

\end{document}

答案2

以下是一些代码,可帮助您开始了解我在上面的评论中提到的方向。我建议采用逐步完善的过程:

  • (1)首先放置您需要的所有节点(例如绝对节点,就像我做的那样,使用矩阵,通过所述库使用相对定位等)
  • (2)绘制直线互连
  • 所有这些都可以帮助你把东西放在正确的位置
  • (3)细化互联

广告 1,节点

  • 顶层只是一个(A)包含文本的节点
  • 第二级只是为了说明,只保存另一个节点中的图形(I1)\coordinate(扩展名为零的 \node,即任何内容)
  • 第三层向你展示如何通过锚点将一个节点连接到另一个节点

广告 2,线条

您是否连接了预期的内容?您能让节点留在原处吗?

结果

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{graphicx}

\begin{document}
 \begin{tikzpicture}
    % ~~~ (1) placing nodes first ~~~~~~~~~~
    %     top level
    \node (A) at (0,0) {Gaps and overlaps due to manufacturing process variation};
    
    %     first level
    \node       (I1) at (-3,-2) {\includegraphics[width=3cm]{tape}};
    \coordinate (I2) at (3,-2); % just a dummy
    
    \node (T2) at (-5,-4) {Robot inaccuracy};
    \node[anchor=north,yshift=-3mm]
               at (T2.south) {\includegraphics[width=3cm]{robot}};
    
    % ~~~ (2) draw some lines ~~~~~~~~~~
    \draw (A) -- (I1);
    \draw (A) -- (I2);
    
    \draw (I1) -- (T2);
    
 \end{tikzpicture}
\end{document}

广告 3,细化线条,即引入蜿蜒

例如这个答案使用中间点

关于 class standalone

为什么要使用它?因为开发图纸会更容易。参见例如本示例将它们包含为 pdf在其他文件中。

图片

我从整体图中剪下了它们;无法将它们粘贴到这里,因为它们……太小了,无法上传……

答案3

我花了比预期更长的时间才创造出这种风格Sandy G 的回答

\documentclass{standalone}
% ateb: https://tex.stackexchange.com/a/714910/ addasayd o ateb Sandy G: https://tex.stackexchange.com/a/714881/
\usepackage[edges]{forest}
\usepackage{array}
\usepackage{duckuments}
\newcolumntype{C}[1]{>{\centering}p{#1}}
\forestset{%
  declare autowrapped toks={descriptor}{},
  declare autowrapped toks={image}{},
  declare dimen={align to}{0pt},
  align me/.style={%
    before typesetting nodes={
      if={> Od > {align to}{0pt} } {%
        align/.process={ Ow {align to}{C{##1}} },
        tier/.option=level,
      }{},
    },
  },
  describe image/.style={%
    delay={
      align me,
      split option={content}{:}{temptoksc,temptoksa},
      if temptoksa={}{}{%
        descriptor/.register=temptoksc,
        image/.register=temptoksa,
        replace by/.process={OOOw3{descriptor}{node options}{align to}{[##1,append,align to=##3,##2,forked edge,l sep'=0pt,align me]}},
        delay={content/.option=image,no edge},
      },
    },
  },
}
\begin{document}

\begin{forest}
  forked edges,
  for tree={
    describe image,
    font=\sffamily,
    if level=1{% for the first level
      align to'=4cm,
    }{%
      if level=2{% for the terminal level
        align to'=3cm,
      }{%
        align=c, 
      },
    },
  },
  [Gaps and overlaps due to manufacturing process variation
    [Tape position variation:{\includegraphics[width=\linewidth, height=1cm]{example-image-a}}
      [Robot\\inaccuracy:{\includegraphics[width=\linewidth]{example-image-duck}}]
      [Tape lateral movement on the roller:{\includegraphics[width=\linewidth]{example-image-duck}}]
    ]
    [Tape position variation:{\includegraphics[width=\linewidth, height=1cm]{example-image-b}}
      [Tape width variation:{\includegraphics[width=\linewidth]{example-image-duck}}]
      [Tape compaction under roller:{\includegraphics[width=\linewidth]{example-image-duck}}]
    ]
  ]
\end{forest}

\end{document}

[由于 Okular 错误导致没有图像:对想象力的负担表示歉意。]

来自社区,经过 2 次编译运行:

结果

相关内容