Discover millions of ebooks, audiobooks, and so much more with a free trial

From $11.99/month after trial. Cancel anytime.

LaTeX Beginner's Guide: Create visually appealing texts, articles, and books for business and science using LaTeX
LaTeX Beginner's Guide: Create visually appealing texts, articles, and books for business and science using LaTeX
LaTeX Beginner's Guide: Create visually appealing texts, articles, and books for business and science using LaTeX
Ebook675 pages3 hours

LaTeX Beginner's Guide: Create visually appealing texts, articles, and books for business and science using LaTeX

Rating: 0 out of 5 stars

()

Read preview

About this ebook

LaTeX is high-quality open source typesetting software that produces professional prints and PDF files. It's a powerful and complex tool with a multitude of features, so getting started can be intimidating. However, once you become comfortable with LaTeX, its capabilities far outweigh any initial challenges, and this book will help you with just that!
The LaTeX Beginner's Guide will make getting started with LaTeX easy. If you are writing mathematical, scientific, or business papers, or have a thesis to write, this is the perfect book for you. With the help of fully explained examples, this book offers a practical introduction to LaTeX with plenty of step-by-step examples that will help you achieve professional-level results in no time. You'll learn to typeset documents containing tables, figures, formulas, and common book elements such as bibliographies, glossaries, and indexes, and go on to manage complex documents and use modern PDF features. You'll also get to grips with using macros and styles to maintain a consistent document structure while saving typing work.
By the end of this LaTeX book, you'll have learned how to fine-tune text and page layout, create professional-looking tables, include figures, present complex mathematical formulas, manage complex documents, and benefit from modern PDF features.

LanguageEnglish
Release dateOct 6, 2021
ISBN9781801072588
LaTeX Beginner's Guide: Create visually appealing texts, articles, and books for business and science using LaTeX
Author

Stefan Kottwitz

Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation. For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX and goLaTeX and the Q&A sites TeXwelt and TeXnique. He runs the TeX graphics gallery sites TeXample, TikZ, and PGFplots, the TeXlive online compiler, the TeXdoc service, and the CTAN software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet. He publishes ideas and news from the TeX world on his blogs LaTeX and TeX. Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.

Read more from Stefan Kottwitz

Related to LaTeX Beginner's Guide

Related ebooks

Computers For You

View More

