Essential LaTeX, BibTeX and BibLaTeX tips for research students

This article is long overdue. I was requested by many PhD candidates to write an article about essential tips of LaTeX and its most important packages, BibteX and BibLaTeX.

This article is dedicated to all research students who are using LaTeX to write papers, posters, presentation slides, dissertations and theses.

This article is not a tutorial of LaTeX, BibTeX or BibLaTeX. At the end of this article I will provide beginners with many material and books to consult.

Quick Introduction of LaTeX, BibTeX and BibLaTeX

LaTeX pronounced «Lah-tech» or «Lay-tech», is a typesetting system and a typesetting language. According to the LaTeX project website, LaTeX is the “de facto standard for the communication and publication of scientific documents”.

BibTeX and BibLaTeX are two very famous references management software and notation languages.  BibLaTeX is more advanced, more fancier than the good old BibTeX. Actually, BibLaTeX is considered the successor of BibTeX. Both in a technical sense are TeX packages that come by default these days with all the major distributions of LaTeX. BibTeX has an executable or sort of a compiler that is run behind the scenes when you compile your LaTeX document. This compiler is used to parse your BibTeX bibliography notations which represent your sources (papers, books, online material etc…) i.e. entries in the .bib file. Same for BibLaTeX but the executable or the processing program is called Biber. You do not have to worry about any of this as both of them are available by default in major TeX distributions. BibTeX is very old but still used. BibTeX is great for numerical citation styles such as IEEE, ACM etc… but can be extremely annoying when it comes to using an (author, year) citation style  such as (Bakri, 2016) [Harvard, APA etc…] or a label-based citation style (a.k.a alphanumeric) such as [ABC95] (ex: alpha) or a superscript-based citation style such as the one used by the nature journal. When using only BibTeX, you end up being forced to use another LaTeX package such as natbib in tandem with BibTeX. Nowadays, students learn LaTeX then BibTeX  and then move on to learn and adopt BibLaTeX. I believe this is what you should do. BibTeX is still commonly used by the majority of journals & conference proceedings, this is why it is still alive. Last update of BibTeX was done 9 years ago. So in my opinion you have to learn it first (don’t be afraid there is not much to learn) even if you find yourself obliged to switch later to BibLaTeX which probably will occur at a certain time especially if you will not use simple bracketed numeric citations styles and when you realise you need advanced customisations of your citations.

LaTeX allows you to create very  beautiful conference and journal articles, technical reports, books, theses, dissertations, posters, resumés, leaflets, flyers, business cards, slides presentations (through the Beamer package per example) and the list goes on and on. If you have tried to submit before to any academic workshop, conference or journal, you will realise that they usually provide you with a LaTeX template for the style and layout of the papers in their proceedings. LaTeX is distributed by the servers of CTAN (Comprehensive TeX Archive Network). In there you can actually download many individual packages (little specialised LaTeX programs that do a particular task) and their documentation.

Benefits of LaTeX (why using it – Isn’t Microsoft Word just fine?)

LaTeX is an excellent tool for producing very good professional looking documents. It a language with some learning curve. The question that you might be asking is: What is wrong with Microsoft Word or other Word processors? My answer is nothing. Microsoft Word is an amazing powerful product. You can write a PhD thesis in it and still get a PhD. If you are doing a PhD in Divinity or Literature or something like that, I believe it is not worth spending any time learning LaTeX so that the document look nicer. MS Word in such cases is just fine.

That has been said, LaTeX has a lot of benefits and powers over Microsoft Word or any other word processors. The following list presents few benefits that make LaTeX very attractive in academia  especially in the scientific fields:

  1. The look and feel of the documents produced by LaTeX is superior to the look and feel that a Word Processor can produce. You might wander why? Well, because LaTeX is like an aristocratic lady. She knows all the etiquette concerning the right amount of spacing, the right and advisable typographical rules used in the industry of publishing, the captions vel cetera; in addition to knowing per example where to place tables or figures (normally LaTeX aims for the top of the page) among many formatting and style etiquette. There are lot of rules that LaTeX take control of and execute them in your document on your behalf in order to make the document look so beautiful and so harmonic. Of course you can overwrite that behaviour but if you leave LaTeX do its thing, in the majority of cases,  you are guaranteed to get a beautiful professional looking article, poster, presentation, academic paper, a book or a PhD thesis.
  2. The biggest of all advantages is the separation of style of the document from the content of the document. That is huge advantage!! LaTeX ensure consistent formatting  and that the style of a document can be changed by simply changing a class file or loading some packages with few lines. Imagine doing that with Microsoft Word and imagine you have document of 200 or 300 pages. It will be impossible. So you would pass by every page and change the styles of headings or whatever. Let me give this concrete example: You have a thesis of 300 pages all your figures captions are labelled as ‘Figure’. You were asked to change captions them to ‘Fig’ but the cross references inside the text should be “figure”. What will you do? You can do a search and replace but that will have unexpected and unwanted changes. This effect can be achieved in LaTeX in a single line. That’s it.
  3. LaTeX has advanced typesetting and apparent advantage in typesetting complex mathematical  equations and scientific notations than any word processor.  Imagine you are writing a thesis that require so much Math and symbols. You will find LateX is a lot easier for you than composing complicated equations with the equations designers  you find normally in word processors. LaTeX contains even symbols not present and could not be found in any word processors.
  4. LaTeX is the king of cross-referencing chapters, sections, subsections, paragraphs, equations, figures, tables etc… It makes it easy to generate a list of tables, a list of figures, a list of algorithms or listings or list of “whatever you want really”, and update them and customise them in all possible way. It is very easy to create an index, a glossary, a bibliography. Per example, I will speak later about back-referencing: a process that can never be made in MS Word in a million year.  The point I am driving home here is that LaTeX contains extremely advanced features that fills out books. In addition, if you use with LaTeX another program which also compile a sort of language called BibTeX and say you have 400 citations  and say you were asked to change the style of these citations. No problem one line. or asked to reorder them alphabetically: also no problem one line.
  5. LaTeX frankly allows you NOT to piss off reviewers of papers or examiners of your thesis by presenting to them a badly formatted document. Impressions are very important! It is human nature, you can not do anything about it. LaTeX does not even allow you to have a badly formatted document due to its nature (unless if you mess with it and overwrite things you are not suppose to do).
  6. LaTeX is the aristocratic lady that knows how to present well what is known as f-ligatures. Ligatures always look beautiful in LaTeX.
  7. LaTeX is not bogged down (performance wise) by the amount of material in your document. Have you had the experience of your MS Word document of like 300 pages becomes extremely slow especially when you have a lot of images, tables  and cross references and  to make things even worse a Mendeley plugin keeping an eye on any changes in the locations of the references? That document is bound to crash or  at least you have to wait some time until you see changes when you write. In LaTeX you do not have such problem. Actually you can write LaTeX code with the most primitive text editor, you have. All the formatting happens in the output after running the building process of LaTeX.
  8.  A lot of supervisors demand explicitly from you to use LaTeX. They do not accept anything else. If you are in doubt, ask your prospective supervisor/advisor whether he wants you to use LaTeX, some supervisors put that explicitly on their profile pages so that prospective PhD students are aware of this requirement. PhDs are very demanding and fast-paced especially in the sciences. You will find yourself writing to your supervisor/adviser every week or two a report of some sort.
  9. Certain features necessary for writing PhD theses or Masters dissertations are simply not present in MS Word.  A) Do we have short captions and long captions in MS Word? I don’t think so.  I always look at those ugly MS Word theses of few people who decided to be stubborn, where the list of Figures or List of Tables have these gigantic captions that spans lines and lines screaming out. First, if your caption is that long it means something wrong. Either you need to divide your tables or figures into subcomponents or you are putting some sort of legend that should not appear in list of figures or list of tables at the beginning of the thesis. In LaTeX, you can have for each part, chapter, section, subsection, subsubsection, paragraph, subparagraph, figure, table, equation, theorem etc. a short caption and a long caption ( using the LaTeX code: \caption[Short caption goes here….]{Long caption goes here….} ). That means you can give a short caption that appears only in the List of Figures or the List of tables or the List of theorems, so forth, and a long caption that appears under the figure or above the table. Textual Legends under tables or above figures are very easy to do in LaTeX, you just provide another starred caption at the end of your code (before closing the environment): \caption*{Legend can be as huge as you want and guaranteed of not appearing in list of figures or tables}. The star tells LaTeX not to put the caption in the List of Figures or List of Tables. B) Can you do back references in MS Word? of course not. C) The power of glossaries commands in LaTeX like \gls{..}, \acrshort{…}, \acrshortpl{….}, \acrlong{…}, \acrlongpl{….},  \acrfull{…}, \acrfullpl{….}, is not present in MS Word. LaTeX is amazing! imagine you can define glossaries and acronyms with plural and singular forms, with short, long and full forms and with a sorting order. Inside your text, you do not have to remember whether the acronym that is used for the first time is expanded or not; you just write the \gls{…} command and LaTeX makes sure that the first time an acronym is used inside the test, it will be expanded. 
  10. The prenote and postnote of citations: things like see p.3 or pp. 23-25, cf. (Behr et al., 2001) … it is quite easy to add them and LaTeX knows whether to put a p or pp without you typing it explicitly.
  11. Multiple bibliographies in the same document can be done  easily  in either BibTeX  or BibLaTeX. This is needed for instances such as creating a bibliography or references list for each chapter in a book, or for each article or poem in an anthology etc… or when we want to classify or divide references based on the types of the sources such as books, articles, webography.., or based on a topic or on specific keywords or for specific authors or based on primary vs secondary sources etc… I don’t think that this is easy to do in MS Word or Mendeley or Endnote as far as I know. PS: for BibTeX on its own you cannot do multiple bibliographies, you need additional packages such as multibib, chapterbib or splitbib. For BibLaTeX, you do not need any additional packages.
  12. Cleveref ( or clever referencing): makes cross-referencing very easy. It figures out automatically whether you are cross-referencing a figure, an equation, a table, a chapter, an appendix etc. Not to mention, you can change the style, with few lines of LaTeX code so all your “Figure” becomes “Fig.” etc.
  13. … I am sure there are many more…

Hopefully, I have convinced you why you should learn LaTeX and BibTeX/BibLaTeX.

Essential LaTeX tools that every research student should know

Major LaTeX Systems/Distributions

You need to install one of the following LaTeX Distributions or  Systems as a first step. Bear in mind some of the distributions takes a very long time to download and install due to the sheer amount of LaTeX packages ( thousands of packages). A lot of LaTeX distributions of systems allow you to install a minimum version which I totally recommend. Whenever you need a certain package you can always download and install it either separately or through built-in GUI packages manager. This makes the installation faster and takes less space on your computer.

