| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2005 by Ben Reish % |
| 4 |
% This file may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License, either |
| 6 |
% version 1.2 of this license or (at your option) any later |
| 7 |
% version. The latest version of this license is in: |
| 8 |
% |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% |
| 11 |
% and version 1.2 or later is part of all distributions of |
| 12 |
% LaTeX version 1999/12/01 or later. |
| 13 |
% |
| 14 |
% \fi |
| 15 |
% \iffalse |
| 16 |
%<*driver> |
| 17 |
\ProvidesFile{recipecard.dtx} |
| 18 |
%</driver> |
| 19 |
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 20 |
%<class>\ProvidesClass{recipecard} |
| 21 |
%<*class> |
| 22 |
[2006/10/03 v2.0 Recipecard Class typesets recipes to fit note |
| 23 |
cards] |
| 24 |
%</class> |
| 25 |
%<*batchfile> |
| 26 |
\begingroup |
| 27 |
\input docstrip.tex |
| 28 |
\keepsilent \preamble This is a generated file. Copyright (C) 2005 |
| 29 |
by Ben Reish This file may be distributed and/or modified under the |
| 30 |
conditions of the LaTeX Project Public License, either version 1.2 |
| 31 |
of this license or (at your option) any later version. The latest |
| 32 |
version of this license is in: http://www.latex-project.org/lppl.txt |
| 33 |
and version 1.2 or later is part of all distributions of LaTeX |
| 34 |
version 1999/12/01 or later. |
| 35 |
\endpreamble |
| 36 |
\generate{\file{recipecard.cls}{\from{recipecard.dtx}{class}}} |
| 37 |
\Msg{*********************************************************} |
| 38 |
\Msg{*} \Msg{* To finish the installation you have to move the} |
| 39 |
\Msg{* following file into a directory searched by TeX:} \Msg{*} |
| 40 |
\Msg{* \space\space recipecard.cls} \Msg{*} \Msg{* To produce the |
| 41 |
documentation run the file recipecard.dtx} \Msg{* through LaTeX.} |
| 42 |
\Msg{*} \Msg{* Happy TeXing!} |
| 43 |
\Msg{*********************************************************} |
| 44 |
\endgroup |
| 45 |
%</batchfile> |
| 46 |
% |
| 47 |
%<*driver> |
| 48 |
\documentclass{ltxdoc} |
| 49 |
\EnableCrossrefs \CodelineIndex \RecordChanges |
| 50 |
\begin{document} |
| 51 |
\DocInput{recipecard.dtx} |
| 52 |
\end{document} |
| 53 |
%</driver> |
| 54 |
% \fi |
| 55 |
% \CheckSum{391} |
| 56 |
% |
| 57 |
% \CharacterTable |
| 58 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 59 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 60 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 61 |
% Exclamation \! Double quote \" Hash (number) \# |
| 62 |
% Dollar \$ Percent \% Ampersand \& |
| 63 |
% Acute accent \' Left paren \( Right paren \) |
| 64 |
% Asterisk \* Plus \+ Comma \, |
| 65 |
% Minus \- Point \. Solidus \/ |
| 66 |
% Colon \: Semicolon \; Less than \<% |
| 67 |
% Equals \= Greater than \> Question mark \? |
| 68 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 69 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 70 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 71 |
% Right brace \} Tilde \~} |
| 72 |
% |
| 73 |
% |
| 74 |
% \changes{v1.0}{2005/12/21}{Initial version} |
| 75 |
% |
| 76 |
% \GetFileInfo{recipecard.dtx} |
| 77 |
% |
| 78 |
% \DoNotIndex{\section,\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\@ne,\advance} |
| 79 |
% \DoNotIndex{\begingroup,\catcode,\closein,\closeout,\day,\def,\edef,\else,\empty} |
| 80 |
% \DoNotIndex{\(,\),\and,\begin,\bfseries,\end,\expandafter,\par,\geometry} |
| 81 |
% \DoNotIndex{\hbox,\hspace,\ifthenelse,\newcommand,\or,\pagetotal,\raggedright} |
| 82 |
% \DoNotIndex{\setcounter,\setlength,\string,\the,\typeout,\value} |
| 83 |
% |
| 84 |
% \title{The \textsf{recipecard} class\thanks{This document |
| 85 |
% corresponds to \textsf{recipecard.dtx}~\fileversion, |
| 86 |
% dated \filedate.}} |
| 87 |
% \author{Ben Reish \\ \texttt{[email protected]}} |
| 88 |
% |
| 89 |
% \maketitle |
| 90 |
% |
| 91 |
% \begin{abstract} |
| 92 |
% The point of this package is to typeset recipes. I tried \textsf{cooking.sty} |
| 93 |
% and did not like the results so I am making my own. |
| 94 |
% \texttt{Recipecard} is an alternate method for typesetting recipes. |
| 95 |
% Created by Ben Reish \copyright{}2005 |
| 96 |
% \end{abstract} |
| 97 |
% |
| 98 |
% \changes{v1.6}{2006/7/21}{Added more verbage to the explanations of |
| 99 |
% how the code operates.} |
| 100 |
% \changes{v1.7}{2006/9/7}{Added sections and subsections to class documentation.} |
| 101 |
% \changes{v2.0}{2006/9/11}{Added table of contents to first page.} |
| 102 |
% |
| 103 |
% \tableofcontents |
| 104 |
% |
| 105 |
% \section{Introduction} |
| 106 |
% For those who yearn to have typed note cards for their recipes, |
| 107 |
% \textsf{recipecard}\ has been created. The user can print out |
| 108 |
% his or her recipes in this class and then cut the pages along the |
| 109 |
% box outlines for pieces that will fit on a notecard. Hopefully, |
| 110 |
% multiple dimensions of note cards will be accommodated. This class |
| 111 |
% is based on the \textsf{article}\ class. This class is issued |
| 112 |
% under the \LaTeXe\ Project Public License. |
| 113 |
% |
| 114 |
% The |recipecard| class was created to look like a recipe card. The |
| 115 |
% card begins with a title and across from the title is the number |
| 116 |
% of servings the recipe makes. Then comes three columns of ingredients |
| 117 |
% if there are enough ingredients and depending on the number |
| 118 |
% of ingredients per column, which can be changed from recipe to |
| 119 |
% recipe. After the ingredients comes the instructions on making |
| 120 |
% the recipe. Finally, if the user has used the |\cookingtime| and |
| 121 |
% |\cooktemp| commands, those two are below the instructions. |
| 122 |
% |
| 123 |
% \setlength{\unitlength}{1mm} \vspace{5pt} \hspace{3cm} |
| 124 |
% \begin{picture}(50,30) |
| 125 |
% \put(0,0){\framebox(50,30){}} |
| 126 |
% \put(1,28.5){\dashbox{.5}(25,1){title}} |
| 127 |
% \put(42,28.5){\dashbox{.5}(7,1){}} |
| 128 |
% \multiput(1,22)(16,0){3}{\dashbox{.5}(15,6){}} |
| 129 |
% \put(7.5,21.5){\line(1,0){35}} |
| 130 |
% \put(1,9){\dashbox{.5}(48,12){instructions}} |
| 131 |
% \multiput(1,7.5)(38,0){2}{\dashbox{.5}(10,1){}} |
| 132 |
% \end{picture} |
| 133 |
% |
| 134 |
% \changes{v1.53}{2006/7/21}{Added figure to help describe the% |
| 135 |
% layout of the recipe card.} |
| 136 |
% |
| 137 |
% \section{Usage} |
| 138 |
% |
| 139 |
% \subsection{Class Options} |
| 140 |
% The |recipecard| class has three Class Options which can be selected |
| 141 |
% at the |\DocumentClass| statement. Each option tells the class |
| 142 |
% what size the card output will be. The options are: |fivebysevn| |
| 143 |
% (5 inches by 7 inches), |fourbysix| (4 inches by 6 inches), and |
| 144 |
% |threebyfive| (3 inches by 5 inches). The |fivebysevn| option is intended |
| 145 |
% for use with 5 inch by 7 inch note cards and places two note cards |
| 146 |
% per page. The |fourbysix| option is intended for use with 4 inch |
| 147 |
% by 6 inch note cards and places two note cards per page. The |
| 148 |
% |threebyfive| option is intended for use with 3 inch by 5 inch |
| 149 |
% note cards and places two note cards per page. Originally, the |
| 150 |
% code should have been able to place four 3 inch by 5 inch note |
| 151 |
% cards per page, but that just did not work. One other thing that |
| 152 |
% did not work is the ability to automatically break long recipes |
| 153 |
% onto separate note cards. That is something that the user will |
| 154 |
% have to take care of when the recipe prints. |
| 155 |
% |
| 156 |
% The default option is the |fivebyseven| option. A sample |
| 157 |
% |\Documentclass| statement might look like: |
| 158 |
% |\documentclass[fourbysix]{recipecard}|. |
| 159 |
% |
| 160 |
% \subsection{User Commands} |
| 161 |
% |
| 162 |
% \DescribeMacro{\ingredient} |
| 163 |
% The |\ingredient| \marg{ingredient} command adds an ingredient |
| 164 |
% to the next recipe. It is used before the |recipe| environment |
| 165 |
% because the list it is creating is printed at the beginning of |
| 166 |
% the next instance of the |recipe| environment. |
| 167 |
% |
| 168 |
% \DescribeMacro{\changeingrdlistnum} |
| 169 |
% The |\changeingrdlistnum| \marg{num} command will change the |
| 170 |
% number of ingredients per column to \meta{num}. The user |
| 171 |
% can create his or her own command to shorten up the command |
| 172 |
% name. It should be used before the instance of the |recipe| |
| 173 |
% environment that it is supposed to change. The user can make use |
| 174 |
% of this command as often as he or she likes. The command will |
| 175 |
% change all the following instances of the |recipe| environment |
| 176 |
% as well. For a more uniform look to the printed card, the user |
| 177 |
% should divide the number of ingredients per recipe by 3 and round up. |
| 178 |
% |
| 179 |
% \DescribeEnv{recipe} |
| 180 |
% The |recipe| environment is the staging area for each recipe. |
| 181 |
% Use it to group all the information about each recipe into |
| 182 |
% one area. Its call out looks like: |\begin{recipe}| \marg{title} |
| 183 |
% \marg{servings} \ldots |\end{recipe}|. The instructions for |
| 184 |
% making the recipe go in between the |\begin| and |\end| |
| 185 |
% commands. The |\cooktemp| and |\cookingtime| commands go in |
| 186 |
% with the instructions. |
| 187 |
% |
| 188 |
% \DescribeMacro{\cooktemp} |
| 189 |
% The |\cooktemp| \marg{temp} \marg{deg}\ macro adds a cooking |
| 190 |
% temperature to the card. The \meta{temp} is the numerical |
| 191 |
% temperature. The \meta{deg}\ is the units. Put |
| 192 |
% `C' in for \meta{deg} for Celsius or `F' for Fahrenheit. For |
| 193 |
% example, if the user wanted 350\textsuperscript{$\circ$} |
| 194 |
% Fahrenheit for the cooking temperature, the command would |
| 195 |
% look like: |\cooktemp{350}{F}| |
| 196 |
% |
| 197 |
% \DescribeMacro{\cookingtime} |
| 198 |
% The |\cookingtime| \marg{time} command adds a bold face |
| 199 |
% ``Cook Time: \meta{time}'' to the bottom of the card. |
| 200 |
% |
| 201 |
% \StopEventually{\PrintIndex} |
| 202 |
% |
| 203 |
% \section{Implementation} |
| 204 |
% |
| 205 |
% \subsection{Class Definition} |
| 206 |
% \begin{macrocode} |
| 207 |
\RequirePackage{calc,ifthen,boxedminipage} |
| 208 |
% \end{macrocode} |
| 209 |
% The user will need the |calc|, |ifthen|, |geometry|, and |
| 210 |
% |boxedminipage| packages for the |recipecard| class to |
| 211 |
% operate correctly. These should be available with the user's |
| 212 |
% distribution of \LaTeXe\ or from \emph{CTAN} at \textsc{www.ctan.org}. |
| 213 |
% |
| 214 |
% The |geometry| package is used because it seems easier than |
| 215 |
% attempting to use the old style layout commands. |
| 216 |
% |
| 217 |
% After requiring the |geometry| package, the code creates new boolean |
| 218 |
% variables and token registers for use later in the class. |
| 219 |
% \begin{macrocode} |
| 220 |
\RequirePackage[letterpaper,noheadfoot]{geometry} %showframe |
| 221 |
\newboolean{fiveseven} \newboolean{foursix} \newboolean{threefive} |
| 222 |
\newtoks{\@ta} \newtoks{\@tb} \newtoks{\@listone} \newtoks\@listtwo |
| 223 |
\newtoks\@listthree \def\@nil{} |
| 224 |
|
| 225 |
\renewcommand{\normalsize}{\fontsize{10pt}{12pt}\usefont{T1}{ptm}{m}{n}% |
| 226 |
\selectfont} |
| 227 |
% \end{macrocode} |
| 228 |
% These commands are general specifications needed by any class. |
| 229 |
% First, select the default font. Then set up the page layout |
| 230 |
% in general. After that, create a couple of length dimensions |
| 231 |
% so that each size of notecard can have its own height and |
| 232 |
% width of the ingredient columns. |
| 233 |
% \begin{macrocode} |
| 234 |
\setlength{\textwidth}{7in} \setlength{\textheight}{10.25in} |
| 235 |
\setlength{\paperwidth}{8.5in} \setlength{\paperheight}{11in} |
| 236 |
\newlength{\@ingredientlist} \newlength{\@cardheight} |
| 237 |
\newcommand{\textdegree}{\textsuperscript{$\circ$}} |
| 238 |
% \end{macrocode} |
| 239 |
% The |\textdegree| command is needed for the |\cooktemp| command |
| 240 |
% which will be described later. It is made available to the user |
| 241 |
% at any point in the class by defining a command for it. |
| 242 |
% |
| 243 |
% \subsection{Options} |
| 244 |
% Next, the class-specific options are defined. |
| 245 |
% \begin{macrocode} |
| 246 |
\DeclareOption{fivebyseven}{\geometry{% |
| 247 |
body={7in,10.25in},left=.75in}% centering,right=.75in |
| 248 |
\setlength{\@ingredientlist}{2in} \setlength{\@cardheight}{5in}% |
| 249 |
\setboolean{fiveseven}{true}} |
| 250 |
% \end{macrocode} |
| 251 |
% The |fivebyseven| option resets the page layout so that |
| 252 |
% two 5~inch by 7~inch notecards can be placed on the front |
| 253 |
% of one page. There is a little extra space so that the |
| 254 |
% user can cut the pieces out without harming either notecard. |
| 255 |
% This option sets the \meta{\@cardheight} to 5~inches and the |
| 256 |
% ingredient list column width, \meta{\@ingredientlist}, to 2~inches. |
| 257 |
% Finally, it sets the |fiveseven| boolean to true so that |
| 258 |
% any other things the class might need on a size specific |
| 259 |
% basis can be set inside an |if| statement later as necessary. |
| 260 |
% \begin{macrocode} |
| 261 |
\DeclareOption{fourbysix}{\geometry{% |
| 262 |
body={6in,8.15in},left=.75in}%right=1.75in |
| 263 |
\setlength\@ingredientlist{1.75in}% |
| 264 |
\setlength\@cardheight{4in} \setboolean{foursix}{true}} |
| 265 |
% \end{macrocode} |
| 266 |
% The |fourbysix| option resets the page layout so that |
| 267 |
% two 4~inch by 6~inch notecards can be placed on the front |
| 268 |
% of one page. There is a little extra space so that the |
| 269 |
% user can cut the pieces out without harming either notecard. |
| 270 |
% This option sets the \meta{\@cardheight} to 4~inches and the |
| 271 |
% ingredient list column width, \meta{\@ingredientlist}, to 1.75~inches. |
| 272 |
% Finally, it sets the |foursix| boolean to true so that |
| 273 |
% any other things the class might need on a size specific |
| 274 |
% basis can be set inside an |if| statement later as necessary. |
| 275 |
% \begin{macrocode} |
| 276 |
\DeclareOption{threebyfive}{\geometry{% |
| 277 |
landscape,body={10.25in,6.25in},left=.375in}%,right=.375in |
| 278 |
\setlength\@ingredientlist{1.5in}% |
| 279 |
\setlength\@cardheight{3in} \setboolean{threefive}{true}} |
| 280 |
% \end{macrocode} |
| 281 |
% The |threebyfive| option resets the page layout so that |
| 282 |
% four 3~inch by 5~inch notecards can be placed on the front |
| 283 |
% of one page. There is a little extra space so that the |
| 284 |
% user can cut the pieces out without harming either notecard. |
| 285 |
% This option sets the \meta{\@cardheight} to 3~inches and the |
| 286 |
% ingredient list column width, \meta{\@ingredientlist}, to 1.5~inches. |
| 287 |
% Finally, it sets the |threefive| boolean to true so that |
| 288 |
% any other things the class might need on a size specific |
| 289 |
% basis can be set inside an |if| statement later as necessary. |
| 290 |
% Note: The class does not print four 3'' by 5'' notecards to |
| 291 |
% the page. It only gets two to the page. |
| 292 |
% \begin{macrocode} |
| 293 |
\DeclareOption{nothing}{\relax} |
| 294 |
|
| 295 |
\DeclareOption*{\typeout{What's \CurrentOption?}} |
| 296 |
|
| 297 |
\ExecuteOptions{fivebyseven,nothing} |
| 298 |
|
| 299 |
\ProcessOptions\relax |
| 300 |
% \end{macrocode} |
| 301 |
% Once the options are defined, the class must be given a default |
| 302 |
% option to use if none is specified by the user. In this case, |
| 303 |
% the |fivebyseven| option is chosen. |
| 304 |
% \begin{macrocode} |
| 305 |
|
| 306 |
% \end{macrocode} |
| 307 |
% \subsection{User Commands} |
| 308 |
% The following commands are used to fill in the recipe cards' information. |
| 309 |
% \begin{macro}{\ingredient} |
| 310 |
% The |\ingredient| command is used to define the list of ingredients |
| 311 |
% in the recipe. It is the user-friendly way to add an ingredient. |
| 312 |
% It uses a counter, \meta{ingred@cnt}, to keep track of how many ingredients |
| 313 |
% have been added. The counter is used later. Then the command calls |
| 314 |
% |\@ddtoNgrList| and passes its argument off to that command. The argument |
| 315 |
% of this command can be any length, but remember that it will be wrapped |
| 316 |
% to the next line if it is too long because of the width of the |
| 317 |
% ingredient columns. |
| 318 |
% \begin{macrocode} |
| 319 |
\newcounter{ingred@cnt}\setcounter{ingred@cnt}{0} |
| 320 |
\newcommand{\ingredient}[1]{% |
| 321 |
\stepcounter{ingred@cnt} |
| 322 |
\@ddtoNgrdList{#1} |
| 323 |
%\typeout{\string\ingredient{#1}} |
| 324 |
} |
| 325 |
% \end{macrocode} |
| 326 |
% \end{macro} |
| 327 |
% \begin{macro}{\changeingrdlistnum} |
| 328 |
% The |\changeingrdlistnum| macro allows the user to |
| 329 |
% modify the number of ingredients listed vertically |
| 330 |
% before the class switches to the next column of |
| 331 |
% ingredients. The default value is 7. The number |
| 332 |
% of rows in the ingredient list columns is stored in |
| 333 |
% the \meta{ingred@list} counter. |
| 334 |
% \changes{v1.2}{2006/1/19}{Added the ability to |
| 335 |
% manipulate how many rows are in each column of the |
| 336 |
% ingredients list.} |
| 337 |
% \begin{macrocode} |
| 338 |
\newcounter{ingred@list} \setcounter{ingred@list}{7} |
| 339 |
\newcommand{\changeingrdlistnum}[1]{% |
| 340 |
\setcounter{ingred@list}{#1} |
| 341 |
} |
| 342 |
% \end{macrocode} |
| 343 |
% \end{macro} |
| 344 |
% |
| 345 |
% \begin{environment}{recipe} |
| 346 |
% The |recipe| |
| 347 |
% environment has several things going on. First, the class creates |
| 348 |
% the card width dimension, \meta{@cardwidth}. Depending on the |
| 349 |
% size of cards the user wants at the |\documentclass| |
| 350 |
% instance, the length of \meta{@cardwidth} is different. Any other |
| 351 |
% global settings that change due to the size of the card are to be |
| 352 |
% implemented here. Then the class creates several lengths and a |
| 353 |
% save box called |\@reccardbox| to be used with the |\begin{lrbox}| |
| 354 |
% command. The boolean variables set during the options section of |
| 355 |
% the class come into play here. |
| 356 |
% \changes{v1.3}{2006/1/17}{Added support for 5x7 |
| 357 |
% notecards.} \changes{v1.5}{2006/2/6}{Added support |
| 358 |
% for 4x6 and 3x5 notecards.} \changes{v1.52}{2006/7/28}{Fixed a bug |
| 359 |
% in the 3x5 notecard display that was dropping the third list of |
| 360 |
% ingredients to the bottom of the first list. Also added an indent |
| 361 |
% to paragraphs in the instructions section of the recipe environment.} |
| 362 |
% \begin{macrocode} |
| 363 |
\newdimen{\@cardwidth} |
| 364 |
\ifthenelse{\boolean{fiveseven}}{\setlength\@cardwidth{7in}}{} |
| 365 |
\ifthenelse{\boolean{foursix}}{\setlength\@cardwidth{6in}}{} |
| 366 |
\ifthenelse{\boolean{threefive}}{\setlength\@cardwidth{5in}% |
| 367 |
\changeingrdlistnum{4} |
| 368 |
\renewcommand{\normalsize}{\fontsize{8pt}{10pt}% |
| 369 |
\usefont{T1}{ptm}{m}{n}\selectfont}}{} |
| 370 |
% \end{macrocode} |
| 371 |
% For the 3~inch by 5~inch card, the font needs to be smaller to help |
| 372 |
% fit the same amount of information on the card. The |\normalsize| command |
| 373 |
% is renewed to allow the smaller font. |
| 374 |
% \begin{macrocode} |
| 375 |
\newsavebox{\@reccardbox} \newdimen{\@reccardh} \newdimen{\@rectemp} |
| 376 |
\newdimen{\@hruleoffset} \newdimen{\@rectempa} |
| 377 |
\newdimen{\@rectempb} \newdimen{\@rectempc} \newdimen{\BR@recd} |
| 378 |
\setlength\@rectemp{\@cardheight-2\fboxsep-2\fboxrule-17pt} |
| 379 |
\setlength{\@hruleoffset}{(\@cardwidth-2\fboxsep-2\fboxrule-.714\@cardwidth)/2} |
| 380 |
% \end{macrocode} |
| 381 |
% The code sets the length of \meta{@rectemp} to the height of the card minus two |
| 382 |
% times the separation distance for a framed box minus two times the |
| 383 |
% thickness of the framed box line minus seventeen points for the title |
| 384 |
% font. The \meta{@hruleoffset} length is the distance needed to center the |
| 385 |
% horizontal rule that goes below the ingredients and above the instructions. |
| 386 |
% \begin{macrocode} |
| 387 |
\newenvironment{recipe}[2]{% |
| 388 |
% \end{macrocode} |
| 389 |
% |
| 390 |
% \begin{macrocode} |
| 391 |
\ifthenelse{\equal{#2}{\@empty}}{\def\@recserv{}}% |
| 392 |
{\def\@recserv{Serves: #2}} |
| 393 |
\def\@rectitle{#1 \raggedright} |
| 394 |
% \end{macrocode} |
| 395 |
% The author assumes that one would enter a title for each recipe |
| 396 |
% so the most likely unused argument would be the second one which is the |
| 397 |
% number of serving the recipe makes. The code checks to see if the |
| 398 |
% second argument is empty. If it is the code defines the internal |
| 399 |
% command, |\@recserv| to be empty. If the it is not empty, the code |
| 400 |
% defines |\@recserv| as ``Serves: \meta{servings}.'' Then the code |
| 401 |
% defines the internal command |\@rectitle| as the first argument of |
| 402 |
% |recipe| environment, \meta{title} and applies the |\raggedright| |
| 403 |
% command so that \LaTeX\ does not try to stretch the title all the |
| 404 |
% way across the card. |
| 405 |
% |
| 406 |
% Then the code checks the second and third ingredient lists, |
| 407 |
% |\@listtwo| and |\@listthree|, for emptiness. The code assumes |
| 408 |
% that there will be at least one or two ingredients per recipe and |
| 409 |
% therefore does not check the first list. If either is empty, |
| 410 |
% the code enters a blank list |\item| command into the empty list to |
| 411 |
% avoid an error when \LaTeX\ processes an empty ingredient list token |
| 412 |
% in a list environment. |
| 413 |
% |
| 414 |
% \begin{macrocode} |
| 415 |
\ifthenelse{\equal{\the\@listtwo}{\@empty}}{\@listtwo={\item {}}}{} |
| 416 |
\ifthenelse{\equal{\the\@listthree}{\@empty}}{\@listthree={\item {}}}{} |
| 417 |
% \end{macrocode} |
| 418 |
% Next, the code begins an |lrbox| environment which is like a |\savebox|, |
| 419 |
% but as an environment, it can have more than just static text put in |
| 420 |
% it. This is used so that the whole card in its entirety (title, |
| 421 |
% ingredients, instructions, cooking times and temperatures) can be placed |
| 422 |
% in a |\boxedminipage| command in the ending of the |recipe| environment. |
| 423 |
% The |\boxedminipage| command creates the outline for the card for cutting |
| 424 |
% purposes. |
| 425 |
% |
| 426 |
% Inside the |lrbox|, the code starts a |minipage| environment which |
| 427 |
% will contain all the text on the card. Its width is the card width |
| 428 |
% minus twice the thickness of the line that surrounds the |boxedminipage| |
| 429 |
% minus twice the separation distance between the line and the inside text. |
| 430 |
% |
| 431 |
% Then the code changes the font for the title and servings; then places |
| 432 |
% the title with a horizontal fill white space between it and the number of |
| 433 |
% servings; and then switches back to normal font. |
| 434 |
% \begin{macrocode} |
| 435 |
\begin{lrbox}{\@reccardbox} |
| 436 |
\begin{minipage}[t]{\@cardwidth-2\fboxsep-2\fboxrule} |
| 437 |
\noindent\fontsize{14.4}{17} \usefont{T1}{pzc}{mb}{it}% |
| 438 |
\@rectitle\hspace{\fill}\@recserv\normalsize\normalfont\par |
| 439 |
% \end{macrocode} |
| 440 |
% Here begins three separate |minipage| instances; one for each list of |
| 441 |
% ingredients. The first and second |minipage| instances are separated with |
| 442 |
% a 3 point space, as are the second and third |minipage| instances. Each |
| 443 |
% |minipage| is \meta{@ingredientlist} wide which is set depending |
| 444 |
% upon the size of card the user is wanting. |
| 445 |
% |
| 446 |
% Inside each of the three |minipage| instances is a |\begin{list}| command. |
| 447 |
% This command defines a |list| environment that better meets the needs |
| 448 |
% of the |recipecard| class. The \meta{leftmargin} distance indents the text by |
| 449 |
% $\frac{1}{4}$ inch which makes the text that is word wrapped to the next |
| 450 |
% line indent a noticeable amount. The \meta{itemindent} pulls the first line of |
| 451 |
% each item back out to the edge of the line instead of being indented in |
| 452 |
% a $\frac{1}{4}$ inch. The code also adds a |\raggedright| command to |
| 453 |
% the end of the |list| definition which causes \LaTeX\ to not try to stretch |
| 454 |
% the text of the item across the whole line. After the |list| is defined, |
| 455 |
% the contents of |\@listone| are placed in the |list| environment and the |
| 456 |
% environment is closed. |
| 457 |
% \begin{macrocode} |
| 458 |
\begin{minipage}[t]{\@ingredientlist} |
| 459 |
\begin{list}{}{\setlength\leftmargin{.25in}% |
| 460 |
\setlength\itemindent{-.25in}\raggedright}\the\@listone% |
| 461 |
\end{list}\end{minipage} |
| 462 |
\typeout{first box} |
| 463 |
\hspace{3pt plus 0pt minus 6pt} |
| 464 |
\begin{minipage}[t]{\@ingredientlist} |
| 465 |
\begin{list}{}{\setlength\leftmargin{.25in}% |
| 466 |
\setlength\itemindent{-.25in}\raggedright}\the\@listtwo% |
| 467 |
\end{list}\end{minipage} |
| 468 |
\typeout{second box} |
| 469 |
\hspace{3pt plus 0pt minus 6pt} |
| 470 |
\begin{minipage}[t]{\@ingredientlist} |
| 471 |
\begin{list}{}{\setlength\leftmargin{.25in}% |
| 472 |
\setlength\itemindent{-.25in}\raggedright}\the\@listthree% |
| 473 |
\end{list}\end{minipage} |
| 474 |
\typeout{third box} |
| 475 |
\hspace{\fill} |
| 476 |
\par |
| 477 |
% \end{macrocode} |
| 478 |
% Following the three lists of ingredients, the code skips 3 points vertically and |
| 479 |
% then skips the value of \meta{@hruleoffset} horizontally. Then the code places a line |
| 480 |
% down to separate the ingredients from the instructions. Next, the code skips |
| 481 |
% 3 points vertically before starting the instructions. |
| 482 |
% |
| 483 |
% The |\everypar| token is expanded at the beginning of each new paragraph. |
| 484 |
% This code places a 1em space (\rule[-.5pt]{.5pt}{.8ex}\rule[-.5pt]{1em}% |
| 485 |
% {.5pt}\rule[-.5pt]{.5pt}{.8ex}) indent at the start each paragraph. |
| 486 |
% Because of this, to obtain a fully left aligned sentence or statement, |
| 487 |
% the user will need to use a command like: |\hspace{-1em}|. |
| 488 |
% \begin{macrocode} |
| 489 |
\vspace{3pt} \hspace{\@hruleoffset}% |
| 490 |
\rule{.714\@cardwidth}{0.7pt}% |
| 491 |
\par\vspace{3pt} \hspace{1em}% |
| 492 |
\everypar={\hspace{1em}} |
| 493 |
}{% |
| 494 |
% \end{macrocode} |
| 495 |
% Here begins the commands that are executed at the end of the user-entered |
| 496 |
% text. The code places |\@cooktime| and |\@cooktemp| at the bottom |
| 497 |
% left and right, respectively, of the instructions. Then the code ends the overall |
| 498 |
% |minipage| and |lrbox|. |
| 499 |
% \begin{macrocode} |
| 500 |
\par \noindent \@cooktime \hspace{\fill} \@cooktemp%\par |
| 501 |
\end{minipage}\end{lrbox} |
| 502 |
\vspace{-.25in} \hspace{-21pt} |
| 503 |
% \end{macrocode} |
| 504 |
% Here the code inserts the contents of the |lrbox|, |\@reccardbox|, into |
| 505 |
% a boxed minipage. Then the clean up code starts. Zero the counter, empty |
| 506 |
% the list tokens, and empty the cooking commands. The cooking commands |
| 507 |
% use a global definition because they are placed inside the |recipe| environment, |
| 508 |
% which causes the changes made inside the environment to be reset when the |
| 509 |
% environment ends. The global definition steps out of the environment and |
| 510 |
% makes the changes so that they do not reset when the environment closes. |
| 511 |
% \begin{macrocode} |
| 512 |
\begin{boxedminipage}[t]{\@cardwidth}% |
| 513 |
\rule[-\@rectemp]{0pt}{\@rectemp} \hspace{-4pt} |
| 514 |
\usebox{\@reccardbox}% |
| 515 |
\end{boxedminipage} |
| 516 |
\ifthenelse{\boolean{threefive}}{\hspace{.5ex}}{\par\vspace{.35in}} |
| 517 |
\setcounter{ingred@cnt}{0}% |
| 518 |
\@listone={} |
| 519 |
\@listtwo={} |
| 520 |
\@listthree={} |
| 521 |
\gdef\@cooktime{} \gdef\@cooktemp{} |
| 522 |
\everypar={} |
| 523 |
%\typeout{\string\pagetotal\space\the\pagetotal} |
| 524 |
%\typeout{\string\@listone\space`\the\@listone'} |
| 525 |
} |
| 526 |
% \end{macrocode} |
| 527 |
% \end{environment} |
| 528 |
% \begin{macro}{\cookingtime} |
| 529 |
% The |\cookingtime| \marg{time}\ macro adds a cook time |
| 530 |
% to the card. This command uses an internal command, |\@cooktime|, to |
| 531 |
% place text on the recipe card. The |recipe| environment has the |
| 532 |
% internal command called out right after the instructions which causes |
| 533 |
% |\@cooktime| to be expanded whether or not the user has used |\cookingtime|. |
| 534 |
% If the user has not used |\cookingtime|, then the |\@cooktime| command |
| 535 |
% expands to an empty space. If he or she has used it, then |\@cooktime| |
| 536 |
% is defined as ``Cook Time: \meta{time}'' which is expanded when the |
| 537 |
% |recipe| environment calls the |\@cooktime| command. The |\hspace{-1em}| |
| 538 |
% is because this command is always at the left of the new paragraph, which |
| 539 |
% because of the |\everypar| command in the |recipe| environment, has a |
| 540 |
% 1em indent before it. The negative one here moves the text back up to |
| 541 |
% the edge. The author wanted the cook time to stand out so the bold face |
| 542 |
% font was used. |
| 543 |
% \changes{v1.3}{2006/1/19}{Added the cook time |
| 544 |
% to the card.} |
| 545 |
% \begin{macrocode} |
| 546 |
\def\@cooktime{} |
| 547 |
\newcommand{\cookingtime}[1]{% |
| 548 |
\def\@cooktime{\hbox{\hspace{-1em}\bfseries Cook Time: #1}} |
| 549 |
} |
| 550 |
% \end{macrocode} |
| 551 |
% \end{macro} |
| 552 |
% \begin{macro}{\cooktemp} |
| 553 |
% The |\cooktemp| command uses an internal command, |\@cooktemp| |
| 554 |
% to insert the cooking temperature into the recipe. As with |\@cooktime|, |
| 555 |
% |\@cooktemp| is called by the |recipe| environment regardless of |
| 556 |
% it being empty or not. Again, the author wanted the cooking |
| 557 |
% temperature to stand out so the code uses the bold font. |
| 558 |
% \changes{v1.3}{2006/1/19}{Added the cooking temperature |
| 559 |
% to the card.} |
| 560 |
% \begin{macrocode} |
| 561 |
\def\@cooktemp{} |
| 562 |
\newcommand{\cooktemp}[2]{% |
| 563 |
\def\@cooktemp{\hbox{\bfseries % |
| 564 |
Temperature: #1\textdegree\hspace{-1.5pt}#2}} |
| 565 |
} |
| 566 |
% \end{macrocode} |
| 567 |
% \end{macro} |
| 568 |
% \subsection{Non-User Commands} |
| 569 |
% Here are the commands that only the class may call. These commands |
| 570 |
% help to hide and safeguard the inner workings of the class. |
| 571 |
% \begin{macro}{\@ddtoNgrdList} |
| 572 |
% The |\@ddtoNgrdList| \marg{ingredient}\ adds the |
| 573 |
% latest ingredient to one of the token lists for |
| 574 |
% the printout of the recipe card. This is an internal |
| 575 |
% function and is not user friendly. It calculates |
| 576 |
% which column to put the current ingredient into |
| 577 |
% using the number of ingredients listed so far and |
| 578 |
% the maximum number allowed in each column. |
| 579 |
% \changes{v1.2}{2006/1/19}{Implemented the ability |
| 580 |
% to change how many rows were in each column of |
| 581 |
% the ingredients list.} |
| 582 |
% \begin{macrocode} |
| 583 |
\newcounter{@tempa}\newcounter{@tempb} \newcounter{@tempc} |
| 584 |
\newcommand{\@ddtoNgrdList}[1]{% |
| 585 |
\setcounter{@tempa}{\theingred@list+1}% |
| 586 |
\setcounter{@tempb}{2*\theingred@list+1}% |
| 587 |
\setcounter{@tempc}{3*\theingred@list+1}% |
| 588 |
% \end{macrocode} |
| 589 |
% After initializing the limit numbers for the columns of |
| 590 |
% ingredients, decide what column (1, 2, or 3) to put the |
| 591 |
% latest ingredient into. If this is the first time through |
| 592 |
% the sequence, clear the lists. |
| 593 |
% \begin{macrocode} |
| 594 |
\ifthenelse{\value{ingred@cnt}=1}{% |
| 595 |
\@ta={} \@listone={} \@listtwo={} \@listthree={}% |
| 596 |
}{} |
| 597 |
\ifthenelse{\value{ingred@cnt}<\value{@tempa}}{% |
| 598 |
%\typeout{\string\@listone :\space\the\@listone} |
| 599 |
\expandafter\@ta\expandafter=% |
| 600 |
\expandafter{\the\@listone \item #1} |
| 601 |
\@listone=\@ta}{% |
| 602 |
\ifthenelse{\(\value{ingred@cnt}>\value{@tempa}% |
| 603 |
\or \value{ingred@cnt}=\value{@tempa}% |
| 604 |
\)\and\value{ingred@cnt}<\value{@tempb}}{% |
| 605 |
% \end{macrocode} |
| 606 |
% This if statement states, ``if the value of \meta{ingred@cnt} is greater |
| 607 |
% than the value of \meta{@tempa} (which is the number of ingredients per |
| 608 |
% column plus one) or equal to the value of \meta{@tempa}'' and ``the value |
| 609 |
% of \meta{ingred@cnt} is less than the value of \meta{@tempb} (which is the |
| 610 |
% number of ingredients per column times two plus one).'' If the |
| 611 |
% previous is true the code then evaluates the following statement. |
| 612 |
% \begin{macrocode} |
| 613 |
\expandafter\@ta\expandafter=% |
| 614 |
\expandafter{\the\@listtwo \item #1} |
| 615 |
% \end{macrocode} |
| 616 |
% The |\expandafter|'s skip the following token, so the previous statement, |
| 617 |
% on the first time through reads ``|\the\@listtwo|'' which expands to the |
| 618 |
% contents of |\@listtwo| and then returns to the beginning of the statement. |
| 619 |
% Then the code reads back through the statement. It has used the |
| 620 |
% |\expandafter|'s so they are not there for the second reading of the |
| 621 |
% statement. The second time through, the statement reads, |
| 622 |
% ``|\@ta={\item| \meta{ingredient1} |... \item | (now it inputs the contents |
| 623 |
% of the first argument of the command).'' Now |\@ta| is the whole of |
| 624 |
% |\@listtwo| plus the statement, ``|\item| \meta{ingredient5}'' (for example). |
| 625 |
% Lastly, the code sets |\@listtwo| to the value of |\@ta|. |
| 626 |
% \begin{macrocode} |
| 627 |
\@listtwo=\@ta}{% |
| 628 |
\ifthenelse{\(\value{ingred@cnt}>\value{@tempb}% |
| 629 |
\or \value{ingred@cnt}=\value{@tempb}\)\and% |
| 630 |
\value{ingred@cnt}<\value{@tempc}}{% |
| 631 |
\expandafter\@ta\expandafter=% |
| 632 |
\expandafter{\the\@listthree \item #1} |
| 633 |
\@listthree=\@ta}{% |
| 634 |
% \end{macrocode} |
| 635 |
% The first two columns are pretty self-explanatory. If the |
| 636 |
% ingredient counter (\meta{ingred@cnt}) is greater than the |
| 637 |
% number of items per column (\meta{ingred@list}) times 3, then an |
| 638 |
% error is necessary. To continue processing, the class adds the |
| 639 |
% offending item to the last column any way but puts out an error. |
| 640 |
% As noted in the error message, the way around the error is to use |
| 641 |
% |\changeingrdlistnum| command to change the number of ingredients |
| 642 |
% allowed per column. |
| 643 |
% \begin{macrocode} |
| 644 |
\ifthenelse{\(\value{ingred@cnt}>\value{@tempc}% |
| 645 |
\or\value{ingred@cnt}=\value{@tempc}\)}{% |
| 646 |
\setcounter{ingred@cnt}{2} |
| 647 |
\expandafter\@ta\expandafter=% |
| 648 |
\expandafter{\the\@listthree \item #1} |
| 649 |
\@listthree=\@ta}{% |
| 650 |
\ClassError{recipecard}{More than \the@tempc\space ingredients for |
| 651 |
one recipe card}{Unfortunately, the card |
| 652 |
design only allows for three columns of a total of |
| 653 |
\the@tempc\space ingredients. Hint: change the value of |
| 654 |
\string\changeingrdlistnum. |
| 655 |
Congratulations! You have used more ingredients |
| 656 |
than this Class was designed for.} |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
} |
| 661 |
%\typeout{ingred@cnt\space\theingred@cnt} |
| 662 |
} |
| 663 |
% \end{macrocode} |
| 664 |
% \end{macro} |
| 665 |
% |
| 666 |
% \Finale |
| 667 |
\endinput |