recipe.sty 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. \newenvironment{recipe}[3]{%
  16. \bigskip%
  17. \begin{adjustwidth}{4em}{4em}%
  18. \centerline{\textbf{#1}}%
  19. \recipe@contributor{#2}\hfill\recipe@servings{#3}\\
  20. \newenvironment{note}{\textit{Note:}}{}
  21. \newenvironment{ingredients}{%
  22. \smallskip%
  23. \begin{center}%
  24. \let\ingredient=\recipe@ingredient
  25. \begin{tabular}{lr}
  26. \toprule%
  27. }{%
  28. \bottomrule%
  29. \end{tabular}%
  30. \end{center}%
  31. \smallskip%
  32. }%
  33. \smallskip
  34. }{%
  35. \end{adjustwidth}%
  36. \bigskip%
  37. }
  38. \endinput