Outils pour utilisateurs

Outils du site


issue194:latex

Ceci est une ancienne révision du document !


For this project, I am going to put together a small book from several files. Since I like to cook, I also collect recipes, particularly recipes of Chinese dishes. So this book is going to be a cookbook. The techniques and procedures can be used for any book. I went over putting several files together to generate one PDF in FCM #190. This project will use the techniques discussed in that previous work and expand upon them.

The first thing we need to do is open a new document. The document class needs to be “book”. The document class “article” could be used but that will change the options available. For example, ‘article’ sets margins for printing one side only. The ‘book’ class is designed to produce a PDF that could be printed and bound as a book with two-sided printing. This means margins are not left and right, but inside and outside. It also means the text of the book starts on a right-hand page and that each chapter starts on a right-hand page. If a chapter ends with a right-hand, odd-numbered page, then a blank left-hand page is inserted before the next chapter starts. When using the document class ‘article’, pages are neither left nor right, text flows from one page to another as if being printed in one long column.

Top right is the code I will start with. I have put my annotations below the code.

All lines starting with a percent symbol are comments. All lines starting with a back slash are Latex instructions. \frontmatter, \mainmatter, \backmatter instructions work with the ‘book’ document class but are not allowed in the article document class.

\tableofcontents uses the \chapter instructions in each of the recipes to make the table-of-contents automatically. The \include commands bring the individual recipe files into the PDF. These files are in the same directory as this “master” file. That is not necessary. If they were in one or more different directories, the directory names are added to the include, for example \include{recipe/Bao}. Latex assumes names of included files end with “.tex”.

This revision of the cookbook does not have any back matter. A real cookbook would have a recipe name index and an ingredient index. Since these recipes include ingredients specific to Chinese food, I might also include a glossary. Those are topics for another article (or two).

Top right is a sample of one of the included files.

Notes for the included file: \chapter{chapter title} \section*{section name} The * means this section is not numbered \begin{itemize} starts an unordered or bulleted list \item 3 1/2 cups flour \item 1 tablespoon shortening \end{itemize} \section*{Instructions} \begin{enumerate} starts a numbered or ordered list \item Put 3 cups of the flour into a bowl. … \end{enumerate}

When the PDF is built, the instruction \include{Bao} is replaced by the contents of the Bao.tex file. That means the Bao.tex file does not have any of the introductory or concluding instructions. This particular recipe does have text after the list of instructions. It is important not to include the \end{document} instruction at the end of the included file.

This is my first edit of the first part of the cookbook. It requires more work. For example, the fraction in 3 1/2 cups of 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 that Latex formats it as ½. (Any other fractions should be reformatted as well.) Ideally, all dry ingredients would be measured in grams, and all liquid ingredients in millilitres. That would eliminate the fractions but also make the cookbook unsaleable in Canada and the U.S.A.

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. 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.

Cookbooks deserve to be illustrated with photos. Some recipes can benefit from images as well as words to show how a dish is put together.

I need to decide if I am happy with the way the book looks. Do I want to change the page size or the margins or the default fonts being used? Do I want to add some color? Drop caps are nice if used judiciously. There is the end matter to build: index, indices, glossary. You can probably think of other changes you would make if you were writing, editing, publishing a book. We will work through some or perhaps all of these features in the next few columns.

issue194/latex.1688186932.txt.gz · Dernière modification : 2023/07/01 06:48 de d52fr