cookbook/recipe.cls

113 lines
2.6 KiB
TeX

%
% Copyright 2016 (c) Anna Schumaker.
%
\ProvidesClass{recipe}
\LoadClass[letterpaper]{letter}
\RequirePackage{gensymb}
\RequirePackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\RequirePackage{multicol}
\RequirePackage{newcent}
\RequirePackage{ragged2e}
\pagestyle{empty}
% Macros for setting recipe variables
\def\recipe@serves{ }
\def\recipe@servingsize{ }
\def\recipe@source{ }
\newcommand{\recipeName}[1] {\def\recipe@name{#1}}
\newcommand{\recipeServes}[1] {\def\recipe@serves{Serves: \textbf{#1}}}
\newcommand{\recipeServingSize}[1]
{
\def\recipe@servingsize{, serving size: \textbf{#1}}
}
\newcommand{\recipeMakes}[2] {\def\recipe@serves{Makes: \textbf{#1} #2}}
\newcommand{\recipeSource}[1] {\def\recipe@source{\footnote{#1}}}
\newcommand{\recipeSourceBook}[2] {\recipeSource{{\em #1}. Page: #2.}}
\newcommand{\recipeSourcePerson}[2]{\recipeSource{{\em #1}. From: #2.}}
\newcommand{\recipeSourceWeb}[2] {\recipeSource{{\em #1}. Source: #2.}}
% Preformatted fractions
\newcommand{\fraction}[2] {\(\mathbf{\frac{#1}{#2}}\)\ }
\newcommand{\third} {\fraction{1}{3}}
\newcommand{\half} {\fraction{1}{2}}
\newcommand{\twothirds} {\fraction{2}{3}}
\newcommand{\quarter} {\fraction{1}{4}}
\newcommand{\threequarters} {\fraction{3}{4}}
\newcommand{\eighth} {\fraction{1}{8}}
% Format a Fahrenheit temperature
\newcommand{\ftemp}[1] {#1\degree F}
\newcommand{\newsection}[1]
{
\vspace{0.5em}\flushleft{\Large{\textbf{#1:}}}
}
% Extend the \begin{document} command
\AtBeginDocument
{
\centering{
\Huge{\textbf{\recipe@name}}\LARGE{\recipe@source} \\
\vspace{0.25em}
\LARGE{\em{\recipe@serves\recipe@servingsize}}
}
\vspace{1em}
}
% Add an environment and commands for ingredients
\newenvironment{ingredients}
{
\newsection{Ingredients}
\begin{multicols}{2}
\begin{itemize}
}
{
\end{itemize}
\end{multicols}
}
\newenvironment{ingredientsSmall}
{
\newsection{Ingredients}
\begin{itemize}
}
{
\end{itemize}
}
\newcommand{\addIngredient}[2] {\large{\item{\textbf{#1} #2}}}
\newcommand{\addIngredientName}[1] {\large{\item{#1}}}
% Add an environment and commands for steps
\newenvironment{section}[1]
{
\newsection{#1}
\begin{enumerate}
\setlength\itemsep{0.75em}
}
{
\end{enumerate}
}
\newenvironment{steps} {\begin{section}{Steps}} {\end{section}}
\newcommand{\addStep}[1] {\large{\item{#1}}}
\newcommand{\ingredient}[1] {\underline{\smash{#1}}}
% Add a command for other recipe notes
\newcommand{\addNote}[2]
{
\newsection{#1}
\begin{itemize}
\item[]\large{#2}
\end{itemize}
}
\newcommand{\addReheating}[1] {\addNote{Reheating}{#1}}
\newcommand{\addSuggestion}[2] {\addNote{Suggested #1}{#2}}