该树的 LaTeX 代码在其他模板中可以运行,但当复制到 Springer Nature 模板时,会显示错误。
这是我的代码:
\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}
如何解决?
谢谢
答案1
尝试此设置。(加载顺序发生变化,列类型有小错误)。
\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}
树的代码如所发布的那样,请遵循必定会遵循的建议。
答案2
编辑:
由于您的问题已在@Simon Dispa 回答中得到解决,因此这里添加了一些有关使用该forest
包绘制的树的建议。
我认为您的图像代码没有必要那么复杂。尝试使用以下 MWE,其树定义更一致,树代码更短:
\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}
这使: