recipe.sty 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. \ProvidesPackage{recipe}[2020/01/30 Recipe Typesetting for OpenCookbook]
  2. \ProcessOptions\relax
  3. \RequirePackage{etoolbox}
  4. \RequirePackage{nicefrac}
  5. \RequirePackage{booktabs}
  6. \RequirePackage{changepage}
  7. \newcommand\half{\nicefrac{1}{2}}
  8. \newcommand\quarter{\nicefrac{1}{4}}
  9. \newcommand\third{\nicefrac{1}{3}}
  10. \newcommand\twothirds{\nicefrac{2}{3}}
  11. \newcommand\threequarters{\nicefrac{3}{4}}
  12. \newcommand\recipe@ingredient[2]{#1 & #2 \\}
  13. \newcommand\recipe@serving[1]{\ifblank{#1}{}{\textit{#1 servings}}}
  14. \newcommand\recipe@contributor[1]{\ifblank{#1}{}{Courtesy of #1}}
  15. \newcommand\recipe@majorstep[1]{\par\smallskip\textbf{#1}\par}
  16. \newenvironment{recipe}[3]{%
  17. \bigskip%
  18. \begin{adjustwidth}{4em}{4em}%
  19. \let\majorstep=\recipe@majorstep
  20. \centerline{\textbf{#1}}%
  21. \recipe@contributor{#2}\hfill\recipe@serving{#3}\\
  22. \smallskip%
  23. \newenvironment{note}{\textit{Note:}}{}
  24. \newenvironment{ingredients}{%
  25. \smallskip%
  26. \begin{center}%
  27. \let\ingredient=\recipe@ingredient
  28. \begin{tabular}{lr}
  29. \toprule%
  30. }{%
  31. \bottomrule%
  32. \end{tabular}%
  33. \end{center}%
  34. \smallskip%
  35. }%
  36. }{%
  37. \end{adjustwidth}%
  38. \bigskip%
  39. }
  40. \endinput