Outils pour utilisateurs

Outils du site


issue219:latex

Whitefoot - Part Two If you read the Latex column in FCM 218, you may remember I am going to try adding three more features to the book about Whitefoot the Wood Mouse: drop caps for the initial paragraph of each chapter, the geometry package, and illustrations. Before I do those three, I will change the size of the type to be a little friendlier to children’s eyes. When I finished last time, I had reset the font to Noto Serif but made no change to the type size. Note: For those who do not know, Noto is a shortened form of “No tofu”. It means this font has an extensive set of characters and supports Unicode. That means it can be used for many languages of the world without generating little blank boxes (“tofu” - □) as substitutes for missing characters. The various styles of the Noto font family are available for free from fonts.google.com, fontsquirrel.com, exfont.com, and other font distributors. Without a type size in the documentclass instruction, Latex generates 68 pages. Setting the default type size to 10pt generates 109 pages. Since this is a book, every chapter will start on a right-hand page by default. Without a default type size, almost all 32 chapters use two pages, a right page and a left page. If I increase the type size, many or all chapters become three pages (right, left, right), then Latex will automatically add a blank left page at the end of each chapter. I would like to avoid using all that extra paper. During my scan of the pages, I noticed many of the epigraphs were occupying four lines of type, not two. In order to adjust most of them to two lines I increased the width of the epigraph area usually to to eight centimetres but to ten or twelve centimetres if necessary: \setlength{\epigraphwidth}{8cm} Changing the default size of the Noto type to 11pt in the documentclass command generates 120 pages and 12pt further increases the page count to 124. Removing the paragraph indent and extra line spacing, and returning to 10pt default size, drops the page count to 75. However, that is not a good design choice. Perhaps a different typeface would be better. These are the choices book designers and other desktop publishing experts encounter regularly. After several experiments and a few test prints, I decided to use the FourierNC package at 11pt. It generates New Century Schoolbook text. That seems appropriate to me since I first encountered Thornton W. Burgess in a grade school classroom. Using the default margins for the document class “book”, and using letter size paper, this choice generates 91 pages. As I scrolled through each variation in type size, I noticed some widows and orphans. These terms denote only the first line of a paragraph appearing at the bottom of a page (orphan), or only the last line of a paragraph appearing at the top of a page (widow). These problems and others can be identified in the error log in TexStudio using the widows-and-orphans package. Widows, and often orphans, can be eliminated using the nowidow package. Even if you use the nowidow package, I strongly recommend looking through the generated document carefully to find any orphans that appear in the TexStudio log. Almost always, the adjustments made by the nowidow package will also eliminate orphans. However, you may need to edit the text or introduce an artificial line break or page break in order to correct any orphaned line you find. Note: Do the final check for widows and orphans after you have made all the other adjustments which affect how much text is on a page. Otherwise you may insert a line break or page break that causes another widow or orphan or generates an undesirable blank page. Setting up the drop caps has to be done for each chapter individually. For drop caps, I used the lettrine package. It has good documentation and three sample documents. I chose not to use any options, to have the first letter of the first word in a chapter use two lines, and the rest of the first word in small caps. (See the accompanying image in this issue.) This had to be done for each chapter separately, which was a little tedious to do for thirty-two chapters. However I am pleased with the result. To get the document ready for printing as a book, some margin adjustments are required. Books are printed on both sides of the sheet of paper. In order to bind the pages into a book, the right-hand side of the left pages and the left-hand side of the right pages must be set wide enough so there is extra paper which will be used in the binding process. In book printing terminology, these two margins are the inside margins. Usually inside margins are larger than outside margins. It is also customary for bottom margins to be larger than top margins. This is a children’s book and needs to be sized to fit a child’s hand. Standard letter paper is too large. After measuring some children’s books in my house I decided to set the page size to 230mm * 150mm (9in * 6in). Outside margins will be 25mm, inside margins will be the same. Contents will start 20mm from the top. The bottom margin will be 40mm, this includes the space for page numbers. These measurements need to be set in the options for the geometry package. You can see the code in the accompanying image. In an Internet search, I found only one illustration suitable to this particular book. I had expected to find several good images and some not-so-good images. I guess either the original book did not have many illustrations, or the images are still protected by copyright. The image is of Whitefoot and Mrs. Whitefoot, so it belongs near the end of the story. The Latex code for the image contains a few explanations in comments. Code to insert an image \begin{figure}[h] %Use [b] to move to bottom of page

