3

I try to rotate a tikz-tree and a table which are in a minipage environment by using \landscape because the tree besides the table is to wide. Now, the tree and the table are not centered. The last column of the table is almost not on the page. Therefore I tried to use the geometry package with \newgeometry{left=5mm,right=5mm,top=5mm,bottom=5mm} and set the margins to 5mm (I only want it for a single page). Unfortunately this does not work. I always get an error. Furthermore the text in the first column in the table is not centered like in the others. What do I wrong? Here is my code:

\documentclass[doc,apacite]{apa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%%%%Tikz%%%%%%
\usepackage{tikz}
\usetikzlibrary{trees,matrix,fit}
\usetikzlibrary{shapes}
%%%%Table%%%%%
\usepackage{ctable} % needed for \cmidrule{}
\usepackage{multirow} % needed for \multirow{}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
%%%%%%%%%%%%%%
\usepackage{pgfkeys}
\usepackage{lscape}

\usepackage{geometry}
\geometry{paper=a4paper, left=35mm, right=35mm, top=35mm, bottom=30mm} 

\newlength\sibdist
\setlength\sibdist{1cm}
%\newcommand\sibdist{1.5cm}

\begin{document}

\newgeometry{left=5mm,right=5mm,top=5mm,bottom=5mm}

\footnotesize
\begin{landscape}
\begin{minipage}[t]{290pt}
\vspace{40pt}
%\hspace{0pt}
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.0cm, sibling distance=6cm]
\tikzstyle{level 2}=[level distance=5.0cm, sibling distance=4cm]
\tikzstyle{level 3}=[level distance=5.0cm, sibling distance=4cm]
% Define styles for bags and leafs
\tikzstyle{bag} = [text width=4em, text centered]
\tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]
\begin{tikzpicture}[grow=right,
sloped,
myrect/.style={draw=black,fill=white!100,text width=3cm,align=center,inner sep=5pt},
myellipse/.style={ellipse,draw=black,fill=black!0,inner sep=2pt,text width=2.8cm,align=center},
myrect2/.style={rectangle,rounded corners = 15,draw=black,fill=white!100,text width=3.3cm,align=center,inner sep=5pt},]
\node[myrect]{ario}
    child {
        node[myrect2]{itari}        
            child {
                node[label=right:
                    ,myrect2]{ntolog} {}
                        child {node[myrect2]
                        {ards}
                        edge from parent
                        node[above] {$R$}
                        node[below]  {}}
                        child {node[myrect2]
                        {ndcy tow}
                        edge from parent
                        node[above] {$R+k$}
                        node[below]  {}}
                edge from parent
                node[above] {$D-k$}
                node[below]  {}
            }
            child {
                node[myrect2]
                    {omin}
                edge from parent
                node[above] {$D+k$}
                node[below]  {}
            }
            edge from parent 
            node[above] {}
            node[below]  {$u$}
    }
    child {
        node[myrect2]{nse}        
        edge from parent         
            node[above] {$u-k$}
            node[below]  {}
    };
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}[t]{150pt}
\vspace{0pt}
\hspace{10pt}
%\begin{table}[h]
%\renewcommand{\arraystretch}{2.5}
\begin{tabular}{|m{1.6cm}|m{1.6cm}|m{1.6cm}|m{1.6cm}|}
                  nt & nt & nt & nt \\ \hline \hline
\rule{0pt}{60pt} e & le & ble & able  \\ \hline
\rule{0pt}{60pt} H & H & H & H  \\ \hline 
\rule{0pt}{60pt} m & m  & m  & e  \\ \hline
\rule{0pt}{60pt} le & le & le & le
\end{tabular}
%\renewcommand{\arraystretch}{1}
%\end{table}
\end{minipage}
\end{landscape}

\restoregeometry

\end{document}

2 Answers 2

1

Your minipage width is inappropriate. I changed it to 0.5\textwidth. You have given too big dimension for rounded corners which I changed to 3mm. Also, your invisible rule is not having depth, resulting in the incorrect alignment of first column. I have added the depth in \rule[-27pt]{0pt}{60pt} (change -27pt suitably). And at last, you have many un-necessary packages loaded, for example ctable. (\cmidrule is provided by booktabs)

The code:

\documentclass[doc,apacite]{apa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%%%%Tikz%%%%%%
\usepackage{tikz}
\usetikzlibrary{trees,matrix,fit}
\usetikzlibrary{shapes}
%%%%Table%%%%%
%\usepackage{ctable} % needed for \cmidrule{}
\usepackage{multirow} % needed for \multirow{}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
%%%%%%%%%%%%%%
\usepackage{pgfkeys}
\usepackage{lscape}

\usepackage{geometry}
\geometry{paper=a4paper, left=35mm, right=35mm, top=35mm, bottom=30mm}

\newlength\sibdist
\setlength\sibdist{1cm}
%\newcommand\sibdist{1.5cm}

\begin{document}

\newgeometry{left=5mm,right=5mm,top=5mm,bottom=5mm}

\footnotesize
\begin{landscape}
\begin{minipage}{0.5\textwidth}   %% changed this
\vspace{40pt}
%\hspace{0pt}
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.0cm, sibling distance=6cm]
\tikzstyle{level 2}=[level distance=5.0cm, sibling distance=4cm]
\tikzstyle{level 3}=[level distance=5.0cm, sibling distance=4cm]
% Define styles for bags and leafs
\tikzstyle{bag} = [text width=4em, text centered]
\tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]
\begin{tikzpicture}[grow=right,
sloped,
myrect/.style={draw=black,fill=white!100,text width=3cm,align=center,inner sep=5pt},
myellipse/.style={ellipse,draw=black,fill=black!0,inner sep=2pt,text width=2.8cm,align=center},
myrect2/.style={rectangle,rounded corners =3mm,draw=black,fill=white!100,text width=3.3cm,align=center,inner sep=5pt},]
\node[myrect]{ario}
    child {
        node[myrect2]{itari}
            child {
                node[label=right:
                    ,myrect2]{ntolog} {}
                        child {node[myrect2]
                        {ards}
                        edge from parent
                        node[above] {$R$}
                        node[below]  {}}
                        child {node[myrect2]
                        {ndcy tow}
                        edge from parent
                        node[above] {$R+k$}
                        node[below]  {}}
                edge from parent
                node[above] {$D-k$}
                node[below]  {}
            }
            child {
                node[myrect2]
                    {omin}
                edge from parent
                node[above] {$D+k$}
                node[below]  {}
            }
            edge from parent
            node[above] {}
            node[below]  {$u$}
    }
    child {
        node[myrect2]{nse}
        edge from parent
            node[above] {$u-k$}
            node[below]  {}
    };
\end{tikzpicture}
\end{minipage}%   % added a % at the end of line
\hfill
\begin{minipage}{0.5\textwidth}
\vspace{0pt}
\hspace{10pt}
%\begin{table}[h]
%\renewcommand{\arraystretch}{2.5}
\begin{tabular}{|m{1.6cm}|m{1.6cm}|m{1.6cm}|m{1.6cm}|}
                  nt & nt & nt & nt \\ \hline \hline
\rule[-27pt]{0pt}{60pt} e & le & ble & able  \\ \hline
\rule[-27pt]{0pt}{60pt} H & H & H & H  \\ \hline
\rule[-27pt]{0pt}{60pt} m & m  & m  & e  \\ \hline
\rule[-27pt]{0pt}{60pt} le & le & le & le \\ \hline %% added
\end{tabular}
%\renewcommand{\arraystretch}{1}
%\end{table}
\end{minipage}
\end{landscape}

\restoregeometry

\end{document}

enter image description here

1

You don't need geometry and \newgeometry, particularly for a class intended for submissions like apa.

Here's a way that doesn't require guessing at the pagination parameters of the class. The tabular around the tikzpicture is just for vertically center it. The \newsavebox is just a convenience for avoiding

\makebox[0pt]{\smash{%
  <all the material for picture and table>
}}

which would make the code more difficult to maintain.

\documentclass[doc,apacite]{apa}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%%%%Tikz%%%%%%
\usepackage{tikz}
\usetikzlibrary{trees,matrix,fit}
\usetikzlibrary{shapes}
%%%%Table%%%%%
\usepackage{ctable} % needed for \cmidrule{}
\usepackage{multirow} % needed for \multirow{}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}
%%%%%%%%%%%%%%
\usepackage{pgfkeys}
\usepackage{lscape}


\newlength\sibdist
\setlength\sibdist{1cm}
\newsavebox\sibsavebox

\begin{document}


\begin{landscape}
\footnotesize
\begin{lrbox}{\sibsavebox}
\begin{tabular}{@{}c@{}}
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.0cm, sibling distance=6cm]
\tikzstyle{level 2}=[level distance=5.0cm, sibling distance=4cm]
\tikzstyle{level 3}=[level distance=5.0cm, sibling distance=4cm]
% Define styles for bags and leafs
\tikzstyle{bag} = [text width=4em, text centered]
\tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]
\begin{tikzpicture}[
  grow=right,
  sloped,
  myrect/.style={
    draw=black,fill=white!100,text width=3cm,align=center,inner sep=5pt
  },
  myellipse/.style={
    ellipse,draw=black,fill=black!0,inner sep=2pt,text width=2.8cm,align=center
  },
  myrect2/.style={
    rectangle,rounded corners = 15,draw=black,fill=white!100,text width=3.3cm,
    align=center,inner sep=5pt
  },
]
\node[myrect]{ario}
    child {
        node[myrect2]{itari}        
            child {
                node[label=right:
                    ,myrect2]{ntolog} {}
                        child {node[myrect2]
                        {ards}
                        edge from parent
                        node[above] {$R$}
                        node[below]  {}}
                        child {node[myrect2]
                        {ndcy tow}
                        edge from parent
                        node[above] {$R+k$}
                        node[below]  {}}
                edge from parent
                node[above] {$D-k$}
                node[below]  {}
            }
            child {
                node[myrect2]
                    {omin}
                edge from parent
                node[above] {$D+k$}
                node[below]  {}
            }
            edge from parent 
            node[above] {}
            node[below]  {$u$}
    }
    child {
        node[myrect2]{nse}        
        edge from parent         
            node[above] {$u-k$}
            node[below]  {}
    };
\end{tikzpicture}
\end{tabular}%
\hspace{1cm}% <------------------------------------------ adjust here
\begin{tabular}{|m{1.6cm}|m{1.6cm}|m{1.6cm}|m{1.6cm}|}
                  nt & nt & nt & nt \\ \hline \hline
\rule{0pt}{60pt} e & le & ble & able  \\ \hline
\rule{0pt}{60pt} H & H & H & H  \\ \hline 
\rule{0pt}{60pt} m & m  & m  & e  \\ \hline
\rule{0pt}{60pt} le & le & le & le
\end{tabular}
\end{lrbox}

\centering
\vspace*{\fill}
\makebox[0pt]{\smash{\usebox{\sibsavebox}}}
\vspace*{\fill}

\end{landscape}


\end{document}

enter image description here

You must log in to answer this question.

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