Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
LaTeX Beginner's Guide
LaTeX Beginner's Guide

LaTeX Beginner's Guide: When there’s a scientific or technical paper to write, the versatility of LaTeX is very attractive. But where can you learn about the software? The answer is this superb beginner’s guide, packed with examples and explanations.

eBook
$26.09 $28.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

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

LaTeX Beginner's Guide

Chapter 2. Formatting Words, Lines, and Paragraphs

In the last chapter, we installed LaTeX and used the TeXworks editor to write our first document. Now we will speak about the structure of a document and we will focus on the text details and its formatting.

In this chapter, we shall:

  • Speak about logical formatting

  • Learn how to modify font, shape, and style of text

  • Use boxes to limit the text width

  • See how to break lines and how to improve hyphenation

  • Explore justification and formatting of paragraphs

By working with examples and trying out new features, we shall learn some basic concepts of LaTeX. By the end of this chapter, we will be familiar with commands and environments. You will even be able to define your own commands.

Understanding logical formatting


In the previous chapter, we wrote a small example document. Let's extend it a bit to get an illustrative example for understanding the typical document structure.

Time for action – titling your document


We will take the first example and insert some commands that will produce a nice-looking title.

  1. Type the following code in the editor; modify the previous example if you like:

    \documentclass[a4paper,11pt]{article}
    \begin{document}
    \title{Example 2}
    \author{My name}
    \date{January 5, 2011}
    \maketitle
    \section{What's this?}
    This is our second document. It contains a title and a section with text.
    \end{document}
  2. Click the Typeset button.

  3. View the output:

What just happened?

In the first chapter, we talked about logical formatting. First, let's look at this example from that point of view. We told LaTeX that:

  • Our document is of the type article. It will be printed on A4 paper using a size of 11 points for the base font.

  • The title is "Example 2".

  • You are the author.

  • The document was written on January 5, 2011.

  • Concerning the content of the document:

    • It begins with a title.

    • The first section shall have the heading "What's this?"

    • The following text is "This is our second...

How LaTeX reads your input


Before we continue writing, let's look at how LaTeX understands what you've written in the editor.

Time for action – trying out the effect of spaces, line breaks, and empty lines


We will take the first example and insert spaces and line breaks.

  1. Modify the previous example as follows:

    \documentclass[a4paper,11pt]{article}
    \begin{document}
    \title{Example 3}
    \author{My name}
    \date{January 5, 2011}
    \maketitle
    \section{What's this?}
    This        is   our
    second document.
    
    It contains two paragraphs. The first line of a paragraph will be
    indented, but not when it follows a heading.
    % Here's a comment.
    \end{document}
  2. Typeset.

  3. View the output:

What just happened?

Though we've inserted some spaces, the distances between the words in the output remained the same. The reason is that LaTeX treats multiple spaces just like a single space. Also, a single line break has the same effect like a single space. It doesn't matter how you arrange your text in the editor using spaces or breaks, the output will stay the same.

A blank line denotes a paragraph break. Like spaces, multiple empty lines are treated as...

Time for action – writing special characters in our text


We will write a very short example printing out an amount of dollars and a percent number, then we shall try more symbols:

  1. Create a new document and enter the following lines:

    \documentclass{article}
    \begin{document}
    Statement \#1:
    50\% of \$100 makes \$50.
    More special symbols are \&, \_, \{ and \}.
    \end{document}
  2. Typeset and view the output:

What just happened?

By putting a backslash before such a special symbol, we turned it into a LaTeX command. This command has the only purpose of printing out that symbol.

Note

The command for printing a backslash is \textbackslash. If you would like to know what \\ might be used for, it is used as a shortcut for a line break command. That's a bit odd, but line breaks occur frequently whereas backslashes are rarely needed in the output, therefore this shortcut has been chosen.

There's a wealth of symbols that we can use for math formulas, chess notation, zodiac signs, music scores, and more. We don...

Formatting text – fonts, shapes, and styles


LaTeX already does some formatting. For example, we've seen that section headings are bigger than normal text and bold faced. Now we will learn how to modify the appearance of the text ourselves.

Time for action – tuning the font shape


We will emphasize an important word in a text and we will see how to make words appear bold, italic, or slanted. We shall figure out how to highlight words in a part of some text that's already emphasized:

  1. Create a new document containing the following code:

    \documentclass{article}
    \begin{document}
    Text can be \emph{emphasized}.
    
    Besides being \textit{italic} words could be \textbf{bold},
    \textsl{slanted} or typeset in \textsc{Small Caps}.
    
    Such commands can be \textit{\textbf{nested}}.
    
    \emph{See how \emph{emphasizing} looks when nested.}
    \end{document}
  2. Typeset and have a look at the output:

What just happened?

At first, we used the command \emph, giving one word as an argument to this command. This argument will be typeset in italic shape, because this is the default way how LaTeX emphasizes text.

Text-formatting commands usually look like \text**{argument}, where ** stands for a two letter abbreviation like bf for bold face, it for italic, and sl for...

Time for action – switching to sans-serif and to typewriter fonts


Imagine that we start to write an article about LaTeX's Internet resources. To get a clearly readable heading, we shall use a font without frills. The body text will contain a web address; we choose a typewriter font to stress it:

  1. Create a LaTeX document with the following code:

    \documentclass{article}
    \begin{document}
    \section{\textsf{\LaTeX\ resources on the internet}}
    The best place for downloading LaTeX related software is CTAN.
    Its address is \texttt{http://www.ctan.org}.
    \end{document}
  2. Typeset and look at the result:

What just happened?

We encountered more font commands. By using \textsf, we've chosen the sans-serif font in the section heading. We used the command \texttt to get the typewriter font for the web address. Those commands can be used just like the font commands we've learned before.

The letters in the LaTeX standard font have so-called serifs , those small decorative details at the end of a letter's strokes. Serifs...

Time for action – switching the font family


We will modify the previous example using font family switching commands:

  1. Modify the example to get the following code:

    \documentclass{article}
    \begin{document}
    \section{\sffamily\LaTeX\ resources in the internet}
    The best place for downloading LaTeX related software is CTAN.
    Its address is \ttfamily http://www.ctan.org\rmfamily.
    \end{document}
  2. Typeset and compare the output to the previous one; it's the same.

What just happened?

By using the command \sffamily, we switched over to sans serif font. This change has been made inside an argument, so it's valid only there.

We used the command \ttfamily to switch to a typewriter font. The typewriter font will be used from this point onwards. By using \rmfamily, we returned to Roman font.

These commands don't produce any output, but they will affect the following text. We will call such a command a declaration .

Now have a closer look at the section number: it's a digit with serifs, which doesn't match the remaining...

Time for action – exploring grouping by braces


We shall use curly braces to tell LaTeX where to apply a command and where to stop that:

  1. Modify our first font shape example to get this code:

    \documentclass{article}
    \begin{document}
    {\sffamily
    Text can be {\em emphasized}.
    
    Besides being {\itshape italic} words could be {\bfseries bold},
    {\slshape slanted} or typeset in {\scshape Small Caps}.
    
    Such commands can be {\itshape\bfseries nested}.}
    
    {\em See how {\em emphasizing} looks when nested.}
    \end{document}
  2. Typeset and check out the output:

What just happened?

We started with an opening curly brace. The effect of the following command \sffamily lasted until we stopped it with the corresponding closing brace. That closing brace came at the end of the highlighted code. This highlighting shows the area of the code where \sffamily is valid.

We replaced every font command by the corresponding declaration. Remember, \em is the declaration version of \emph. Further, we surrounded every declaration and...

Time for action – exploring font sizes


We will try out every font size available by LaTeX's default font size commands. For testing, we exceptionally use them in the body text—their main use is in the macro definitions:

  1. Create a document with the following code:

    \documentclass{article}
    \begin{document}
    \noindent\tiny We \scriptsize start \footnotesize \small small,
    \normalsize get \large big \Large and \LARGE bigger,
    \huge huge and \Huge gigantic!
    \end{document}
  2. Typeset and observe the output:

What just happened?

At first, we used \noindent . This command suppresses the paragraph indentation. Then we used all 10 available size declarations, starting small with \tiny and ending really big with \Huge. There are no corresponding commands taking arguments, so we would have to use curly braces to delimit their scope, as we learned to before.

The actual resulting font size depends on the base font. If your document has a base font of 12 pt, then \tiny would result in text bigger than with a base font...

Time for action – using an environment to adjust the font size


We will produce a title with a larger and bigger font:

  1. Create another small document with this code:

    \documentclass{article}
    \begin{document}
    \begin{huge}
    \bfseries
    A small example
    
    \end{huge}
    \bigskip
    This is just another small illustrative example.
    \end{document}
  2. Typeset to see the result:

What just happened?

By writing \begin{huge}, we told LaTeX to switch to a huge font size just like with the \huge command. \end{huge} informs LaTeX that this size change should end now. From this point onwards, the font size is the same as before \begin{huge}.

Inside this environment, we use the declaration \bfseries . Note that the effect of this declaration ended together with the end of the environment.

The empty line before \end{huge} denotes a paragraph break. Using the command \bigskip , we skipped some space vertically.

For every declaration there's a corresponding environment carrying the same name except the backslash. Using environments...

Saving time and effort – creating your own commands


If you're frequently using the same term in your document, it would be annoying to type it again and again. What if you later decided to change that term or its formatting? To avoid searching and replacing in the whole document, LaTeX allows you to define your own commands in your preamble. They are also called macros . Give it a name. Later in the document you just need to use this name whenever you want to change this term. We need to do it just once in the macro definition. This will affect the whole document. Let's see how it works.

Time for action – creating our first command using it as anabbreviation


We will define a short command printing out the name of the TeX Users Group:

  1. Type this code into a new document:

    \documentclass{article}
    \newcommand{\TUG}{TeX Users Group}
    \begin{document}
    \section{The \TUG}
    The \TUG\ is an organization for people who are interested in \TeX\ or \LaTeX.
    \end{document}
  2. Typeset and look at the result:

What just happened?

\newcommand in the highlighted line defines our command. The first argument is the name we chose for it, and the second argument is the text we want it to put out in the document.

Now, whenever we type \TUG in our document, the complete name will appear. If we later decide to change the name or its formatting, we just need to change this \newcommand line. Then it will be applied for the complete document.

You may use formatting commands inside your command definition. Let's say you would like to change the formatting of all occurrences of this name to be typeset in small caps...

Time for action – adding intelligent spacing to command output


We will load the package xspace. Its only purpose is to fulfill this need.

  1. Modify the previous example to get the following code:

    \documentclass{article}
    \usepackage{xspace}
    \newcommand{\TUG}{\textsc{TeX Users Group}\xspace}
    \begin{document}
    \section{The \TUG}
    The \TUG is an organization for people who are interested in \TeX\ or \LaTeX.
    \end{document}
  2. Typeset, see that the spacing between the words is correct, even without the backslash:

What just happened?

\usepackage{xspace} tells LaTeX to load the package called xspace and to read in all of its definitions. From now on we may use all commands contained in that package. This package provides the command \xspace that inserts a space depending on the following character: If a dot, a comma, an exclamation, or a quotation mark follows, it won't insert a space, but if a normal letter follows, then it will. Usually, that's exactly what we want.

Imagine you've mentioned the TUG several...

Time for action – creating a macro for formatting keywords


We will use \newcommand again, but this time we will introduce a parameter that will contain our keyword. Let's just use it on some terms that we've got to know in this chapter:

  1. Type this code example:

    \documentclass{article}	
    \newcommand{\keyword}[1]{\textbf{#1}}
    \begin{document}
    \keyword{Grouping} by curly braces limits the
    \keyword{scope} of \keyword{declarations}.
    \end{document}
  2. Typeset and notice the look of the keywords in the output:

What just happened?

Let's look at the highlighted line in the code. The number 1 in the square brackets marks the number of arguments that we want to use in the command. #1 will be replaced by the value of the first argument. #2 would refer to a second argument, and so on.

Now if you want to modify the appearance of all keywords to be italic, just modify the definition of \keyword and the change will be global.

Using optional arguments

In one preceding example, we've used \newcommand with two arguments...

Time for action – marking keywords with optional formatting


We will use \newcommand another time, this time with an optional parameter concerning the formatting and a mandatory argument for the keyword:

  1. Modify the previous example to get this code:

    \documentclass{article}
    \newcommand{\keyword}[2][\bfseries]{{#1#2}}
    \begin{document}
    \keyword{Grouping} by curly braces limits the
    \keyword{scope} of \keyword[\itshape]{declarations}.
    \end{document}
  2. Typeset and check out the result:

What just happened?

Let's look again at the bold marked line in the code. By using [\bfseries], we introduced an optional parameter. We refer to it with #1. Its default value is \bfseries. Since we used a declaration this time, we added a pair of braces to ensure that only the keyword is affected by the declaration.

Later in the document, we gave [\itshape] to \keyword, changing the default formatting to italics.

Here's the definition of the \newcommand:

\newcommand{command}[arguments][optional]{definition}

command

The name...

Using boxes to limit the width of paragraphs


We won't always write the text just from left to right over the complete text width. Sometimes, we'd like a paragraph to have a smaller width, for instance, when we would like to put text and a picture side-by-side.

Time for action – creating a narrow text column


We would like to explain the acronym TUG in a text column of only 3 cm width:

  1. Create a new document containing these four lines:

    \documentclass{article}
    \begin{document}
    \parbox{3cm}{TUG is an acronym. It means \TeX\ Users Group.}
    \end{document}
  2. Typeset and take a critical look at the output:

What just happened?

We used the command \parbox to create a column. We stated the width of 3 cm in the first argument and the contained text in the second argument to \parbox.

\parbox takes the argument text and formats the output to fit the specified width. We see that the text is fully justified. Our example shows an obvious problem: insisting on full justification could lead to undesirable big gaps in the text. Possible solutions are:

  • Introducing hyphenation: the word acronym could easily be divided

  • Improving justification: LaTeX could do better

  • Giving up full justification: narrow text could look better when it's only left justified

We will check out all of...

Time for action – using the minipage environment


We will use the minipage environment instead of \parbox to get a text with a width of just 3 cm.

  1. Modify the parbox example to get the following code:

    \documentclass{article}
    \begin{document}
    \begin{minipage}{3cm}
    TUG is an acronym. It means \TeX\ Users Group.
    \end{minipage}
    \end{document}
  2. Typeset and look at the output:

What just happened?

By using \begin{minipage}, we started a "page in a page". We specified the width of 3cm by the mandatory argument. From this point onwards, the text lines will have a width of 3cm. They will be automatically wrapped and fully justified. We ended this restriction with \end{minipage}. Any text typed afterwards would run over the complete body text width.

Note: There won't be a page break in such a "minipage".

Have you been a hero struggling with the \parbox and all of its optional arguments? The minipage environment accepts all those arguments as well with the same meaning.

Have a go hero – creating a footnote inside...

Breaking lines and paragraphs


Generally, when you're writing text, you don't need to care about the line wrapping. Just type the text with your editor; LaTeX will make it fit to the line and take care of the justification. If you want to begin a new paragraph, in consequence of getting a line break in the output, just insert an empty line before you continue with your text.

Now we will find out how to control the line wrapping. First we will see how to improve the automatic line breaking. Then we will learn commands to insert breaks directly.

Improving hyphenation

If you look at longer texts, you will notice that it's outstanding how the text is fully justified by LaTeX and how the spacing between words is evenly distributed on the lines. If necessary, LaTeX will divide words and put hyphens at the end of the line in order to break the lines in a better way. LaTeX already uses very good algorithms to hyphenate words, but it may happen that it can't find an acceptable way to divide a word. The...

Time for action – stating division points for words


No matter how good the justification skill is, text in very narrow columns is extremely hard to justify. The previous example showed it pitiless. We will tell LaTeX how a word could be divided:

  1. Insert the following line into the preamble of the previous example:

    \hyphenation{acro-nym}
  2. Typeset and look at the output:

What just happened?

We've told LaTeX that the word acronym may have a division point between acro and nym. That means a hyphen might be put after acro at the end of the line and nym goes to the following line.

The \hyphenation command tells LaTeX where the division points of a word may be. Its argument may contain several words separated by spaces. For each word, we can indicate several points. For instance we could extend the argument by more division points and more word variants like this:

\hyphenation{ac-ro-nym ac-ro-nym-ic a-cro-nym-i-cal-ly}

You could also indicate division points in the body text by inserting a backslash followed...

Time for action – using microtype


We will improve our previous example by loading the microtype package :

  1. Insert the following line into the preamble of the previous example:

    \usepackage{microtype}
  2. Typeset and look at the output:

What just happened?

We have loaded the microtype package without any options, relying on its default behavior. It introduces font expansion to tweak the justification and uses hanging punctuation to improve the optical appearance of the margins. This may reduce the need of hyphenation and improves the "grayness" of the output. You've seen its effect on a narrow column—imagine the improvement on wide text—keep that in mind and try it out later!

Though microtype provides powerful features and options for the advanced typesetter, we usually won't need to do more than just load it to profit from it. There's an extensive package documentation if you want to study it in depth.

microtype does nice tweaking, but it's not a cure-all; we should still take care of proper hyphenation...

Time for action – using line breaks


We will type the beginning of a famous poem by Edgar Allan Poe. As the author has specified where a verse has to end, we shall insert line breaks there.

  1. Create a document containing these lines:

    \documentclass{article}
    \begin{document}
    \emph{Annabel Lee}\\
    It was many and many a year ago,\\
    In a kingdom by the sea,\\
    That a maiden there lived whom you may know\\
    By the name of Annabel Lee
    \end{document}
  2. Typeset and view the output:

What just happened?

The very short command \\ ended a line; the following text was put to the next line. That's different to a paragraph break: we're still in the same paragraph. The command called \newline has the same effect.

There's another command called \linebreak, which tells LaTeX to end the line but to keep the full justification. Therefore, the space between the words would be stretched to reach the right margin. This could cause unpleasant gaps—that's why that command is rarely used.

Have a go hero – exploring line breaking...

Exploring the fine details


Typographic conventions may require paying attention to small details; there are different dashes, and the space around a dot may vary depending on the context. The space after some letters may depend on the following one, so much so that some letters may even be joined to a single one. Such constructions are called ligatures. Let's have a closer look at them.

Time for action – exploring ligatures


We will check out Example 3 to discover a ligature. Afterwards, we will have a close look at the default ligatures:

  1. Open Example 3 in TeXworks, click the Typeset button. Move the mouse pointer into the output window, right over the word first, and then click the left button.

  2. Go to the editor window, and then add a paragraph break by with empty line and the following letter combinations: ff fi flffiffl -- ---

  3. Add a paragraph break, repeat the preceding line, but this time insert \/ between the letters: f\/f f\/i f\/l f\/f\/i f\/f\/l -\/- -\/-\/-

  4. Typeset and compare the letters in the output:

What just happened?

By left-clicking the mouse in the output window, you activated TeXworks' magnifying glass. It allows inspecting the output in detail as the area around the mouse pointer will be enlarged. You can see that two or even three letters have been joined, but not in the last line: the command \/ prevented this.

Understanding ligatures

If the letter i follows...

Time for action – using differently spaced dots


We shall typeset a short text containing periods to see the default behavior. Afterwards, we will create an example where LaTeX's automation fails; we shall see how to correct it. We will learn how to simplify all this spacing using a different style.

  1. Create a new document in TeXworks:

    \documentclass{article}
    \begin{document}
    \TeX\ was designed by Donald E. Knuth.
    It has become a de facto standard in mathematics.
    \end{document}
  2. Typeset to see the output:

  3. Now add a paragraph break followed by this line:

    Look at the spacing etc. in LaTeX. See it?
  4. Check out the spacing after the two periods in the output:

  5. Correct the spacing by inserting a backslash and \@:

    Look at the spacing etc.\ in LaTeX\@. See it?
  6. Now remove the extra \ and \@ we've added, insert the declaration \frenchspacing into the preamble, and typeset to see the difference:

What just happened?

The first step shows typical text and its output. As you can see, LaTeX adds a little space after the...

Time for action – comparing dots to ellipsis


We will write an ellipsis in two ways: firstly by simply writing dots, secondly by using a dedicated command. Let's compare!

  1. Create a new document in TeXworks:

    \documentclass{article}
    \begin{document}
    Here are three dots... compare them to the ellipsis\ldots
    \end{document}
  2. Check out the difference:

What just happened?

We used the command \ldots to print out an ellipsis—three consecutive dots with a wider spacing. Such dots may indicate a pause, an unfinished thought, or an omitted word. When we just accumulated dots, they were typeset tightly together. However, it's common to print those dots wider.

Setting accents

Some languages have letters with accents that you can't simply type with your editor. In case you need to write such letters: let's see how to do it.

Time for action – experimenting with accents


We will write some words having letters with accents in Portuguese and in French.

  1. Create a new document:

    \documentclass{article}
    \begin{document}
    N\~{a}o compreendo. H\'{a} aqui algu\'{e}mque fale ingl\^{e}s?
    
    Comment \c{c}a va? O\`{u} se trouve l'a\'{e}roport?
    \end{document}
  2. Typeset to see the generated accents:

What just happened?

LaTeX provides some special commands to produce a variety of accents. They may be combined with any letter. Such a command consists of a backslash followed by one character. The accent will be put above or below the letter that has to follow in curly braces. The following table will list these commands and their effect:

Using special characters directly in the editor

It might be a bit cumbersome to use those accent commands. There's a package that extends LaTeX basic capabilities. It allows you to enter at least some commonly used accented and other special characters directly.

Time for action – using accents directly


We will modify the previous example daring to enter accented letters directly in the editor.

  1. Create a new document:

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \begin{document}
    Não compreendo. Há aqui alguém que fale inglês?
    
    Comment çava? Où se trouve l'aéroport?
    \end{document}
  2. Typeset and compare to the previous output:

What just happened?

We loaded the inputenc package. The option utf8 tells the package to use Unicode input encoding, which provides many more symbols than just the ASCII code. Now we just need to find the symbol on the keyboard and to type it.

TeXworks supports Unicode/UTF-8. Depending on operating system and editor, you might need to use another option when loading inputenc. A rule of thumb: utf8 works on most Linux and Unix systems, like Mac OS X, and latin1 works with most Windows editors.

Note

Today, many Windows editors move to UTF-8. This is seemingly becoming the cross-platform standard.

Turning off full justification


Though commonly your text will look fine if full justification is used, there may be occasions when it's not the optimum. For instance, full justification could be displeasing if the text lines are short. In such a case, it could be sufficient to justify only to the left side. We shall see how to put this into practice, further how to right-justify, and how to get centered lines.

Time for action – justifying a paragraph to the left


Remember the first parbox example which was fully justified but had those big gaps between the words. We shall give up justification to the right side to avoid such gaps.

  1. Create a new document containing these lines:

    \documentclass{article}
    \begin{document}
    \parbox{3cm}{\raggedright
        TUG is an acronym. It means \TeX\ Users Group.}
    \end{document}
  2. Typeset and look at the output:

What just happened?

We inserted the declaration \raggedright . From this point onwards, the text will be ragged-right. In other words, the text will be moved to the left margin - "flushed-left". There won't be hyphenation.

Because we used this declaration inside a box, it's only valid there, like inside environments. After the box, the text will be fully justified again.

If we want the whole document to be ragged-right, we just need to use \raggedright in our preamble.

Creating ragged-left text

There might be occasions when we would like to achieve the opposite effect...

Time for action – centering a title


We shall create a nice looking title for our document. It should contain the title, the author, and the date. All those lines have to be centered.

  1. Write a document containing this code:

    \documentclass{article}
    \pagestyle{empty}
    \begin{document}
    {\centering
        \huge\bfseries Centered text \\
        \Large\normalfont written by me \\
        \normalsize\today
    
    }
    \end{document}
  2. Typeset to see the output:

What just happened?

Because only the title should be centered, we opened a group to limit the centering. Through the declaration \centering , we made the remaining text of this group horizontally aligned to the center. We inserted a paragraph break: it's always a good idea to do it before ending the group when paragraph-affecting commands were used. By the brace after \today , we ended the group. If you complement some following text, it will be typeset normally, not centered.

\centering is commonly used when pictures or tables are inserted, further on title pages and...

Time for action – centering verses


Let's reuse the fragment of the poem "Annabel Lee". This time we shall center all verses:

  1. Create a document containing these lines:

    \documentclass{article}
    \usepackage{url}
    \begin{document}
    \noindent This is the beginning of a poem
    by Edgar Allan Poe:
    \begin{center}
        \emph{Annabel Lee}
    \end{center}
    \begin{center}
        It was many and many a year ago,\\
        In a kingdom by the sea,\\
        That a maiden there lived whom you may know\\
        By the name of Annabel Lee
    \end{center}
    The complete poem can be read on
    \url{http://www.online-literature.com/poe/576/}.
    \end{document}
  2. Typeset and see the output:

What just happened?

We began with \noindent avoiding the paragraph indentation. \begin{center} started the center environment. It begins a new paragraph, leaving some space to the preceding text. \end{center} ended this environment. We used the environment twice. In the second one, we inserted \\ to end the verses.

After the center environment ended, some space followed...

Displaying quotes


Imagine your text contains a quotation of another author. It might be hard to read if it's just embedded in your words. A common way to improve the readability is displaying: setting the text off by indenting on both margins.

Time for action – quoting a scientist


We will quote thoughts of famous physicists.

  1. Create a new document containing these lines:

    \documentclass{article}
    \begin{document}
    Niels Bohr said: ``An expert is a person who has made
    all the mistakes that can be made in a very narrow field.''
    Albert Einstein said:
    \begin{quote}
    Anyone who has never made a mistake has never tried anything new.
    \end{quote}
    Errors are inevitable. So, let's be brave trying something new.
    \end{document}
  2. Typeset to see the result:

What just happened?

Firstly we quoted inline. `produced a left quotation mark; the character is also called a backtick . 'gave a right quotation mark. We just typed two such symbols to get double quotes.

Then we used the quote environment to display a quotation. We did not begin a new paragraph for it, because the quotation is already set a bit off. That's the reason we don't use a blank line before and after the environment.

Quoting longer text

When writing short quotations, the quote environment looks...

Time for action – quoting TeX's benefits


We will quote some of the benefits of TeX and LaTeX found on a web page on CTAN.

  1. Start a new document. This time, it will be a bit longer:

    \documentclass{article}
    \usepackage{url}
    \begin{document}
    The authors of the CTAN team listed ten good reasons
    for using \TeX. Among them are:
    \begin{quotation}
        \TeX\ has the best output. What you end with,
    the symbols on the page, is as useable, and beautiful,
    as a non-professional can produce.
    
        \TeX\ knows typesetting. As those plain text samples
    show, \TeX's has more sophisticated typographical algorithms
    such as those for making paragraphs and for hyphenating.
    
        \TeX\ is fast. On today's machines \TeX\ is very fast.
        It is easy on memory and disk space, too. 
    
        \TeX\ is stable. It is in wide use, with a long history.
        It has been tested by millions of users, on demanding input.
        It will never eat your document. Never.
    \end{quotation}
    The original text can be found on
    \url{ http://www.ctan...

Time for action – spacing between paragraphs instead of indentation


We like to avoid the paragraph indentation. Instead, we shall separate the paragraphs by some vertical space.

  1. Create copy of the previous example and reuse most of it this way:

    \documentclass{article}
    \usepackage{parskip}
    \usepackage{url}
    \begin{document}
    The authors of the CTAN team listed ten good reasons
    for using \TeX. Among them are:
    
    \TeX\ has the best output. What you end with,
    the symbols on the page, is as useable, and beautiful,
    as a non-professional can produce\ldots
    
    The original text can be found on
    \url{ http://www.ctan.org/what_is_tex.html}.
    \end{document}
  2. See the effect:

What just happened?

The highlighted line shows that we've loaded the parskip package. Its only purpose is to remove the paragraph indentation completely. At the same time, this package introduces a skip between paragraphs. But this package doesn't affect the definition of the quotation environment—you still could use the quote environment.

In order...

Summary


In this chapter, we developed the basics: editing, arranging, and formatting of text.

Specifically, we covered:

  • Modifying shape and style of text and its font

  • Breaking lines and improving hyphenation

  • Controlling justification of text

We got to know the basic LaTeX concepts:

  • Commands and declarations, mandatory and optional arguments

  • Definition of new commands

  • Using environments

  • Using packages, how they can be loaded and options to packages

Keep in mind that even though we've used formatting commands directly in the text when exploring them, you should use them inside command definitions in the preamble to allow easy changes for the future. During your learning and writing process, you probably will get to know further useful commands and packages that could improve your previously written commands.

We've learned general practices:

  • As often as possible, create your own macros to achieve a logical structure. You will be rewarded with consistent formatting and changes could easily be applied to...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Use LaTeX's powerful features to produce professionally designed texts
  • Install LaTeX; download, set up, and use additional styles, templates, and tools
  • Typeset math formulas and scientific expressions to the highest standards
  • Include graphics and work with figures and tables
  • Benefit from professional fonts and modern PDF features

Description

LaTeX is 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. There is no official support and certain aspects such as layout modifications can seem rather complicated. It may seem more straightforward to use Word or other WYSIWG programs, 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 Business papers, or have a thesis to write, then this is the perfect book for you. LaTeX Beginner's Guide offers you a practical introduction to LaTeX with plenty of step-by-step examples. Beginning with the installation and basic usage, you will learn to typeset documents containing tables, figures, formulas, and common book elements like bibliographies, glossaries, and indexes and go on to managing complex documents and using modern PDF features. It's easy to use LaTeX, when you have LaTeX Beginner's Guide to 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. You will learn to fine-tune text and page layout, create professional looking tables as well as include figures and write 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 like software archives, web forums, and online compilers completes this introductory guide. It's easy to use LaTeX, when you have LaTeX Beginner's Guide to hand.

Who is this book 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. Particularly during studying in school and university you will benefit much, as a mathematician or physicist as well as an engineer or a humanist. Everybody with high expectations who plans to write a paper or a book will be delighted by this stable software.

What you will learn

  • Install LaTeX and use the TeXworks editor to compile documents
  • Design the page layout; create dynamic headers and footers
  • Fine-tune appearances and the space of words, symbols, and lines
  • Apply intelligent justification and customized hyphenation to achieve fine text design
  • Typeset professional-looking tables and create bulleted and enumerated lists
  • Write sophisticated math formulas, from in-text expressions to complex multi-line equations with various alignments
  • Cross-reference objects such as figures, tables, and equations
  • Load fonts and vary their shape and style; choose between thousands of LaTeX symbols from specialized fonts
  • Use macros to save time and effort; load packages to extend LaTeX s capabilities
  • Generate an index, cite books, and create bibliographies
  • Use external pictures, color, PDF bookmarks, and hyperlinks
  • Structure and manage large documents by splitting the input
  • Manage large documents containing lists, index, and bibliography
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 21, 2011
Length: 336 pages
Edition : 1st
Language : English
ISBN-13 : 9781847199867
Tools :

What do you get with Print?

Product feature icon Instant access to your digital copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Redeem a companion digital copy on all Print orders
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
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Mar 21, 2011
Length: 336 pages
Edition : 1st
Language : English
ISBN-13 : 9781847199867
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.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
$199.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
$279.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 $ 173.97
LaTeX Cookbook
$69.99
LaTeX Beginner's Guide
$48.99
Building Machine Learning Systems with Python
$54.99
Total $ 173.97 Stars icon

Table of Contents

13 Chapters
Getting Started with LaTeX Chevron down icon Chevron up icon
Formatting Words, Lines, and Paragraphs Chevron down icon Chevron up icon
Formatting Words, Lines, and Paragraphs
Understanding logical formatting
Time for action – titling your document
How LaTeX reads your input
Time for action – trying out the effect of spaces, line breaks, and empty lines
Time for action – writing special characters in our text
Formatting text – fonts, shapes, and styles
Time for action – tuning the font shape
Time for action – switching to sans-serif and to typewriter fonts
Time for action – switching the font family
Time for action – exploring grouping by braces
Time for action – exploring font sizes
Time for action – using an environment to adjust the font size
Saving time and effort – creating your own commands
Time for action – creating our first command using it as anabbreviation
Time for action – adding intelligent spacing to command output
Time for action – creating a macro for formatting keywords
Time for action – marking keywords with optional formatting
Using boxes to limit the width of paragraphs
Time for action – creating a narrow text column
Time for action – using the minipage environment
Breaking lines and paragraphs
Time for action – stating division points for words
Time for action – using microtype
Time for action – using line breaks
Exploring the fine details
Time for action – exploring ligatures
Time for action – using differently spaced dots
Time for action – comparing dots to ellipsis
Time for action – experimenting with accents
Time for action – using accents directly
Turning off full justification
Time for action – justifying a paragraph to the left
Time for action – centering a title
Time for action – centering verses
Displaying quotes
Time for action – quoting a scientist
Time for action – quoting TeX's benefits
Time for action – spacing between paragraphs instead of indentation
Summary
Designing Pages Chevron down icon Chevron up icon
Creating Lists Chevron down icon Chevron up icon
Creating Tables and Inserting Pictures Chevron down icon Chevron up icon
Cross-Referencing Chevron down icon Chevron up icon
Listing Content and References Chevron down icon Chevron up icon
Typing Math Formulas Chevron down icon Chevron up icon
Using Fonts Chevron down icon Chevron up icon
Developing Large Documents Chevron down icon Chevron up icon
Enhancing Your Documents Further Chevron down icon Chevron up icon
Troubleshooting Chevron down icon Chevron up icon
Using Online Resources Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(20 Ratings)
5 star 65%
4 star 25%
3 star 10%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Richard Catlin Sep 29, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
After a couple of hours, I was using TexWorks and creating a PDF book with TOC and index. Just what I was looking for.
Amazon Verified review Amazon
Amazon Customer Jul 26, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very happy with this product!
Amazon Verified review Amazon
sshahraz Dec 09, 2012
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I looked at any single review of the offered similar titles in Amazon and decided to purchase this one. I am happy. Here are my reflections:1. Great size, so a serious reader can read and practice it in less than a week and become a working LaTexer!2. The chapters are incremental3. To the extent I practiced it the examples are all correct and working4. Full of examples that can solve the problemsAre there LaTex problems that have not been addressed by this book? Of course. There are so many subtle ones that one needs to search internet to get a good handle on them.I recommend the book to all beginners.
Amazon Verified review Amazon
Stuart Smith Aug 12, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book to delve into detail.
Amazon Verified review Amazon
luminos717 Apr 04, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent supplementary guide to the LaTex User Manual, which you should print off and get bound.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the digital copy I get with my Print order? Chevron down icon Chevron up icon

When you buy any Print edition of our Books, you can redeem (for free) the eBook edition of the Print Book you’ve purchased. This gives you instant access to your book when you make an order via PDF, EPUB or our online Reader experience.

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
Modal Close icon
Modal Close icon