\centering
\includegraphics[scale=1]{whitefootcouple} 

% Scale determines the size of the image. % Image is in the same directory as text and is a standard image format so only the name is required \end{figure} I experimented with a package called zwpagelayout. I think it could be a useful substitute for the geometry package. It includes some features I wished to use for this book. After reading the documentation several times, I was unable to learn how to turn on the extra features. Zwpagelayout did not offer any advantages over geometry. Since I was reasonably content with the page layout I got with geometry, I abandoned zwpagelayout. It will be worth learning but will take more time than I have at present. As I have said before, I intend to print the PDF and then bind it into a book. That means I need to print on two sides of each sheet of paper. Organizing the pages into the desired page layout and getting them to print in the correct order is called imposition. This is the last important task before printing. All of the publisher’s design choices must be finished before imposition. The pgfmorepages package seems to be a reasonable choice to use for imposition with Latex. It can reduce four pages of text to two pages (1 sheet) of paper or eight pages to four pages (2 sheets). This package presented two problems for me. It puts four pages into two by reducing the type by 50%. That means the text of page 5 for example remains on page 5 but it is difficult to read. Of course I can solve that by doubling the default size of the text before applying pgfmorepages. Adjusting the font can mean generating more widows, which will be corrected with the no-widows package. It also means a page-by-page review to look for orphans and for any unnecessary blank pages. Any linebreak or pagebreak commands would also have to be examined to find out if they are still appropriate. The other is an issue for binding, not for printing. If I accept the eight pages into four pages then the first eight pages will print as a group. When this group is folded together they will make a two-sheet signature. I would prefer to work with sixteen-page or four-sheet signature when I come to bind this book. The documentation for pgfmorepages has a sample to help with defining a new layout. There are many comments. In the future, I may try to make a new layout which will be 16 text pages on eight physical pages (four sheets of paper), book format. Because of time pressure (not from FCM but from other things in my life), I decided to abandon the pgfmoreages package. My desire to bind Whitefoot the Wood Mouse is a personal one. I need to be able to use Latex to make a PDF with appropriate page sizes and crop marks for a children’s book. Generating that PDF can wait a little while. The final code for the preamble and the heading for the first chapter accompanies this text. \documentclass[letterpaper]{book} \usepackage[paperheight=230mm, paperwidth=150mm,inner=25mm,outer=25mm, top=20mm,bottom=40mm]{geometry} \usepackage{graphicx} %for image \usepackage[fontsize=12pt]{fontsize} \usepackage{epigraph} \usepackage{fouriernc} %fonts \usepackage{lettrine} %dropcaps \usepackage[defaultlines=2,all]{nowidow} %corrects widows \usepackage[check=warning]{widows-and-orphans} %finds widows and orphans \title{Whitefoot the Wood Mouse} \author{Thornton W. Burgess} \date{\today} \begin{document}

\maketitle
\tableofcontents

\chapter{Whitefoot Spends A Happy Winter} For now that is the end of our adventures with Whitefoot. Next issue, I will resume my perusal of some of the packages available at ctan.org. There are sixteen topics starting with I and seven starting with J. In those two groups, I will look for topics that might be of general interest. If you have any special requests for tasks you want to do in Latex, send me an email (rboardman@psmail.net). Talk to you again in the next issue.

issue219/latex.txt · Dernière modification : 2025/07/17 18:04 de philou511