issue218:latex
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
issue218:latex [2025/06/30 07:22] – d52fr | issue218:latex [2025/06/30 15:49] (Version actuelle) – d52fr | ||
---|---|---|---|
Ligne 2: | Ligne 2: | ||
First I need to have a text file for the selected book. It is available in three different epub formats on the Gutenberg site as well as two Kindle formats, and a html and a plain text file which is the one I want. The text file needs to be edited somewhat. The Table of Contents needs to be removed because Latex will build a new one. I removed the Gutenberg Licence since I plan to print and bind one copy as a gift. I saved the txt file as an odt file using LibreOffice. Then I used the Writer2Latex filter extension to convert the file to the tex format. ** | First I need to have a text file for the selected book. It is available in three different epub formats on the Gutenberg site as well as two Kindle formats, and a html and a plain text file which is the one I want. The text file needs to be edited somewhat. The Table of Contents needs to be removed because Latex will build a new one. I removed the Gutenberg Licence since I plan to print and bind one copy as a gift. I saved the txt file as an odt file using LibreOffice. Then I used the Writer2Latex filter extension to convert the file to the tex format. ** | ||
+ | |||
+ | Cette fois, je vais travailler avec un vrai document, et non avec l'un des milliers de logiciels disponibles sur ctan.org. Je vais convertir le fichier texte d'un livre existant en fichier PDF LaTeX. J'ai eu l' | ||
+ | |||
+ | Je dois d' | ||
+ | |||
**Once the file has been converted, I opened the tex file in my preferred editor, TexStudio, to do the cleanup. Of course I could do some of the cleanup in the odt file before converting it to a tex file. I could also edit the tex file LibreOffice generated in a text editor but I like the advantage of the color coding in TexStudio. I find it easier and faster to work with the tex file instead of the odt file. | **Once the file has been converted, I opened the tex file in my preferred editor, TexStudio, to do the cleanup. Of course I could do some of the cleanup in the odt file before converting it to a tex file. I could also edit the tex file LibreOffice generated in a text editor but I like the advantage of the color coding in TexStudio. I find it easier and faster to work with the tex file instead of the odt file. | ||
The first thing I did was generate the pdf file using TexStudio before I started editing. I wanted to be sure it was error free before I started deleting unnecessary code. Good thing I compiled first. LibreOffice inserted two Latex commands to make the Table of Contents clickable but there was an error somewhere in the hypersetup command. Since I intend to print the generated pdf file on paper, any hypertext links are irrelevant. So I commented out both the hypersetup and the usepackage{hyperref} commands from the generated file. Since that cleared the error I then deleted those two commands.** | The first thing I did was generate the pdf file using TexStudio before I started editing. I wanted to be sure it was error free before I started deleting unnecessary code. Good thing I compiled first. LibreOffice inserted two Latex commands to make the Table of Contents clickable but there was an error somewhere in the hypersetup command. Since I intend to print the generated pdf file on paper, any hypertext links are irrelevant. So I commented out both the hypersetup and the usepackage{hyperref} commands from the generated file. Since that cleared the error I then deleted those two commands.** | ||
+ | |||
+ | Une fois le fichier converti, j'ai ouvert le fichier .tex dans mon éditeur préféré, TexStudio, pour le nettoyer. Bien sûr, je pourrais effectuer une partie du nettoyage dans le fichier .odt avant de le convertir en fichier .tex. Je pourrais également modifier le fichier .tex généré par LibreOffice dans un éditeur de texte, mais j' | ||
+ | |||
+ | J'ai d' | ||
+ | |||
**Remember each time you make a change to the Latex commands, regenerate the PDF. This will check for errors in the code and it will also save the current code. Doing this step after every change is a little time consuming. However, I learned long ago when making changes to code (or just about anything) change one thing then make sure it works as you want, then change the next one thing and check again. | **Remember each time you make a change to the Latex commands, regenerate the PDF. This will check for errors in the code and it will also save the current code. Doing this step after every change is a little time consuming. However, I learned long ago when making changes to code (or just about anything) change one thing then make sure it works as you want, then change the next one thing and check again. | ||
There were a number of “length” commands which were generated by LibreOffice in order to be sure the geometry of the Latex-generated PDF document would match the page style used in LibreOffice. I will set page size, printed area size, and other page geometry options later in the Latex process, so I removed those length commands. There was a short section of footnote rules and another section of page styles. Both are not needed so I removed them. Then I generated the PDF again to check for any errors. This time there were no errors. Next I made necessary corrections to the title and author in the preamble. That made the title and author in the body redundant so they were removed.** | There were a number of “length” commands which were generated by LibreOffice in order to be sure the geometry of the Latex-generated PDF document would match the page style used in LibreOffice. I will set page size, printed area size, and other page geometry options later in the Latex process, so I removed those length commands. There was a short section of footnote rules and another section of page styles. Both are not needed so I removed them. Then I generated the PDF again to check for any errors. This time there were no errors. Next I made necessary corrections to the title and author in the preamble. That made the title and author in the body redundant so they were removed.** | ||
+ | |||
+ | N' | ||
+ | |||
+ | LibreOffice générait plusieurs commandes « length » afin de garantir que la géométrie du document PDF généré par LaTeX corresponde au style de page utilisé dans LibreOffice. Je définirai la taille de la page, la taille de la zone d' | ||
+ | |||
**I noticed every paragraph of the text started with {\ttfamily{ and ended with a closing curly brace. While those defined the paragraph, they were unnecessary, | **I noticed every paragraph of the text started with {\ttfamily{ and ended with a closing curly brace. While those defined the paragraph, they were unnecessary, | ||
As I scrolled through the tex file, I saw the \bigskip command many times. This is used by Latex to make large vertical areas of white space. I assume the Writer2Latex extension converted multiple CR/LF codes to bigskip. Since I will use other Latex instructions to control white space, I removed the bigskip commands as well. Again I generated the PDF and scrolled through it to make sure there was no inappropriate white space and no long paragraphs. (This is a children’s book, so paragraphs should be short, two or three sentences. If you are working with a different file then adjust your editing accordingly.)** | As I scrolled through the tex file, I saw the \bigskip command many times. This is used by Latex to make large vertical areas of white space. I assume the Writer2Latex extension converted multiple CR/LF codes to bigskip. Since I will use other Latex instructions to control white space, I removed the bigskip commands as well. Again I generated the PDF and scrolled through it to make sure there was no inappropriate white space and no long paragraphs. (This is a children’s book, so paragraphs should be short, two or three sentences. If you are working with a different file then adjust your editing accordingly.)** | ||
+ | |||
+ | J'ai remarqué que chaque paragraphe du texte commençait par {\ttfamily{ et se terminait par une accolade fermante. Bien que ces accolades définissent le paragraphe, elles étaient inutiles, car chaque paragraphe était séparé du suivant par au moins deux CR/LF (deux appuis sur la touche < | ||
+ | |||
+ | En parcourant le fichier tex, j'ai vu la commande \bigskip à plusieurs reprises. Elle est utilisée par LaTeX pour créer de grandes zones verticales d' | ||
+ | |||
**This finished the majority of the cleanup. Then it was time to make this text file look more like a book. At this point in the editing process, the PDF was 33 full letter-size pages. The document class was article, and the default type size was 10pt. This is a book for children. It was originally printed and bound in a size suitable to be held by small hands. Like most books, each chapter should start on a separate page. | **This finished the majority of the cleanup. Then it was time to make this text file look more like a book. At this point in the editing process, the PDF was 33 full letter-size pages. The document class was article, and the default type size was 10pt. This is a book for children. It was originally printed and bound in a size suitable to be held by small hands. Like most books, each chapter should start on a separate page. | ||
Ligne 22: | Ligne 42: | ||
Latex automatically numbers chapters. If the text you work with has chapter numbers, as Whitefoot the Wood Mouse did, you should probably delete them when you edit the chapter command.** | Latex automatically numbers chapters. If the text you work with has chapter numbers, as Whitefoot the Wood Mouse did, you should probably delete them when you edit the chapter command.** | ||
+ | |||
+ | Ceci a permis d' | ||
+ | |||
+ | J'ai changé la classe de document en « book » et la police par défaut en « Noto Serif ». Afin de tirer parti du formatage des titres intégré, j'ai stylisé chaque titre de chapitre comme un chapitre. La fonction Rechercher/ | ||
+ | |||
+ | • Les chapitres ne sont autorisés que dans la classe de document « book », | ||
+ | • Le texte de chaque chapitre doit être entre accolades ; | ||
+ | |||
+ | LaTeX numérote automatiquement les chapitres. Si le texte que vous utilisez comporte des numéros de chapitre, comme c' | ||
+ | |||
**Note: If you do not want the automatic chapter numbering then change the \chapter command to \chapter*, i.e. add an asterisk after the word “chapter”. This also removes the chapter from the Table of Contents. | **Note: If you do not want the automatic chapter numbering then change the \chapter command to \chapter*, i.e. add an asterisk after the word “chapter”. This also removes the chapter from the Table of Contents. | ||
Ligne 28: | Ligne 58: | ||
I adjusted the leading (spacing between lines), and added a paragraph indent. After I use the geometry package (next issue), I will look at a printed page to find out if I think my work is usable by primary school students. I am also considering using drop caps, large initial capital letters at the beginning of the first paragraph of each chapter. Perhaps I can find some illustrations to add to the text. These are tasks for the time.** | I adjusted the leading (spacing between lines), and added a paragraph indent. After I use the geometry package (next issue), I will look at a printed page to find out if I think my work is usable by primary school students. I am also considering using drop caps, large initial capital letters at the beginning of the first paragraph of each chapter. Perhaps I can find some illustrations to add to the text. These are tasks for the time.** | ||
+ | |||
+ | Remarque : Si vous ne souhaitez pas la numérotation automatique des chapitres, remplacez la commande \chapter par \chapter*, c' | ||
+ | |||
+ | De nombreux chapitres de Whitefoot the Wood Mouse commencent par des poèmes de deux lignes. Le texte de ces poèmes commence par une accolade ou une barre oblique inverse, ce qui peut poser problème lors de la compilation du fichier. Lors de la modification des commandes de chapitre, j'ai également supprimé les éléments gênants. Ces poèmes de deux lignes m'ont rappelé un paquet que j'ai examiné dans FCM n° 212, qui formate de petits extraits de texte au début des chapitres. Ce paquet, appelé epigraph, est très simple à utiliser. Cependant, ce petit livre contenait de nombreuses épigraphes. L' | ||
+ | |||
+ | J'ai ajusté l' | ||
+ | |||
**Here is the code (with a few comments) for the preamble so far followed by the code to make an epigraph. | **Here is the code (with a few comments) for the preamble so far followed by the code to make an epigraph. | ||
Ligne 39: | Ligne 76: | ||
For the second part of this project, I am going to add a drop cap in the first paragraph of each chapter to add a little visual interest. I will alter the page geometry to get the file ready for imposition. Imposition is a process used to put the text on the correct printed pages in order to bind them into a book. If you do not need or want to make your file into a printed book, then imposition is not necessary. However you might want to change the page geometry to make the PDF look more like a printed book. If I can find some suitable illustrations I may include them. I hope you will join me next time.** | For the second part of this project, I am going to add a drop cap in the first paragraph of each chapter to add a little visual interest. I will alter the page geometry to get the file ready for imposition. Imposition is a process used to put the text on the correct printed pages in order to bind them into a book. If you do not need or want to make your file into a printed book, then imposition is not necessary. However you might want to change the page geometry to make the PDF look more like a printed book. If I can find some suitable illustrations I may include them. I hope you will join me next time.** | ||
+ | |||
+ | Voici le code (avec quelques commentaires) du préambule, suivi du code pour créer une épigraphe. | ||
+ | |||
+ | Pour créer une épigraphe, j'ai utilisé : | ||
+ | |||
+ | \epigraph{You never can tell! You never can tell! | ||
+ | Things going wrong will often end well.}{Whitefoot} | ||
+ | |||
+ | (On ne sait jamais ! On ne sait jamais ! Les erreurs finissent souvent bien. - Whitefoot) | ||
+ | |||
+ | Cette chronique contient des images d'une épigraphe et du début d'un chapitre. | ||
+ | |||
+ | Pour la deuxième partie de ce projet, je vais ajouter une lettrine au premier paragraphe de chaque chapitre pour un rendu visuel plus intéressant. Je modifierai la géométrie de la page afin de préparer le fichier pour l' | ||
issue218/latex.txt · Dernière modification : 2025/06/30 15:49 de d52fr