Science and technology

Create stunning PDFs in LaTeX

The LaTeX doc preparation system has an fascinating historical past. When programmer Don Knuth wrote his first e book, The Art of Computer Programming, in 1968, it was produced utilizing an old-style printing press technique. When he revealed the second version in 1976, the writer had moved to trendy phototypesetting.

Knuth was sad with how the brand new version seemed. Addressing the issue from a programmer’s perspective, Knuth determined to create his personal textual content processing system so his future books could possibly be formatted to look the identical method, for each e book within the collection. And so it was that Don Knuth wrote the primary model of TeX in 1978.

A couple of years later, Leslie Lamport created a set of macros that assist authors write complicated paperwork extra simply. Lamport’s macro extensions, LaTeX, primarily extends TeX to simply produce every kind of paperwork. For instance, many educational organizations use LaTeX to publish journals and proceedings.

Writing paperwork in LaTeX

It’s straightforward to be taught the fundamentals of LaTeX by writing a brief article. Let’s begin by borrowing from the About Opensource.com web page to create this pattern enter file:

$ cat about.tex
documentclass{article}
start{doc}

Opensource.com is a premier, every day publication targeted on
open supply and Linux tutorials, tales, and sources.

We're a various and welcoming group, made up of employees
editors, Correspondents, contributors, and readers. We
worth variations in expertise, abilities, backgrounds, and
experiences. There are a couple of alternative ways to get entangled
as a reader or a author.

finish{doc}

Like different doc formatting applications, LaTeX collects phrases and fills paragraphs. That means you possibly can add new textual content in the course of a paragraph and never fear about how the ultimate doc will look. As lengthy as you do not add a clean line in the course of a paragraph, LaTeX creates totally justified paragraphs. When it finds a clean line, LaTeX begins a brand new paragraph.

LaTeX wants a couple of management statements to outline the doc. Every LaTeX doc ought to begin with a declaration of the doc’s class. LaTeX helps a number of sorts of paperwork, together with letters, books, and articles. For this instance, I used documentclass{article} to set the article class.

Tell LaTeX the place the textual content begins and ends with the start{doc} and finish{doc} statements. If you add textual content earlier than the start{doc}, LaTeX generates an error. Any textual content after finish{doc} is ignored.

Process this doc utilizing 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.
getting into prolonged mode
(./about.tex
LaTeX2e <2020-10-01> patch degree 4
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX doc 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 web page, 736 bytes).
Transcript written on about.log.

LaTeX produces a number of textual content so you possibly can see what it’s doing. If your doc comprises errors, LaTeX prints a message, and presumably immediate for what it ought to do. In most circumstances, you possibly can sort exit on the immediate to pressure LaTeX to give up.

If LaTeX was profitable in producing a doc, it produces a file with a .dvi extension. The DVI stands for Device Independent as a result of you should utilize quite a lot of instruments to create other forms of output. For instance, the dvipdf program converts the DVI file to a PDF file.

$ dvipdf about.dvi

(Jim Hall, CC BY-SA 4.0)

Adding lists

LaTeX helps two sorts of lists: an enumerated listing the place every merchandise begins with a quantity, and an itemized or “bullet” listing. Add a brief enumerated listing after the second paragraph to listing the ways in which people can get entangled with Opensource.com:

start{enumerate}
merchandise Be a author
merchandise Be a reader
finish{enumerate}

Similar to how that you must present start and finish statements round a doc definition, you additionally want to supply start and finish statements round a listing. Within the listing, begin every new merchandise with an merchandise command. When you course of this new file with LaTeX and convert it to PDF format, you see your listing formatted as a numbered listing:

(Jim Hall, CC BY-SA 4.0)

You may also add lists inside a listing. This is a neat function if that you must present a listing with a number of choices for every merchandise. For instance, you possibly can add a couple of totally different sources for folk who wish to grow to be writers at Opensource.com. The embedded listing makes use of its personal start and finish statements. I’ll add some additional house round this instance so it is simpler to see, however LaTeX would not actually care in regards to the clean traces and further areas:

start{enumerate}
merchandise Be a author

  start{itemize}
  merchandise Resources for writers
  merchandise Contributor Club
  merchandise Correspondent Program
  finish{itemize}

