1-3: Text Structures, Effects, and Characters
This lesson explains the most common structures used in text: bulleted and numbered lists, sections and subsections, and the title page. As well, you will learn how to italicize and bolden your text, and create special characters — like long dashes and accents (for your communiqués).
Bulleted and Numbered Lists
We use bulleted lists a lot in our lessons, to help make it clear when there is a series of equally-important items to be explained. LaTeX also offers lists, in several varieties: itemize
for bulleted lists and enumerate
for numbered lists (there is a third description
style we skip since it’s less useful).
All of these commands are used in the form \begin{itemize}…
\end{itemize}
(rather than \itemize{}). We’ve already seen a similar pair of commands, \begin{document}
and \end{document}
. We say that these commands create environments.
The command \item
begins a new bullet point inside of an itemize environment. For example,
\begin{itemize} \item an item \item another \end{itemize}
will create
- To change the look of an individual bullet point, use
\item[«sym»]
where«sym»
is the symbol you want to use, such as$\circ$
or$\diamond$
- To change the look of all of the bullet points, use
\renewcommand{\labelitemi}{«sym»}
. But to affect deeper levels of nested lists apply this to\labelitemii
oriii
oriv
instead.
(Recall that square brackets [...]
are used for optional arguments.)
The enumerate environment automatically generates an increasing sequence of numbers:
\begin{enumerate} \item an item \item another \end{enumerate}
Similar to itemize, the enumerate environment can be modified with \renewcommand
. The code
\renewcommand{\theenumi}{\Roman{enumi}} \renewcommand{\labelenumi}{(\theenumi)}
creates a list numbered (I), (II), etc. The first line indicates we wish to use uppercase roman numerals, and the second line indicates we wish to place parentheses around the number. In place of \Roman
you can also put \arabic
, \alph
, \Alph
, \roman
, or \fnsymbol
. In addition, you can change what number the enumerate environment starts at using \setcounter{enumi}{«num»}
. More customization is available with the enumerate
package; see more information here.
What a Character!
We previously talked about \textbackslash
, which gives you the backslash character \. Another example of characters which are dealt with specially in LaTeX are quote marks. What you would probably try first is
here are 'single quotes' and "double quotes"
but this gives the wrong output
As you can see, the right-hand (closing) marks are ok, but the left-hand (opening) marks are not. To specify opening quotes in LaTeX,
- use the back-quote or back-tick symbol
`
(located to the left of the 1 key) to get an opening single quote - use two back-quotes
``
to get an opening double quote.
Try running the following through LaTeX to confirm that it gives you the expected output.
here are `single quotes' and ``double quotes"
The—Thin−Black–Lines
LaTeX supplies different kinds of dashes for different situations. Knowing about how to use them will help your writing look professional and clear. For a more thorough explanation of best practices in punctuation, check out The Elements of Style, The Chicago Manual of Style, or Wikipedia, which we link to below.
- When you write a hyphen character
-
in math mode, it is interpreted as a minus sign. For example,$-1=0-1$
has two minus signs, and this is typeset as - A single hyphen in text input
-
gives you a hyphen in text output, and this should be used to separate the parts of a compound word like in “nineteenth-century recipe” or “man-eating shark.” - A double hyphen in text input
--
gives you a longer en dash. The most common usage of this dash is to separate a range or comparison, such as “for kids ages 1–92” or “a 5–5 tie score.” - A triple hyphen in text input
---
gives you the longest em dash. You can use two of these — like parentheses — to set off an optional part of a sentence. It can be used to indicate certain kinds of breaks — stronger than a comma, but weaker than a period.
Exercise (nickname: alligator
)
The Ellipsis… also known as \ldots
To get three dots in a row, use the \ldots
command. We’ll later discuss the different orientations of dots that you can get in math mode.
Accentuate the Positive
Accents in LaTeX text are handled by using backslash commands. We give some examples:
- acute accent, created with
\'
such asfianc\'ee
giving fiancée - grave accent, created with
\`
such ascr\`eme
giving crème - cedilla, created with
\c{}
such asgar\c{c}on
giving garçon - circumflex, created with
\^
such asp\^ate
giving pâte - umlaut, created with
\"
such asG\"odel
giving Gödel - Hungarian umlaut, created with
\H{}
such asErd\H{o}s
giving Erdős - tilde, created with
\~
such asjalape\~no
giving jalapeño
The {}
braces are required only for some accents, but are generally harmless even if you include them in other places. If you are curious, can you guess what accented letters will be produced by \aa\ae\i\o\ss
?
Putting symbols atop variables in math mode like \(\vec{x}\) is different; we’ll cover this later.
Stand Out
Use \emph{some text}
to italicize some text in LaTeX. As you may guess, the command name is short for emphasize. Why isn’t it called italicize? The reason is that the \emph
command will also be smart enough to show emphasis in a different way when the surrounding text is already emphasized. For example, as we’ll see later, theorem statements are usually typeset entirely in italics, but \emph
will be sensitive to the context and actually de-italicize its contents.
To get bold text, use \textbf{}
.
Exercise (nickname: pate
)
En français, pâte can mean either pastry or paste, its plural pâtes most commonly refers to pasta noodles, and pâté is a congealed meat product.
(There are commands that can force italicization, but we wouldn’t normally recommend them. The same goes with some alternative ways to get boldface. Underlining is not a recommended practice in professional print typesetting, so that also takes more work.)
Titles and Sections
Generating titles and sections with LaTeX is very easy, and the formatting is handled automatically for you. Specify the title and author name inside of the \title{}
and \author{}
commands. Optionally, include \date{}
— or leave it out to default to today’s date. Then use \maketitle
to generate the title. Here is an example.
\documentclass{article} \begin{document} \title{My first title page} \author{Anonymous} %\date{Smarch 17, 20xx} % optional \maketitle This is the content. % don't put content before \maketitle \end{document}
This will produce a document that looks like this (we produced it on August 15, not today!):
The title and author will also show up in the metadata of the pdf file that you produce.
Newlines: \\
At this time it is convenient to introduce the command \\
which is the newline command. In the title page you might use it to put multiple author lines such as:
\author{Anonymous \\ Technological High School of Technology}
It can be used anywhere in normal text, too. It ends one line and begins a new one, but it does not begin a new paragraph and therefore has no indent or extra vertical separation between lines.
\section{}
and \subsection{}
Structuring your document is very easy in LaTeX using the \section{}
and \subsection{}
commands. Between the {}
you put the section’s title. Here is an example:
Here is some text before the first section \section{First Section Title} Some content for the first section. \section{Second Section Title} Some content for the second section.
This produces:
As you can see, the sections are automatically numbered and the section title is set in a large bold font. Once you get used to this idea, several other opportunities for structuring your document are available:
- The section title may include math like
\section{Delicious $\pi$}
. - The
\subsection{}
command is similar, and produces smaller headings with two-part numbers like 2.1. There is also\subsubsection{}
if you need it! - By using these commands, you make it possible for LaTeX to automatically build a table of contents using
\tableofcontents
.- Note: if you change the sections, subsections, or pages, you might need to run LaTeX twice before you see these changes reflected in the table of contents, depending on what LaTeX program you’re using.
- If you want sections without numbering (which is more natural in very short documents) then add an asterisk after the command name, such as
\section*{«section title»}
.- Note: using
*
will remove the section from the automatically generated table of contents. To manually add a line to the table of contents, try looking into the\addcontentsline
command.
- Note: using
Exercise (nickname: sections
)
Note: The first paragraph in a section will have its indent removed by default. Please note that if a paragraph in a previous exercise has an indent and yours no longer does or vice versa that we will not be removing any marks; we expect this to happen occasionally. This may also mean that your paragraph breaks from line to line at a different word than it used to. This is okay too and is expected.
When you are copy-and-pasting your old solutions in to a single file, you might accidentally cause an error by copying too much or too little at the start or end. We recommend that you should recompile your document after each copy-and-paste, which can make it easier to catch such an error as soon as it occurs and fix it easily. Be sure not to leave this to the last minute.