recipe-book/main.tex

196 lines
4.1 KiB
TeX

\documentclass{article}
\usepackage{fancyhdr,wrapfig,xcolor,graphicx,xparse,lmodern,cooking-units}
\renewcommand*\familydefault{\sfdefault} % Force the sans-serif version of any font used
\usepackage[%
papersize={5.5in,8.5in},
margin=0.75in,
top=0.75in,
bottom=0.75in
]{geometry}
\usepackage[%
unicode=true,
bookmarks=true,
bookmarksnumbered=false,
bookmarksopen=false,
breaklinks=false,
pdfborder={0 0 1},
backref=section,
colorlinks=false
]{hyperref} % PDF meta-information specification
% https://tex.stackexchange.com/questions/366229/an-aesthetically-pleasing-recipe-book-template
% have to define a cup cause the cooking-units writer is german and doesn't understand the flawed american way to measure ingredients.
\declarecookingunit{cup}
\cudefinename {English}
{
{cup} {cup}[cups]
{oz} {ounce}[ounces]
}
\cusetup{use-phrases=true}
% Removing the numbers from the sections & sub-sections
\setcounter{secnumdepth}{0}
\newcounter{stepnum}
\makeatletter
\def\plus{\texttt{+}\hspace{.3em}}
\def\minus{\texttt{-}\hspace{.3em}}
%% From Donald Arseneau. Add after the wrapping text. Whew!
\def\wrapfill{% Just glad it works.
\par
\ifx\parshape\WF@fudgeparshape
\nobreak
\ifnum\c@WF@wrappedlines>\@ne
\advance\c@WF@wrappedlines\m@ne
\vskip\c@WF@wrappedlines\baselineskip
\global\c@WF@wrappedlines\z@
\fi
\allowbreak
\WF@finale
\fi
}
%% 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}
\tableofcontents}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\makeatother
%% Vary the colors at will
\definecolor{vegcolor}{rgb}{0,0.5,0.2}
\colorlet{gfcolor}{brown}
\definecolor{frzcolor}{rgb}{0,0.8,0.8}
\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:
%% #1 [optional headnote]; #2 Title of recipe; #3 [Initial instructions]
\NewDocumentCommand{\recipe}{o m o}{%
\setcounter{stepnum}{0}%
\newpage
\thispagestyle{fancy}
\lhead{}%
\chead{}%
\rhead{}%
\lfoot{}%
\rfoot{}%
\subsection{#2}%
\IfNoValueF{#1}{\begin{center}\testoneline{#1}\end{center}}
\IfNoValueF{#3}{\noindent\emph{#3}\par\medskip}
}
\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{\glutenfree}{%
{\large\color{gfcolor}\textbf{GF}}%
}
\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}%
}
%% Optional argument is the width of the graphic, default = 1in
\newcommand{\showpic}[3][1in]{%
\begin{center}
\bigskip
\includegraphics[width=#1]{#2}%
\par
\medskip
\testoneline{#3}%
\par
\end{center}%
}
\NewDocumentEnvironment{step}{}{%
\parindent0pt
\leftskip0pt
\begin{minipage}{\textwidth}
\begin{wrapfigure}{r}{0pt}
\kern-0.5em
\vrule width 1pt\enskip
\begin{minipage}{0.5\textwidth}
\leftskip=1.5em
\parindent=-1.5em
\parskip=0.25em
\obeylines
}{%
\wrapfill
\end{minipage}
\medskip
}
\NewDocumentCommand{\method}{}{%
\end{minipage}
\end{wrapfigure}
\rightskip0pt plus 2em
\parskip0.25em
\everypar={\llap{\stepcounter{stepnum}\hbox to 1.5em{\thestepnum.\hfill}}}
}
\pagestyle{plain}
\setlength{\intextsep}{0pt}
\begin{document}
\fontfamily{lmss}\selectfont
\frontmatter
\mainmatter
\input{orderedrecipes.tex}
\end{document}