我正在使用 tikz 绘制我的树。我想调整最后节点的位置,如预期图(最后图)。其次,我想将树定位在页面的中心。你能帮我修复 latex 代码吗?谢谢
\documentclass[preprint,12pt, sort&compress]{elsarticle}
\usepackage{tikz}
\usetikzlibrary{trees}
\usepackage{tikz-qtree,ulem}
\begin{document}
\begin{figure}[htp]
\centering
\begin{tikzpicture}[level distance=50pt,every node/.style={draw, rectangle},
attribute/.style={%
grow=down, xshift=0cm,
text centered, text width=1in,
edge from parent path={(\tikzparentnode) |- ($(\tikzparentnode)!0.5!(\tikzchildnode)$) -| (\tikzchildnode)}},
]
\tikzset{edge from parent/.style={draw,->,
edge from parent path={(\tikzparentnode.south) -- +(0,-8pt) -| (\tikzchildnode)}}}
\tikzset{every tree node/.style={align=center}}
\tikzset{every level 1 node/.style={font=\small, text width=3cm}}
\tikzset{every level 2 node/.style={font=\small, }}
\Tree [.{{This is first level}}
[.{This is first level} [.{AAAA \\AAAAAAAA}
[.{This is left \\side of graph}
[.{First Child} ]
[.{Second Child} ]]
[.{This is right \\side of graph} ]]
[.{BBBB \\BBBBBBB}
[.{This is left \\side of graph} ]
[.{This is right \\side of graph} ]]]
[.{Right side} [.{CCCCC \\CCCCCCCCCCCCC}
[.{First Child} ]
[.{Second Child} ]]
[.{DDDDDDDDDD \\DDDDDDDDDDDDDD}
[.{First Child} ]
[.{Second Child} ] ]]
]
\end{tikzpicture}
\end{figure}
\end{document}
这是我使用上述代码的当前结果
我的预期结果是
答案1
您的图片很长。因此,您可以在序言中使用 \usepackage{graphicx} 旋转同一个图形,并在正文中紧接着 \begin{figure} 行写入 \rotatebox{90}{ 并在 \end{tikzpicture}} 末尾关闭括号。现在编译并获取图表。否则使用 usepackage{lscape} 并在正文中 \begin{landscape}.........\end{landscape}