Ceci est une ancienne révision du document !
Welcome to this special 200th issue of Full Circle! This is a very big milestone for any magazine, especially considering FCM is distributed electronically and for free. This issue should coincide with my twentieth Latex column. However I missed deadlines a couple of times so this is actually my eighteenth appearance in FCM. Happy 200th birthday to FCM. I look forward to receiving a copy every month. I encourage subscribers to support this project through Patreon or other means. I also encourage subscribers to write something relevant to the operating system and the many different software packages we use. A one-off article is welcomed by the editor and publisher. Do you play a game or use a particular bit of software regularly – write a review. Have you discovered a command line technique that saves you time or makes your system more secure or . . . and want to share it with others – write an article. Now on to Latex.
Our sample cookbook has a few recipes, an index, a (very short) glossary. The Table of Contents and Bibliography have clickable links so readers can easily jump from one part of the PDF to another. This time we are going to make a cover so the cookbook look more professional. Then we should be done with this project and ready to move to something else.
The current title page has the book title, the author (in this case the compiler) and the date the book was last compiled. Because this file uses the document class book there is default formatting attached to each of these elements. The formatting includes font, font size, font style and leading (line spacing). This is the code that generates the page.
In the preamble there are two elements for the title page. These elements contain the values for author and title that are then used by the instruction maketitle.
\author{Robert Boardman} \title{Favourite Chinese Recipes} Below the preamble: \begin{document} \frontmatter \maketitle
frontmatter is an element that can be used with documentclass{book}. Frontmatter, mainmatter and backmatter are used by documentclass{book} to divide a book into pieces. Each piece has its own default formatting. Each piece starts on a new page (right hand side page, odd-numbered page). The maketitle command uses the author and title information in the preamble (plus the current date) to generate a plain, serviceable title page. I want to generate a cover page that will contain not only the title and author but also some element or elements that will be attractive and memorable. Initially this book will only be available as a PDF so the cover gives the reader their first impression. Since this book would be distributed freely, if a reader is not favourably impressed then the file can be easily deleted at no cost.
The best method is to generate a new file for the cover (which I called cover.tex). An independent file gives more freedom for formatting. It allows for formatting that is separate from the formatting for the other pages. If this were a printed book the cover.tex file would be printed separately and bound with the text. For this generated PDF we can use a few instructions to make the cover file look like a printed cover. I will talk about these instructions after I talk about the issue of fonts in the document.
The fonts used by default are not what I would like to use in this document. There is nothing wrong with how they look but they do not have the variety of options I like. I decided to use the Noto font family. It is an enormous family, it is Unicode compliant and it is free. (Noto is available from goggle.com/fonts.) I downloaded and installed the Noto family as instructed on CTAN. I followed the instructions about rebuilding the font map so Latex could find the newly installed font using the sudo texhash command. I added the following line to the preamble. Then I recompiled the cookbook.
\usepackage{noto}
The compile generated an error. One font, a single version of one type of Noto Serif Bold, could not be found so the compile failed. I thought perhaps this font is available in one of the other Noto font downloads on CTAN. I downloaded and unzipped Noto Condensed and Noto Math. To install these I had to copy files from my download area to the relevant directories in the Tex installation. The compile continued to fail. When the compile fails there is no PDF generated.
I went on a hunt to find the missing file. After an hour or so I was sent back to the original install page on CTAN. Obviously the missing font was not supposed to be missing. I decided to try again the following day. (I find this is often good practice when my level of frustration builds and builds.) After about half an hour of more searching I found the missing file listed as part of another zip. Could I download and install just the missing font? No. Could I download and install the zip it was in? No. However this zip was a package for Linux and could be installed using apt. Yeah!
apt install texlive-fonts-extra
Note: Texlive is said to be a quick and easy way to get up and running using Tex. It is one of the ways to get Tex installed and running on a Windows machine. In this instance all I installed was a set of fonts. I did not end up with two different installations of Tex in Linux.
This installation contained over 1GB of font files, some of them may have overwritten existing fonts. It did install the missing Noto Serif Bold file which was the aim of the search. Now when I compile fcmcover.tex it succeeds and a new PDF is generated. Since the file is a PDF which will be viewed on screen I decided to change the default font for the document to the sans-serif typefaces of Noto. I altered the use package instruction with an option.
\usepackage[sf]{noto}
The [sf] instructs Latex to use the sans-serif typefaces by default. The document on CTAN for installation of the Noto family say to use [sfdefault]. However that generated a new error which I did not spend any time to troubleshoot. The [sf] option did what I wanted. I will use the Noto sans-serif family for both the cover (the subject of this article) and the rest of the book.
Here is the code for the cover page so far:
\begin{center} \fontsize{36}{60} \selectfont Favourite Chinese Recipes
\fontsize{24}{48} \selectfont compiled by Robert Boardman
\fontsize{24}{36} \selectfont from many sources \end{center}
I wanted the text of the cover page to be centred so I put it all in the center environment. The fontsize instruction requires two options: the size of the font and the size of the line spacing (the printer’s term is leading). The selectfont instruction is required after every change in font instruction. This cover.tex file is included after the usepackage[sfdefault]{noto} instruction in the fcm200cover.tex file so it does not need to be repeated in the cover.tex file.
Note: The last font instruction in cover.tex is fontsize{24}{36}. The rest of the document will use this instruction until a new font instruction is issued followed by selectfont. After the include for cover.tex there is fontsize{11}{13} and then selectfont. This instruction sets the basic font size and line spacing for the rest of the document.
Now the text is where I want it and looks the way I want it. It is time to add a graphic that gives the same message as the title. I want the graphic to flow behind the text. I changed the graphic I downloaded to shades of grey, adjusted its size and changed brightness and contrast. I want it to be visible but not obscure the text.
It took several hours of digging on CTAN and on other sites to find out how to do what I want – which is place a watermark behind the text. I will not bore you with the saga, I will just present the results. The secret turned out to be using a package called tcolorbox which is part of the regular installation of Latex. Then I had to sift through the 544 page manual for tcolorbox. Here is the final addition to the main file:
\usepackage[skins]{tcolorbox} \tcbset{colframe=black!25!white, colback=green!10!white, halign=center, valign=center, width=15cm, height=15cm, arc=5mm}
I do not know what the “skins” option does but it is necessary for the graphic to appear. Colframe and colback are colour instructions. The syntax is simple once you know what it is. Black!25!white means blend 25% black and 75% white. White is the default second colour so this command can be shortened to black!25. (or green!10). Halign and valign should be obvious. Width and height control the size of the box, getting appropriate values can require some experimenting. Arc sets the diameter of the curve in the corners of the frame.
Here is the important new code from the cover.tex file.
\begin{tcolorbox}[enhanced, watermark graphics=steamer.pdf, watermark opacity=0.6, watermark stretch=1.0]
I discovered tcolorbox would only accept graphics in PDF format even though the manual shows PNG and other formats. Opacity refers to how transparent / opaque the image appears. Stretch determines the size of the image in the tcolorbox frame. The value “1” means it fills the frame. Values larger than 1 increase the size of the image but the size of the frame does not change so only part of the image is visible.
I have had a steep learning curve to complete this part of the cookbook. I have only learned very little of the capabilities of tcolorbox. I am just starting to learn about font use in Latex. It has been both frustrating and fun to do this cover. Next time I hope the project will not require quite so much time. December is always a busy month in my house and with my family. I hope you have an enjoyable and relaxing month.
If you have any suggestions about a project that could perhaps be done in Latex, or if you have a project and are stuck at some point let me know. Perhaps we can solve the problem or build a project together.