# Howto Write a Thesis using LaTeX: Export Scalable Graphs from Excel to Inkscape

The trick with creating nice looking and scalable graphs is the same as discussed in Howto Write a Thesis using LaTeX: Generate Resolution Independent Figures Using Inkscape. Instead of saving the graph as ‘common’ image, meaning as bitmap, jpeg or png, graphs should also be generated as vector graphics.

Unfortunately, Excel does not provide an obvious way to export graphs as vector graphics (at least, I do not know any). But, fortunately, there is a little workaround which I will describe in this little tutorial.

First, assume we have some data present in an Excel sheet and generated any plot from the data. In the example below, I put in some data from the top of my head (without any scientific verification!) on how probable it is to went totally crazy, formatting your hard drive, destroy all your lab equipment and move to any abbey in Tibet for the rest of your live dependent on the amount of time you spend already to prepare your thesis.

To export this nice and somehow scary graph from Excel and to import it in our LaTeX document, we first need to select the graph by clicking on it, you should see a border around the figure. Note that it is important to select the figure only as we just want to export the graph and not the whole document!

Next, we select File->Save As … from the context menu and save it as PDF! See the screenshot below (Sorry, my installation of Excel is German)

That’s all that needs to be done in Excel. Actually, we would be easily able to import the PDF just generated into our LaTeX document, but there is some beautification needed which is best to be done with Inkscape.

To do so, we first open Inkscape and select File->Open (do NOT use Import!) from the context menu. Browse to the recently generated PDF file and press the Open button.

It might take a few seconds until the next dialogue should pop up. Do not touch any configuration at the import dialogue, simply press OK. The graph may be placed like that:

Note that the imported graph behaves like it would have been created with Inkscape meaning that you can easily click elements, remove or edit them. I personally do not like the grey border around the graph, so I remove it by clicking the border and removing it. You might want to change the colour, axis titles, font size or whatever…

Next, we go to File->Document Properties… to set the page size to fit the graph with some spacing of 10px.

Last, we save the plot as PDF file by selecting File->Save as from the context menu.
Remind that you need to select PDF as file type. That’s it, we just created a resolution independent scalable graph with Excel and Inkscape. Of course, this PDF can be included in our LaTeX document in the same way as any other image, namely by writing:

A scary and maybe exaggerated Graph is shown in Figure ??.
\begin{figure}[ht]
\centering
\includegraphics[width=0.5\textwidth]{fig/FreakingOut.pdf}
\caption[Short caption]{Detailed caption}
\label{fig:imageGraph}
\end{figure}

Also, the graphicx package should be added to the preamble of the Thesis.tex file:

\usepackage{graphicx}

# Howto write a thesis using LaTeX, Part 3: Tips and Tricks

We’ve already seen in part 1 and part 2 of this tutorial, how to install and set up software components and howto organize folders and files. Also, we have created a basic structure of our thesis. In this final part 3, I will give you some tips and tricks that made my live easier while creating my PhD thesis.

To be easier found by search engines, I’m gonna create a separate post for each single tip, trick or hack, whatever name you prefer. But, in order to preserve the scope of this tutorial, we will see how to include the generated stuff into our test thesis.

So, here you go, a list of tips, tricks and hacks helping you with your thesis:

Assume you have generated an image like described in the link above, you can use the following code to include it to your thesis:

An example figure is shown in Figure ??.
\begin{figure}[ht]
\centering
\includegraphics[width=0.5\textwidth]{fig/image.pdf}
\caption[Short caption]{Detailed caption}
\label{fig:image}
\end{figure}

And of course, we need to import the graphicx package in the preamble of the Thesis.tex file:

\usepackage{graphicx}

Thesis Template

If you are a student of the faculty “Biologie und Vorklinische Medizin der Universität Regensburg” in Germany, you can also download the predefined title page:
UR-Titlepage
Thesis Template with UR title page included

I hope you enjoyed reading this tutorial. Now you are all set, you are prepared to write a thesis so fancy that you supervisor is forced to give you the best mark available without reading even a single word of you’ve written. I’m just kidding, of course, content is most important, but at least, you do not have to figure out every problem with LaTeX on your own and you can invest your time on writing text.

If you like this tutorial, please recommend it and leave a command, if you don’t like, tell me what you want me to improve or just don’t tell anybody 😉

# Howto Write a Thesis using LaTeX: Generate Resolution Independent Figures Using Inkscape

Do you really want to have that Golum of a figure in your thesis? Of course not!
Any figure you create for your thesis should be a vector graphic. Remind from part 1 of this tutorial, that there is a general difference between vector graphics and “common” images. Vector graphics do not save pixel values, but generate a description of the image, like you would say: “There is a circle in the left part of the image and another one in the right part. Both have a black border and gray background. The circles are further connected by an arrow.” Well, the real description might be a bit more accurate and fortunately, LaTeX can understand that description if we provide it in the correct format.

