The LaTeX document preparation system has an interesting history. When programmer Don Knuth wrote his first book, The Art of Computer Programming, in 1968, it was produced using an old-style printing press method. When he published the second edition in 1976, the publisher had moved to modern phototypesetting.
Knuth was unhappy with how the new edition looked. Addressing the problem from a programmer's perspective, Knuth decided to create his own text processing system so his future books could be formatted to look the same way, for every book in the series. And so it was that Don Knuth wrote the first version of TeX in 1978.
A few years later, Leslie Lamport created a set of macros that help authors write complex documents more easily. Lamport's macro extensions, LaTeX, essentially extends TeX to easily produce all kinds of documents. For example, many academic organizations use LaTeX to publish journals and proceedings.
It's easy to learn the basics of LaTeX by writing a short article. Let's start by borrowing from the About Opensource.com page to create this sample input file:
$ cat about.tex \documentclass \begin Opensource.com is a premier, daily publication focused on open source and Linux tutorials, stories, and resources. We're a diverse and inviting group, made up of staff editors, Correspondents, contributors, and readers. We value differences in skills, talents, backgrounds, and experiences. There are a few different ways to get involved as a reader or a writer. \end
Like other document formatting programs, LaTeX collects words and fills paragraphs. That means you can add new text in the middle of a paragraph and not worry about how the final document will look. As long as you don't add a blank line in the middle of a paragraph, LaTeX creates fully justified paragraphs. When it finds a blank line, LaTeX starts a new paragraph.
LaTeX needs a few control statements to define the document. Every LaTeX document should start with a declaration of the document's class. LaTeX supports several kinds of documents, including letters, books, and articles. For this example, I used \documentclass to set the article class.
Tell LaTeX where the text begins and ends with the \begin and \end statements. If you add text before the \begin , LaTeX generates an error. Any text after \end is ignored.
Process this document using LaTeX with the latex command:
$ latex about.tex This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./about.tex LaTeX2e patch level 4 (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2020/04/10 v1.4m Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) No file about.aux. [1] (./about.aux) ) Output written on about.dvi (1 page, 736 bytes). Transcript written on about.log.
LaTeX produces a lot of text so you can see what it is doing. If your document contains errors, LaTeX prints a message, and possibly prompt for what it should do. In most cases, you can type exit at the prompt to force LaTeX to quit.
If LaTeX was successful in generating a document, it produces a file with a .dvi extension. The DVI stands for Device Independent because you can use a variety of tools to create other kinds of output. For example, the dvipdf program converts the DVI file to a PDF file.
$ dvipdf about.dvi
(Jim Hall, CC BY-SA 4.0)
LaTeX supports two kinds of lists: an enumerated list where each item starts with a number, and an itemized or "bullet" list. Add a short enumerated list after the second paragraph to list the ways that folks can get involved with Opensource.com:
\begin \item Be a writer \item Be a reader \end
Similar to how you need to provide \begin and \end statements around a document definition, you also need to provide \begin and \end statements around a list. Within the list, start each new item with an \item command. When you process this new file with LaTeX and convert it to PDF format, you see your list formatted as a numbered list:
(Jim Hall, CC BY-SA 4.0)