Icon for parent category 'Writing'

Alignment & Simple Environments

This chapter will talk about some very simple environments that are quite important. They are nothing fancy or complicated. You just need to know they exist and how they work.

Alignment

If you don’t want LaTeX to justify a certain part of the text, you can override the alignment with these commands.

EnvironmentSwitch CommandDescription
flushleft\raggedrightLeft aligned text
flushright\raggedleftRight aligned text
centercenteringCentred text
1\begin{flushleft}
2    This text is aligned to the left, which is seen by the uneven right margin (in contrast with justified text). If this paragraph gets much, much longer than this, it makes an even bigger difference. But, it's usually preferred to have most of your text justified.\
3    \raggedleft
4    Woah, now we're aligned to the right.
5\end{flushleft}
Code left > output right
Code left > output right

Verbatim

If you’re trying to typeset computer code, you don’t want LaTeX commands interfering with that. The verbatim environment displays exactly what you put in there—without processing—in a monospaced font. This means that it also leaves all whitespace and returns as they are.

The starred variation does the same, but replaces all spaces with a special character to emphasize them.

 1\begin{verbatim}
 2    p {
 3        color:red;
 4    }
 5\end{verbatim}
 6
 7\begin{verbatim*}
 8    p {
 9        color:red;
10    }
11\end{verbatim*}
Code left > output right
Code left > output right

If you don’t want a whole environment, but inline code, you can use the \verb+text+ command. The + here is the delimiter, which signals the start and end of the command. This can be any character, except for letters, * or space. This too has a starred variation that emphasises whitespace.

1An accented a is made with \'a. Whoops, sorry, I mean \verb+\'a+
Code left > output right
Code left > output right

Quotations

The quote environment is used for quotes, examples or important phrases.

The quotation environment is especially useful for long quotes, consisting of several paragraphs, because it indents the first line of each paragraph.

1\begin{quote}
2    To be, or not to be.
3\end{quote}
4
5\begin{quotation} To be, or not to be, that is the question: Whether 'tis Nobler in the mind to suffer The Slings and Arrows of outrageous Fortune, Or to take Arms against a Sea of troubles, And by opposing end them: to die, to sleep No more; and by a sleep, to say we end The Heart-ache, and the thousand Natural shocks That Flesh is heir to? 'Tis a consummation
6
7Devoutly to be wished. To die, to sleep, To sleep, perchance to Dream; aye, there's the rub, For in that sleep of death, what dreams may come, When we have shuffled off this mortal coil, Must give us pause. There's the respect That makes Calamity of so long life:
8\end{quotation}
Code left > output right
Code left > output right

The verse environment is used for poems, where line breaks and white space are very important. So actually, in this case, with our current Shakespearean spirits, we would have been better of using this environment 🎶

Why use these environments if they barely change anything? Semantics, semantics! If you read your document now, you know exactly what something is supposed to represent: a quote. You can always change the styling later to be wildly different. But you can’t easily retrieve lost meaning from a badly marked up document.

Support me and this website!

Want to support me?

Buy one of my projects. You get something nice, I get something nice.

Donate through a popular platform using the link below.

Simply giving feedback or spreading the word is also worth a lot.