Reviews for LaTeX Beginner's Guide

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    LaTeX Beginner's Guide - Stefan Kottwitz

    Cover.png

    BIRMINGHAM—MUMBAI

    LaTeX Beginner's Guide

    Second Edition

    Copyright © 2021 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    Group Product Manager: Rohit Rajkumar

    Publishing Product Manager: Ashitosh Gupta

    Senior Editor: Hayden Edwards

    Content Development Editor: Rashi Dubey

    Technical Editor: Simran Haresh Udasi

    Copy Editor: Safis Editing

    Project Coordinator: Manthan Patel

    Proofreader: Safis Editing

    Indexer: Manju Arasan

    Production Designer: Roshan Kawale

    First published: March 2011

    Second edition: August 2021

    Production reference: 1030921

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham

    B3 2PB, UK.

    ISBN 978-1-80107-865-8

    www.packt.com

    To the members of TUG and DANTE for supporting TeX and LaTeX development, infrastructure, and education. To all the helpers on internet forums for their tireless support for LaTeX beginners.

    – Stefan Kottwitz

    Contributors

    About the author

    Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation.

    For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX.org and goLaTeX.de and the Q&A sites TeXwelt.de and TeXnique.fr. He runs the TeX graphics gallery sites TeXample.net, TikZ.net, and PGFplots.net, the TeXlive.net online compiler, the TeXdoc.org service, and the CTAN.net software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet.com. He publishes ideas and news from the TeX world on his blogs LaTeX.net and TeX.co.

    Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.

    About the reviewers

    LianTze Lim has reveled in the joys and beauty of LaTeX typesetting for nearly two decades. She is currently Community TeXpert at Overleaf and has been helping Overleaf users with LaTeX-related questions since 2014.

    Joseph Wright is the author of the popular siunitx package for units, leads maintenance of the beamer class, and is a member of the LaTeX project. He is also one of the moderators on the popular TeX – LaTeX Stack Exchange Q&A site.

    Table of Contents

    Preface

    Chapter 1: Getting Started with LaTeX

    Technical requirements

    What is LaTeX?

    Benefits of LaTeX

    Virtues of open source

    Separation of form and content

    Portability

    Protection for your work

    How to get started with LaTeX

    Approaches to working with LaTeX

    Installing and using LaTeX

    Installing TeX Live using the net installer wizard

    Installing TeX Live offline

    Installing TeX Live on other operating systems

    Updating TeX Live and installing new packages

    Creating our first document

    Checking out advanced LaTeX editors

    Working with LaTeX online using Overleaf

    What Overleaf requires and delivers

    Benefits of Overleaf

    Caveats of working online

    Creating our first document online

    Exploring Overleaf

    Grammar and language feedback with Writefull

    Reviewing and commenting

    Accessing documentation

    Summary

    Chapter 2: Formatting Text and Creating Macros

    Technical requirements

    Working with logical formatting

    Creating a document with a title and heading

    Exploring the document structure

    Understanding LaTeX commands

    Understanding LaTeX environments

    Understanding how LaTeX reads our input

    Printing out special symbols

    Modifying the text fonts

    Adjusting the font shape

    Choosing the font family

    Confining the effect of commands by braces

    Exploring font sizes

    Creating our own commands

    Using macros for simple text

    Proper spacing after commands

    Creating more universal commands and using arguments

    Using boxes to limit the width of paragraphs

    Creating a narrow text box

    Producing common paragraph boxes

    Exploring further features of paragraph boxes

    Using mini pages

    Breaking lines and paragraphs

    Improving hyphenation

    Preventing hyphenation

    Improving the justification

    Breaking lines manually

    Exploring line breaking options

    Preventing line breaks

    Turning off full justification

    Creating ragged-right text

    Creating ragged-left text

    Centering text

    Using environments for justification

    Displaying quotes

    Quoting longer text

    Summary

    Chapter 3: Designing Pages

    Technical requirements

    Creating a book with chapters

    Defining the margins

    Using class options

    Designing headers and footers

    Understanding page styles

    Customizing headers and footers

    Using decorative lines in headers or footers

    Changing LaTeX's header marks

    Using footnotes

    Modifying the footnote line

    Using packages to expand footnote styles

    Breaking pages

    Enlarging a page

    Changing the line spacing

    Creating a table of contents

    Summary

    Chapter 4: Creating Lists

    Technical requirements

    Building lists

    Creating a bulleted list

    Building an enumerated list

    Producing a definition list

    Customizing lists

    Getting compact lists

    Choosing bullets and numbering format

    Suspending and continuing lists

    Summary

    Chapter 5: Including Images

    Technical requirements

    Including an image

    Choosing an optimal file type

    Scaling an image

    Including whole pages

    Putting images behind the text

    Managing floating images

    Understanding placement options

    Forcing the output of figures

    Limiting floating

    Avoiding floating at all

    Arranging several images

    Letting text flow around images

    Summary

    Chapter 6: Creating Tables

    Technical requirements

    Using tab stops to write in columns

    Typesetting tables

    Drawing lines in tables

    Understanding formatting arguments

    Increasing the row height

    Beautifying tables

    Adjusting lengths

    Spanning entries over multiple columns

    Inserting code column-wise

    Spanning entries over multiple rows

    Adding captions to tables

    Placing captions above

    Customizing captions

    Using packages for further customizations

    Auto-fitting columns to the table width

    Generating multi-page tables

    Coloring tables

    Using landscape orientation

    Aligning columns at the decimal point

    Handling narrow columns

    Summary

    Chapter 7: Using Cross-References

    Technical requirements

    Setting labels and references

    Assigning a label

    Referring to a label

    Referring to a page

    Using advanced referencing

    Producing intelligent page references

    Fine-tuning page references

    Referring to page ranges

    Using automatic reference names

    Combining intelligent references with automatic naming

    Referring to labels in other documents

    Turning references into hyperlinks

    Summary

    Chapter 8: Listing Contents and References

    Technical requirements

    Customizing the table of contents

    Adjusting the depth of the TOC

    Shortening entries

    Adding entries manually

    Creating and customizing lists of figures

    Creating a list of tables

    Using packages for customization

    Generating an index

    Defining index entries and subentries

    Specifying page ranges

    Using symbols and macros in the index

    Referring to other index entries

    Fine-tuning page numbers

    Designing the index layout

    Creating a bibliography

    Using the standard bibliography environment

    Using bibliography databases with BibTeX

    Looking at the BibTeX entry fields

    Referring to Internet resources

    Understanding BibTeX entry types

    Choosing the bibliography style

    Listing references without citing

    Changing the headings

    Summary

    Chapter 9: Writing Math Formulas

    Technical requirements

    Writing basic formulas

    Embedding math expressions within text

    Displaying formulas

    Numbering equations

    Adding subscripts and superscripts

    Using operators

    Taking roots

    Writing fractions

    Writing Greek letters

    Writing script letters

    Producing an ellipsis

    Changing the font, style, and size

    Customizing displayed formulas

    Typesetting multi-line formulas

    Numbering rows in multi-line formulas

    Inserting text into formulas

    Exploring the wealth of math symbols

    Binary operation symbols

    Binary relation symbols

    Inequality relation symbols

    Subset and superset symbols

    Arrows

    Harpoons

    Symbols derived from letters

    Miscellaneous symbols

    Writing units

    Variable sized operators

    Variable sized delimiters

    Building math structures

    Creating arrays

    Typesetting matrices

    Writing binomial coefficients

    Underlining and overlining

    Setting accents

    Putting a symbol above or below another one

    Writing theorems and definitions

    Further tools for writing mathematics

    Summary

    Chapter 10: Using Fonts

    Technical requirements

    Using comprehensive font bundles

    Latin Modern – a replacement for the standard font

    Kp-Fonts – another extensive set of fonts

    Using specific font families

    Serif fonts

    Sans-serif fonts

    Typewriter fonts

    Calligraphic fonts

    Using arbitrary fonts

    Selecting the main font

    Selecting multiple font families

    Summary

    Chapter 11: Developing Large Documents

    Technical requirements

    Splitting the input

    Including small pieces of code

    Including bigger parts of a document

    Compiling parts of a document

    Creating front and back matter

    Designing a title page

    Working with templates

    Summary

    Chapter 12: Enhancing Your Documents Further

    Technical requirements

    Using hyperlinks and bookmarks

    Adding hyperlinks

    Customizing hyperlinks

    Creating hyperlinks manually

    Creating bookmarks manually

    Using math formulas and special symbols in bookmarks

    Designing headings

    Coloring our documents

    Summary

    Chapter 13: Troubleshooting

    Technical requirements

    Understanding and fixing errors

    Handling the preamble and document body

    Using commands and environments

    Writing math formulas

    Working with files

    Creating tables and arrays

    Working with lists

    Working with floating figures and tables

    General syntax errors

    Handling warnings

    Justifying text

    Referencing

    Choosing fonts

    Placing figures and tables

    Customizing the document class

    Avoiding obsolete classes and packages

    General troubleshooting

    Summary

    Chapter 14: Using Online Resources

    Web forums, Q&A sites, and discussion boards

    LaTeX.org

    TeX and LaTeX on Stack Exchange

    Forums in other languages

    Usenet groups

    Lists of frequently asked questions

    Mailing lists

    TeX user group sites

    The TeX Users Group

    DANTE

    The LaTeX project

    UK TUG – TeX in the United Kingdom

    Other local user groups

    Websites for LaTeX software and editors

    LaTeX distributions

    LaTeX editors

    CTAN – the Comprehensive TeX Archive Network

    Graphics galleries

    LaTeX blogs

    Twitter messages

    Summary

    Why subscribe?

    Other Books You May Enjoy

    Packt is searching for authors like you

    Preface

    LaTeX is a high-quality open source typesetting software that produces professional prints and PDF files. However, as LaTeX is a powerful and complex tool, getting started can be intimidating, and specific aspects such as layout modifications can seem rather complicated. Using Microsoft Word or other word-processing software may seem more straightforward, but once you've become acquainted, LaTeX's capabilities far outweigh any initial difficulties. This book guides you through these challenges and makes beginning with LaTeX easy. If you are writing mathematical, scientific, or technical papers, this is the perfect book for you.

    LaTeX Beginner's Guide Second Edition offers you a practical introduction to LaTeX. Beginning with the installation and basic usage, you will learn to typeset documents containing tables, figures, formulas, and common book elements such as bibliographies, glossaries, and indexes. Lots of step-by-step examples start with fine-tuning text, formulas, and page layout, and proceed with managing complex documents and using modern PDF features. It's easy to start with LaTeX when you have LaTeX Beginner's Guide Second Edition at hand.

    This practical book will guide you through the essential steps of LaTeX, from installing LaTeX, formatting, and justification, to page design. Right from the beginning, you will learn to use macros and styles to maintain a consistent document structure while saving typing work. This book will help you learn to create professional-looking tables, along with including figures and writing complex mathematical formulas. You will see how to generate bibliographies and indexes with ease. Finally, you will learn how to manage complex documents and how to benefit from modern PDF features. Detailed information about online resources such as software archives, web forums, and online compilers complement this introductory guide.

    Who this book is for

    If you are about to write mathematical or scientific papers, seminar handouts, or even plan to write a thesis, then this book offers you a fast-paced and practical introduction. Those studying in school and university as mathematicians or physicists will benefit greatly, as well as engineers and humanities students. Anybody with high expectations who plans to write a paper or a book will be delighted by this high-quality, stable software.

    What this book covers

    Chapter 1, Getting Started with LaTeX, introduces LaTeX and explains its benefits. It guides you through the download and installation of a comprehensive LaTeX distribution and shows you how to create your first LaTeX document. It also introduces the use of the online LaTeX software Overleaf. Furthermore, you will get familiar with accessing package documentation.

    Chapter 2, Formatting Text and Creating Macros, explains how to vary font, shape, and text styles. It deals with centering and justification of paragraphs and how we can improve line breaks and hyphenation. It introduces logical formatting and describes how to define macros and how to use environments and packages.

    Chapter 3, Designing Pages, shows how you can adjust the margins and change the line spacing. It demonstrates portrait, landscape, and two-column layouts. In this chapter, we will create dynamic headers and footers and learn how to control page breaking and how to use footnotes. Along the way, you will also learn about redefining existing commands and using class options.

    Chapter 4, Creating Lists, deals with arranging text in bulleted, numbered, and definition lists. You will learn how to choose bullets and numbering styles and how to design the overall layout of lists.

    Chapter 5, Including Images, shows you how to include external pictures with captions in your documents. You will learn how to benefit from LaTeX's automated figures placement and how to fine-tune it.

    Chapter 6, Creating Tables, shows you how to create professional-looking tables and goes deep into formatting details.

    Chapter 7, Using Cross-References, introduces intelligent referencing to sections, footnotes, tables, figures, and numbered environments in general.

    Chapter 8, Listing Contents and References, deals with creating and customizing a table of contents and lists of figures and tables. Furthermore, it explains how to cite books, create bibliographies, and generate an index.

    Chapter 9, Writing Math Formulas, explains mathematical typesetting in depth. It starts with basic formulas and continues with centered and numbered equations. It shows how to align multi-line equations. In detail, it shows how to typeset math symbols such as roots, arrows, Greek letters, and operators. Moreover, you will learn to build complex math structures such as fractions, stacked expressions, and matrices.

    Chapter 10, Using Fonts, takes us into the world of fonts and demonstrates various fonts, including Roman, sans-serif, and typewriter fonts, in different shapes.

    Chapter 11, Developing Large Documents, helps in managing large documents by splitting them into several files. After reading this chapter, you will be able to create complex projects building upon sub-files. Furthermore, we deal with front matter and back matter with different page numbering and separate title pages. We will work through this by creating an example book. By doing this, you will get familiar with using document templates, and finally you can write your own thesis, book, or report.

    Chapter 12, Enhancing Your Documents Further, brings color into your documents. It shows you how to modify headings of chapters and all kinds of sections. We will learn how to create feature-rich PDF documents with bookmarks, hyperlinks, and metadata.

    Chapter 13, Troubleshooting, provides us with tools for problem-solving. We will learn about different kinds of LaTeX errors and warnings and how to deal with them. After reading this chapter, you will understand LaTeX's messages and know how to use them to fix errors.

    Chapter 14, Using Online Resources, guides you through the vast amount of LaTeX information on the internet. We will visit an online LaTeX forum and a LaTeX Q&A site. This chapter points the way to the huge LaTeX software archives, TeX user groups' homepages, mailing lists, Usenet groups, and LaTeX graphics galleries. It tells you where you can download LaTeX-capable editors and where you can meet LaTeX friends on blogs and Twitter.

    To get the most out of this book

    You need access to a computer with LaTeX on it. An online connection would be helpful regarding installation and updates. We can install LaTeX on most operating systems, so you can use Windows, Linux, macOS, or Unix.

    This book uses the freely available TeX Live distribution, which runs on all mentioned platforms. You just need an internet connection or the TeX Live DVD to install it. In the book, we work with the cross-platform editor TeXworks, but you could use any editor you like.

    Without installing LaTeX, you can work with the code examples at https://latexguide.org, which comes with an online compiler.

    If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book's GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

    Download the example code files

    You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/LaTeX-Beginner-s-Guide-Second-Edition. If there's an update to the code, it will be updated in the GitHub repository.

    The book's website at https://latexguide.org offers code downloads as well. You may also visit https://latex-cookbook.net, which provides further complete code examples with an online compiler.

    We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

    Conventions used

    There are a number of text conventions used throughout this book.

    Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: Load the fontenc package and choose T1 font encoding.

    A block of code is set as follows:

    \[

      \int_a^b \! f(x) \, dx = \lim_{\Delta x \rightarrow 0}

      \sum_{i=1}^{n} f(x_i) \,\Delta x_i

    \]

    When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

    \documentclass{book}

    \usepackage{cleveref}

    \crefname{enumi}{position}{positions}

    \begin{document}

    \chapter{Statistics}

    \label{stats}

    \section{Most used packages by LaTeX.org users}

    \label{packages}

    Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: Click the Typeset button to compile the document.

    Tips or important notes

    Appear like this.

    Get in touch

    Feedback from our readers is always welcome.

    General feedback: If you have questions about any aspect of this book, email us at [email protected] and mention the book title in the subject of your message.

    LaTeX questions: If you have any question about LaTeX, you can visit the author's forum at https://latex.org

    Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

    Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

    If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

    Chapter 1: Getting Started with LaTeX

    You are familiar with word processing software: you type something, and the software prints it as it is on screen. In contrast, LaTeX, as typesetting software, receives instructions and text from you, and then creates the output. It produces high-quality output based on sophisticated algorithms for justification, text alignment, whitespace balancing, figure placement, and more, such as predefined formatting styles for headings and general page layout, which you can customize.

    Are you ready to leave those what you see is what you get word processors behind and to enter the world of accurate, reliable, and high-quality typesetting? Yes? Then let's go together!

    It's great that you decided to learn LaTeX. This book will guide you along the way to help you get the most out of it. Let's speak briefly about LaTeX's benefits and the challenges, and then we shall prepare our tools.

    In this chapter, we will get to know LaTeX, as well as how to install and use it. Specifically, our topics will be as follows:

    What is LaTeX?

    Installing and using LaTeX

    Working with LaTeX online using Overleaf

    Accessing documentation

    At the end of this chapter, you will have working LaTeX software, and you will know how to edit and typeset a document and how to obtain further documentation.

    So, let's get started.

    Technical requirements

    We will focus on the Windows operating system here, but you can also install LaTeX on Mac OS X, Linux, and other systems.

    A complete installation takes about 8 GB of disk space.

    If you have an internet connection, you don't have to install LaTeX. You can use online LaTeX software, such as Overleaf. We will look at Overleaf at the end of this chapter.

    All code examples of this book are available on GitHub at https://github.com/PacktPublishing/LaTeX-Beginner-s-Guide.

    On the book's website, https://latexguide.org, you can read, edit, and compile every code example in this book online without installing anything. An internet browser with JavaScript enabled is all you need for this, and a PC, laptop, tablet, or smartphone.

    What is LaTeX?

    LaTeX is free, open source software for typesetting documents. In other words, it's a document preparation system. LaTeX is not a word processor, but it's a document markup language.

    It was initially written by Leslie Lamport and is based on the TeX typesetting engine by Donald Knuth. People often refer to it as just TeX, meaning LaTeX. It has a long history; you can read about it at https://tug.org/whatis.html.

    For now, let's continue by looking at how we can make the most of LaTeX.

    Benefits of LaTeX

    LaTeX

    Enjoying the preview?
    Page 1 of 1