Sorry friends, but this is not going to be a tutorial in Inkscape, you will find many of them in the web. This is more a guide on how to use a vector graphic in LaTeX. Let’s assume we have drawn an image in Inkscape that may look like:

First, we have to resize the document to the content to avoid extra spacing around the image. From the top menu, select File->Document Properties. A new dialog will pop up. Notice that there is an area called Resize page to content:

I usually use margins of 10.00 at each side. Then, simple press the “Resize page …” button and you will see that your document has been resized to your content. Be aware not to select a specific object while resizing, otherwise the document will be resized to the object size.

Once the image is ready, you can save the image as PDF by selecting File->Save As and choosing “Save as type” to be “Portable Document Format (*.pdf)”. You can simply use the default PDF setting and click OK in the dialog shown next. And that’s it! Inkscape is automatically generating a vector graphic based PDF. Please note that the default format for vector graphics is SVG, but as we want to use the graphic with LaTeX, we prefer to have a PDF file.

Let’s save the PDF image to the images subfolder (called fig) of our thesis project folder and name it image.pdf. All we have to do now, is to display the image in the thesis. For example, lets show the image in our “Boring Stuff” chapter. We are including figures by LaTeX command:

\chapter{Boring Stuff}
An example figure is shown in Figure ??.
\begin{figure}[ht]
\centering
\includegraphics[width=0.5\textwidth]{fig/image.pdf}
\caption[Short caption]{Detailed caption}
\label{fig:image}
\end{figure}

To get this working, we need to import the graphicx package in the preamble of the Thesis.tex file:

\usepackage{graphicx}

Once we translated the file to pdf (twice to update also the reference), we will see the figure in the Thesis.pdf file.

Please note, that also the list of figures at the end of the document has been updated and now includes an entry with the short description of the figure. To see the benefit of the vector graphic, here is a part of the image within the document, rescaled to 500%:

As you see, the figure can be scaled to any dimension without loosing resolution.

# Howto write a thesis using LaTeX, Part 1: Setting up software components

In this tutorial, I will explain howto write a thesis (which may be a master, PhD or any other thesis) using the document markup language LaTeX. I assume that most of you are using Windows as operating system, thus I did a fresh installation of Windows 8 and I will use it throughout this tutorial. Nevertheless, I think if you are using an older version of Windows, there might be no difference. For you guys using Mac Os X or Linux based systems, you may use the tutorial as well, but figure out howto install software components on your system by yourself. I am using Ubuntu and a MacBook, too, and will probably add some more tutorials for these systems soon. Ok, so we have a fresh raw installation of Windows 8, no additional software installed. Of course, before start writing anything for your thesis, you will have to get some fancy and helpful software. Here is an overview of software component that will be used throughout this tutorial where installation will be explained in the following sections.

• MikTex (includes everything you need to run Latex)
• Texmaker (Helpful editor to write Latex code)
• Inkscape (Vector graphic program)
• Dropbox (Save your work in the cloud)
• Notepad++ (A great text editor)
• Excel2Latex (Plugin to export tables from Excel to Latex)

Thesis Template

If you are a student of the faculty “Biologie und Vorklinische Medizin der Universität Regensburg” in Germany, you can also download the predefined title page:
UR-Titlepage
Thesis Template with UR title page included

# 1. Install Software

If you live in Europe, you may select A4 as preferred paper size, Americans are using Letter as far as I know. So I usually choose A4. LaTeX is a software that has many additional stuff that can be added for specific things. For example, if you are a software developer, you might want to display source code of algorithms in your thesis. Therefore you want some additional functionality for LaTeX. Fortunately, there is a huge community providing stuff for anything you might imagine. These additional things are stored in so called packages. We will see later on how we can install and use them. MiKTeX is very nice to us by providing a package manager that is searching and installing packages for us. In the second option of the screenshot above, we can define if MiKTeX is allowed to install them on the fly, meaning if we are referencing a package in our code that is not yet installed, MiKTeX is recognizing it and installs it automatically. I prefer to be asked before, as I want to know which packages are being installed on my system. Remaining installation is just straight forward.

We immediately see that the program is built of three columns. Once we have started writing, the most left one will show the structure of our document, namely headings etc. The middle one is going to be our text editor where we put the LaTeX code in and the right one will show the translated PDF document. At this point I need to say, that we are going to translate our document into PDF. Originally, LaTeX is going to produce DVI files which is not used very often nowadays. Good, lets try if LaTeX already works by creating a new file by clicking the icon in the top left corner of Texmaker. Now, in the middle column, a new file has been opened. Type in the following and press save:

\documentclass{book}
\begin{document}
Test
\end{document}

Please don’t worry what that means, we will revisit that later.
If you are using Windows 8 as I do, you might wonder that you can’t save the file due to permission errors (Really Windows? Managed to have a new version that is even more silly than the old one?). The trick is that you have to provide a file extension on your own. So save the file as Test.tex not only Test. Note that .tex is the file extension indicating that this is a LaTeX file like .docx is used for Microsoft Word files.

On the bottom left of Texmaker, there are some buttons, press the Messages/Log button and you may note that at the bottom of the middle text editor column, something appeared called output window. This is a console that is providing output information of translating the text to the PDF file. Next, select from the top menu Tools->PDFLaTex and you will see that some messages are shown in the output window. Select  Tools->PDFLaTex again. Next, select Tools->View PDF and a PDF file should be displayed in the right column of Texmaker:

Congratulations, you just created your first LaTeX document and successfully translated it  to a PDF file. Please don’t worry about anything we’ve done so far, this was just to check whether our installation works or not. If you run into any trouble and you could not produce a PDF file, please check if your Texmaker has automatically identified LaTeX installation correctly. You may check that in Options->Configure Texmaker where Commands should look like:

Of course, some paths might be different.

Great, we are able to use LaTeX and can produce a PDF document from LaTeX code. But to write a fancy thesis, we need to install some more helpers.

1.3 Get Inkscape

Justifiably, you may ask: “Why do I need to install a graphics program? I just want to write my thesis and I already have plenty of graphic programs installed” OK, you do not necessarily need Inkscape, but you should use a software that can save images as vector graphics. Now, I may have finally confused you and you are angrily pressing your browsers back button know. I will clarify, there are generally speaking two kinds of images used on computers, the one and normally used ones are pixel based graphics, these are for example PNG or BMP or JPEG images like the screenshots provided in this tutorial. So, the image is built of a matrix of pixel values (squares) that do have one single color. You will have noticed that in the past while zooming an image too far. Further, there is the resolution, saying how many of these pixels exist in the image. The biggest disadvantage of this file formats is that if you are zooming the image, there are too less pixel values available and the image gets cloudy or you are seeing these pixel squares. Of course, we do not want to have cloudy images in our thesis, especially if we are providing graphs or similar stuff. The other option is to use vector graphics. A vector graphic image is simple a text file where the image is described in the sense of: “There is a black line of thickness 3 from the top left corner to the middle of the image”. The real painting of the image is done by the program that displays the image and if you zoom in, the lines, circles and whatever you may draw are still correctly defined. The end of this too long story is that we use vector graphics to get sharp images even if we zoom in extremely into the PDF file. Please note, that of course you cannot transform a pixel image or a photo into a vector graphic.

## 1.4 Even more software

Lastly, lets take some notes about other helpful software that you may use for writing your thesis.

First, I strongly recommend using any cloud drive service like Dropbox for saving your files into! Once you wrote the first 100 pages which took you probably a few month in real time and about 5 years of you age and your computer crashed for any weird reason you may be enormously happy to have a backup of your LaTeX code on a save place at the internet and you might even send me some flowers (I would prefer chocolate by the way) for giving you that hint. Further, I saved a version at the end of each day separately to be able to go back to any status of the thesis. A note for security and privacy folks, I agree with your complaints, but you can save your stuff encrypted or packed in a password saved zip file. Think about what is more critical, loosing all your work or having the risk of somebody hacking a cloud service seeing your LaTeX code?. Or make sure to save your stuff at least regularly on any independent hard drive.

Another helpful software, not only for your thesis, is called Notepad++ and is a text editor that serves anything you will need when editing text files. We will be using it later for managing our bibliography file.

Last but not least, I use Microsoft Excel to generate graphs, plots and tables as there is a nice wizard for changing styles etc. A huge advantage which I will also explain in one of the next parts of this tutorial is that you can export graphics from Excel to PDF as vector graphics. As you remember, this leads to graphs that can be scaled to any extreme.
An excellent plug-in for Excel is Excel2Latex. You will only have to download the file from the website and open it with Excel to get two additional buttons in your Excel Add-Ins menu. You can find additional information on installation at the project website.

Conclusion

In Part 1 of this tutorial, we managed to set up our system to be able to start writing our thesis and we already produced a little PDF document using LaTeX. Part 2 is going to quickly introduce LaTeX. There are plenty of more extended and better introductions to really learn how to deal with LaTeX. But I want to give a short overview of what it is and why it makes sense to use it. But you will learn how to organize your folders, files and how to build the general structure of your thesis

The most interesting part will probably be Part 3, where I gonna show you some of the hacks and tricks that I have used to make life easier and to produce a nice looking thesis (at least in my opinion).

==> Continue with Part 2