0

The LaTeX code of the tree works in other templates, but when copied to the Springer Nature template, it shows errors.

Here is my code:

    \RequirePackage{tikz}
    
    \documentclass[default,iicol]{sn-jnl}
    
    %\usepackage{graphicx}
    %\usepackage{forest}
    %\usetikzlibrary{shadows}
    %\usepackage{program}
    %\usepackage{tikz}
    
    \jyear{2021}%
    \raggedbottom
    
    \begin{document}
    
    \title[Article Title]{Article Title}
    
    \author*[1,2]{\fnm{First} \sur{Author}}\email{[email protected]}
    \author[2,3]{\fnm{Second} \sur{Author}}\email{[email protected]}
    \equalcont{These authors contributed equally to this work.}
    \author[1,2]{\fnm{Third} \sur{Author}}\email{[email protected]}
    \equalcont{These authors contributed equally to this work.}
    \affil*[1]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{100190}, \state{State}, \country{Country}}}
    \affil[2]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{10587}, \state{State}, \country{Country}}}
    \affil[3]{\orgdiv{Department}, \orgname{Organization}, \orgaddress{\street{Street}, \city{City}, \postcode{610101}, \state{State}, \country{Country}}}
    
    
    \abstract{The abstract serves both as a general introduction to the topic and as a brief, non-technical summary of the main results and their implications. Authors are advised to check the author instructions for the journal they are submitting to for word limits and if structural elements like subheadings, citations, or equations are permitted.}
    
    \keywords{keyword1, Keyword2, Keyword3, Keyword4}
    
    \maketitle
    
    \section{Introduction}\label{sec1}
    The Introduction section, of referenced text expands on the background of the work (some overlap with the Abstract is acceptable). The introduction should not include subheadings.
    Springer Nature does not impose a strict layout as standard however authors are advised to check the individual requirements for the journal they are planning to submit to as there may be journal-level preferences. When preparing your text please also be aware that some stylistic choices are not supported in full text XML (publication version), including coloured font. These will not be replicated in the typeset article if it is accepted. 
    
    \section{Results}\label{sec2}
    Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.
    
    \section{This is an example for first level head---section head}\label{sec3}
    \subsection{This is an example for second level head---subsection head}\label{subsec2}
    \subsubsection{This is an example for third level head---subsubsection head}\label{subsubsec2}
    Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. 
    \section{Figures}\label{sec5}
    Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.
    
    \section{Tree}\label{sec6}
    Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.
    
    
    
    \begin{figure}[!t]
    \centering
    
    {\footnotesize
    \begin{forest}
    /tikz/every node/.append style={font=\footnotesize},
    for tree={
    if level=0{align=center}{
        align={@{}P{23mm}@{}}
                                },
    grow=east,
    draw,
    font=\footnotesize,
    edge path={
        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(3mm,0) |- (.child anchor)\forestoption{edge label};
                },
    parent anchor=east,
    child anchor=west,
    l sep=10mm,
    tier/.wrap pgfmath arg={tier #1}{level()},
    edge={ultra thick, rounded corners=2pt},
    fill=white,
    rounded corners=2pt,
    drop shadow,
            }
    [root
    [name2, edge+={-stealth}
        [name21 , edge+={-stealth}]
    ]
    [name1, edge+={-stealth}
        [name12 , edge+={-stealth}]
        [name13 , edge+={-stealth}]
    ]
    ]
    \end{forest}
    }
    
    \caption{simple tree}
    \end{figure}
    
    
    \end{document}

How it can be solved ?

Thanks

1
  • You do not seem to load forest, do you?
    – user255043
    Nov 23, 2021 at 13:24

2 Answers 2

3

Try this set up. (Changes in the order of loading and a minor typo in the columns type).

a

\RequirePackage{forest}
\documentclass[default,iicol]{sn-jnl}

\usepackage{graphicx}
\RequirePackage{tikz}
\usetikzlibrary{shadows}

\begin{document}        

    \section{Tree}\label{sec6}
    Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.
            
    \begin{figure}[!t]
        \centering
        
        {\footnotesize
            \begin{forest}
                /tikz/every node/.append style={font=\footnotesize},
                for tree={
                    if level=0{align=center}{
                        align={@{}p{23mm}@{}} % changed use p{23cm} <<<<<
                    },
                    grow=east,
                    draw,
                    font=\footnotesize,
                    edge path={
                        \noexpand\path [draw, \forestoption{edge}] (!u.parent anchor) -- +(3mm,0) |- (.child anchor)\forestoption{edge label};
                    },
                    parent anchor=east,
                    child anchor=west,
                    l sep=10mm,
                    tier/.wrap pgfmath arg={tier #1}{level()},
                    edge={ultra thick, rounded corners=2pt},
                    fill=white,
                    rounded corners=2pt,
                    drop shadow,
                }
                [root
                [name2, edge+={-stealth}
                [name21 , edge+={-stealth}]
                ]
                [name1, edge+={-stealth}
                [name12 , edge+={-stealth}]
                [name13 , edge+={-stealth}]
                ]
                ]
            \end{forest}
        }
        
        \caption{simple tree}
    \end{figure}    
    
\end{document}

Code for the tree left as posted, follow the suggestions that will surely follow.

1
  • Thank you Simon
    – Lee
    Nov 23, 2021 at 16:24
1

Edit: Since your problem is solved in @Simon Dispa answer, here is added some suggestion regarding your tree drawn by use of the forest package.

According to my opinion your image code is unnecessary complicated. Try the following MWE with more consistent tree definition and shorter tree code:

\RequirePackage[edges]{forest}  % <--- it also load `tikz` package  
\documentclass[default,iicol]{sn-jnl}
\usetikzlibrary{arrows.meta,    % <---
                shadows}

\begin{document}

\section{Tree}\label{sec6}
Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text. Sample body text.

    \begin{figure}[ht]
\centering
    \begin{forest}
for tree={
% nodes
    draw, fill=white, drop shadow,
    font=\footnotesize,
% tree
    grow = east,
    parent anchor = east,
    child anchor  = west,
% edges
    forked edge,
    s sep = 2mm,
    l sep = 8mm,
 fork sep = 4mm,    % distance from parent to branching point
     edge = {very thick, rounded corners=2pt, -{Stealth[length=2mm]}},
        }
[root
    [name2
        [name21, edge=sharp corners]    % <---
    ]
    [name1
        [name12]
        [name13]
    ]
]
\end{forest}
\caption{simple tree}
\label{fig:forest}
    \end{figure}

\end{document}

which gives:

enter image description here

2
  • Thank you Zarko
    – Lee
    Nov 23, 2021 at 16:24
  • @Lee, you are welcome. Now you may consider to accept one of received answers ;-)
    – Zarko
    Nov 23, 2021 at 16:33

You must log in to answer this question.

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