Ceci est une ancienne révision du document !
Last time, I showed how to get started making a book. I had several files with some recipes in them and used the include command to get Latex to import them into the book as the PDF is generated. I noted there were some problems with this first iteration that need to be fixed. I pointed out situations I intend to correct.
1) For example the fraction in 3 1/2 cups flour needs to look like a fraction. I could write it as a decimal but that would cause confusion. “Does 3.5 mean 3 ½ or 35 cups?” So I need to change the 1/2 so Latex formats it as ½. (All other fractions should be reformatted as well.)
2) There is at least one file currently included that has more than one recipe in it. I want to separate each recipe into a different tex file and a different include so I can arrange the recipes in the order I want.
3) I will probably add “chapters” which will be section dividers: perhaps meat, eggs, vegetables, soup, fish, etc. or perhaps sections for dishes from different parts of China.
I finished fixing item 2 quickly. Each recipe is now in a separate chapter. One file had three recipes in it. Fixing this meant cutting and pasting each recipe into a separate file.
Fixing item 1 was straightforward but tedious. I had to review every recipe file looking for fractions. Then I had to change the type entry 1/2 into a real fraction using the function frac{numerator}/{denominator}. Because this is an inline Latex math function it has to be surrounded by dollar signs. Using TexStudio made the typing error-free. I simply typed \frac and TexStudio filled in the correct syntax. I could have also used the Math menu item and selected fraction. Once the first fraction had been written it was simple to copy and paste it over and over and over and … in every file. Of course I had to make sure I used the correct value of the fraction when I replaced it. For example the difference between 1/2 cup and 3/4 cup can be significant.
After fixing those two items the book is starting to look a little more professional. As I went through each recipe.tex file I noticed some inconsistencies in the recipes. Different recipes had different amounts and kinds of text between the title (chapter name) and the Ingredients list. Some had a short description or story in text. Others had preparation times and / or servings and other auxiliary cooking information.
Some recipes used a capital T for tablespoon and a lower case t for teaspoon. Some used Tbsp, others used Tb or tb or tbs for tablespoon. There was not as much variation for teaspoon.
Should 1 unit be singular and multiple units plural or all units singular? For example should the sequence be: 1 cup, 2 cups or 1 cup, 2 cup?
A few recipes had units in the metric system, most did not. This has something to do with the source and age of the recipes I selected. Recipes from American and most Canadian cookbook writers until very recently have always used Imperial units. Cookbooks from outside North America for sale in North America may use Imperial units only or Imperial units with the equivalent metric units in brackets.
Of course if you are putting together a family history or a novel or a play your book will not have the same presentation “issues” this cookbook has. Nevertheless you need to pay attention to consistency in chapter structure, headers and footers, fonts, etc. Inconsistency in presentation is a hallmark of amateurs at work.
Headings for dividers between sections are easy to put in place. Arrange the recipes into the desired order. Decide what you are going to call each section. Then make a new file with the appropriate name (sectionbuns.tex). I might have a section for buns. Its file will look like:
\chapter{Buns}
and include an introduction to this part of the book. What is considered a “bun” in Chinese cuisine? Which areas of the country feature buns in their meals? General features of buns and bun recipes, etc.
I would save it as sectionbuns.tex. Then put a new include statement in the main file for the book that would say:
\include{sectionbuns}
That would generate two new pages. The first page would automatically be on the right side (odd-numbered page). The second page it generates is a blank page on the left side (even numbered page) because the next include starts a new chapter and every new chapter starts with a right hand page by default. This is a default built into the style sheet for Latex books.
As long as I keep all the information about buns to two pages I can take advantage of the empty generated page by either writing a lot of information about buns or inserting an image, perhaps a photo of different types of buns.
Note: If you set the documenttype to article you cannot use the chapter instruction. However, each new “section” (chapter) of your book will start on the next page, no blank pages. There are no left and right pages in an article.
I do not like the number of blank pages generated by the chapter element. I want to eliminate as many of these blank pages as possible. Having different recipes on facing pages (left and right) is a layout used in many cookbooks. I can make that change by changing the chapter instruction in each recipe to section. Since the include instruction has a built-in page break between each included file this will generate what I want for pages. The problem with this is in the Table of Contents. By default chapters are numbered 1, 2, 3, etc. sections are numbered as 0.1, 0.2, 0.3, etc. Also by default section names are in smaller type than chapters in the Table of Contents. If I use the instruction \section* the sections will not be numbered, they will also not be listed in the Table of Contents.
I decided to set up and work with a compromise. I am not completely happy with it but it satisfies my major criteria. All of the recipes are listed in the Table of Contents. There are dividers for each type of recipe. There are no blank pages between recipes. It will be possible to insert new recipes into the book without a major reworking of the code. The compromise is as follows.
1. Each dividing page (section divider) will start with the instruction \chapter{type of food).
2. Each recipe will start with the instruction \section{name of recipe}.
You can see the effect of this choice in the image shown top right and also in the snippet from a sample recipe (bottom right).
I prefer to have no numbering for either chapters or sections. However, that requires editing the style sheet for the book or finding a premade template at ctan.org that already uses a style sheet I prefer. Another option is to write a macro in the book file which makes my preferred changes. Perhaps I will have time to work with one of these options for another issue.