Using xcookybooky in LaTeX, I have many ingredients, but it does go into the next page

Viewed 419

I'm trying to write a recipe in LaTeX using xcookybooky. The current recipe (lasagne) has way too many ingredients, and it cannot fit in one page. Unfortunately, the ingredient list does not split over two pages, the text simply goes out of the page.

The LaTeX code in and of itself is simply a very long ingredients list made in a recipe environment. Does anyone know how to fix this?

Thanks

Edit: I see the picture I was trying to add did not appear. Instead I'll copy some of the code in. This compiles as it should for me, although the ingredients list still goes out of the page.

\documentclass[
a4paper,
11pt
]{article} 

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman, english]{babel}

\usepackage{textcomp}
\usepackage{gensymb}

\usepackage{nicefrac}

\usepackage[
    nowarnings,
]
{xcookybooky}
 
\DeclareRobustCommand{\textcelcius}{\ensuremath{^{\circ}\mathrm{C}}}


\setcounter{secnumdepth}{1}
\renewcommand*{\recipesection}[2][]
{
    \subsection[#1]{#2}
}
\renewcommand{\subsectionmark}[1]
{
}


\usepackage{hyperref}   

\begin{document}

\begin{recipe}
[% 
    preparationtime = {\unit[1]{h}},
    bakingtime={\unit[20-25]{min}},
    bakingtemperature={\protect\bakingtemperature{
        fanoven=\unit[175]{\textcelcius}}},
    portion = {\portion{6}},
]
{Spinach Lasagne}

\graph
    {
        %small=Recipes/MainCourses/BBQChicken/Small.jpg,
        big=Recipes/Vegetarian/SpinachLasagne/Big.jpg
    }
    
\ingredients
    {
        \textbf{Sauce}\\
        2 & chopped onions\\
        \unit[2]{tbsp} & Olive oil\\
        3 & chopped cloves of garlic\\
        \unit[2]{tsps} & dried thyme\\
        4 & grated carrots\\
        3 & grated celery leaves\\
        1 & grated squash\\
        1 & grated aubergine\\
        \unit[250]{g} & mushrooms\\
        \unit[1]{dL} & tomato paste\\
        \unit[1]{can} & chopped tomatoes\\
        To taste & salt and pepper\\
        \\
        \textbf{Spinach}\\
        \unit[500]{g} & frozen spinach\\
        \unit[1]{dL} & cream\\
        1 & onion\\
        1 & clove of garlic\\
        \unit[2]{tbsp} & oil\\
        To taste & salt \& pepper \& fresh basil\\
        \\
        \textbf{Mornay}\\
        \unit[2]{tbsp} & butter\\
        \unit[2]{tbsp} & flour\\
        \unit[3]{dL} & milk\\
        \unit[125]{g} & fresh mozzarella\\
        To taste & salt \& pepper \& nutmeg\\
        \\
        \unit[250]{g} & Lasagne plates\\
        Enough & mozzarella
    }
    
\end{recipe}

\end{document}
1 Answers

It is documented in the xcookybooky manual that lines breaks within the ingredients list are not possible due to technical reasons.

However you could temporarily reimplement the recipe and ingredients macros like this:

\documentclass[
a4paper,
11pt
]{article} 

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage[ngerman, english]{babel}

\usepackage{textcomp}
\usepackage{gensymb}

\usepackage{paracol}
\usepackage{supertabular}
\usepackage{lipsum}

\usepackage{nicefrac}

\usepackage[
    nowarnings,
]
{xcookybooky}
 
\DeclareRobustCommand{\textcelcius}{\ensuremath{^{\circ}\mathrm{C}}}


\setcounter{secnumdepth}{1}
\renewcommand*{\recipesection}[2][]
{
    \subsection[#1]{#2}
}
\renewcommand{\subsectionmark}[1]
{
}


\usepackage{hyperref}   

\begin{document}

\begingroup
\makeatletter
\renewenvironment{recipe}[2][]
{% initialisation
    \setkeys{recipe}{preparationtime, bakingtime, bakingtemperature, portion, calory, source}
    \setkeys{picture}{small, big, smallpicturewidth=\xcb@smallpicturewidth, bigpicturewidth=\xcb@bigpicturewidth} % load the default values
    \def\xcb@hook@pregraph{}
    \def\xcb@hook@pretitle{}
    \def\xcb@introduction{}
    \def\xcb@hook@prepreparation{}
    \preparation{}
    \def\xcb@hook@postpreparation{}
    \def\xcb@hook@preingredients{}
    \ingredients{}
    \def\xcb@hook@postingredients{}
    \def\xcb@suggestion{}
    \def\xcb@hint{}

    \def\xcb@recipename{#2}
    \setkeys{recipe}{#1}  % reading the optional parameters

    \setcounter{xcb@newpagefoot}{1}
    \setcounter{xcb@newpagehead}{\value{page}}
}
{% this part is executed at \end{recipe}
%% FIRST BLOCK
    \xcb@hook@pregraph
    \if@twoside
        \ifodd\arabic{page}
            \begin{minipage}[T]{\xcb@picture@bigwidth}
                \xcb@picture@big
            \end{minipage}
            \hfill
            \begin{minipage}[T]{\xcb@picture@smallwidth}
                \xcb@picture@small
            \end{minipage}
        \else
            \begin{minipage}[T]{\xcb@picture@smallwidth}
                \xcb@picture@small
            \end{minipage}
            \hfill
            \begin{minipage}[T]{\xcb@picture@bigwidth}
                \xcb@picture@big
            \end{minipage}
        \fi
    \else
        \begin{minipage}[T]{\xcb@picture@bigwidth}
            \xcb@picture@big
        \end{minipage}
        \hfill
        \begin{minipage}[T]{\xcb@picture@smallwidth}
            \xcb@picture@small
        \end{minipage}
    \fi

%% SECOND BLOCK
    \xcb@hook@pretitle
    \recipesection[\normalsize\xcb@recipename]%
    {\hspace{-1em}\textcolor{\xcb@color@recipename}{\xcb@font@recipename\xcb@recipename}}
    \xcb@cmd@recipeoverview

    \xcb@introduction

%% THIRD BLOCK
    \columnratio{0.66}
    \begin{paracol}{2}
        \xcb@hook@prepreparation
    
        \xcb@preparation
    
        \xcb@hook@postpreparation
    
        \xcb@suggestion
    
        \vfill
    
        \xcb@cmd@wrapfill
        \xcb@hint
        \setcounter{xcb@newpagefoot}{0}
      \switchcolumn
            \xcb@hook@preingredients

            \xcb@ingredients

            \xcb@hook@postingredients
    \end{paracol}
}

\renewcommand*{\ingredients}[2][\empty]
{% The optional argument contains the number of lines
    \def\xcb@ingredientslines{#1}
    \def\xcb@ingredients
    {%
        \xcb@name@inghead
        \\[1em]
        {\xcb@fontsize@ing\color{\xcb@color@ing}
        \begin{supertabular}{r>{\raggedright\arraybackslash}p{3cm}}
            #2
        \end{supertabular}}
    }
}
\makeatother
\begin{recipe}
[% 
    preparationtime = {\unit[1]{h}},
    bakingtime={\unit[20-25]{min}},
    bakingtemperature={\protect\bakingtemperature{
        fanoven=\unit[175]{\textcelcius}}},
    portion = {\portion{6}},
]
{Spinach Lasagne}

\graph
    {
        %small=Recipes/MainCourses/BBQChicken/Small.jpg,
        big=example-image
    }
    
\ingredients
    {
        \textbf{Sauce}\\
        2 & chopped onions\\
        \unit[2]{tbsp} & Olive oil\\
        3 & chopped cloves of garlic\\
        \unit[2]{tsps} & dried thyme\\
        4 & grated carrots\\
        3 & grated celery leaves\\
        1 & grated squash\\
        1 & grated aubergine\\
        \unit[250]{g} & mushrooms\\
        \unit[1]{dL} & tomato paste\\
        \unit[1]{can} & chopped tomatoes\\
        To taste & salt and pepper\\
        \\
        \textbf{Spinach}\\
        \unit[500]{g} & frozen spinach\\
        \unit[1]{dL} & cream\\
        1 & onion\\
        1 & clove of garlic\\
        \unit[2]{tbsp} & oil\\
        To taste & salt \& pepper \& fresh basil\\
        \\
        \textbf{Mornay}\\
        \unit[2]{tbsp} & butter\\
        \unit[2]{tbsp} & flour\\
        \unit[3]{dL} & milk\\
        \unit[125]{g} & fresh mozzarella\\
        To taste & salt \& pepper \& nutmeg\\
        \\
        \unit[250]{g} & Lasagne plates\\
        Enough & mozzarella\\
    }
    
    \preparation{
      \step \lipsum[2]
      
      \step \lipsum[2]
      
      \step \lipsum[2]
      
      \step \lipsum[2]
      
      \step \lipsum[2]
      
      \step \lipsum[2]
    }
    
\end{recipe}
\endgroup

\end{document}

Caveats:

  • the width of the ingredients column is hard coded. Change p{3cm} to whatever value is suitable for you

  • the preparations column won't wrap around the ingredients.

enter image description here

Related