Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
LaTeX Cookbook
LaTeX Cookbook

LaTeX Cookbook: Over 90 hands-on recipes for quickly preparing LaTeX documents to solve various challenging tasks

eBook
€28.99 €41.99
Paperback
€52.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

LaTeX Cookbook

Chapter 2. Tuning the Text

This chapter contains the following recipes:

  • Inputting accented characters
  • Improving justification and hyphenation
  • Converting numbers to words
  • Putting text into a colorful box
  • Visualizing the layout
  • Visualizing boxes of letters and symbols
  • Typesetting in a grid
  • Absolute positioning of text
  • Starting a paragraph with an oversized letter
  • Fitting text to a shape
  • Creating a pull quote

Introduction

The previous chapter presented recipes for creating whole documents. You may use them as starting points. Now, we will focus on customizing text details. The upcoming sections broadly deal with the following:

  • Manipulating text
  • Positioning and arranging text
  • Shaping paragraphs

We are not yet dealing with fonts. This topic deserves a whole chapter, and will be covered in Chapter 3, Adjusting Fonts.

We will start with some very useful basics, cover some helpful things, and end the chapter with recipes that show off what LaTeX can do beyond rectangular paragraphs.

Inputting accented characters

By default, LaTeX works with simple ASCII characters. For accented characters, such as in the German word "schön", you need to type sch\"on into your editor. The babel command with the ngerman option simplifies the syntax to sch"on. But there is an easier way.

How to do it...

We will activate extended input character support as follows:

  1. Check your editor's configuration and find out its input encoding setting. utf8 (UTF-8 means Unicode) is standard for Linux, Mac OS X, and some Windows editors. However, some Windows editors still work with latin1 or cp1250/cp1252, while some older Macs use applemac.
  2. Load the inputenc package with the corresponding option, like so:
    \usepackage[utf8]{inputenc}
  3. Now you can directly type characters such as a, ü, ö, é, and è in to your document.

Tip

If you need help with editor settings, you can post a question in the forum at http://latex-community.org/forum/. This web site provides support...

Improving justification and hyphenation

Sometimes, you may get warnings like overfull \hbox, or you may notice words hanging in the margin. This is a sign that LaTeX has had serious problems with justification. Now, we will take a look at how to improve that.

How to do it...