Tex Live

Tex Live is available for Linux distributions and Microsoft Windows. It is a famous Tex distribution that is quite rich.

MacTeX

As you guessed, MacTeX is the TeX Distribution of Choice for the Mac OS folks.

MiKTeX

MiKTeX is a distribution available for Mac OS, Linux OSs and Microsoft Windows.

proTeXt

proTeXt is a distribution dedicated only for MS Windows folks. I do not like it so much but it is here just for completion sake.

TeX Editors

There are many LaTeX editors out there but the most famous LaTeX editors are  TexStudio, Texmaker or TeXWorks.  The best in my opinion and the most intelligent is TexStudio, and this is for different reasons. You can insert many snippets of LaTeX very quickly, you can have wizards to create tables (which is an annoying thing in LaTeX), You can place figures through GUI , you can create a Beamer Presentation very quickly etc…. Now one will argue that this is available also in other LaTeX Editors, this is true but what is not available in many editors is a technology called Intelligent Code Completion and suggestion. Meaning the Editor continues for you your typed commands, scans the file system for images among many other cool features.

LaTex Editors are not LaTeX. They are just dummy editors on top of a LaTeX distribution. Newbies confuse that. Actually you can use any simple text editor (Notepad, vim…) for writing LaTeX documents and then you can compile and build your thesis from the command line or Terminal. You wont be able to build your documents, If you only install a LaTeX Editor without installing an actual LaTeX Distribution.

Online LaTeX Editors

Do not rely on them for no reason other than they make you lazy. That means they are pretty cool! The greatest of all benefits of these types of editors is the fact that THEY ARE ON THE WEB,  meaning they are accessible from everywhere on the planet and no need to deal with installing a LaTeX Distribution and then installing a LaTeX Editor. Another benefit is that they all have cloud storage, similar to the one provided by Dropbox, Google Drive or Microsoft OneDrive. That means your paper, your dissertation or your thesis is stored on their system, backed up regularly (since the majority of these services have some sort of version/revision control system) and which you and your collaborators can edit, compile and comment on; all of this while remaining online. Pretty Cool! The following are the most used web editors:

Overleaf Online Editor

Overleaf is very famous among PhD and Masters students. You can upload your already written thesis in LaTeX or create a totally new one from tons of templates. The beauty of this service is that your report or thesis is totally stored on the cloud and saved every few seconds automatically. You can revert back to a previous versions if needed, since the history of changes is also stored. So you do not need to back up on a continuous basis. You can share the LaTeX thesis, academic paper or  report with your supervisor/advisor or with any of your coauthors. They can comment on different parts of the document. They can even edit if you allow them at the same time so everyone has the latest version. So there are many collaboration features in this service. You can integrate the tool with Dropbox, Google Drive and GitHub among others. There is a cool feature in Overleaf where you write your LaTeX code, the moment you finish you can see how it looks like. In addition Overleaf has features like spell checker, syntax highlighting, text folding, built-in PDF viewer… Pretty cool features! don’t you think? I should mention that the free version, give you first a 100 MB  of cloud storage space. You get additional 100 MB when you complete you profile, when you send invitation  to the application to friends (on Facebook, Twitter LinkedIn and Google Plus) and when you link your Overleaf profile to an OCRID.

Papeeria Online LaTeX Editor

Papeeria online service is massive. They have a complete TeX Live distribution behind the scene. Almost same features as Overleaf (real-time collaboration, syntax highlighting, text folding, auto-completion and spell checker, in build PDF viewer) but additionally you can write also Markdown.  They have many templates to choose from for Theses, IEEE papers, reports, presentation slides….

ShareLaTeX Online LaTeX Editor

Almost similar service is ShareLaTeX same features as previous online tools. I only like their documentation to be frank with you 🙂

Front-ends to LaTeX

Lyx – The Document Processor

