[2] A Crash Course to LaTeX

   |   6 minute read   |   Using 1103 words

Do you ever get annoyed while writing papers because of a lack of layout consistency? Do you hate it when you need to change everything by hand? Do you ever try to click on something that just won’t highlight, for some godforsaken reason? Or want to display fancy mathematical formulas, but your WYSIWYG editor is too cumbersome to handle?

If you answered yes to any of the questions above, I’ve got just the thing for you: LaTeX Now, before you put on that catsuit, let me explain to you what is.

LaTeX is a markup language designed to be both logical and easily extended. Most of you probably have at least a little experience with markup languages: Markdown is a very popular one, for instance. But why would you use LaTeX over any other WYSIWYG editor? It’s easy: because it’s easier to keep track of your document’s structure, less hassle (usually), and because it has implementations for lots of neat formulas. But let’s cut the crap, and start editing.

Installation

Before you begin, you should know that LaTeX is written in plain text (saved with the .tex extension), and then converted by a special program, to all sorts of formats (for example, HTML or PDF). On Linux, you can install a package called texlive with your favorite package manager, and then execute pdflatex <filename> to convert your file to PDF. I don’t use Windows or Mac myself, but MiKTeX is popular for Windows, and MacTeX is popular for Mac, so those are probably your best shot.

Besides PDF, there are a lot of other formats LaTeX converts to, like HTML, DVI, PostScript, RTF, and even images, for some reason. These all have their own compilers, which you can also easily find with a quick search on the wired.

Actually Starting

Alright then, now that you’ve got your LaTeX-to-PDF converter all set up, let’s have a look at some text you can compile, shall we? I believe in learning by example, so that’s exactly what we’re gonna do. Now, LaTeX uses commands to perform markup operations; all commands start with a backslash, and look something like \command[option1][option2]{argument1}{argument2}.

Generally speaking, most everyday commands only have one argument and no options, but there are more complex exceptions. The syntax is always the same.

Here is an example LaTeX file:

1  \documentclass[a4paper,12pt]{article}
2
3  \title{Chocolate Mooose}
4  \date{}
5  \author{The Swedish Chef}
6
7  \begin{document}
8     \pagenumbering{gobble}
9     \maketitle
10    \newpage
11    \pagenumbering{arabic}
12
13    \section{Step oone}
14      Noo, toodie wee well meg dee \emph{chocolate mooose}.
15      Step oone, geet a five-pound block oof chocolate.
16
17    \section{Step Twoo}
18      Step twoo, get dee mooose. Heer, mooosee mooosee mooosee
19      mooosee!
20
21    \section{Step three}
22      Step three, put dee mooose een dee bleender.
23
24      \textbf{Nuutice}: dee bleender cun't hundel dee entlers.
25      Put dee entlers een last.
26
27      \subsection{tiip}
28        Seeve dee entlers, yoo cun use dem fur furks.
29
30    \section{Steep fuur}
31      Steep fuur, put chocolate een weeth moose, und bleend egen.
32      % This is a comment. Hi.
33
34    \section{Duuuune!}
35      Uum! Dees ees guud mooosee!
36  \end{document}

Decyphering

Now, there’s a lot going on here, so we’ll go through it line by line.

1 In line one, we define the document class, which defines how our article will look. Our document uses “article” which is the most frequently used class, but many others exist. Feel free to look into these, but if you ever don’t know what to pick, pick article. We also tell the compiler the size of our paper (A4) and the size of our font (12 pt).

3 to 5 In these lines, we define the author, date and title for our document, which will be used on our title page. Since I haven’t the faintest when this sketch first aired or was written, I’m leaving the date blank. If you completely leave out the date command, it will default to the current date.

7 and 36 These lines declare the start and end of our document. The actual formatting will be done between them.

8 This command makes sure that the current page (the first one, in this case) gets excluded from the page numbers. We want this here because this is our title page.

9 This command formats our title page see with the title and the author. Normally the date would be displayed here too, but since we left that empty, it won’t be.

10 This command makes sure the rest of the current page will be kept blank, and and puts the ‘cursor’ on the next page.

11 Here, we set the page numbering to arabic (1, 2, 3, 4). Other possible arguments are roman (i, ii, iii, iv), Roman (I, II, III, IV), and alph (a, b, c, d). Small roman numbers look like soykaf though, don’t use them.

13, 17, 21, 30, and 34 These commands declare, as you might have guessed, sections. A section is a part of the document, with a title above it, which is specified in its argument.

14 The emph command in this section puts emphasis on its argument: normally this displays as italic text, except when you nest emph commands, in which case the second emph will become normal text again (so it still stands out).

24 The textbf command here makes text bold.

27 This command declares, yes, you’ve guessed it once again, a subsection. These get slightly smaller titles than normal sections.

32 The text after % is a comment. It will be ignored by the compiler. Comments can be placed in-line as well as on their own lines.

As you can see, the actual text in every section is indented. This is not required (at least not with most compilers), but considered a good organization practice, as it makes your document easier to read and edit.

Conclusion

This article was but a short introduction to LaTeX. If you want more (and you should), I highly recommend the wikibook listed in the credits below.

LaTeX might feel a bit alien in the beginning, but it is really the soykaf once you get the hang of it. Thanks for reading.

The source file for this document and the example if you want to check them out, can be found at https://vivesce.re/lainzine/latex.

Credits

  • [https://www.puppetresources.com/documents/script49.txt](https://www. puppetresources.com/documents/script49.txt): Place where I got the muppet script.
  • https://en.wikibooks.org/wiki/LaTeX: A wikibook about LaTeX, from which I pulled some information I had forgotten.
  • LaTeX: Some silly markup language I wrote this article in.
  • My parents: For telling me to not go on nefarious websites with hackers and stuff. I– I’m sorry.