LaTeX, Part (6): Other REALLY important basics– Spacing

Previously, I showed you how to set up the most basic TeX document that is humanly possible. For a quick review, it goes like this:

% the percent sign tells LaTeX to ignore everything on this line, until the next carriage return
% your preamble is the spot right after \documentclass
% content!!!

Easy, right? Of course, this is also the most boring document possible. Before we can make it more interesting, I must first delve into how spacing works.


LaTeX thinks it knows everything about typesetting. And it probably does. Regardless, it does a lot of things that you won’t want it to do, so figuring out how to reign the beast requires a fair amount of time. The good thing about this, of course, is that most typesetting will be done quite nicely for you, and you just have to adjust for your specific circumstances.

First things first. LaTeX will stick a HUMONGOUS amount of space around the edges of your document. And I really mean huge. It gives something like 2 inch margins. This is for good reason, as having a narrower line of text improves readability. But it looks awfully dumb when you are using standard letter-sized paper. To change this, as with most things in TeX, you just need to throw a package in. As I mentioned previously, this is done through the \usepackage command in your preamble. There are several packages for shrinking your margins down.

The easiest one to use that still looks nice is called fullpage. To use it, just type \usepackage{fullpage} in your preamble. It will shrink down your margins, but you don’t have control over how much (I think it makes it an inch all over?).

A better one, that gives you more control, is called geometry. This requires some options, which are predictable enough. Let’s say you want to have 1in margins all the way around:


Note that the options (in square brackets) absolutely must come before the package name. The order of lengths, however, does not matter. You can also define lengths by pixels and cm, and probably many other ways.

The geometry package comes with a lot of other options as well, but we’re just doing the basics. I should also point out that there are ways of adjusting margins without using packages, and using regular TeX commands, but they are generally more complicated.

LaTeX is pretty clever with the way it runs margins. It was made to do things like write mathematics textbooks, so it automatically alters margins for left and right pages (though the geometry package overrides this) so that you can have giant outside margins for taking notes.

Now that we have some control over the margins, let’s talk about spacing while typesetting:

You will notice that LaTeX will pretty much ignore every type of extra space you can come up with. You should definitely try these out, so you get used to this. If you hit space bar more than once in a row, it won’t matter, since the final document will ignore all but the first space. Also, when you tab the beginning of a line (or anywhere else) that space does not show up at all in your document. This is great for building a hierarchical document that is easy to follow (which I would highly recommend), but takes some getting used to.

Now, carriage returns (or, simply, “hitting Enter”). A single carriage return is 100% ignored by LaTeX. For example, if you were to type


with a carriage return after each letter, LaTeX would give you the word “h e l l o” on one line. Try it!

To actually make a new paragraph, you just need two carriage returns. You can also use the “\” symbol to do spacing things. Look at the screenshot below to see what the output of the different methods is.

Notice a few trends? If you have an entire empty space between lines with content, then you will get a carriage return and and indentation of the new line. Let’s go through each example.

In number (2), there is one return after each letter. The output has them all on the same line with a space inserted in between each. Number (3) has a full space (two carriage returns) between each letter, and so every letter has its own line and is indented. Number (4) uses the “\” after each letter, and we get new lines without indentation [NOTE: the “\” symbol followed by anything other than a space will be interpreted as a command in LaTeX]. Finally, for number (5) there is a “\\” after each plus a full space between each letter. This puts each letter on its own space, indented, with a full empty line in between. Note that if those second returns were missing, the empty lines would also disappear.

So, yeah, it’s a bit complicated. Unless you need to fiddle with it, I would just recommend using the double carriage-return method to separate paragraphs.

If you need to force LaTeX to give you or remove an indentation before a paragraph, use the commands \noindent or \indent, respectively. These don’t always work!

There isn’t really an easy way to get this straight without just playing around with it. Eventually it will be second nature to you.

That’s it for basic spacing. As you can imagine, the more precise you want to be with setting up spaces, the more work you have to put in to figuring it out. Just remember that LaTeX is a typesetting system, not a word processor. It is designed to spit out the best looking documents possible, using all the standard spacing used in typesetting. It’s not meant to be tweaked extensively (though, with some patience, it certainly can be).

<- Back to Part (5) | Continue to Part (7) [doesn’t exist yet!]->

4 thoughts on “LaTeX, Part (6): Other REALLY important basics– Spacing

  1. Hi Adam,

    Great tutorial! This is especially helpful, since the documentation for Texmaker is relatively terse. However, I found Texmaker quite intuitive and easy to get started with (even before stumbling upon your great blog).

    One question I have as a newbie: Have you found Texmaker to be a stable program (i.e., no sudden crashing/closing of the program)?

    Thanks and great job!

  2. Thanks for the feedback!

    So far I’ve had very few problems with Texmaker crashing. Periodically, with multiple large documents open, it has ended up hanging and I had to kill the process, but this has been very infrequent.

    TeXnic Center is an editor for Windows that is basically the same, but I think a little more stable if that’s a concern.

  3. Adam,

    This is an excellent guide. Thank you so much for posting this. I am an undergraduate student and my teacher has suggested to our class to start to learn LaTex before we go into the job market or to graduate school. And this is just what I needed to see before I got involved in learned LaTex. Thanks again.

    -Scott Gadd

  4. The documentation of texmaker is not very clear on the issue of configuration except when i met this tutorial. all d the best as i expect more

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s