LaTeX Tips and Best Practices
A guide for a smooth completion of your thesis
Written in 2017 during my PhD; kept as a record. Several tools named here are gone: Mendeley Desktop is discontinued, ShareLaTeX merged into Overleaf.
Completing a Ph.D. can be a hell of a task. It took me lots of time to develop a framework that optimizes how I do research and 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.
I hope this post can help you complete your PhD smoothly.
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 a great tool to arrange my bibliography (the Mendeley Desktop client I used has since been discontinued). 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 created a separate folder for each research field I was focusing on e.g.,
Dataset Profiling,Linked Data quality - I also had a separate folder for every paper I have written. That folder contained all the papers I have read that influenced my research for that paper and/or have been referenced in it.
- Finally, 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:
- Research Library
- 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 Organisation
- Create a structure to include your papers in an organised fashion. I keep separate folders for
papers,posters,presentations,reportsandthesis. 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 have a large number of papers, you can add another hierarchy level 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
utilfolder in the root. This will hold misc files that you need globally. For me, I have aLaTeXfolder inside that includes all the document classes that I use across my papers. I then reference the class using a relative path. This way, you will not need to maintain different copies of the same files in each paper's folder. Also this folder will include aBibliographyfolder containing a centralised.bibfile. I will come to this in details after. - In every paper folder, create a separate folder for your
figuresto include shapes, graphics and charts andtablesto include.xls, .csv, .lyxfiles or any information related to creating tables.
An example of my folder structure
- PhD Research
- 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
.texfiles are included in the paper by adding\input{directory/subdirectory/something.tex}to your main.texfile in the appropriate place. - The
Utilfolder in this case will include additional files:- All package inclusions
\usepackage{}, command declarations, etc. required for the paper are included ininclude.tex - Formatting and special stylings are included in
format.texfile.
- All package inclusions
- Thesis
- Part1
- Chapter1
- abstract
- acknowledgement
- acronyms
- appendix
- background
- conclusions
- introduction
- util
- figures
- include.tex
- format.tex
Environment Setup
- I cannot stress enough the importance of using a versioning system like or . It is vital for collaborative authoring.
- My development machine is a Mac running OSX Yosemite. I use . MacTeX is an all-in-one package installing the following:
- GUI Applications: , , , , the spell checker , and some documentation
- Ghostscript 9.10
- TeX Live 2014, the actual TeX distribution
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
.csvformat and generate.texcode from it. - There are several online
.texgenerators. I use , and found it very useful for small/medium tables. - There is a handy Excel macro to convert tables in Excel files to LaTeX; I keep a converter macro (
Excel To LaTeX Table Converter.xla) in my utils folder.
Editing LaTeX with Sublime Text
I use 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 is used to generate the result of the LaTeX build.
Assuming you already have install the 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
- 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
\urlcommand to represent URLs. - Use
~to have a non-breaking space between the last word 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 use the past tense? It generally makes sentences more complicated and harder 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. So why not have a centralised .bib file that I can maintain once and reference from all my other papers? The idea is:
- There is a central
.bibfile 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
.bibfile. - BibTeX looks in the
.auxfile for the list of references, goes to the.bibfile, extracts the relevant entries, and puts them in a local.bblfile ready for insertion into 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 thought that I was 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
titlebetween 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
bibentry. 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
inproceedingsjust 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
\urlcommand. - 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
incollectionelement, this is often incorrect. In most of your references, those Springer volumes are just proceedings of conferences
Some Useful Hacks
- Loading the package prevents using LaTeX's declarations as environments.
- Loading the package fixes some LaTeX2e errors (obsolete since 2015: its fixes were merged into the LaTeX kernel, so recent distributions no longer need it).
- changes LaTeX's default math style to comply with some international standards, specifically regarding Greek letters, see package description.
- for checking references in a document: numbered but unlabeled equations, labels that are never used in the text, and unused bibliography entries.
- (originally on ShareLaTeX, which has since merged into Overleaf)
Further links
I also kept a bunch of bookmarks for the relevant conferences and journals, followed their Twitter accounts, and had dedicated columns for their feeds and hashtags in Tweetdeck (itself now shut down). The bookmarks that survived: