# Why am I having this problem with exam class and the package newicktree?

I'm having trouble getting phylogenetic trees to display correctly within the solution environment of the exam class. For some reason, they are positioned way far to the right (running off the page) in that environment. See MWE below.

% Compile with XeLaTeX to deal with EPS graphics in trees.

\usepackage{newicktree}

\begin{document}
\begin{questions}

\question[5] The tree is correctly positioned on the page if it comes after the solution environment.
\begin{solution}
\end{solution}
\begin{newicktree}
\righttree \contemporarytips\nobranchlengths \setunitlength{4in}
\drawtree{(((ferns \& allies, (angiosperms, gymnosperms)),bryophytes), blue-green algae);}
\end{newicktree}

\question[5] The tree is not correctly positioned within the solution environment.
\begin{solution}
\begin{newicktree}
\righttree \contemporarytips\nobranchlengths \setunitlength{4in}
\drawtree{(((ferns \& allies, (angiosperms, gymnosperms)),bryophytes), blue-green algae);}
\end{newicktree}
\end{solution}

\end{questions}
\end{document}

• Package newicktree Oct 14 '14 at 15:40
• I'm wondering why the package author abuses \dimen20 (usually \jot) and \dimen21 (usually \leftmargin) in a context where something is typeset. Very bad LaTeX programming. Oct 14 '14 at 16:09

Inserting a blank line in the solution environment to create a new paragraph before the newicktree environment did the trick. See below for full code.

% Compile with XeLaTeX to deal with EPS graphics in trees.

\usepackage{newicktree}

\begin{document}
\begin{questions}

\question[5] The tree is correctly positioned on the page if it comes after the solution environment.
\begin{solution}
\end{solution}
\begin{newicktree}
\righttree \contemporarytips\nobranchlengths \setunitlength{4in}
\drawtree{(((ferns \& allies, (angiosperms, gymnosperms)),bryophytes), blue-green algae);}
\end{newicktree}

\question[5] The tree is not correctly positioned within the solution environment.
\begin{solution}

\begin{newicktree}
\righttree \contemporarytips\nobranchlengths \setunitlength{4in}
\drawtree{(((ferns \& allies, (angiosperms, gymnosperms)),bryophytes), blue-green algae);}
\end{newicktree}
\end{solution}

\end{questions}
\end{document}