You can start with any document. We will optimize it with settings in the preamble. If you don't have one at hand, you can take one from the code package for this book, specifically for the first chapter, or download one at http://latex-cookbook.net. Let's proceed:

  1. Load the package babel with your document languages as options. Use the preferred language as the last option:
    \usepackage[ngerman,english]{babel}
  2. If you would like to use handy shortcuts of the ngerman package with English too, add the following lines of code:
    \useshorthands{"}
    \addto\extrasenglish{\languageshorthands{ngerman}}
  3. Load the fontenc package with the T1 option set:
    \usepackage[T1]{fontenc}
  4. Load the microtype package for improved micro-typography...

Converting numbers to words

Numbers are sometimes written in words rather than using numerals. LaTeX is capable of automatically converting numbers to words. This is especially useful for values which originate from LaTeX counters, such as page or section numbers.

How to do it...

Load the fmtcount package and use its commands for conversion:

  1. Start with any document class, such as article:
    \documentclass{article}
  2. Load the fmtcount package:
    \usepackage{fmtcount}
  3. Begin the document:
    \begin{document}
  4. Write some text. Use the following instructions:
    • Whenever you'd like to convert a number to a word, use the command \numberstringnum.
    • To print a counter value as a word, use \numberstring.
    • For a similar purpose, but in ordinal form, use \ordinalstringnum or \ordinalstring. Let's take a look at the following commands:
      This document should have \numberstringnum{32}
      pages, now we are on page \numberstring{page}
      in the \ordinalstring{section} section.
  5. End the document:
    \end{document}
  6. Compile the document...

Putting text into a colorful box

You often see important content put into a colored box, especially on posters and slides, although it's used in other documents, too. In this recipe, we will put a little text and also whole paragraphs into a colored box. They can also have titles.

How to do it...

We will use the tcolorbox package. It is based on pgf, so you need to have that package installed as well.

We will create a box with the defaults, a titled box with split content, and boxes placed inline that fit the width of the content. Proceed as follows:

  1. Create a small document based on any document class. The article package is a simple choice. Load the blindtext package to generate dummy text. This time, we will use the pangram option to create short pangrams as dummy text. The blindtext package requires the babel package, so we load it before. We also set English as the language. Furthermore, load the tcolorbox package. Our base document looks like this:
    \documentclass{article}
    \usepackage...

Visualizing the layout

At the time of designing a document, one may like to have an exact view of the dimensions and position of the text body, the header and footer, and the space for the margin notes. LaTeX can print help lines for you so you can examine the layout and use it to position extra elements.

How to do it...

Load the showframe package. This means the following steps:

  1. Open your document or a sample for testing. Here, we will use the very first document from Chapter 1, The Variety of Document Types.
  2. Add the following line at the end of your preamble:
    \usepackage{showframe}
  3. Compile the document. You will see frames around text body, margin note area, and header and footer:
    How to do it...
  4. Examining the layout can give you ideas about making adjustments, such as changing the margins or other page dimensions. If you don't need these help lines any more, you can disable the package by commenting out \usepackage{showframe} or by deleting it.

How it works...

We simply loaded the showframe package. It...

Introduction


The previous chapter presented recipes for creating whole documents. You may use them as starting points. Now, we will focus on customizing text details. The upcoming sections broadly deal with the following:

  • Manipulating text

  • Positioning and arranging text

  • Shaping paragraphs

We are not yet dealing with fonts. This topic deserves a whole chapter, and will be covered in Chapter 3, Adjusting Fonts.

We will start with some very useful basics, cover some helpful things, and end the chapter with recipes that show off what LaTeX can do beyond rectangular paragraphs.

Inputting accented characters


By default, LaTeX works with simple ASCII characters. For accented characters, such as in the German word "schön", you need to type sch\"on into your editor. The babel command with the ngerman option simplifies the syntax to sch"on. But there is an easier way.

How to do it...

We will activate extended input character support as follows:

  1. Check your editor's configuration and find out its input encoding setting. utf8 (UTF-8 means Unicode) is standard for Linux, Mac OS X, and some Windows editors. However, some Windows editors still work with latin1 or cp1250/cp1252, while some older Macs use applemac.

  2. Load the inputenc package with the corresponding option, like so:

    \usepackage[utf8]{inputenc}
  3. Now you can directly type characters such as a, ü, ö, é, and è in to your document.

Tip

If you need help with editor settings, you can post a question in the forum at http://latex-community.org/forum/. This web site provides support forums for various LaTeX editors.

How it works...

Improving justification and hyphenation


Sometimes, you may get warnings like overfull \hbox, or you may notice words hanging in the margin. This is a sign that LaTeX has had serious problems with justification. Now, we will take a look at how to improve that.

How to do it...

You can start with any document. We will optimize it with settings in the preamble. If you don't have one at hand, you can take one from the code package for this book, specifically for the first chapter, or download one at http://latex-cookbook.net. Let's proceed:

  1. Load the package babel with your document languages as options. Use the preferred language as the last option:

    \usepackage[ngerman,english]{babel}
  2. If you would like to use handy shortcuts of the ngerman package with English too, add the following lines of code:

    \useshorthands{"}
    \addto\extrasenglish{\languageshorthands{ngerman}}
  3. Load the fontenc package with the T1 option set:

    \usepackage[T1]{fontenc}
  4. Load the microtype package for improved micro-typography:

    \usepackage...

Converting numbers to words


Numbers are sometimes written in words rather than using numerals. LaTeX is capable of automatically converting numbers to words. This is especially useful for values which originate from LaTeX counters, such as page or section numbers.

How to do it...

Load the fmtcount package and use its commands for conversion:

  1. Start with any document class, such as article:

    \documentclass{article}
  2. Load the fmtcount package:

    \usepackage{fmtcount}
  3. Begin the document:

    \begin{document}
  4. Write some text. Use the following instructions:

    • Whenever you'd like to convert a number to a word, use the command \numberstringnum.

    • To print a counter value as a word, use \numberstring.

    • For a similar purpose, but in ordinal form, use \ordinalstringnum or \ordinalstring. Let's take a look at the following commands:

      This document should have \numberstringnum{32}
      pages, now we are on page \numberstring{page}
      in the \ordinalstring{section} section.
  5. End the document:

    \end{document}
  6. Compile the document. All numbers...

Putting text into a colorful box


You often see important content put into a colored box, especially on posters and slides, although it's used in other documents, too. In this recipe, we will put a little text and also whole paragraphs into a colored box. They can also have titles.

How to do it...

We will use the tcolorbox package. It is based on pgf, so you need to have that package installed as well.

We will create a box with the defaults, a titled box with split content, and boxes placed inline that fit the width of the content. Proceed as follows:

  1. Create a small document based on any document class. The article package is a simple choice. Load the blindtext package to generate dummy text. This time, we will use the pangram option to create short pangrams as dummy text. The blindtext package requires the babel package, so we load it before. We also set English as the language. Furthermore, load the tcolorbox package. Our base document looks like this:

    \documentclass{article}
    \usepackage[english...

Visualizing the layout


At the time of designing a document, one may like to have an exact view of the dimensions and position of the text body, the header and footer, and the space for the margin notes. LaTeX can print help lines for you so you can examine the layout and use it to position extra elements.

How to do it...

Load the showframe package. This means the following steps:

  1. Open your document or a sample for testing. Here, we will use the very first document from Chapter 1, The Variety of Document Types.

  2. Add the following line at the end of your preamble:

    \usepackage{showframe}
  3. Compile the document. You will see frames around text body, margin note area, and header and footer:

  4. Examining the layout can give you ideas about making adjustments, such as changing the margins or other page dimensions. If you don't need these help lines any more, you can disable the package by commenting out \usepackage{showframe} or by deleting it.

How it works...

We simply loaded the showframe package. It prints...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Work with modern document classes, such as KOMA-Script classes
  • Explore the latest LaTeX packages, including TikZ, pgfplots, and biblatex
  • An example-driven approach to creating stunning graphics directly within LaTeX

Description

LaTeX is a high-quality typesetting software and is very popular, especially among scientists. Its programming language gives you full control over every aspect of your documents, no matter how complex they are. LaTeX's huge amount of customizable templates and supporting packages cover most aspects of writing with embedded typographic expertise. With this book you will learn to leverage the capabilities of the latest document classes and explore the functionalities of the newest packages. The book starts with examples of common document types. It provides you with samples for tuning text design, using fonts, embedding images, and creating legible tables. Common document parts such as the bibliography, glossary, and index are covered, with LaTeX's modern approach.You will learn how to create excellent graphics directly within LaTeX, including diagrams and plots quickly and easily. Finally, you will discover how to use the new engines XeTeX and LuaTeX for advanced programming and calculating with LaTeX. The example-driven approach of this book is sure to increase your productivity.

Who is this book for?

If you already know the basics of LaTeX and you like to get fast, efficient solutions, this is the perfect book for you. If you are an advanced reader, you can use this book's example-driven format to take your skillset to the next level. Some familiarity with the basic syntax of LaTeX and how to use the editor of your choice for compiling is required.

What you will learn

  • Choose the right document class for your project to customize its features
  • Utilize fonts globally and locally
  • Frame, shape, arrange, and annotate images
  • Add a bibliography, a glossary, and an index
  • Create colorful graphics including diagrams, flow charts, bar charts, trees, plots in 2d and 3d, time lines, and mindmaps
  • Solve typical tasks for various sciences including math, physics, chemistry, electrotechnics, and computer science
  • Optimize PDF output and enrich it with meta data, annotations, popups, animations, and fillin fields
  • Explore the outstanding capabilities of the newest engines and formats such as XeLaTeX, LuaLaTeX, and LaTeX3

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 28, 2015
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396305
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 28, 2015
Length: 378 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396305
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 126.97
LaTeX Beginner's Guide
€37.99
LaTeX Cookbook
€52.99
LaTeX Beginner's Guide
€35.99
Total 126.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. The Variety of Document Types Chevron down icon Chevron up icon
2. Tuning the Text Chevron down icon Chevron up icon
3. Adjusting Fonts Chevron down icon Chevron up icon
4. Working with Images Chevron down icon Chevron up icon
5. Beautiful Designs Chevron down icon Chevron up icon
6. Designing Tables Chevron down icon Chevron up icon
7. Contents, Indexes, and Bibliographies Chevron down icon Chevron up icon
8. Getting the Most out of the PDF Chevron down icon Chevron up icon
9. Creating Graphics Chevron down icon Chevron up icon
10. Advanced Mathematics Chevron down icon Chevron up icon
11. Science and Technology Chevron down icon Chevron up icon
12. Getting Support on the Internet Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(5 Ratings)
5 star 100%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Amazon Customer Jan 26, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A splendid book that should be read if you want to learn latex. The exhibition is clear and minimalist so that learning is fun.
Amazon Verified review Amazon
Zen Lobo Mar 15, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book covering many very advanced types of documents that can be prepared using LaTeX
Amazon Verified review Amazon
D. Lee Dec 27, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book. It provides some good examples but more importantly contained what I needed. It’s also nice because I don’t have to search discussion post hoping to find the information.
Amazon Verified review Amazon
xyah Sep 28, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
todo ok, gracias por todo, en orden y a tiempo. gracias por todo, muy bueno, tks all ok, tks. bien
Amazon Verified review Amazon
Mark Sep 15, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book showcases a great many possible uses of LaTeX, many of them surprising and useful. The "recipes" can quickly be used to setup templates. Even if you don't use the "recipes" for the purpose the author intended, they're easy to apply for other purposes, and showing what you can learn about later. LaTeX is a gradual learning process, easy to start with, but difficult to master. I'm no scientist or academic, but after skimming through sections, and diligently reading others, I feel empowered. At least I know what's possible and where to begin to get started. The greatest obstacle for new users of LaTeX isn't understanding how to learn it, but what they can learn to do with it. This answers that in depth.The authors other book for beginning LaTeX is the best FirstStudy available. And I would recommend this book to top it off. Both of these together have helped to make me a LaTeX enthusiast. Yes, this author has nailed it twice in a row.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.