\newenvironment 创建额外页面

\newenvironment 创建额外页面

以下代码生成:

在此处输入图片描述

\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]
\section{Three Additional Strategies}
\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}

显然出现了问题,因为生成了额外的页面。有人能解释一下为什么会发生这种情况吗,以及如何重写命令以停止这种行为吗?

答案1

Multicol 必须猜测是否应该开始新页面或当前页面是否有空间。Just after\item使这变得棘手,因为此时有很多待处理的活动。删除虚假组、添加一些 ingorespaces 并放入一个空框来终止项目会使事情更稳定。

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

答案2

您可以从定义中删除该组:

\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]
\section{Three Additional Strategies}
\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}

相关内容