我正在玩弄我找到的食谱模板这里。它运行良好,具有一些漂亮的功能,但我对其中一部分感到困惑。告诉您烹饪时间以及是 V 还是 F 的页眉和页脚部分在调用新食谱之前不会消失。这意味着,如果两个食谱之间有文字,则页眉会不断弹出。例如,请参见下面的图片。
所以我希望第 3 页和第 4 页上没有任何页眉/页脚,有什么简单的方法可以将它们清除掉吗?
\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}
食谱.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"
答案1
您展示的代码是 - 有一些变化可能需要重新考虑(为什么\recipe
不是在.sty
文件中,仅举一个例子?) - 我在回答这个问题时提供了代码:美观的食谱模板我给你发了一条消息,详细说明了如何做你要求的事情美观的食谱模板。
以下是修订版原来的我相信,这段代码可以满足您的需求。基本上,在 的定义中,\recipe
我\pagestyle{fancy}
在 之后添加了\newpage
。 并在序言的末尾(在您显示的文件末尾)更改\pagestyle{fancy}
为。\pagestyle{plain}
.sty
% !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}