LaTeX Best Practices

A guide for a smooth completion of your thesis

March 27 2017
Reading Time: 12 minutes

Completing a PhD can be a hell of a task. It took me lots of time to be able to come up with a framework to optimise how i do research and how i write and execute deliverables. I hope that this post can help you in completing yours

Completing a PhD can be a hell of a task. It took me lots of time to be able to come up with a framework that optimises how i do research and how i write and publish my research. This post discusses some of the tools and techniques i used in addition to LaTEX best practices. These are gathered either by experience, online search and most importantly the wisdom of my PhD supervisor @Raphael Troncy.

I hope this post can help you complete your PhD smoothly.

You can head to my PhD Github repository to see all my LaTEX recommendations in action

Mendeley and Bibliography Management

Doing effective and genuine research requires that you familiarise yourself with the state of the art in your field. This requires reading tons of journal, conference and workshop papers. However, after some time, recalling what you have read and being able to effectively reference that in your research becomes a daunting task.

I personally found Mendeley a great tool to arrange my bibliography. It has loads of features, but i have used it mainly to arrange my digital research library. I have used Mendeley basically as follows:

  • As i did not have a specific research topic in the beginning, i was skimming various wide fields. As a result, i have created a separate folder for each research field i was focusing on e.g., Dataset Profiling, Linked Data quality
  • I had a root folder for conferences, journals and workshops that contained a separate folder for each relevant venue for my research. For example, i had:
  • I also had a separate folder foe even paper i have made. That folder contained all the papers i have read that influenced my research for that paper and/or have been referenced in it.
├── Conferences
    ├── ISWC'13 - International Semantic Web conference 2013
    ├── ESWC'13 - Extended Semantic Web conference 2013
├── Workshops
	├── PROFILES'15 - International Workshop on Dataset PROFIling and fEderated Search for Linked Data
├── Posters
    ├── Semantic Web Journal
    ├── IJSWIS - International Journal on Semantic Web and Information Systems

General Organisations

  • Create a structure to include your papers in an organised fashion. I keep separate folders for papers, posters, presentations, reports and thesis. Note: Demo and research paper are included in the same folder, you can decide to have posters and demo in the same folder. It is up to you.
  • To easily navigate through papers, it is good to have a separate folder for each conference (if you a large number of papers, and then from there you have another hierarchy with the year) but for me it is a flat structure inside each folder with a naming convention that follows <Conference>'<Year> - <Paper Name>.
  • Keep a util folder in the root. This will help misc files that you need globally. For me, i have a LaTeX folder inside that includes all the document classes that i use across my papers. I then reference the class using relative path. This way, you will need to maintain different copies of the same files in each paper’s folder. Also this folder will include a Bibliography folder containing a centralised .bib file. I will come to this in details after.
  • In every paper folder, create a separate folder for your figures to include shapes, graphics and charts and tables to include .xls, .csv, .lyx files or any information related to creating tables.

An Example of my folders structure

├── Papers
│   ├── ESWC'13 - SNARC A Semantic Social News Aggregator
│   │   ├── figures
│   │   └── presentation
│   ├── IJSWIS - Towards An Objective Assessment Framework for Linked Data Quality
│   │   ├── figures
│   │   └── tables
│   ├── PROFILES'15 - An Extensible Framework to Validate and Build Dataset Profiles
│   │   └── figures
├── Posters
│   ├── ESWC'14 - What are the Important Properties of an Entity - Comparing Users and Knowledge Graph Point of View
│   │   └── poster
│   └── WWW'15 - Observing The State of Linked Open Data Cloud Metadata
│       └── figures
├── Presentations
├── Progress Reports CIFRE & Workplans
│   ├── CIFRE Activity Reports
│   ├── Conferences Attestations
│   ├── EDITE Progress Reports
│   ├── EURECOM PhD Scientific Council
│   │   ├── EURECOM PhD Day 2013
│   │   └── EURECOM PhD Day 2014
│   └── PhD Interim Report
│       ├── figures
│       └── presentation
└── Util
    ├── Bibliography
    └── LaTEX

Special Organisation

For special reports (or thesis), when you have multiple .tex files and things can get messy then you can:

  • Create separate folder for each section (introduction, abstract, etc.). Each directory contain all the LaTeX code, and could have further subdirectories if required. All .tex files are included in the paper by adding \input{directory/subdirectory/something.tex} to your main .tex file in the appropriate place.
  • The Util folder in this case will include additional files:
    • All package inclusions \usepackage{}, command declarations, etc. required for the paper are included in include.tex
    • Formatting and special stylings are included in format.tex file.
├── Thesis
│   ├── Part1
│   │   └── Chapter1
│   ├── abstract
│   ├── acknowledgement
│   ├── acronyms
│   ├── appendix
│   ├── background
│   ├── conclusions
│   ├── introduction
│   └── util
│       └── figures
        └── include.tex
        └── format.tex

Environment Setup

  • I cannot stress enough on the importance of using a versioning system like git or svn. It is vital for collaborative authoring.
  • My development machine is a Mac running OSX Yosemite. I use MacTEX. MacTex is an all-in-one package installing the following:

Generating LaTeX Tables

  • A nice program that provides a GUI for various tasks is Lyx. I have not used it for Mac but it was useful when editing/creating tables on Windows. It can import data in .csv format and generate .tex code from it.
  • There is several online .tex generators. I use the online LaTeX table generator, and found it very useful for small/medium tables.
  • There is a handy Excel script to convert tables in Excel files to LaTeX. You can find it in Util/Excel To LaTeX Table Converter.xla

Editing LaTeX with Sublime Text

I use Sublime Text for nearly everything, so using it to write LaTeX was the logical choice for me. With the correct plugins it is a handy editor. You first need to make sure you have a valid TeX distribution (see above) and installed Skim PDF Viewer. Skim is used to generate the result of the LaTeX build.

Assuming you already have package control installed install the LaTeX Tools package. Now, after editing a LaTeX document, simply hit cmd+b to build the file and launch it in Skim.

Note Make sure you have the build settings in Sublime Text set to automatic [tools -> Build Systems].

Now you will be able to use latex in Sublime. A powerful feature is auto-completion for references and citations, just start typing \cite{ or \ref{ and you will get the list of targets in a dropdown list (where you can also filter) to select from.

LaTeX Writing Tips

  • Use as few packages as possible. That’s because packages tend to conflict and go obsolete check this
  • Call the packages in particular order. Some packages require (or are recommended) to be called before/after other packages. Some must be called among the last, some among the first.
  • Use comment blocks to identify each section
  • Use labels always to refer to sections, figures or tables. Start your label for each with a unique string e.g. fig:, sec:, tab:. This is useful when the auto-complete suggests several entries, you can easily filter and find what you want exactly.
  • Always use \url command to represent URLs.
  • Use ~ to have a space between the last work and the reference or citation e.g. in~cite{}
  • In your LaTeX document, avoid as much as possible to control the layout. Hence, you should never use \\ Either you want to start a new paragraph or you don’t but you should let LaTeX format the paper.

Writing-Style Tips

  • When writing, try to use as much as possible the present tense (as opposed to the past tense). Most of the things you’re writing are still true, so why using the past tense? This, generally, makes sentences which are much more complicated and hard to read.

Working with Citations and .bib files

I used to have a separate .bib file for each paper. However, i ended up using a bunch of the same references in more than one paper. I thought of why not having a centralised .bib file where i can maintain and then reference this file from all my other papers. The idea is:

  • There is a central .bib file containing just about every reference you (or your coauthors) have ever even thought of.
  • You (and your various coauthors) have a variety of documents that refer to stuff in this central .bib file.
  • You want to look in the .aux file for a list of references, then go to this .bib file, extracts the relevant entries, and then puts them in a local .bbl file ready for insertion in to the document for each paper.

This is done automatically by BibTex. So for me, in every paper now i only add \bibliography{../../Util/Bibliography/bibliography} and i am good to go.

Maintaining a clean .bib file

I used to copy/paste BibTex citations from the Internet and though that i am good to go. However, the information copied is very noisy and contains lots of unneeded information. The best practice is to check what are the required information for each bib entry and include only that. For example, for the @inproceedings you need to have [title, author, year, booktitle]. In addition make sure to:

  • Escape the accents and special characters in people names
  • Try to always write “firstName lastName” and not “lastName, firstName” or an initial for the firstName or whatever … all this is decided by the bib style (e.g. a .bst file). Use the “and” operator between authors and not the comma.
  • Include the title between double curly braces. This way the capitalisation will be respected as you write. Otherwise, all words will be lower case, including acronyms, etc. Don’t write a final dot in the title, the style will add one already.
  • Have a consistent way of naming the bib entry. Choose whatever you like, for example i chose: <Main_author_LastName>:<Conference/Venue>:<Year> where the year is in two digits representation, e.g. Assaf:ESWC:13
  • For inproceedings just write the conference name, and do not include the address, or month, or even the word Proceedings since the style might display it as well and you don’t want to read “Proceedings of Proceedings of …”
  • If you write a URL, anywhere, then say it’s a url using the \url command.
  • Don’t write journal abbreviation, or conference abbreviation, again the style can do this.
  • If you use the article element, then specify the volume and number.
  • Don’t use the incollection element, this is often incorrect. In most of your references, those Springer volumes are just proceedings of conferences

Some Useful Hacks

  • Loading the strict package prevents using LaTeX’s declarations as environments.
  • Loading the fixltx2e package fixes some LaTeX2e errors.
  • fixmath changes LaTeX’s default math style to comply with some international standards, specifically regarding Greek letters, see package description.
  • refcheck for checking “references in a document, looking for numbered but unlabeled equations, for labels which are not used in the text, for unused bibliography references.
  • LaTeX Templates

I have also kept a bunch of bookmarks for all the relevant conferences, journals. Made sure i also follow their respective Twitter accounts and made also a separate columns in Tweetdeck for their Tweet feed and for specific hashtags. Some of these bookmarks are:

Journals and Research Portals


Twitter Facebook Google+