Generalmulticol skipping a page

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
wrightjj
Posts: 10
Joined: Sat Apr 04, 2009 6:32 am

multicol skipping a page

Post by wrightjj »

Code: Select all

\documentclass[letterpaper,11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multicol}
I'm having a problem with the multicol package. I'm making a cookbook and the title of each recipe starts with a flushleft environment like this:

Code: Select all

\begin{flushleft}
\vspace{3\baselineskip}
\textbf{\LARGE{ recipe name goes here }}\\
\end{flushleft}
Following each recipe title is the list of ingredients which I use a two-column multicol environment for. At the top of page 17 in my cookbook a new recipe starts but then the rest of the page is blank and then the ingredients start on page 18. This is not an isolated incident so I would like to figure out how to fix it without just doing a "cheap" fix.

I set \setcounter{tracingmulticols}{1} to track some output from multicol:

Code: Select all

Package multicol: Starting environment with 2 columns on input line 705.
Package multicol: Current page:
(multicol) height=650.43001pt: used 687.83704pt -> free=-37.40703pt
(multicol) needed 50.0pt (for \premulticols ) on input line 705.
[16] [17]
Package multicol: Column spec: 469.75502pt = indent + columns + sep =
(multicol) 0.0pt + 2 x 219.8775pt + 1 x 30.0pt on input line 718.
Package multicol: Current page:
(multicol) height=650.43001pt: used 79.00003pt -> free=571.42998pt
(multicol) needed 20.0pt (for \postmulticols ) on input line 718.
Package multicol: Ending environment on input line 718.
You can see that towards the bottom of page 16 (a few lines before the [16] above) multicol checks to see if there is enough space to start a new multicol environment. \premulticols needs 50.0pt space but there is only -37.40703pt space available. The documentation for multicol says if there isn't enough space then multicol will start a new page. Above you can even see that page 17 is being skipped ([16] [17]). But I'm not sure why multicol is checking at the bottom of page 16 when the title is on the top of page 17 and it comes after the title!!! I'm fairly new to LaTeX but why isn't flushleft "reporting" that it is on page 17? Anyone have an idea?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multicol skipping a page

Post by localghost »

Build a minimal working example (MWE). Perhaps the recipe class can be helpful for your work.


Best regards
Thorsten¹
wrightjj
Posts: 10
Joined: Sat Apr 04, 2009 6:32 am

multicol skipping a page

Post by wrightjj »

Ok this does it. You should be able to see that page 2 there is a title at top of page but then the rest follows on page 3.

Code: Select all

\documentclass[letterpaper,11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multicol}

\setlength{\columnsep}{30pt} % space inbetween columns in multicol
\setlength{\parskip}{-2pt} % to tighten up the paragraphs

\begin{document}

\begin{flushleft}\textbf{\LARGE{Recipe}}\end{flushleft}
\begin{flushleft}\textit{A summary about the recipe}\end{flushleft}
\begin{multicols}{2}\raggedcolumns
\noindent ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1
\end{multicols}
\paragraph*{}blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 


\begin{flushleft}\vspace{3.5\baselineskip}\textbf{\LARGE{Recipe}}\end{flushleft}
\begin{multicols}{2}\raggedcolumns
\noindent ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1
\end{multicols}
\paragraph*{}blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 


\begin{flushleft}\vspace{3\baselineskip}\textbf{\LARGE{Recipe}}\end{flushleft}
\begin{multicols}{2}\raggedcolumns
\noindent ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1
\end{multicols}
\paragraph*{}blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 


\begin{flushleft}\vspace{3\baselineskip}\textbf{\LARGE{Recipe}}\end{flushleft}
\begin{multicols}{2}\raggedcolumns
\noindent ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1\\
ingredient 1
\end{multicols}
\paragraph*{}blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

\end{document}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multicol skipping a page

Post by localghost »

You are thinking too much like you were using a word processor, but you should think more in a complete different manner. After all you are on the move in the LaTeX world. Consider the following code.

Code: Select all

\documentclass[11pt,letterpaper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{babel}
\usepackage[compact,raggedright]{titlesec}
\usepackage{multicol}
\usepackage{blindtext}

\setlength{\parindent}{0em}
\setlength{\columnsep}{30pt} % space inbetween columns in multicol

\newenvironment{inglist}{%
  \begin{list}{}{%
    \settowidth{\labelwidth}{0em}
    \setlength{\labelsep}{0em}
    \setlength{\leftmargin}{0pt}
    \setlength{\rightmargin}{0pt}
    \setlength{\parsep}{0.5ex plus 0.2ex minus 0.1ex}
    \setlength{\itemsep}{0ex plus 0.2ex}
  }
}{\end{list}}

\newenvironment{summary}{%
  \begin{trivlist}
    \raggedright
    \itshape
    \item[]
}{\end{trivlist}}

\begin{document}

\section*{Recipe}
  \begin{summary}
    A summary about the recipe.
  \end{summary}
  \begin{multicols}{2}
    \raggedcolumns
    \begin{inglist}
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
    \end{inglist}
  \end{multicols}
  \blindtext

\section*{Recipe}
  \begin{summary}
    A summary about the recipe.
  \end{summary}
  \begin{multicols}{2}
    \raggedcolumns
    \begin{inglist}
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
    \end{inglist}
  \end{multicols}
  \blindtext

\section*{Recipe}
  \begin{summary}
    A summary about the recipe.
  \end{summary}
  \begin{multicols}{2}
    \raggedcolumns
    \begin{inglist}
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
    \end{inglist}
  \end{multicols}
  \blindtext

\section*{Recipe}
  \begin{summary}
    A summary about the recipe.
  \end{summary}
  \begin{multicols}{2}
    \raggedcolumns
    \begin{inglist}
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
      \item ingredient 1
    \end{inglist}
  \end{multicols}
  \blindtext
\end{document}
I defined two new environments. One for the summary of a recipe and a new list for the ingredients. With these structures typesetting the recipes is more flexible and has much less restrictions than your approach. Perhaps your rigid structure caused the misbaviour.

However, I didn't find the exact cause for the empty page. Maybe a result of careless browsing your code. But my suggestions may help. In case of further questions, feel free to ask.
wrightjj
Posts: 10
Joined: Sat Apr 04, 2009 6:32 am

multicol skipping a page

Post by wrightjj »

Wow, great reply. I definitely am going to be asking you some questions as I dissect what you've suggested. First off, why do you use trivlist for the summary? I had:

Code: Select all

\newcommand{\summary}[1]{
\begin{flushleft}
\textit{#1}\\
\end{flushleft}
}
Is there an advantage to using trivlist and doing it your way?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multicol skipping a page

Post by localghost »

Your version is again too rigid. The new summary environment is a derivative of the center environment, which is internally defined as a list. It is more flexible regarding spaces.
wrightjj
Posts: 10
Joined: Sat Apr 04, 2009 6:32 am

multicol skipping a page

Post by wrightjj »

Ok next question. For my list of ingredients, I'm using the hanging package so the first line won't be indented and then all the subsequent lines will be indented. So when one ingredient item is very long it will wrap indented and look nice, distinguishing between a continued single item and a new item. I tried putting the ingredients list as a list but have been unsuccessful in incorporating the hanging package into it. Here's what I originally had:

Code: Select all

% \parskip is previously set to -2pt, to tighten up the paragraphs
\newenvironment{ingred}{
\setlength{\parskip}{0pt} % because \parskip effects the hanging package
\begin{multicols}{2}\raggedcolumns
}{
\end{multicols}
\setlength{\parskip}{-2pt}
}

\newcommand{\recitem}[1]{\begin{hangparas}{11pt}{1}#1\end{hangparas}}
So then the list of ingredients looks like this:

Code: Select all

\begin{ingred}
\recitem{ ingredient 1 }
\recitem{ ingredient 2 }

\end{ingred}
Now taking what you have suggested, I've tried doing the following, but I can't get hanging to work properly in it:

Code: Select all

\newenvironment{inglist}{%
  \begin{list}{}{%
    \settowidth{\labelwidth}{0em}
    \setlength{\labelsep}{0em}
    \setlength{\leftmargin}{15pt}
    \setlength{\rightmargin}{15pt}
    \setlength{\parsep}{0.5ex plus 0.2ex minus 0.1ex}
    \setlength{\itemsep}{0ex plus 0.2ex}
  }
}{\end{list}}

\newcommand{\recitem}{
\item \hangpara{11pt}{1}
}

\newenvironment{ingred}{
\begin{multicols}{2}\raggedcolumns
\begin{inglist}
}{
\end{inglist}
\end{multicols}
}
And then of course I would call it something like this:

Code: Select all

\begin{ingred}
\recitem ingredient 1
\recitem ingredient 2

\end{ingred}
Any suggestions?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

multicol skipping a page

Post by localghost »

From my point of view there is no need for an additional package. A simple modification of the inglist environment by adding a setup for the length \itemindent will do as well.

Code: Select all

\newenvironment{inglist}{%
  \begin{list}{}{%
    \setlength{\itemindent}{-1em}
    \setlength{\labelwidth}{0em}
    \setlength{\labelsep}{0em}
    \setlength{\leftmargin}{1em}
    \setlength{\rightmargin}{0em}
    \setlength{\parsep}{0.5ex plus 0.2ex minus 0.1ex}
    \setlength{\itemsep}{0ex plus 0.2ex}
  }
}{\end{list}}
Note that the length \leftmargin now has to balance \itemindent.
Post Reply