A very basic guide to start writing in LaTeX right now

Prabath Swarna
the start codon
Published in
4 min readMar 5, 2017

Unless you are here by chance you would know what Latex is. But just to be on the same page, Latex is a typesetting system which is very much similar to html. Just like html is the markup language for web pages Latex is the markup language for books and printed documents.

You can download Latex and the underlying Tex typesetting system from here:

But assuming you want to get started right away, downloading and having a fully fledged Latex system can wait. You can use the online Latex editor at www.overleaf.com until you get to know the hang of it.

Getting started

On the editor you will see two panes. On the left the source code and on the right the final document. Let’s go through the most important bits needed for any document. Delete all the source code and add this part:

\documentclass[a4paper]{article}

\documentclass{...} — this is where you mention the type of the document you intend to write. Inside the brackets you can have article, minimal, letter, report and etc. depending on your document. For what purpose each is used is explained here:

https://en.wikibooks.org/wiki/LaTeX/Document_Structure

For simplicity we will be using article for our first document. A4paper in brackets tells the software what size of paper to use.

Then we begin the document:

\documentclass[a4paper]{article}
\begin{document}
...
\end{document}

Between the \begin and the \end you can include everything you want to include in your document. When the programme reaches the \end{document} it stops the compilation.

Adding the Title and Author and Date

\documentclass[a4paper]{article}
\begin{document}
\title{My first Document}
\author{Your Name}
\date{March 2017}
\maketitle
\end{document}

You can put the document title, author and date inside the brackets following \title, \author and \date respectively. These doesn’t get inserted into the document until it gets to \maketitle.

Sections and Subsections

When you want to add Heading and subheadings you can use the \section{...} and \subsection{...}. Enter the text you want for the topic inside the braces. Your code will now look like this:

\documentclass[a4paper]{article}
\begin{document}
\title{My first Document}
\author{Your Name}
\date{March 2017}
\maketitle
\section{New section}
\subsection{New subsection}
\end{document}

When this is compiled you will see your topic in large letters and a number next to it. If you want to avoid numbered sections you can have \section*{...}or \subsection*{...}instead. Other document classes like book or reports will support \chapter{...}.

Lists

There are three list types. For unordered lists you use itemize and for numbered lists you can use enumerate and there’s a description lists for instances like definitions and such.

\begin{itemize}  
\item Hello I'm first
\item Hey second here
\item Third and last
\end{itemize}

If you have enumerate instead of itemize you would have a numbered list.

Italics, Bold and etc.

To italicize or bold use \textit and \textbf. If you want bold-italic text nest one in another: \textit{\textbf{Your Text Here}}.

To underline text use: \underline

Tables

Drawing tables can be tricky but once you get the hang of it, the outcome is beautiful. The environment you use is \tabular

\begin{tabular}{| l | c r |}
a & b & c \\
d & e & f \\
\hline
g & h & i \\
\hline
\end{tabular}

Let’s tackle this line by line. What \begin{tabular} means is straightforward. It starts the table. The brackets following it is for the number of columns and text alignment in each column. l means left align, c for center and r for right align. The | in between means a vertical line separates the two columns. If you don’t want a vertical line replace it with a space just like between columns 2 and 3.

In the following lines the cells are configured. & is used for column breaks. And at the end of each line is \\ which is there to indicate a line break. If you want a horizontal line between the rows you can add \hlineafter each line break.

More formatting can be found here:

--

--