Lyx is a document processor that uses the WYSIWYM paradigm (an acronym for “what you see is what you mean”) . Lyx in lay terms, is a front-end to LaTeX  (do not confuse Lyx with a LaTeX Editor like  TexStudio, Texmaker or TeXWorks… Lyx allows you to write a document the way you write an MS Word document (well to be fair almost the way you write a  MS Word document). You still have to use LaTeX terminology and LaTeX concepts. Lyx is a Kind of a GUI layer on top the LaTeX ecosystem. The cool thing is not that, the cool thing is that it spits out (Export) many formats needed (PDF, LaTeX, MS Word, MS Excel, HTML, RTF vel cetera) and takes in (Import) many format like MS Word, MS Excel, LaTeX, plain text vel cetra.

I use Lyx as an intermediary tool to convert an MS Word document to LaTeX, although not the best of conversion  tool since you find many things you need to tweak afterwards.

There is also BaKoMa TeX Word which is this time a WYSIWYG (What You See is What You Get) but cost money I believe.

LaTeX important conversions tools

Convert LaTeX to MS Word & Vice versa

You might need to convert your LaTeX thesis or paper to MS Word document at certain time during your research degree. This happens usually when you are collaborating with folks who do not use or know LateX. It makes sense to dedicate a section for this matter.

TeX2Word and Word2TeX

Chikrii Softlab offers two tools that convert MS Word documents to LaTeX and vice versa. These tools cost money. I personally did not try any of them to give you an honest review but please check them out in case they suit your needs.

GrindEQ LaTeX-to-Word & GrindEQ Word-to-LaTeX

The GrindEQ tools are awesome with impressive results but cost money. By impressive I mean they take care of images, tables among other things. You can of course buy academic licences which are way cheaper. But I believe it is totally worth investing in these tools especially  if you find yourself in need of converting your LaTeX papers or chapters to MS Word documents and vice versa. This happens usually when you are collaborating with folks who do not use or know LateX.

Pandoc a universal document converter 

Pandoc is awesome! It is a free universal converter that covers many markup formats. You can convert LaTeX to DOC or DOCX and vice versa. You might need to tweak the resulting document but it is free and it works like a charm! After you install Pandoc check that it can be invoked from the OS terminal or command line

pandoc –version

To transform a TeX document to a docx with amazing results

pandoc -s chap1.tex -o chap1.docx

Lyx – The Document Processor

Lyx can be used to convert LaTeX into MS Word. Lyx is free.  I have mentioned that before. I have use it personally. The results are not bad but you should keep in mind that you do need to tweak the MS Word document that is generated.

Microsoft Word Add-Ins Store 

You probably know that you can install additional add-ins inside your Microsoft Office products. I am hesitant of recommending something here since many of these add-ins relies on VB Macros. Some are free and some are not. Have a look at the Microsoft store and please download an add-in that has many good reviews and is used by many people.

Latex2rtf (RTF as an intermediary format)

LateX2RTF is a free tool that converts LaTeX to RTF (Rich Text Format). Then, you can use any word processor such Microsoft Word to transform RTF file to DOC or DOCX. Bare in the mind, the result is not that great!

TeX4ht: LaTeX to HTML (HTML as an intermediary format)

TeX4ht package and processing program is pretty old and is a free tool. It transforms your LaTeX document to HTML. It is installed by default in many TeX distributions but you have to know how to use a command line. Frankly speaking even the HTML produced is not that great but it might be useful in some cases where you have a document that does not contain a lot of images or tables. Once you have your HTML files, you can use Microsoft Word to transform the HTML to DOC or DOCX.

LaTeX Tables Online Creator tools

LaTeX is very powerful this is why it is used. People do not use LaTeX because they want to be fancy, they use it because  it is extremely powerful. Unfortunately, you will discover that creating a table in LaTeX is not as easy as doing it in Microsoft Word. This is maybe the only feature in LaTeX that I feel is really annoying. Nevertheless, there are many solutions to use than to construct manually a LaTeX table.

LaTeX Tables Builders inside LaTeX Editors

Inside LaTeX Editors like TexStudio per example, there are usually wizards that help you create a LaTeX table. You might see a Graphical User Interface that helps you do that. The following image shows the Quick Tabular Wizard in TeXStudio LaTeX Editor.

Quick Tabular Wizard in TexStudio (on Mac OS)
Quick Tabular Wizard in TexStudio (on Mac OS)

The Effective way to create LaTeX tables

Creating tables especially complicated ones is concern for many writers despite the existence of many websites, tools, LaTeX packages and GUI features inside many famous LaTeX editors that facilitate that.

The following is one of the best websites that I recommend you to  use in order  to create LaTeX tables.

The LaTeX Online Tables Generator

LaTeX Tables Generator is the most famous online tool used to create LaTeX tables. I use this tool quite often. You can construct your table directly in the tool or you can import data from a CSV file. You can of course save any Excel File to CSV from Microsoft Excel itself.

You can also import the LaTeX code of a table. You can generate two styles the default table style or the booktabs table styles. I prefer the Booktabs table style because it looks nicer. You need to  have the booktabs LaTeX package installed and loaded in the preamble of your LaTeX document. Booktabs table style is very tidy style and looks clean and beautiful and it is used in many academic papers and PhD theses.

The cool thing about the LaTeX online table generator is that you can save your tables as a tgn files. The file format .tgn is a custom table generator file. You can load tgn files later if you want to change something in the table.

I always have a folder inside every chapter folder of my LaTeX thesis where I store all my tables as .tgn files. This is in case later I want to make any changes to the tables.

Other useful Tools

Detexify LaTeX handwritten symbol recognition: is a tool that helps you figure out unique characters and symbols codes through handwriting recognition (PS: you do not need a digital pen – writing with your mouse would suffice).

Essential Tips of LaTeX, BibTeX and BibLaTeX

A – How to construct correctly the .bib (BibTeX) file & how to acquire references?

Both BibTeX & BibLaTeX are bibliography systems. They aim mainly to format and manage the references. They are used in tandem with the LaTeX typesetting system. The extension of a BibTeX or BibLaTeX file is .bib

What the majority of people  end up doing when using this method, is they create a file with .bib extension in a normal text editor or in one of the  famous TeX Editors (like TexStudio, Texmaker or Texworks…). For each reference;  a lot of folks write it down manually  in the bib file which is a  primitive method but  produces nevertheless a better and a more complete bibliographical entry!

The following is an example of a BibTeX entry:

@inproceedings{bakri2016virtual,
  title={Virtual Worlds and the 3D Web--time for convergence?},
  author={Bakri, Hussein and Allison, Colin and Miller, Alan and Oliver, Iain},
  booktitle={International Conference on Immersive Learning},
  pages={29--42},
  year={2016},
  organization={Springer}
}

There is a faster way: Many of us go to Google Scholar, search for the paper/book in question, choose the Cite Icon (the two quotes icon), then choose BibTeX, which leads to a BibTeX code  similar to the code above. The code would be copied into the BibTex file (.bib). This is done for every reference needed. You can imagine the size and cheer amount of references at the end of a PhD thesis or a Masters dissertation per example. You have the possibility of having many .bib files each pertaining to a topic covered by your thesis/dissertation. I like to divide my bibliography into many .bib files and  to use a lot of comments in the bib files because it keeps the references more organised under specific themes.

To cite any reference from the .bib file in the actual thesis LaTeX document, you would use the LaTeX commands \cite{BibTeX_Key}, or \citeauthor{BibTeX_Key} for citing only the authors or \citeyear{BibTeX_Key} for citing only the year, or \citeN{BibTeX_Key} for noun citations and many more…depending on your needs.

There are websites that help you cite well according to a specific referencing style and allow you then to export the citations to either EndNote or a BibTeX or to any other bibliographical format. Few examples: Cite This for Me and citefast. The problem with these websites is that the method that is used is too primitive & too manual since you have to fill manually a lot of necessary fields for citing a resource compared to using a referencing software such as Endnote or using BibTeX/BibLaTeX export features in scholarly search engines and from publishers websites but the advantage is that you know that you are following exactly the citation style you need and that your citations are both correct and complete.

You have the possibility of course of having many .bib files each for a topic per example covered by your thesis. I tend to like this method of having many .bib files because it keeps your references more organised under specific themes.

One of the major problems, with the manual approach to add citations to the .bib file is that you might add accidentally the same reference many times so there would be many redundancies. Of course you can detect them and remove them and there are also a lot of tools (ex JabRef) and Python/Perl scripts that clean up the .bib file(s) for you. Some TeX editors have features that do that also.

Be Very Cautious: Google Scholar does not always give you a complete and correct BibTeX entry code. As I said, your citation should contain if it is possible  ALL the required BibTeX/BibLaTeX fields depending on the type of the citation (book, article, booklet, inproceeding…) + as much as possible of the optional fields (the more the better). Please consult a citation guide book for how to appropriately cite a specific source if these automatic tools give you something weird. I had many publishers contact me about missing fields in references. References which I have copied the BibTeX code verbatim from Google Scholar engine.

The right way to obtain a bib code: Either go to the publisher site or use DOIs. You probably have some familiarity with DOIs (Digital Object Identifiers). Every published paper/book… has a DOI number (aimed to identify digital online resources). A DOI looks something like this: 10.1145/1595496.1562908. You need to know what is the DOI of the paper in question and then go to  http://dx.doi.org/[PUT HERE THE DOI]. This will redirect you normally  to the publisher related web page of the paper where on it you will be told normally how to cite the paper properly (there is always an export format feature for BibTeX somewhere on the page). The difference here is you are following what the publisher wants you to do when citing a paper and not what Google Scholar gives you.

To illustrate this. The following is the Google Scholar version of the generated BibTeX Code of the survey paper titled (“A survey on service quality description”):

@article{kritikos2013survey,
title={A survey on service quality description},
author={Kritikos, Kyriakos and Pernici, Barbara and Plebani, Pierluigi and Cappiello, Cinzia and Comuzzi, Marco and Benrernou, Salima and Brandic, Ivona and Kert{\'e}sz, Attila and Parkin, Michael and Carro, Manuel},
journal={ACM Computing Surveys (CSUR)},
volume={46},
number={1},
pages={1},
year={2013},
publisher={ACM}
}

The publisher BibTeX code of the same survey paper (from ACM Digital Library):

article{Kritikos:2013:SSQ:2522968.2522969,
author = {Kritikos, Kyriakos and Pernici, Barbara and Plebani, Pierluigi and Cappiello, Cinzia and Comuzzi, Marco and Benrernou, Salima and Brandic, Ivona and Kert{\'e}sz, Attila and Parkin, Michael and Carro, Manuel},
title = {A Survey on Service Quality Description},
journal = {ACM Comput. Surv.},
issue_date = {October 2013},
volume = {46},
number = {1},
month = jul,
year = {2013},
issn = {0360-0300},
pages = {1:1--1:58},
articleno = {1},
numpages = {58},
url = {http://doi.acm.org/10.1145/2522968.2522969},
doi = {10.1145/2522968.2522969},
acmid = {2522969},
publisher = {ACM},
address = {New York, NY, USA},
keywords = {QoS, SLA, Service, description, life-cycle, metamodel, model, provisioning, quality, service-level agreement},
}

You can see clearly that the code given by the publisher is a lot more detailed and precise than that of Google Scholar. A lot of publishers allow you to export the citation in different formats with or without the abstract (Yes!, you can include all the abstract text inside your BibTeX code (abstract={…}).

Pay attention: The key provided by publishers is awfully long and sometimes meaningless. In the example above, the ACM digital library gave us “Kritikos:2013:SSQ:2522968.2522969”, a horribly long and weird key. It is better to use the Google Scholar key: “kritikos2013survey” which is way more meaningful and better. I advice you to use the Google Scholar Key but the content code of BibTeX from the publisher directly.

A more automatic way: JabRef

JabRef is one of the tools that you say to yourself when seeing it for the first time: Why the Hell I don’t know about this??

JabRef is an amazing open source Java Graphical User Interface (GUI)  bibliography reference management system similar to Mendely, Zotero etc.. but dedicated for the LaTeX/BibTeX/BibLaTeX folks. The support between BibTeX and BibLaTeX can be toggled (File then choose ‘switch to Biblatex mode’).

If you load your existing (.bib) file(s) in JabRef (by using File/Open Library). It will detect all BibTeX redundancies and mistakes in the bib file (Amazing! right!).

JabRef version: 4.3.1 - BibTeX entries Redundancies checker
JabRef version: 4.3.1 – BibTeX entries Redundancies checker

 

JabRef 4.3.1 - Main Window
JabRef version 4.3.1 – Main Window

You can add manually BibTeX entries depending on different types, or copy BibTeX raw text or BibTeX Code from other places. Export references to RDF, HTML, Endnote, MS Office, OpenOffice, LibreOffice….among others file formats. You can generate a BibTeX key or use the ones provided by publishers/Google Scholar.

You can open the DOI link of any paper/book which has it in your database. You can rank your references, mark them and give them certain colours to differentiate them. It allows you to edit/create/delete Essential, Optional and Deprecated fields. You can add an abstract for a paper and you can write comments. There is an amazing feature called ‘Related Articles’ which fetch you all related articles/papers you might need to consider.

The tool has good integration with Open source office suites like OpenOffice/LibreOffice and can link to your favourite text editor or LaTeX Editor (mainly TexStudio and Texmaker). In addition, you can search and fetch from the tool itself papers/books (like searching ACM Digital Library and the like…)

BibDesk

BibDesk  is a graphical bibliography manager for BibTeX/BibLaTeX file management. Unfortunately, BibDesk is only for Mac OS Users. It is not as powerful as JabRef.

BibDesk MacOS image
BibDesk on my Mac OS

 

B – Correct the annoying lowercase references in BibTeX/BibLaTeX, How to solve this?

Have you seen ugly references that looks like this (title of the paper is all lower case):

Ugly reference: Title of the paper is all lower case
Ugly reference: Title of the paper is all lower case

The BibTeX code of the above reference is the following:

@inproceedings{kostoska2015virtual,
title={Virtual, Remote Participation in Museum Visits by Older Adults: A Feasibility Study},
author={Kostoska, Galena and Baez, Marcos and Daniel, Florian and Casati, Fabio},
booktitle={8th International Workshop on Personalized Access to Cultural Heritage (PATCH 2015), ACM IUI 2015},
pages={1–4},
year={2015}
}

Do you know why? People copy normally the BibTeX reference code from either Google Scholar or export it from the publisher website as it is, titles of papers will normally have only one set of { } and this will show all letters of the title in lowercase. This is due to  the “brace depth” problem.
To make the title NOT appear in lower case  or make it look like what you normally find in the title of academic papers i.e titles using the ‘Smart Case’ (every word is capitalised expect conjunctions & articles), you need to tell BibTeX please can you not mess with case of the title, I want the case of the title as it is. To do that you need to use extra curly braces {… } around your title. Usually the titles of academic papers as I said are in ‘Smart Case’ format meaning the first letter of every word is capitalised except the connectors. Majority of advanced LaTeX editors have a feature to transform any phrase to ‘Title Smart Case’.

The first reference would be solved by including another set of { } around the title:

@inproceedings{kostoska2015virtual,
title={{Virtual, Remote Participation in Museum Visits by Older Adults: A Feasibility Study}},
author={Kostoska, Galena and Baez, Marcos and Daniel, Florian and Casati, Fabio},
booktitle={8th International Workshop on Personalized Access to Cultural Heritage (PATCH 2015), ACM IUI 2015},
pages={1–4},
year={2015}
}

Result:

Smart Capitalization is preserved as should be.
‘Title Smart Case’ is preserved as it should be.

C – How to squeeze space in LaTeX documents?

Ah! this happens to everyone especially especially when writing a paper and you are trying desperately to squeeze space.  A great article I advise you to read is found here.

Important and Interesting Packages and Commands to Master in LaTeX

For Commands: there are a lot and I am not going to throw at you a list of some sort, won’t be useful to you.  If you read an introductory/intermediate LaTeX book (which you need to do in order to learn LateX), you will get that list anyway. After learning LaTeX at least reaching a good book, I advise you to master defining your own LaTeX commands and renewing the definition of existing LaTeX commands  using the \newcommand and \renewcommand. In my personal experience: these tasks are extremely handy. This is because you might use several commands on certain snippets of text, it makes sense organising and defining  your own new bespoke commands that allow you to avoid being repetitive.

My recommendations concerning learning the most important LaTeX packages:

The packages that do miracles in cross-references and navigational links:

  1. Hperref package:  used for handling cross-references and produces live hypertext links. In other words, it is used for manipulating hypertext marks & links in LaTeX. This package allows you to have clickable citations, clickable titles in the table of content, clickable short captions in the list of figures and list of tables among many other features. It contains Backref package which could be loaded also separately.  This Backref package/or option in hyperref package is awesome! It allows you to add in the references of your bibliography – a clickable back reference to the point or page in which each reference was used (i.e. Back referencing from the bibliography to the in-text citations). You can click on a reference and see where it is used inside the actual text. 

An Example of the usage of the backref feature.

An Example of the usage of the backref feature
You can click on any page where a citation was used. If this is not cool, what is cool?

The packages for creating an index

These packages will be needed when writing your PhD Thesis. 

  1. makeindex package
  2. xindy package

The packages for creating a glossary

  1. glossaries package

The packages that allows you to create amazing presentation slides:

  1. beamer package

The packages for mathematics and equations

  1. amsmath Package
  2. mathtools Package

The packages that embed movies, sounds and 3D models in your PDF from LaTeX

I wrote an article that teaches you how to embed into a PDF, Interactive 3D Models, videos, sound clips via LaTeX.

  1. movie15  and Media9 Multimedia inclusion packages:  these packages em­bed movies, sounds and 3D ob­jects into PDF doc­u­ments. Media9 can embed in­ter­ac­tive Flash (SWF) and 3D ob­jects (manly the formats of  Adobe U3D & PRC). Microsoft Word can also embed 3D models with formats such gLTF. The movie15 and Media9 Packages are only available in MikTeX and TeX Live.
  2. asymptote Package:
  3. pst-solides3d package:
  4. Sketch Package

Packages that draw 2D and 3D Graphics

These are normally used also for statistical plots by R or Python.

  1. TiKZ package contained in the pgf macro package: is the most famous and the most powerful. Please see my articles ( 1, 23 and 4). explaining how R export tikz plots which you can include quite easily in your LaTeX documents.

The packages for Languages

  1. Babel Package.

The packages for citations

  1. BibTeX
  2. BibLaTeX & Biber
  3. natbib
  4. multibib

Packages for cross-referencing

  1. cleveref

The journey from Gnuplot to LaTeX

All the following methods explains what to do if you have a plot you already scripted in gnuplot and you want to include it into your LaTeX document.

The latex GNUplot terminal for LaTeX

This is one of the most famous terminal to output to if you want to output a picture environment.

set terminal latex
set output ‘plot.tex’
set title ‘Awesome Plot’
set xlabel ‘X Axis Label’
set ylabel ‘Y Axis Label’
plot (x/4)**2, sin(x), 1/x

This will produce a plot.tex file per example containing the LaTeX picture environment which you can include into LaTeX document.

% GNUPLOT: LaTeX picture
\setlength{\unitlength}{0.240900pt}
\ifx\plotpoint\undefined\newsavebox{\plotpoint}\fi
\begin{picture}(1500,900)(0,0)
\sbox{\plotpoint}{\rule[-0.200pt]{0.400pt}{0.400pt}}%
\put(130.0,82.0){\rule[-0.200pt]{4.818pt}{0.400pt}}
….
….
\end{picture}

You can later include the .tex wherever you want in the document in the form:

\begin{figure}[h!]
\centering
\input{plot2}
\caption[Short Caption Goes Here]{Long Caption Goes Here}
\label{fig:AwsomeGNUplot}
\end{figure}

The only difference here is instead of putting \includegraphics[width=0.5\textwidth]{figure}, you put \input{…} with the name of the plot without the .tex

The epslatex GNUplot terminal for LaTeX

set terminal epslatex

It is a LaTeX picture environment using graphicx package and produces a Postscript file and .tex file. In other sense, this technique produces a LaTeX picture with Postscript. You set the output as a .tex file. Same technique exactly as above.

The emtex GNUplot terminal for LateX

set terminal emtex

LaTeX picture environment with emTeX specials

The TikZ terminal for LaTeX

set terminal tikz

A terminal that allows you to output your plot as LaTeX TikZ graphics macro via the lua script driver (which still export plots files as .tex files)  thus you then include those plots inside your LaTeX Document with the technique mentioned above.

The texdraw terminal for LaTeX

set terminal texdraw

A terminal that allows you to output your plot as LaTeX texdraw environment.

The pstricks GNUplot terminal

A terminal that allows you to output your plot as LaTeX picture environment with PSTricks macros.

Gnuplot code Inside LaTeX

Do you know that you do not have to switch to gnuplot as an external program to generate your .tex plots? You can embed your gnuplot plotting code, from inside your LaTeX document itself. Awesome isn’t it? This can be done through a LaTeX package called  gnuplottex which allows you to include/embed Gnu­plot code directly inside your LaTeX documents.

Matplotlib and LaTeX

LaTeX into matplotlib plots and vice versa

There are many techniques to make matplotlib integrate well with LaTeX. I would assume LaTeX is installed of course.

First technique: startup style configuration RC Params

This technique is somehow similar to the next one but done differently. You can include any LaTeX code both math and text modes inside any matplotlib text feature (like labels of Axis, titles, annotations vel cetera). It is better explained in the following example:

#!/usr/bin/python3
import matplotlib.pyplot as plt

test_scores = [34, 65, 76, 88, 98, 96, 32, 65, 34, 87, 78, 67, 89, 90, 100, 87, 66, 69, 72, 100]
time_spent = [11, 23, 34, 32, 33, 45, 21, 50, 12, 60, 56, 53, 50, 44, 50, 56, 40, 34, 67, 60]

plt.rc('text', usetex=True)
plt.scatter(time_spent, test_scores)

plt.title(r'Test scores VS Time Spent \n this is a LaTeX formula:$\Delta x = y^2

The figure generated will look like the following:

LaTeX code inside matplotlib chart

As you can see from the example code and figure above, we managed to write LaTeX commands inside a matplotlib plot (e.g. \textbf{ } even using the math mode $…$ to include symbols and equations). You can see how much this can be convenient.

Same outcome can be achieved by specifying  also matplotlib.rcParams[‘text.usetex’] =true.

Second Technique: producing plots as PS file (Postscript)

You need to specify your parameters into a dictionary for the rcParams. You should make sure that the ‘backend’ option is ‘ps’ and the ‘text.usetex’ should be True .  So you specify the parameters as you want in the following form (example taken from LaTeXify Matplotlib, Matplotlib: latex examples)

fig_wdith_pt = 246 #this can be obtained from LaTeX by using \showthe\columnwidth
#or from your academic paper LaTeX style template
#(so you need the width of the column (if 2 column or 1 column)
#could be generalised to Poster
inches_per_pt =1.0/72.27  #an inch is 72.27 points
golden_mean = (sqrt(5) - 1.0)/2.0 #Aesthetic ratio
fig_width = inches_per_pt * fig_wdith_pt  #Get you the width in inches
fig_height = golden_mean * fig_width #Get you the height in inches, preserving the golden ratio mean

params = {'backend': 'ps',
          'text.latex.preamble': ['\usepackage{gensymb}'],
          'axes.labelsize': 8, # fontsize for x and y labels (was 10)
          'axes.titlesize': 8,
          'text.fontsize': 8, # was 10
          'legend.fontsize': 8, # was 10
          'xtick.labelsize': 8,
          'ytick.labelsize': 8,
          'text.usetex': True,
          'figure.figsize': [fig_width,fig_height],
          'font.family': 'serif'
    }
matplotlib.rcParams.update(params)
...code for the plot...
plt.savefig('image.eps')

Then the encapsulated Postscript Vector Graphics file (.eps) can be included into you LaTeX like any other image. To tell you the truth, there is even a better approach with a better quality which is to transform your plot into a plotting language used quite often in LaTeX, known as TiKz. So in other words, it is like LaTeX itself is plotting the matplotlib chart. How to do that? please see next section.

Transforming matplotlib graphs to LaTeX TiKZ

There is a good library that can be found here that coverts a matplotlib figure into Tikz/PGFplots  LaTeX code which you can then be integrated into your LaTeX document (On LaTeX side, you can do the same procedure that I have explained in my series 1, 2,  covering R and LaTeX)

Good LaTeX Learning Resources

  1. The Wikibooks LaTeX: Best Resource! awesome articles covering a big range of LaTeX topics although some articles are still not completely written.
  2. ShareLaTeX Documentation: I like their documentation on LaTeX. The documentation is not complete or exhaustive but it is easy to read.
  3. Dickimaw LaTeX Books and Articles: Mainly 3 Books: (1) “LaTeX for Complete Novices” , the book covers how to write a PhD thesis in LaTeX and is a marvelous book: (2) “Using LaTeX to Write a PhD Thesis” and “LaTeX for Administrative Work“. The 3 books mentioned are online, free and have PDF versions if you want to print them. They all come with many LaTeX exercises and solutions and all the source code used in the books can be downloaded. I totally recommend them, they did miracles to my understanding of LaTeX when I started learning it.
  4. The Not So Short Introduction to LATEX and the An essential guide to LaTeX usage. Both of these guides are somehow old now but nevertheless contain good material.
  5. CTAN for checking documentations of individual LaTeX packages or individual document classes since books covers only common packages. You always can use the terminal/command line “texdoc” tool to fetch the PDF guide of any package. Type per example, on a terminal/command line “texdoc memoir” to get the documentation of memoir.
  6. There is a lovely FAQ (Frequently Asked Questions) web site with tons of material on LaTeX and its related tools (BibTeX, makeindex, AMSTeX…) which can be found at texfaq.
  7. I recommend the following books if you need more a more in depth understanding of LaTeX: The Latex Companion, Guide to LaTeX (Tools and Techniques for Computer Typesetting), The LateX Web Companion (a somehow old book (1999) that contains explanations of a lot of cool stuff including how to use LaTeX for Web publishing etc… ) and The LaTeX Graphics Companion (2007).
  8. I will be publishing on Udemy a 21 hours+ introductory course on LaTeX/BibTeX. It will be my first online video course. Hopefully it would be enjoyable and useful for students. I will add the link here later whenever the course is ready and published and I will add coupon discounts here for you to enrol and get a good discount. I was thinking of making this course completely free since I will not be able to have the time to manage it or to support students in terms of answering their questions on a regular basis but then the course took considerable time and time is money. I might change my mind later who knows! I am known to be a crazy man. I have recorded almost half of the lectures now. The course will covers all the basics (Document Structure, Page Layout, text and paragraph formatting, colours, fonts, lists, languages (including How to write in Semitic languages), rotations, tables, figures, floats, captions, headers and footers, footnotes, hyperlink and URLs…), Mathematics, Theorems, notations from some scientific fields, Listings, how to create a glossary, an index, mastering BibTeX, BibLaTeX, bibliography (including hyper-referencing and back referencing), a big number of tools/editors/online editors, a complete section on Tikz, all sort of integration between R and LaTeX (tables, plots) and vice versa, All sort of integration between GNUplot and LaTeX and vice versa, all integration between the Python Matplotlib and LaTeX and vice versa, how to embed 3D models, videos and sound clips in final PDF, Transform LaTeX into HTML and Vice Versa, Transform LaTeX in rich text and MS Word Document and Vice Versa. How to load data from a CSV file or from a datatool (.dbtex) file or from SQL database and how to manipulate the data (sorting etc…). There is a section on Beamer. I will touch a little bit on Macros and how to create packages. I have a complete section on Templates (that teaches you how to create a Curriculum Vitae, an invoice, a thesis, a dissertation, a poster etc…). In addition, I have sprinkled couple of quizzes to test your knowledge and there are many exercises we do together.  Realise all this time and I did not even dare to call the course other than an introductory course.

Leave a Reply

Your email address will not be published. Required fields are marked *