\newenvironment creating an extra page

The following code produces:

\documentclass[11pt,twoside,openany]{book}

\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage{multicol}

%-------------------------------------------------------------------------------
\usepackage[centering,marginparwidth=2in]{geometry}
\evensidemargin 1.5in
\oddsidemargin 1.5in
\setlength{\textwidth}{5.5in}
%-------------------------------------------------------------------------------

\newenvironment{exotmp}{%
\begingroup
\begin{list}{}{%
\setlength{\leftmargin}{-1.5in}%
\setlength{\rightmargin}{0pt}%
\setlength{\parfillskip}{0pt plus 2fil}
}%
\item%
}
{\end{list}%
\endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{Introduction to Problem Solving}
\lipsum[2]
\section{The Problem-Solving Process and Strategies}
\lipsum[4-7]
\lipsum[5-12]
\begin{exotmp}
\setlength{\columnsep}{0.5cm}
\begin{multicols}{2}
\lipsum[2-9]
\end{multicols}
\begin{enumerate}
\item
\item
\item \lipsum[2-3]
\end{enumerate}
\end{exotmp}
\end{document}


Evidently there is something wrong as an extra page is produced. Can any one explain why this is happening and how to re-write the command so that it stops behaving in that manner?

-
does this help: environment-makes-unnecessary-page-break –  cmhughes Oct 26 '12 at 19:08
@cmhughes Nope. Thanks for the input. –  azetina Oct 26 '12 at 19:11

Multicol has to make a guess as to whether it should start a new page or if ther eis room on the current page. Just after \item makes that tricky as there is a lot of pending activity at that point. removing the spurious group, adding some ingorespaces and putting in an emty box to terminate the item makes things more stable.

\newenvironment{exotmp}{%
\begin{list}{}{%
\setlength{\leftmargin}{-1.5in}%
\setlength{\rightmargin}{0pt}%
\setlength{\parfillskip}{0pt plus 2fil}
}%
\item\mbox{}\ignorespaces
}
{\end{list}\ignorespacesafterend}

-
Can the space created above the environment (at the beginning) be avoided. As it is, it creates an extra space right? –  azetina Oct 26 '12 at 19:42
yes you could \vspace*{-\baselineskip} after the item it depends a bit what the intention of the code is –  David Carlisle Oct 26 '12 at 19:50
As is, the geometry of the page is defined and I created this environment to leave this geometry and work temporarily on it. –  azetina Oct 26 '12 at 19:58
I was thinking of defining the same environment with geometry like: \newenvironment{exotmp}{% \newgeometry{bottom=1.5in} \mbox{}\ignorespaces } {\restoregeometry\ignorespacesafterend} but I can't find how to create the same effect (margin definitions) as what the given environment in my question. –  azetina Oct 26 '12 at 20:17

You can remove the group from your definition:

\documentclass{book}
\usepackage{amsmath,amssymb}
\usepackage{lipsum}
\usepackage{multicol}

%-------------------------------------------------------------------------------
\usepackage[centering,marginparwidth=2in]{geometry}
\evensidemargin 1.5in
\oddsidemargin 1.5in
\setlength{\textwidth}{5.5in}
%-------------------------------------------------------------------------------

\newenvironment{exotmp}{%
\begin{list}{}{%
\setlength{\leftmargin}{-1.5in}%
\setlength{\rightmargin}{0pt}%
\setlength{\parfillskip}{0pt plus 2fil}
}%
\item%
}
{\end{list}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\chapter{Introduction to Problem Solving}
\lipsum[2]
\section{The Problem-Solving Process and Strategies}
\lipsum[4-7]
\lipsum[5-12]
\setlength{\columnsep}{0.5cm}
\begin{exotmp}
\begin{multicols}{2}
\lipsum[2-9]
\end{multicols}
\begin{enumerate}
\item
\item
\item \lipsum[2-3]
\end{enumerate}
\end{exotmp}
\end{document}

-
I get the same results. –  azetina Oct 26 '12 at 19:19
@azetina With my example code? –  Gonzalo Medina Oct 26 '12 at 19:24