LaTeX – The Ulyssis Workshop (part 2)

Last time I introduced the very basics of LaTeX after a workshop organised by Ulyssis, which you can find here. As I promised earlier, today I will talk you through the code to insert tables and figures into your text. For those of you who want to really impress their peers, I will also explain how you can format two figures next to each other (which required some serious googling skills on my behalf). But let’s get started with the basics first.

You can add your table within a \part{Title goes here}, \section{Subtitle goes here}, or \subsection{Subsubtitle goes here} of your \begin{document}, but before your \end{document}. There are several kinds of tables, the most basic one starts by \begin{tabular}{c c c} to specify that you want three columns, and for each row you add item & item & item \\ to fill in the three columns. After you added several rows, don’t forget to \end{tabular}.

For your fancy table you \begin{table}[h] right here, but you want it in the \begin{center} and then you can \begin{tabular}{c c c} with some columns, which you know how to fill in by now (item & item & item \\ for each row). After you \end{tabular}, you add a \caption{fancy table}, you \end{center} and finally, you \end{table}. Once you understand the basics, you can make your life easier by creating your tables in a tool such as

Now in order to add figures to your document, you need to add a package in your preambula – the thing that comes right after \documentclass[11pt]{article} at the start of your document. You can \usepackage{graphicx} to insert some fancy figures. Of course you need to save your picture in the same folder as your .tex file, otherwise it might be hard to find. Now you’re ready to \begin{figure} and \includegraphcs[width=0.5\textwidth]{your figure}, where you define the width of your figure, in this case 50%, but you could also set [width=100mm] to include a figure of 10 cm wide. To center your figure you can use the \centering command, and adding a \caption{your figure} works the same as for tables. Again you need to \end{figure} before you start with the rest of your text.

If you want two figures side by side (or even three, but you can probably figure it out if you understand the mechanism), stackexchange comes to the rescue. Because you need a specific type of \caption, you need to add another package in your preambula called \usepackage{caption}. So again you \begin{figure} by \centering both your figures in the middle of the page. But you now split your figure into two \begin{minipage}{.5\textwidth} each taking up 50% of the width of your page. In order for each figure to look spot on, you should use \centering again, then \includegraphics[width=0.9\linewidth]{first image}. In this case the linewidth for each figure takes up only half of the page, so the 90% used here, actually means you have a 10% margin between this figure and the next. In this case, you need the \captionof{figure}{This figure} to add a caption to the first figure. If you want to refer to your figure in the text you can always add a \label{fig:figure1} and inside your text \ref{fig:figure1} so that the number of the figure is always correct, even if you add other figures. Now you need to \end{minipage} number one, and in order for the two minipages to appear next to each other, you need a % inbetween. Now you can repeat the \begin{minipage}{.5\textwidth} process to add one more figure, and after you \end{minipage}, also \end{figure}.

So there you go, the perfect tables and figures to impress any reader! Next time, I will explain how to add your citations and bibliographic references, BiBTeX style.

LaTeX – The Ulyssis Workshop (part 1)

Because I wanted to try a different approach to learning LaTeX, I went to a workshop organised by Ulyssis, a group of KU Leuven students offering workshops to other students. They explained the basics of LaTeX in about two hours, creating a template for a paper in the first hour and explaining BibTex in the second hour of the workshop. During the workshop they helped install an easy LaTeX editor and a team of students was at hand all the time to answer individual questions. So in this blogpost, I would like to share my newly acquired knowledge!

The structure of a LaTeX document always has the same basic elements, opening the document with the preambula, containing all metadata (the hidden specifics of the document itself). First, we specified the \documentclass adding the size of our font [11pt] and the type of document, namely {article}. If we need to import packages to do the fancy stuff dreams are made of, we need to \usepackage{awesomeness} to add some more functionalities and funky features -for your information, there is no package awesomeness for all I know, but please feel free to make one. Of course you can add the \title{Anything you like}, as well as the \author{me!} and the \date{\today} or any other day you like. No one needs to know you started your paper the day of the deadline.

Alright, we have our metadata, now we can \begin{document} by \maketitle and starting a \newpage for your magical automatically created \tableofcontents on a \newpage. Most papers contain an \abstract, but since LaTeX needs some help understanding what you want exactly, you should still \begin{abstract} and after writing your brilliant summary of everything you are about to write, you need to \end{abstract} for LaTeX to know you are done.

Now you need to start providing your table of contents some content. In an article you can divide your text into \part{one, two, three} and add \section{one, two, three} which can exist of \subsection{one, two, three}. You can add \paragraph{With a lot of witty, smart, funny, intelligent text} and even \textbf{bold text} and \textit{italics}. Furthermore you can also create different types of lists, starting with a bullet list by \begin{itemize} containing several \item items untill you decide to \end{itemize}. Sometimes you need to specify the order of your list \begin{enumerate} again containing \item one and ending your \end{enumerate}. Finally, if you want to provide descriptions to your awesome concepts, you \begin{description} adding \item[awesome concept] with your clear explination before adding another \item[greatness] adding your own brilliant definition and bringing an \end{description} to your awesomeness.

Before you go, don’t forget to \end{document} and feel like a professional programmer while you let LaTeX do the work (press run!), typesetting the best paper you ever wrote. Catch up next time for some more on tables and figures sprucing up your text!