recipe.sty 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. \RequirePackage{xspace}
  8. \newcommand\half{\nicefrac{1}{2}\xspace}
  9. \newcommand\quarter{\nicefrac{1}{4}\xspace}
  10. \newcommand\third{\nicefrac{1}{3}\xspace}
  11. \newcommand\twothirds{\nicefrac{2}{3}\xspace}
  12. \newcommand\threequarters{\nicefrac{3}{4}\xspace}
  13. \newcommand\recipe@ingredient[2]{#1 & #2 \\}
  14. \newcommand\recipe@serving[1]{\ifblank{#1}{}{\textit{#1 servings}}}
  15. \newcommand\recipe@contributor[1]{\ifblank{#1}{}{Courtesy of #1}}
  16. \newcommand\recipe@majorstep[1]{\par\smallskip\textbf{#1}\par}
  17. \newenvironment{recipe}[3]{%
  18. \bigskip%
  19. \begin{adjustwidth}{4em}{4em}%
  20. \let\majorstep=\recipe@majorstep
  21. \centerline{\textbf{#1}}%
  22. \recipe@contributor{#2}\hfill\recipe@serving{#3}\\
  23. \smallskip%
  24. \newenvironment{note}{\textit{Note:}}{}
  25. \newenvironment{ingredients}{%
  26. \smallskip%
  27. \begin{center}%
  28. \let\ingredient=\recipe@ingredient
  29. \begin{tabular}{lr}
  30. \toprule%
  31. }{%
  32. \bottomrule%
  33. \end{tabular}%
  34. \end{center}%
  35. \smallskip%
  36. }%
  37. }{%
  38. \end{adjustwidth}%
  39. \bigskip%
  40. }
  41. \endinput