1

How to include tizpicture, for example defined in ducks package, to a forest node?

Edit: Simplified MWE with comparison result using duck in tikzpicture and in forest.

\documentclass[border=3.141592]{standalone}
\usepackage{forest}
\usetikzlibrary{ducks}

\begin{document}
\tikz[baseline]{\duck[signpost=1]}\quad
    \begin{forest} 
[\tikz{\duck[signpost=1]}]
    \end{forest}
\end{document}

As you can see, the duck image in forest node is not complete, missed is result of option signpost=1.

enter image description here

I guess, that image is included before its process of duck drawing is complete. So far I didn't find a way how to delay inclusion of image, or better, how to correct include such images in forest node.

6
  • 1
    Ducks can be nested in pic, did you try this option?
    – SebGlav
    Commented May 9, 2021 at 9:14
  • @SebGlav, no. I didn't. Can you show me, how to do this in forest?
    – Zarko
    Commented May 9, 2021 at 9:17
  • The syntax would be \draw pic[duck/signpost=1]{duck};, leading to (in the forest node): [\tikz{\draw pic[duck/signpost=1]{duck}}, label=below:Text]. It works well out of the forest environment. But I just tried it into the forest node, and it fails too.
    – SebGlav
    Commented May 9, 2021 at 9:25
  • @SebGlav, unfortunately, this doesn't work correctly. On the duck table is still missed number one. This mean that include pic in such a way is not correct way. Something should be add to forest option that duck image will be correct processed. I don't know what.
    – Zarko
    Commented May 9, 2021 at 10:09
  • Yes, like I said. Very annoying lack, even if we should not nest tikz inside forest nodes, in the first place.
    – SebGlav
    Commented May 9, 2021 at 10:32

1 Answer 1

2

you can add tikz pictures with the tikz key. But you will have to adapt the spacing and the positioning:

\documentclass[border=3.141592]{standalone}
\usepackage{forest}
\usetikzlibrary{ducks}

\begin{document}

    \begin{forest}
for tree = {
% nodes labels
/tikz/every label/.style = {label distance=0pt, inner sep=0pt},
% tree setings
    anchor = south,
     edge = {-, semithick, shorten < = 1em},
    s sep = 30mm,
    l sep = 30mm,
            }
[Text,tikz={\duck[shift=(.north)]},
   [Text,tikz={\duck[shift=(.north),signpost=1]}] % processed
   [Text,tikz={\duck[shift=(.south west),graduate=gray!20!black, tassel=red!70!black]},
    ]
]
    \end{forest}
\end{document}

enter image description here

4
  • Thank you for help (+1). With defining node size and adaptions of duck shifts, I manage toto draw tree as desired. See my answer tex.stackexchange.com/questions/596228/…. I will wait a day or so, if some more answer will come.
    – Zarko
    Commented May 10, 2021 at 14:49
  • @Zarko Now you can accept :). Commented May 23, 2021 at 18:01
  • 1
    @Dr.ManuelKuehner, I just do. Recently days I was mostly off-line :-(
    – Zarko
    Commented May 23, 2021 at 18:02
  • @Zarko Being offline is not always a bad thing :). I go offline now too :). See u. Commented May 23, 2021 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .