GeneralFlushleft at End of 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

Flushleft at End of Page

Post by wrightjj »

Code: Select all

\documentclass[11pt]{article}
\usepackage{geometry,graphicx,verbatim,multicol,xfrac,ifthen,hanging}
\geometry{letterpaper,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
Hi, I'm having a weird problem with flushleft spacing in the article class. I'm making a cookbook with hundreds of recipes. Each recipe is structured like this:

Code: Select all

% NEW RECIPE

% RECIPE NAME
\begin{flushleft}
\vspace{3\baselineskip}
\textbf{\LARGE{ recipe name }}
\end{flushleft}

\index{ text here }
\label{ text here }

% RECIPE SUMMARY
\begin{flushleft}
\textit{ a summary about the recipe }
\end{flushleft}

% RECIPE
\begin{multicols}{2}\raggedcolumns
\begin{hangparas}{11pt}{1}  ingredient 1  \end{hangparas}
\begin{hangparas}{11pt}{1}  ingredient 2  \end{hangparas}
%\vdots
\end{multicols}

% DIRECTIONS
\paragraph*{}
I have everything working and looking like I want it but there is a slight problem. Occasionally, a recipe will get screwed up. It seems to happen when a flushleft begins "perfectly" at the end of a page. The flushleft environment (either recipe name or summary) gets pushed to the beginning of the next page (which is okay) but whatever follows it gets pushed to the following page, as though there was a \pagebreak or \newpage command.

For example, a new recipe starts at the bottom of a page, where the recipe name is displayed. On the next page, the recipe summary is displayed at the top of the page but then the rest of the page is blank. The subsequent list of ingredients starts on the following page.

I have a dozen sections, each containing about fifty recipes. Some sections are fine, everything looks great. However, some sections may have one or even two recipes that are getting improperly spaced like that.

I've checked my code again and again and nothing is out of place. I can't see any reason why this is happening. Anyone have any ideas?

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Flushleft at End of Page

Post by Stefan Kottwitz »

Hi,

could you post a minimal working example showing that behaviour?

Stefan
LaTeX.org admin
wrightjj
Posts: 10
Joined: Sat Apr 04, 2009 6:32 am

Flushleft at End of Page

Post by wrightjj »

In creating my MWE, I figured it out. This is what I had for my "recipe name" command.

Code: Select all

\newcommand{\recipe}[1]{
\begin{flushleft}
\vspace{3\baselineskip}
\textbf{\LARGE{#1}}
\end{flushleft}
\addcontentsline{toc}{subsection}{#1}
}
When I was creating the MWE, I removed the \addcontentsline and reran it just for fun. Of course it was fixed. So I moved the \addcontentsline inside of the flushleft environment. Problem solved!

Code: Select all

\newcommand{\recipe}[1]{
\begin{flushleft}
\vspace{3\baselineskip}
\textbf{\LARGE{#1}}
\addcontentsline{toc}{subsection}{#1}
\end{flushleft}
}
This has brought up a new question for me but I will make another post to make sure it gets proper attention.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Flushleft at End of Page

Post by localghost »

You successfully experienced the sense of a MWE. Using the recipe class could save you a lot of work.


Best regards
Thorsten¹
Post Reply