merchandise Be a reader
finish{enumerate}

The new listing is inserted as an embedded listing inside merchandise #1 since you added the listing between the 2 authentic merchandise statements. You may have as an alternative inserted this listing after merchandise quantity 2 by including the brand new listing earlier than the finish{enumerate} assertion.

(Jim Hall, CC BY-SA 4.0)

Sections and subsections

You could make an extended doc simpler to learn by breaking it up into sections. To add a bit title to a LaTeX doc, use the part{...} assertion, and write the part’s title contained in the braces. For instance, you possibly can add a brand new part titled “About Opensource.com” to the highest of the doc with this:

$ head about.tex
documentclass{article}
start{doc}

part{About Opensource.com}

Opensource.com is a premier, every day publication targeted on
open supply and Linux tutorials, tales, and sources.

We're a various and welcoming group, made up of employees
editors, Correspondents, contributors, and readers. We

The article doc class provides a quantity earlier than every main part, and will increase the font dimension so it stands out within the doc.

(Jim Hall, CC BY-SA 4.0)

For paperwork that require extra group, you possibly can add subsections utilizing the subsection{...} command. Like the part{...} command, enter the subsection’s title between the curly braces.

$ head about.tex
documentclass{article}
start{doc}

part{About Opensource.com}

Opensource.com is a premier, every day publication targeted on
open supply and Linux tutorials, tales, and sources.

subsection{Welcome to the Opensource.com group}

(Jim Hall, CC BY-SA 4.0)

Title and writer

Scientific articles meant for publication require a title, writer, and publication date. LaTeX offers a way so as to add this info by inserting instructions that outline every, then generates the article’s title with a separate maketitle command.

Add “About Us” because the article’s title, “Opensource.com Editors” for the writer, and “July 10, 2022” because the publication date. You should enter this block after the start{doc} and earlier than the remainder of the content material, reminiscent of the primary part:

title{About Us}
writer{Opensource.com Editors}
date{July 10, 2022}
maketitle

When you course of the doc, LaTeX provides the title, writer, and date to the highest of the artcle:

(Jim Hall, CC BY-SA 4.0)

Adding emphasis

Scientific and different technical paperwork usually embrace phrases and phrases that want to hold particular emphasis. LaTeX offers a number of font results you should utilize in technical paperwork, together with emphasis textual content (normally displayed in italics), daring textual content, and small caps.

Update your LaTeX doc to place the phrase “staff editors, Correspondents, contributors, and readers” in italics textual content, and the precise phrases “reader” and “writer” later within the paragraph in emphasis textual content. You may also put the phrase “skills, talents, backgrounds, and experiences” in daring. And whereas it isn’t the proper method to fashion it, you should utilize small caps to sort “Linux.”

$ head -20 about.tex
documentclass{article}
start{doc}

title{About Us}
writer{Opensource.com Editors}
date{July 10, 2022}
maketitle

part{About Opensource.com}

Opensource.com is a premier, every day publication targeted on
open supply and textsc{Linux} tutorials, tales, and sources.

subsection{Welcome to the Opensource.com group}

We're a various and welcoming group, made up of textit{employees
editors, Correspondents, contributors, and readers}. We
worth variations in textbf{expertise, abilities, backgrounds, and
experiences}. There are a couple of alternative ways to get entangled
as a emph{reader} or a emph{author}.

This pattern reveals alternative ways to use totally different kinds to textual content. When that you must add emphasis, use the emph{...} command, with the phrase or phrase between the curly braces. To show textual content in italics, boldface, or small caps, use a variation of the textual content command: textit{...} for italics, textbf{...} for boldface, and textsc{...} for small caps. LaTeX helps plenty of different methods to fashion textual content, however these kinds get you fairly far in writing scientific paperwork.

(Jim Hall, CC BY-SA 4.0)

Using LaTeX

I’ve solely touched on a couple of methods to write down scientific and technical paperwork in LaTeX. Depending in your wants, you too can use LaTeX to insert footnotes and typeset mathematical equations and expressions. To discover different methods to make use of LaTeX for scientific writing, additionally learn A introduction to creating documents in LaTeX right here on Opensource.com.

Most Popular

To Top