1

I am creating what seems like a straightforward tree using tikz and forest. The figure is close to what I want, but appears significantly to the left and right of the expected place, outside the bounds of the figure and even the page.

tree rendering top right

The "1" next to the top node is page numbering.

Code example:

\documentclass[runningheads]{llncs}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathabx}

\usepackage{caption}
\usepackage{subcaption}

\usepackage{tikz}
\usetikzlibrary{svg.path,positioning,shapes,calc,arrows.meta,graphs,graphdrawing}
\usegdlibrary{trees}
\usepackage{forest}

\def\choicep{\times}
\def\seqop{\rightarrow}

\begin{document}

Introductory text.

\begin{figure}
    \begin{tikzpicture}[>=stealth, every node/.style={ellipse,draw},
                        sibling distance=2pt]
        \begin{forest}
        for tree={
            edge = {->},
            ellipse,
            draw,
            math content,
            anchor = center
        },
        [\choicep:4
            [\seqop:1
                [a:1]
                [b:1]
            ]
            [\seqop:1
                [a:1]
                [b:1]
            ]
            [\seqop:1
                [b:1]
                [a:1]
            ]
            [\seqop:1
                [c:1]
                [c:1]
                [c:1]
            ]
        ]
        \end{forest}
    \end{tikzpicture}
    \caption{Misaligned tree (skews top right).}
    \label{fig:discovery-eg-trace}
\end{figure}

Closing text.

\end{document}

This is an MRE, but I found the behaviour originally within a subfigure, with surrounding text, etc. It happily plonks itself over other text, figures, page headers etc. I am using overleaf.

Seems like it should be something basic but has me scratching my head. I also tried \graph and the {} syntax, but that choked on the mathematical symbols for the nodes.

5
  • 4
    forest environment is already a tikzpicture therefore your code nest tikzpictures which is not recommended. if you delete the tikzpicture environment, the forest diagram will go to their place.
    – Ignasi
    Dec 17, 2020 at 9:09
  • That was it. Thank you.
    – Adam Burke
    Dec 17, 2020 at 22:59
  • 2
    I’m voting to close this question because it was solved in comments.
    – cfr
    Dec 24, 2020 at 3:42
  • The answer was both useful and non-obvious to me. I'm neither LaTeX newbie nor guru. So I have copied to an answer, but marked as a community wiki.
    – Adam Burke
    Dec 24, 2020 at 4:52
  • @AdamBurke You did well, I voted to leave open.
    – CarLaTeX
    Dec 24, 2020 at 6:40

1 Answer 1

3

The forest environment is already a tikzpicture, therefore your code nests tikzpictures, which is not recommended. if you delete the tikzpicture environment, the forest diagram will go to their place.

(From @Ignasi in the comments.)

You must log in to answer this question.

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