1

I am playing around with a cookbook template that I found here. It works great and has some nifty features, but I am having trouble with one part. The header and footer parts that tell you about the cooking time and if it is V or F do not disappear until a new recipe is called. This means that if you have text in between two recipes, the headers just keep popping up. See images below for example.

enter image description here

So I would like there not to be any header/footer on pages 3 and 4, is tehre some easy way to flush those away?

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage[%
    %a5paper,
    papersize={5.5in,8.5in},
    margin=0.75in,
    top=0.75in,
    bottom=0.75in,
    %twoside
    ]{geometry}

\usepackage{xcolor} \usepackage{graphicx}

\raggedcolumns \setlength{\multicolsep}{0pt} \setlength{\columnseprule}{1pt}

\makeatletter

\newif\if@mainmatter @mainmattertrue

%% Borrowed from book.cls \newcommand\frontmatter{% \cleardoublepage @mainmatterfalse \pagenumbering{roman}} \newcommand\mainmatter{% \cleardoublepage @mainmattertrue \pagenumbering{arabic}} \makeatother

\newcommand{\SubItem}[1]{ {\setlength\itemindent{15pt} \item[-] #1} }

\usepackage[T2A,T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian,english]{babel}

%% Vary the colors at will

\definecolor{vegcolor}{rgb}{0,0.5,0.2} \definecolor{frzcolor}{rgb}{0,0,1}

\usepackage{recipes}

\begin{document}

\frontmatter \tableofcontents

\mainmatter Write stuff \clearpage

\recipe[text]{Raspberry Chocolate Tiramisu} \serves{4} \preptime{2 hour} \cooktime[Chill time]{11/2 hours} \vegetarian \freeze \begin{ingreds} 100ml Double Strength Coffee 400g Raspberries (blitzed) 200g Mascarpone 2 tbsp Sweetener 1 tsp Vanilla Extract 700g Vanilla Yogurt 15g Dark Chocolate (finely grated) and a really long one \columnbreak \ingredients[For the Crumble Mixture:] 80g Wholemeal Flour 80g Plain Flour 80g Butter (diced) 70g Demerara Sugar \end{ingreds}

\begin{method}[Preheat the oven to Gas Mark 4, Electric \temp{180}, Fan \temp{160}.] Stir the two kinds of flour together in a bowl, add the butter and rub it into the flour. When the mixture looks like breadcrumbs, mix in the brown sugar. Lay the mixture on a shallow baking tray and bake for 25--30 minutes until golden brown. Leave on the side to cool.

 Mix together the mascarpone, sweetener, vanilla extract, and three quarters of the chocolate. Put half the crumble mixture in each of the glasses and pour over half the quark mixture along with half the raspberries.

 Put the other half of the crumble mixture on top, followed by the remaining quark mixture and raspberries. Sprinkle over the last of the chocolate. Chill for 3 hours before serving.

\end {method}

\showit[1.25in]{example-image-b}{This is a picture}

\clearpage \section{a new chapter that has the same headings}

\clearpage Same for this page!

\recipe[This is a simple headnote that describes the product for the user. A simple but elegant dessert.]{This new recipe does not have it though!} \end{document}

recipes.sty

% Your "recipes.sty" package starts here:
%% Thanks to alephzero for the excellent start:

\newcommand{\recipe}[2][]{% \newpage \lhead{}% \chead{}% \rhead{}% \lfoot{}% \rfoot{}% \subsection{#2}% \if###1##% \else \begin{center} \parbox{0.75\linewidth}{\raggedright\itshape#1}% \end{center} \fi } \newcommand{\serves}[2][Serves]{% \chead{#1 #2}} \newcommand{\vegetarian}{% \rhead{\large\color{vegcolor}\textbf{V}}} \newcommand{\freeze}{% \lhead{\large\color{frzcolor}\textbf{F}}} %% Optional arguments for alternate names for these: \newcommand{\preptime}[2][Prep time]{% \lfoot{#1: #2}% } \newcommand{\cooktime}[2][Cook time]{% \rfoot{#1: #2}% } \newcommand{\temp}[1]{% $#1^\circ$C} %% Optional argument is the width of the graphic, default = 1in \newcommand{\showit}[3][1in]{% \begin{center} \bigskip \includegraphics[width=#1]{#2}% \par \medskip \emph{#3} \par \end{center}% }

%% Optional argument for a heading within the ingredients section \newcommand{\ingredients}[1][]{% \if###1##% {\color{red}\Large\textbf{Ingredients}}% \else \emph{#1}% \fi }

%% Use \obeylines to minimize markup \newenvironment{ingreds}{% \parindent0pt \noindent \ingredients \par \smallskip \begin{multicols}{2} \leftskip1em \rightskip0pt plus 3em \parskip=0.25em \obeylines \everypar={\hangindent2em} }{% \end{multicols}% \medskip }

\newcounter{stepnum}

%% Optional argument for an italicized pre-step %% Also use obeylines to minimize markup here as well \newenvironment{method}[1][]{% \setcounter{stepnum}{0} \noindent {\color{red}\Large\textbf{Instructions}}% \par \smallskip \if###1##% \else \noindent \emph{#1} \par \fi \begingroup \parindent0pt \parskip0.25em \leftskip2em \everypar={\llap{\stepcounter{stepnum}\hbox to2em{\thestepnum.\hfill}}} }{% \par \endgroup}

\pagestyle{fancy} % End of "recipes.sty"

Coolcrab
  • 239

1 Answers1

1

The code you show is -- with some changes that might warrant reconsideration (why is the definition of \recipe not in the .sty file, to take but one example?) -- code I supplied in answer to this question: An Aesthetically Pleasing Recipe Book Template I sent you a message detailing how to do what you ask An Aesthetically Pleasing Recipe Book Template.

Here is the revised original code that, I believe, accomplishes what you need. Basically, in the definition of \recipe I added \pagestyle{fancy} after \newpage. And changed \pagestyle{fancy} to \pagestyle{plain} at the end of the preamble (at the end of the .sty file you show).

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = XeLaTeX

%% pagestyle alterations per user request 14 xii 2020

\documentclass{article} \usepackage{fancyhdr} \usepackage{multicol} \usepackage[% %a5paper, papersize={5.5in,8.5in}, margin=0.75in, top=0.75in, bottom=0.75in, %twoside ]{geometry} \usepackage{xcolor} \usepackage{graphicx}

\raggedcolumns \setlength{\multicolsep}{0pt} \setlength{\columnseprule}{1pt}

\makeatletter

%% Used for the headnote and in \showit %% If the text is small it is placed on one line; %% otherwise it is put into a raggedright paragraph. \long\def\testoneline#1{% \sbox@tempboxa{#1}% \ifdim \wd@tempboxa <0.75\linewidth \begingroup \itshape #1\par \endgroup \else \parbox{0.75\linewidth}{\raggedright\itshape#1}% \par \fi }

\newif\if@mainmatter @mainmattertrue

%% Borrowed from book.cls \newcommand\frontmatter{% \cleardoublepage @mainmatterfalse \pagenumbering{roman}} \newcommand\mainmatter{% \cleardoublepage @mainmattertrue \pagenumbering{arabic}} \makeatother

%% Vary the colors at will

\definecolor{vegcolor}{rgb}{0,0.5,0.2} \definecolor{frzcolor}{rgb}{0,0,1} \definecolor{dessertcolor}{rgb}{0.5,0.2,0.1} \definecolor{makeaheadcolor}{rgb}{0.5,0.5,0.6}

%% Thanks to alephzero for the excellent start: \newcommand{\recipe}[2][]{% \newpage \thispagestyle{fancy} \lhead{}% \chead{}% \rhead{}% \lfoot{}% \rfoot{}% \section{#2}% \if###1##% \else \begin{center} \testoneline{#1}% \end{center} \fi } \newcommand{\serves}[2][Serves]{% \chead{#1 #2}} \newcommand{\dishtype}[1]{% \rhead{#1}% } \newcommand{\dishother}[1]{% \lhead{#1}% } \newcommand{\vegetarian}{% {\large\color{vegcolor}\textbf{V}}% } \newcommand{\freeze}{% {\large\color{frzcolor}\textbf{F}}% } \newcommand{\dessert}{% {\large\color{dessertcolor}\textbf{D}}% } \newcommand{\makeahead}{% {\large\color{makeaheadcolor}\textbf{M}}% } %% Optional arguments for alternate names for these: \newcommand{\preptime}[2][Prep time]{% \lfoot{#1: #2}% } \newcommand{\cooktime}[2][Cook time]{% \rfoot{#1: #2}% } \newcommand{\temp}[1]{% $#1^\circ$C} %% Optional argument is the width of the graphic, default = 1in \newcommand{\showit}[3][1in]{% \begin{center} \bigskip \includegraphics[width=#1]{#2}% \par \medskip \testoneline{#3}% \par \end{center}% }

%% Optional argument for a heading within the ingredients section \newcommand{\ingredients}[1][]{% \if###1##% {\color{red}\Large\textbf{Ingredients}}% \else \emph{#1}% \fi }

%% Use \obeylines to minimize markup \newenvironment{ingreds}{% \parindent0pt \noindent \ingredients \par \smallskip \begin{multicols}{2} \leftskip1em \rightskip0pt plus 3em \parskip=0.25em \obeylines \everypar={\hangindent2em} }{% \end{multicols}% \medskip }

\newcounter{stepnum}

%% Optional argument for an italicized pre-step %% Also use obeylines to minimize markup here as well \newenvironment{method}[1][]{% \setcounter{stepnum}{0} \noindent {\color{red}\Large\textbf{Instructions}}% \par \smallskip \if###1##% \else \noindent \emph{#1} \par \fi \begingroup \parindent0pt \parskip0.25em \leftskip2em \everypar={\llap{\stepcounter{stepnum}\hbox to2em{\thestepnum.\hfill}}} }{% \par \endgroup }

\pagestyle{plain}

\begin{document}

\frontmatter \tableofcontents

\mainmatter

\recipe[This is a simple headnote that describes the product for the user. A simple but elegant dessert.]{Raspberry Chocolate Tiramisu} \serves{4} \preptime{1 hour} \cooktime[Chill time]{1$\frac{1}{2}$ hours} \dishtype{\dessert,\vegetarian} \dishother{\makeahead, \freeze} \begin{ingreds} 100ml Double Strength Coffee 400g Raspberries (blitzed) 200g Mascarpone 2 tbsp Sweetener 1 tsp Vanilla Extract 700g Vanilla Yogurt 15g Dark Chocolate (finely grated) and a really long one \columnbreak \ingredients[For the Crumble Mixture:] 80g Wholemeal Flour 80g Plain Flour 80g Butter (diced) 70g Demerara Sugar \end{ingreds}

\begin{method}[Preheat the oven to Gas Mark 4, Electric \temp{180}, Fan \temp{160}.] Stir the two kinds of flour together in a bowl, add the butter and rub it into the flour. When the mixture looks like breadcrumbs, mix in the brown sugar. Lay the mixture on a shallow baking tray and bake for 25--30 minutes until golden brown. Leave on the side to cool.

 Mix together the mascarpone, sweetener, vanilla extract, and three quarters of the chocolate. Put half the crumble mixture in each of the glasses and pour over half the quark mixture along with half the raspberries.

 Put the other half of the crumble mixture on top, followed by the remaining quark mixture and raspberries. Sprinkle over the last of the chocolate. Chill for 3 hours before serving.

This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. This is a bunch of bla bla b la. \end {method}

\showit[1.25in]{example-image-b}{This is a picture}

\end{document}

revised png

sgmoye
  • 8,586