LaTeX is a free doc typesetting software program, used for writing scientific and technical paperwork. LaTeX provides an expert look to paperwork and offers many packages that may assist programmers format textual content in a manner that might in any other case not be attainable with the same old textual content formatting software program.
In contrast to most technical writing software program or documentation instruments like Microsoft Phrase that depend on a What You See Is What You Get (WYSIWYG) editor, LaTeX, as a substitute, makes use of LaTeX instructions to enter and output content material. The TeX engine then takes care of changing these instructions right into a PDF doc.
On this technical writing tutorial, you’ll be taught some widespread LaTeX instructions that may provide help to create your individual LaTeX paperwork.
Learn: Prime Gantt Chart Instruments for Builders
How one can Set up LaTeX
Putting in LaTeX is pretty easy. From the terminal, merely sort the command beneath to start set up:
sudo apt-get set up texlive
Subsequent, you may verify that you’ve got put in LaTeX by checking for the model, coming into the next command:
LaTeX -v #
Or:
LaTeX --version
How one can Write Your First LaTeX Doc
To start writing your first LaTeX doc, create a file that ends with the .tex extension. You should utilize any textual content editor of your alternative, reminiscent of Notepad or Notepad++.
On the primary line of your file, declare the documentclass. This can be a command that defines the kind of doc you’ll write. Discover that the command begins with a ahead slash (). That is the final syntax for writing a LaTeX command:
command.
After the command,you could optionally have curly brackets {}, the place you may declare knowledge. There are a selection of doc sorts you may select from, together with an article or e-book. The doc sort determines how content material might be typeset on the doc.
Right here is a few primary pattern instructions for creating an article sort doc in LaTeX:
documentclass{article} start{doc} My First LaTeX Doc! finish{doc}
Subsequent, embody some phrases between the start{doc} and finish{doc} tags. This constitutes the physique of your doc. The part earlier than the physique is named the preamble and it’s used to set specifics such because the doc class and packages.
The subsequent step is compilation. To compile your code, run the command beneath:
$ pdfLaTeX firstDoc.tex # change firstDoc with the title of your tex file
This can output a .PDF doc known as firstDoc.pdf within the present listing. You may open this file out of your terminal utilizing the evince command:
$ evince firstDoc.pdf
It’s also possible to open the file utilizing any .PDF reader of your alternative.
The next is a listing of a number of the doc sorts – also called doc lessons – out there in LaTeX:
- article: Used for articles featured in scientific journals, brief studies, displays, and in addition for software program documentation
- IEEEtran: Used for articles utilizing the IEEE Transaction for.
- report: Used for lengthy studies, small books, thesis papers, and paperwork containing a number of chapters.
- e-book: Used for precise books.
- slides: Used to create slides.
- letter: Used when creating letters or notes.
Sizing Fonts and Styling Textual content in LaTeX
Programmers can set the font measurement of their textual content in LaTeX by together with the dimensions worth in [ ] brackets after the documentclass command. For instance:
documentclass[14pt]{article}
The above LaTeX command would create textual content that’s 14pt in measurement.
To make your textual content daring or italicized, builders can use emp (or textbf) for daring and textit for italics. To underline textual content, use the underline command.
Learn: Greatest Productiveness Instruments for Builders
Setting Title, Creator, and Date in LaTeX
To set the title, writer, or date of your doc, use the next instructions, respectively: title, writer, or date. To ensure that these attributes to point out up, it is advisable to use the maketitle command in your doc’s physique.
Right here is an instance of how one can set the title, writer, and date in a LaTeX doc utilizing maketitle:
documentclass{article} title{My LaTeX Doc} writer{Michael Jenkins} date{June 2025} start{doc} maketitle This can be a PDF doc created utilizing LaTeX code. finish{doc}
How one can Construction a LaTeX Doc
To incorporate an summary in your LaTeX doc, place it between the next tags:
start{summary} finish{summary}
To create a brand new line, you may both use or newline.
To create a brand new part and chapters, you should use the tags beneath:
part{Part Title} subsection{Subsection Title} part*{Unnumbered Part}
Right here is an instance displaying how one can totally construction a LaTeX doc, together with how one can outline its documentclass:
documentclass{e-book} usepackage{graphicx} graphicspath{{my-images/}} start{doc} tableofcontents chapter{} part{Introduction} subsection{Objective} This defines the supposed use of the doc. It summarizes the purpose of the doc. Ensure that it's temporary and straight to the purpose. subsection{Scope} subsection{Definitions, Acronyms, and Abbreviations} subsection{References} subsection{Overview} chapter{} includegraphics{my-cartoon} part{Necessities} part{Constraints} part*{Unnumbered Part} finish{doc}
To output a desk of contents, it is advisable to add the tableofcontents tag in your doc’s physique.
Documenting Algorithms in LaTeX
First, let’s take a look at how one can add packages to LaTeX. To import a bundle, accomplish that through the use of the usepackage{package-name} command within the doc preamble.
Typically a bundle could not already be downloaded along with your default LaTeX set up. Let’s take use an instance of the algorithm2e bundle which you, as a developer, can use to write down algorithms.
This bundle will be downloaded from the CTAN (Complete TEX Archive Community) repository. Merely seek for the bundle within the search bar after which obtain the offered .ZIP archive. Extract the bundle and find the .sty file (on this case algorithm2e.sty).
Copy this file to the listing of your .tex file (the listing the place you’ll be importing this bundle). Now, you’ll be able to freely import this bundle with none compilation errors.
Right here is a few pattern code displaying how one can use the algorithm2e bundle in LaTeX:
documentclass{article} usepackage{algorithm2e} start{doc} start{algorithm} eIf{$val[0] > $val[1]} { tmp[0] = val[1] tmp[1] = val[0] }{ tmp[0] = val[0] tmp[1] = val[1]} eIf{$val[2] > $val[3]}{ tmp[2] = val[3] tmp[3] = val[2] }{ tmp[2] = val[2] tmp[3] = val[3]} finish{algorithm} finish{doc}
Last Ideas on Technical Writing with LaTeX
LaTeX is a robust typesetting software program that lets you create numerous kinds of technical paperwork, starting from mathematical docs to algorithms. From the examples on this tutorial, it’s best to be capable to confidently create, write, and format LaTeX paperwork.
Learn: How one can Create a Smooth Trying Resume Utilizing LaTeX.