![修改食谱 .sty 文件中的页面行为来管理复杂的食谱](https://linux22.com/image/330948/%E4%BF%AE%E6%94%B9%E9%A3%9F%E8%B0%B1%20.sty%20%E6%96%87%E4%BB%B6%E4%B8%AD%E7%9A%84%E9%A1%B5%E9%9D%A2%E8%A1%8C%E4%B8%BA%E6%9D%A5%E7%AE%A1%E7%90%86%E5%A4%8D%E6%9D%82%E7%9A%84%E9%A3%9F%E8%B0%B1.png)
我正在尝试编辑一个 .sty 文件,用于排版食谱书。这是 Alexis Flesch 的修改饼干书:
问题在于,代码是按小页面来组织页面内容的,如果菜谱的步骤非常多,结果就会像这样:
如果准备步骤太多,我想编辑 .sty 文件,以便手动添加新页面:新页面应仅包含剩余的准备步骤,但宽度为整页,样式与之前的步骤相同,可能在配方末尾添加另一张图片。它不应该有任何时钟符号、配方编号或其他内容。
问题是:我该怎么做?任何帮助都将不胜感激。谢谢。
答案1
以下是来自不同食谱的几个例子。也许这会给你一些启发。
\documentclass{article}
\usepackage[paperwidth=5.5in,paperheight=8.5in,left=.6in,right=.6in,
top=.75in,bottom=.75in]{geometry}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{everypage}
\usepackage{environ}
\usepackage{multicol}
\pagestyle{empty}
\AddEverypageHook{\begin{tikzpicture}[remember picture,overlay]
\node (title) [below=5pt,color=IndianRed] at(current page.north) {\Huge\textsf{\pagehead}};
\node[draw=IndianRed,rounded corners=.2in,minimum width=5in,minimum height=7.2in]
at (current page.center) {};
\node (foot)[above=.3in,fill=Brown,minimum width=5in] at (current page.south) {\strut};
\ifodd\value{page}%
\node[below,fill=Brown,text=white,minimum width=5in] at (title.south)
{\small\phantom{SPEEDS IN PARENTHESIS REFER TO 10-SPEED MOTOR BASE}};
\node[left,fill=white,text=Brown] at (foot.east) {\Huge\textsf{\thepage}};
\else
\node[below,fill=Brown,text=white,minimum width=5in] at (title.south)
{\small SPEEDS IN PARENTHESIS REFER TO 10-SPEED MOTOR BASE};
\node[right,fill=white,text=Brown] at (foot.west) {\Huge\textsf{\thepage}};
\fi
\end{tikzpicture}}
\newcommand{\ingredientitem}[1]% #1 = number (math mode)
{\ifvmode\else\par\fi\leavevmode
\llap{$#1$\hspace{\itemsep}}}
\newcommand{\altitem}{\ifvmode\else\par\fi\leavevmode
\hspace*{-\leftskip}}
\NewEnviron{ingredients}
{\footnotesize\bfseries
\let\item=\ingredientitem
\begin{minipage}[b]{3.75in}\begin{multicols}{2}%
\raggedright
\leftskip=.25in
\BODY
\end{multicols}\end{minipage}}
\newcommand{\flushtext}[1]% #1 = text to be flush right
{\bgroup
\sbox0{#1}\rule{\wd0}{0pt}\hspace{-\wd0}\null\hfill\box0
\egroup}
\begin{document}
\color{Brown}\small
\parskip=4pt plus 1pt minus 1pt
\parindent=0pt
\def\pagehead{BREADS}
\centerline{\textsf{\Large\color{IndianRed}OLD-FASHIONED BANANA BREAD}}
\tikz{\node[black,draw,text width=.3in,inner sep=.1in,minimum height=.5in]{clip art};}
\begin{ingredients}
\item{\frac{1}{3}}cup (125 mL) shortning
\item{1}cup (250 mL) sugar
\item{2}eggs
\item{1}teaspoon (5mL) baking soda
\item{2}cups (500mL) all-purpose flour
\item{3}ripe bananas, sliced
\altitem % to add space, preventing column break at bakeing soda
\end{ingredients}
Preheat oven to $350^\circ$F ($180^\circ$C) .
Grease a $9'' \times 5'' \times 3''$ ($23 \times 13 \times 8$ cm) loaf pan.
Assemble mixer.
Put all ingredients into a large mixing bowl.
Mix on \#3 until thoroughly combined .
Pour into prepared pan.
Bake 1 hour and 10 minutes.
Cool slightly before removing from pan.
\flushtext{\textsf{Yield: 1 loaf}}
\end{document}
\documentclass[twoside]{article}
\usepackage[paperwidth=6in,paperheight=9in,left=1in,right=.5in,
top=.5in,bottom=.5in,footskip=.25in]{geometry}
\usepackage{paracol}
\makeatletter
\def\ps@mystyle{\let\@oddhead=\relax
\let\@evenhead=\relax
\def\@oddfoot{\hfill\normalsize\thepage}%
\def\@evenfoot{\normalsize\thepage\hfill}%
}
\makeatother
\pagestyle{mystyle}
\newcommand{\mytitle}[1]% #1 = text title
{\par
\textbf{\LARGE\ #1}\newline
\vbox{\baselineskip=0pt
\rule{\textwidth}{1pt}\vspace{2pt}
\rule{\textwidth}{.5pt}}
\par}
\newcommand{\ingredientitem}[1]% #1 = number (math mode)
{\ifvmode\else\par\fi\leavevmode
\llap{$#1$\hspace{\itemsep}}}
\newcommand{\altitem}{\ifvmode\else\par\fi\leavevmode
\hspace*{-\leftskip}}
\newenvironment{ingredients}
{\footnotesize\bfseries
\let\item=\ingredientitem
\raggedright\parskip=3pt
\leftskip=.25in
}{\par}
\setcolumnwidth{1.5in,2.5in}
\small
\begin{document}
\parindent=0pt
\parskip=5pt
\raggedright
\mytitle{Pumpkin Squares}
\begin{paracol}{2}
\begin{ingredients}
\item{1}package Duncan Hines Deluxe Spice Cake Mix
\item{\frac{1}{4}}cup plus 2 tablespoons Crisco Oil or Puritan Oil
\item{\frac{1}{2}}teaspoon salt
\item{\frac{1}{4}}teaspoon backing soda
\item{1}can (16 ounces) pumpkin
\item{2}cups whipped topping
\end{ingredients}
\switchcolumn%
Preheat oven to $350^\circ$.
Combine dry cake mix, oil, salt, and baking soda (mixture will be crumbly).
Press evenly in ungreased $13 \times 9 \times 2$-inch pan.
Bake at $350^\circ$ for 20 minutes or until crust is browned around edges.
Meanwhile, prepare pie filling recipe as directed on the can.
Pour over hot baked crust.
Bake at $350^\circ$ for 30 to 35 minutes or until center is firm.
Cool.
Spread whipped topping over cooled pumpkin filling.
Decorate with \textit{pecan halves}, if desired.
Store in refrigerator.
\hfill\textit{12 to 16 servings}
Note: If desired, for topping use dollop of sweetened whipped cream,
or scoop of vanilla ice cream and decorate with shaved chocolate.
\end{paracol}
\end{document}